From 0a235a04c32deee8750eaebe0cf80874f60e105f Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Wed, 25 Jul 2018 15:50:46 +0100 Subject: [PATCH 1/8] Extracted connector into separate library --- .coveragerc | 1 + MANIFEST.in | 2 - README.rst | 12 - neo4j/__init__.py | 1463 +++ neo4j/__main__.py | 3 +- neo4j/addressing.py | 143 - neo4j/bolt/__init__.py | 24 - neo4j/bolt/_io.c | 9975 ------------------- neo4j/bolt/_io.pyx | 322 - neo4j/bolt/cert.py | 74 - neo4j/bolt/connection.py | 701 -- neo4j/bolt/io.py | 277 - neo4j/bolt/response.py | 69 - neo4j/compat/collections.py | 28 - neo4j/compat/ssl.py | 34 - neo4j/exceptions.py | 168 +- neo4j/meta.py | 22 + neo4j/packstream/__init__.py | 27 - neo4j/packstream/_packer.c | 12195 ------------------------ neo4j/packstream/_packer.pyx | 338 - neo4j/packstream/_unpacker.c | 9170 ------------------ neo4j/packstream/_unpacker.pyx | 257 - neo4j/packstream/constants.py | 37 - neo4j/packstream/packer.py | 334 - neo4j/packstream/structure.py | 47 - neo4j/packstream/unpacker.py | 235 - neo4j/util.py | 144 - neo4j/v1/__init__.py | 9 +- neo4j/v1/api.py | 808 -- neo4j/v1/direct.py | 81 - neo4j/v1/exceptions.py | 55 - neo4j/v1/result.py | 285 - neo4j/v1/routing.py | 473 - neo4j/v1/security.py | 130 - neo4j/v1/types/__init__.py | 207 +- neo4j/v1/types/graph.py | 2 +- neo4j/v1/types/spatial.py | 2 +- neo4j/v1/types/temporal.py | 2 +- requirements.txt | 3 +- setup.py | 30 +- test/auth.py | 6 +- test/env.py | 2 +- test/integration/test_driver.py | 2 +- test/integration/test_result.py | 6 +- test/integration/tools.py | 20 +- test/performance/tools.py | 2 +- test/stub/test_directdriver.py | 3 +- test/stub/test_routing.py | 574 -- test/stub/test_routingdriver.py | 11 +- test/unit/test_addressing.py | 69 - test/unit/test_api.py | 2 +- test/unit/test_chunkedinputbuffer.py | 257 - test/unit/test_chunkedoutputbuffer.py | 130 - test/unit/test_connection.py | 198 - test/unit/test_messageframe.py | 123 - test/unit/test_packstream.py | 301 - test/unit/test_routing.py | 352 - test/unit/test_security.py | 4 +- test/unit/test_types.py | 2 +- tox.ini | 4 +- 60 files changed, 1552 insertions(+), 38705 deletions(-) delete mode 100644 neo4j/addressing.py delete mode 100644 neo4j/bolt/__init__.py delete mode 100644 neo4j/bolt/_io.c delete mode 100644 neo4j/bolt/_io.pyx delete mode 100644 neo4j/bolt/cert.py delete mode 100644 neo4j/bolt/connection.py delete mode 100644 neo4j/bolt/io.py delete mode 100644 neo4j/bolt/response.py delete mode 100644 neo4j/compat/collections.py delete mode 100644 neo4j/compat/ssl.py delete mode 100644 neo4j/packstream/__init__.py delete mode 100644 neo4j/packstream/_packer.c delete mode 100644 neo4j/packstream/_packer.pyx delete mode 100644 neo4j/packstream/_unpacker.c delete mode 100644 neo4j/packstream/_unpacker.pyx delete mode 100644 neo4j/packstream/constants.py delete mode 100644 neo4j/packstream/packer.py delete mode 100644 neo4j/packstream/structure.py delete mode 100644 neo4j/packstream/unpacker.py delete mode 100644 neo4j/util.py delete mode 100644 neo4j/v1/api.py delete mode 100644 neo4j/v1/direct.py delete mode 100644 neo4j/v1/exceptions.py delete mode 100644 neo4j/v1/result.py delete mode 100644 neo4j/v1/routing.py delete mode 100644 neo4j/v1/security.py delete mode 100644 test/stub/test_routing.py delete mode 100644 test/unit/test_addressing.py delete mode 100644 test/unit/test_chunkedinputbuffer.py delete mode 100644 test/unit/test_chunkedoutputbuffer.py delete mode 100644 test/unit/test_connection.py delete mode 100644 test/unit/test_messageframe.py delete mode 100644 test/unit/test_packstream.py delete mode 100644 test/unit/test_routing.py diff --git a/.coveragerc b/.coveragerc index 3526be71b..8fc2ed920 100644 --- a/.coveragerc +++ b/.coveragerc @@ -5,6 +5,7 @@ omit = test/* neo4j/compat/* neo4j/util.py + *neobolt* [report] show_missing = True diff --git a/MANIFEST.in b/MANIFEST.in index b4bfa7b81..c2fa55150 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,4 +1,2 @@ global-exclude *.class *.pyc *.pyo *.so *.dll __pycache__ -recursive-include neo4j *.c -recursive-include neo4j *.pyx prune test diff --git a/README.rst b/README.rst index 92fff20c0..5d48c1bb9 100644 --- a/README.rst +++ b/README.rst @@ -30,18 +30,6 @@ Quick Example session.write_transaction(add_friends, "Arthur", "Merlin") session.read_transaction(print_friends, "Arthur") -Logging -============= -The driver provides a built-in logging. The following example code enables debug logging and prints out logs at stdout: - -.. code-block:: python - - from neo4j.util import watch - import logging - from sys import stdout - - watch("neo4j.bolt", logging.DEBUG, stdout) - Installation ============ diff --git a/neo4j/__init__.py b/neo4j/__init__.py index 9136faa8b..062143963 100644 --- a/neo4j/__init__.py +++ b/neo4j/__init__.py @@ -19,4 +19,1467 @@ # limitations under the License. +__all__ = [ + "__version__", + "READ_ACCESS", + "WRITE_ACCESS", + "TRUST_ALL_CERTIFICATES", + "TRUST_CUSTOM_CA_SIGNED_CERTIFICATES", + "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES", + "GraphDatabase", + "Driver", + "DirectDriver", + "RoutingDriver", + "Session", + "Transaction", + "StatementResult", + "BoltStatementResult", + "BoltStatementResultSummary", + "Record", + "DriverError", + "SessionError", + "SessionExpired", + "TransactionError", + "basic_auth", + "custom_auth", + "kerberos_auth", +] + +try: + from neobolt.exceptions import ( + CypherError, + TransientError, + ServiceUnavailable, + ) +except ImportError: + # We allow this to fail because this module can be imported implicitly + # during setup. At that point, dependencies aren't available. + pass +else: + __all__.extend([ + "CypherError", + "TransientError", + "ServiceUnavailable", + ]) + + +from collections import deque, namedtuple, Mapping +from functools import reduce +from operator import xor as xor_operator +from random import random +from time import sleep +from warnings import warn + + +from .compat import perf_counter, urlparse +from .config import * from .meta import version as __version__ + + +READ_ACCESS = "READ" +WRITE_ACCESS = "WRITE" + +INITIAL_RETRY_DELAY = 1.0 +RETRY_DELAY_MULTIPLIER = 2.0 +RETRY_DELAY_JITTER_FACTOR = 0.2 + +STATEMENT_TYPE_READ_ONLY = "r" +STATEMENT_TYPE_READ_WRITE = "rw" +STATEMENT_TYPE_WRITE_ONLY = "w" +STATEMENT_TYPE_SCHEMA_WRITE = "s" + + +_warned_about_transaction_bookmarks = False + + +class GraphDatabase(object): + """ Accessor for :class:`.Driver` construction. + """ + + @classmethod + def driver(cls, uri, **config): + """ Create a :class:`.Driver` object. Calling this method provides + identical functionality to constructing a :class:`.Driver` or + :class:`.Driver` subclass instance directly. + """ + return Driver(uri, **config) + + +class Driver(object): + """ Base class for all types of :class:`.Driver`, instances of which are + used as the primary access point to Neo4j. + + :param uri: URI for a graph database service + :param config: configuration and authentication details (valid keys are listed below) + """ + + #: Overridden by subclasses to specify the URI scheme owned by that + #: class. + uri_scheme = None + + #: Connection pool + _pool = None + + #: Indicator of driver closure. + _closed = False + + @classmethod + def _check_uri(cls, uri): + """ Check whether a URI is compatible with a :class:`.Driver` + subclass. When called from a subclass, execution simply passes + through if the URI scheme is valid for that class. If invalid, + a `ValueError` is raised. + + :param uri: URI to check for compatibility + :raise: `ValueError` if URI scheme is incompatible + """ + parsed = urlparse(uri) + if parsed.scheme != cls.uri_scheme: + raise ValueError("%s objects require the %r URI scheme" % (cls.__name__, cls.uri_scheme)) + + def __new__(cls, uri, **config): + parsed = urlparse(uri) + for subclass in Driver.__subclasses__(): + if parsed.scheme == subclass.uri_scheme: + return subclass(uri, **config) + raise ValueError("URI scheme %r not supported" % parsed.scheme) + + def __del__(self): + self.close() + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def session(self, access_mode=None, **parameters): + """ Create a new :class:`.Session` object based on this + :class:`.Driver`. + + :param access_mode: default access mode (read or write) for + transactions in this session + :param parameters: custom session parameters (see + :class:`.Session` for details) + :returns: new :class:`.Session` object + """ + if self.closed(): + raise DriverError("Driver closed") + + def close(self): + """ Shut down, closing any open connections that were spawned by + this :class:`.Driver`. + """ + if not self._closed: + self._closed = True + if self._pool is not None: + self._pool.close() + self._pool = None + + def closed(self): + return self._closed + + +class DirectDriver(Driver): + """ A :class:`.DirectDriver` is created from a ``bolt`` URI and addresses + a single database instance. This provides basic connectivity to any + database service topology. + """ + + uri_scheme = "bolt" + + def __new__(cls, uri, **config): + from neobolt.addressing import SocketAddress + from neobolt.bolt.connection import DEFAULT_PORT, connect + from neobolt.direct import DirectConnectionPool + from neobolt.security import SecurityPlan + cls._check_uri(uri) + if SocketAddress.parse_routing_context(uri): + raise ValueError("Parameters are not supported with scheme 'bolt'. Given URI: '%s'." % uri) + instance = object.__new__(cls) + # We keep the address containing the host name or IP address exactly + # as-is from the original URI. This means that every new connection + # will carry out DNS resolution, leading to the possibility that + # the connection pool may contain multiple IP address keys, one for + # an old address and one for a new address. + instance.address = SocketAddress.from_uri(uri, DEFAULT_PORT) + instance.security_plan = security_plan = SecurityPlan.build(**config) + instance.encrypted = security_plan.encrypted + + def connector(address, error_handler): + return connect(address, security_plan.ssl_context, error_handler, **config) + + pool = DirectConnectionPool(connector, instance.address, **config) + pool.release(pool.acquire()) + instance._pool = pool + instance._max_retry_time = config.get("max_retry_time", default_config["max_retry_time"]) + return instance + + def session(self, access_mode=None, **parameters): + if "max_retry_time" not in parameters: + parameters["max_retry_time"] = self._max_retry_time + return Session(self._pool.acquire, access_mode, **parameters) + + +class RoutingDriver(Driver): + """ A :class:`.RoutingDriver` is created from a ``bolt+routing`` URI. The + routing behaviour works in tandem with Neo4j's causal clustering feature + by directing read and write behaviour to appropriate cluster members. + """ + + uri_scheme = "bolt+routing" + + def __new__(cls, uri, **config): + from neobolt.addressing import SocketAddress + from neobolt.bolt.connection import DEFAULT_PORT + from neobolt.routing import RoutingConnectionPool + from neobolt.security import SecurityPlan + cls._check_uri(uri) + instance = object.__new__(cls) + instance.initial_address = initial_address = SocketAddress.from_uri(uri, DEFAULT_PORT) + instance.security_plan = security_plan = SecurityPlan.build(**config) + instance.encrypted = security_plan.encrypted + routing_context = SocketAddress.parse_routing_context(uri) + if not security_plan.routing_compatible: + # this error message is case-specific as there is only one incompatible + # scenario right now + raise ValueError("TRUST_ON_FIRST_USE is not compatible with routing") + + def connector(address, error_handler): + from neobolt.bolt.connection import connect + return connect(address, security_plan.ssl_context, error_handler, **config) + + pool = RoutingConnectionPool(connector, initial_address, routing_context, initial_address, **config) + try: + pool.update_routing_table() + except: + pool.close() + raise + else: + instance._pool = pool + instance._max_retry_time = config.get("max_retry_time", default_config["max_retry_time"]) + return instance + + def session(self, access_mode=None, **parameters): + if "max_retry_time" not in parameters: + parameters["max_retry_time"] = self._max_retry_time + return Session(self._pool.acquire, access_mode, **parameters) + + +class Session(object): + """ A :class:`.Session` is a logical context for transactional units + of work. Connections are drawn from the :class:`.Driver` connection + pool as required. + + Session creation is a lightweight operation and sessions are not thread + safe. Therefore a session should generally be short-lived, and not + span multiple threads. + + In general, sessions will be created and destroyed within a `with` + context. For example:: + + with driver.session() as session: + result = session.run("MATCH (a:Person) RETURN a.name") + # do something with the result... + + :param acquirer: callback function for acquiring new connections + with a given access mode + :param access_mode: default access mode (read or write) for + transactions in this session + :param parameters: custom session parameters, including: + + `bookmark` + A single bookmark after which this session should begin. + (Deprecated, use `bookmarks` instead) + + `bookmarks` + A collection of bookmarks after which this session should begin. + + `max_retry_time` + The maximum time after which to stop attempting retries of failed + transactions. + + """ + + # The current connection. + _connection = None + + # The access mode for the current connection. + _connection_access_mode = None + + # The current :class:`.Transaction` instance, if any. + _transaction = None + + # The last result received. + _last_result = None + + # The collection of bookmarks after which the next + # :class:`.Transaction` should be carried out. + _bookmarks = () + + # Default maximum time to keep retrying failed transactions. + _max_retry_time = default_config["max_retry_time"] + + _closed = False + + def __init__(self, acquirer, access_mode, **parameters): + self._acquirer = acquirer + self._default_access_mode = access_mode + for key, value in parameters.items(): + if key == "bookmark": + self._bookmarks = [value] if value else [] + elif key == "bookmarks": + self._bookmarks = value or [] + elif key == "max_retry_time": + self._max_retry_time = value + else: + pass # for compatibility + + def __del__(self): + from neobolt.exceptions import ServiceUnavailable + try: + self.close() + except (SessionError, ServiceUnavailable): + pass + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() + + def _connect(self, access_mode=None): + if access_mode is None: + access_mode = self._default_access_mode + if self._connection: + if access_mode == self._connection_access_mode: + return + self._disconnect(sync=True) + self._connection = self._acquirer(access_mode) + self._connection_access_mode = access_mode + + def _disconnect(self, sync): + from neobolt.exceptions import ConnectionExpired, ServiceUnavailable + if self._connection: + if sync: + try: + self._connection.sync() + except (SessionError, ConnectionExpired, ServiceUnavailable): + pass + if self._connection: + self._connection.in_use = False + self._connection = None + self._connection_access_mode = None + + def close(self): + """ Close the session. This will release any borrowed resources, + such as connections, and will roll back any outstanding transactions. + """ + from neobolt.exceptions import ConnectionExpired, CypherError, ServiceUnavailable + try: + if self.has_transaction(): + try: + self.rollback_transaction() + except (CypherError, TransactionError, SessionError, ConnectionExpired, ServiceUnavailable): + pass + finally: + self._closed = True + self._disconnect(sync=True) + + def closed(self): + """ Indicator for whether or not this session has been closed. + + :returns: :const:`True` if closed, :const:`False` otherwise. + """ + return self._closed + + def run(self, statement, parameters=None, **kwparameters): + """ Run a Cypher statement within an auto-commit transaction. + + The statement is sent and the result header received + immediately but the :class:`.StatementResult` content is + fetched lazily as consumed by the client application. + + If a statement is executed before a previous + :class:`.StatementResult` in the same :class:`.Session` has + been fully consumed, the first result will be fully fetched + and buffered. Note therefore that the generally recommended + pattern of usage is to fully consume one result before + executing a subsequent statement. If two results need to be + consumed in parallel, multiple :class:`.Session` objects + can be used as an alternative to result buffering. + + For more usage details, see :meth:`.Transaction.run`. + + :param statement: template Cypher statement + :param parameters: dictionary of parameters + :param kwparameters: additional keyword parameters + :returns: :class:`.StatementResult` object + """ + from neobolt.exceptions import ConnectionExpired + + if self.closed(): + raise SessionError("Session closed") + if not statement: + raise ValueError("Cannot run an empty statement") + + if not self.has_transaction(): + self._connect() + + result = self.__run__(statement, dict(parameters or {}, **kwparameters)) + + if not self.has_transaction(): + try: + self._connection.send() + self._connection.fetch() + except ConnectionExpired as error: + raise SessionExpired(*error.args) + + return result + + def send(self): + """ Send all outstanding requests. + """ + from neobolt.exceptions import ConnectionExpired + if self._connection: + try: + self._connection.send() + except ConnectionExpired as error: + raise SessionExpired(*error.args) + + def fetch(self): + """ Attempt to fetch at least one more record. + + :returns: number of records fetched + """ + from neobolt.exceptions import ConnectionExpired + if self._connection: + try: + detail_count, _ = self._connection.fetch() + except ConnectionExpired as error: + raise SessionExpired(*error.args) + else: + return detail_count + return 0 + + def sync(self): + """ Carry out a full send and receive. + + :returns: number of records fetched + """ + from neobolt.exceptions import ConnectionExpired + if self._connection: + try: + detail_count, _ = self._connection.sync() + except ConnectionExpired as error: + raise SessionExpired(*error.args) + else: + return detail_count + return 0 + + def detach(self, result): + """ Detach a result from this session by fetching and buffering any + remaining records. + + :param result: + :returns: number of records fetched + """ + count = 0 + + self.send() + fetch = self.fetch + while result.attached(): + count += fetch() + + if self._last_result is result: + self._last_result = None + if not self.has_transaction(): + self._disconnect(sync=False) + + return count + + def last_bookmark(self): + """ The bookmark returned by the last :class:`.Transaction`. + """ + last = None + for bookmark in self._bookmarks: + if last is None: + last = bookmark + else: + last = last_bookmark(last, bookmark) + return last + + def has_transaction(self): + return bool(self._transaction) + + def _create_transaction(self): + self._transaction = Transaction(self, on_close=self._destroy_transaction) + + def _destroy_transaction(self): + self._transaction = None + + def begin_transaction(self, bookmark=None): + """ Create a new :class:`.Transaction` within this session. + Calling this method with a bookmark is equivalent to + + :param bookmark: a bookmark to which the server should + synchronise before beginning the transaction + :returns: new :class:`.Transaction` instance. + :raise: :class:`.TransactionError` if a transaction is already open + """ + if self.has_transaction(): + raise TransactionError("Explicit transaction already open") + + if bookmark is not None: + global _warned_about_transaction_bookmarks + if not _warned_about_transaction_bookmarks: + from warnings import warn + warn("Passing bookmarks at transaction level is deprecated", category=DeprecationWarning, stacklevel=2) + _warned_about_transaction_bookmarks = True + self._bookmarks = [bookmark] + + self._create_transaction() + self._connect() + self.__begin__() + return self._transaction + + def commit_transaction(self): + """ Commit the current transaction. + + :returns: the bookmark returned from the server, if any + :raise: :class:`.TransactionError` if no transaction is currently open + """ + if not self.has_transaction(): + raise TransactionError("No transaction to commit") + self._transaction = None + result = self.__commit__() + result.consume() + bookmark = self.__bookmark__(result) + self._bookmarks = [bookmark] + return bookmark + + def rollback_transaction(self): + """ Rollback the current transaction. + + :raise: :class:`.TransactionError` if no transaction is currently open + """ + from neobolt.exceptions import ServiceUnavailable + if not self.has_transaction(): + raise TransactionError("No transaction to rollback") + self._destroy_transaction() + rollback_result = self.__rollback__() + try: + rollback_result.consume() + except ServiceUnavailable: + pass + + def reset(self): + """ Reset the session. + """ + self._destroy_transaction() + self._connection.reset() + + def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs): + from neobolt.exceptions import ConnectionExpired, TransientError, ServiceUnavailable + + if not callable(unit_of_work): + raise TypeError("Unit of work is not callable") + retry_delay = retry_delay_generator(INITIAL_RETRY_DELAY, + RETRY_DELAY_MULTIPLIER, + RETRY_DELAY_JITTER_FACTOR) + errors = [] + t0 = perf_counter() + while True: + try: + self._create_transaction() + self._connect(access_mode) + self.__begin__() + tx = self._transaction + try: + result = unit_of_work(tx, *args, **kwargs) + except: + if tx.success is None: + tx.success = False + raise + else: + if tx.success is None: + tx.success = True + finally: + tx.close() + except (ServiceUnavailable, SessionExpired, ConnectionExpired) as error: + errors.append(error) + except TransientError as error: + if is_retriable_transient_error(error): + errors.append(error) + else: + raise + else: + return result + t1 = perf_counter() + if t1 - t0 > self._max_retry_time: + break + sleep(next(retry_delay)) + if errors: + raise errors[-1] + else: + raise ServiceUnavailable("Transaction failed") + + def read_transaction(self, unit_of_work, *args, **kwargs): + return self._run_transaction(READ_ACCESS, unit_of_work, *args, **kwargs) + + def write_transaction(self, unit_of_work, *args, **kwargs): + return self._run_transaction(WRITE_ACCESS, unit_of_work, *args, **kwargs) + + def _run(self, statement, parameters): + from neobolt.bolt.connection import RUN, PULL_ALL + from neobolt.bolt.response import Response + if self.closed(): + raise SessionError("Session closed") + + run_response = Response(self._connection) + pull_all_response = Response(self._connection) + self._last_result = result = BoltStatementResult(self, run_response, pull_all_response) + result.statement = ustr(statement) + result.parameters = fix_parameters(parameters, self._connection.protocol_version, + supports_bytes=self._connection.server.supports_bytes()) + + self._connection.append(RUN, (result.statement, result.parameters), response=run_response) + self._connection.append(PULL_ALL, response=pull_all_response) + + return result + + def __run__(self, statement, parameters): + return self._run(statement, parameters) + + def __begin__(self): + if self._bookmarks: + parameters = {"bookmark": self.last_bookmark(), "bookmarks": self._bookmarks} + else: + parameters = {} + return self.__run__(u"BEGIN", parameters) + + def __commit__(self): + return self.__run__(u"COMMIT", {}) + + def __rollback__(self): + return self.__run__(u"ROLLBACK", {}) + + def __bookmark__(self, result): + summary = result.summary() + return summary.metadata.get("bookmark") + + +class Transaction(object): + """ Container for multiple Cypher queries to be executed within + a single context. Transactions can be used within a :py:const:`with` + block where the value of :attr:`.success` will determine whether + the transaction is committed or rolled back on :meth:`.Transaction.close`:: + + with session.begin_transaction() as tx: + pass + + """ + + #: When set, the transaction will be committed on close, otherwise it + #: will be rolled back. This attribute can be set in user code + #: multiple times before a transaction completes with only the final + #: value taking effect. + success = None + + _closed = False + + def __init__(self, session, on_close): + self.session = session + self.on_close = on_close + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + if self.success is None: + self.success = not bool(exc_type) + self.close() + + def run(self, statement, parameters=None, **kwparameters): + """ Run a Cypher statement within the context of this transaction. + + The statement is sent to the server lazily, when its result is + consumed. To force the statement to be sent to the server, use + the :meth:`.Transaction.sync` method. + + Cypher is typically expressed as a statement template plus a + set of named parameters. In Python, parameters may be expressed + through a dictionary of parameters, through individual parameter + arguments, or as a mixture of both. For example, the `run` + statements below are all equivalent:: + + >>> statement = "CREATE (a:Person {name:{name}, age:{age}})" + >>> tx.run(statement, {"name": "Alice", "age": 33}) + >>> tx.run(statement, {"name": "Alice"}, age=33) + >>> tx.run(statement, name="Alice", age=33) + + Parameter values can be of any type supported by the Neo4j type + system. In Python, this includes :class:`bool`, :class:`int`, + :class:`str`, :class:`list` and :class:`dict`. Note however that + :class:`list` properties must be homogenous. + + :param statement: template Cypher statement + :param parameters: dictionary of parameters + :param kwparameters: additional keyword parameters + :returns: :class:`.StatementResult` object + """ + if self.closed(): + raise TransactionError("Transaction closed") + return self.session.run(statement, parameters, **kwparameters) + + def sync(self): + """ Force any queued statements to be sent to the server and + all related results to be fetched and buffered. + + :raise TransactionError: if the transaction is closed + """ + if self.closed(): + raise TransactionError("Transaction closed") + self.session.sync() + + def commit(self): + """ Mark this transaction as successful and close in order to + trigger a COMMIT. + + :raise TransactionError: if already closed + """ + if self.closed(): + raise TransactionError("Transaction closed") + self.success = True + self.close() + + def rollback(self): + """ Mark this transaction as unsuccessful and close in order to + trigger a ROLLBACK. + + :raise TransactionError: if already closed + """ + if self.closed(): + raise TransactionError("Transaction closed") + self.success = False + self.close() + + def close(self): + """ Close this transaction, triggering either a COMMIT or a ROLLBACK. + """ + from neobolt.exceptions import CypherError + if not self.closed(): + try: + self.sync() + except CypherError: + self.success = False + raise + finally: + if self.session.has_transaction(): + if self.success: + self.session.commit_transaction() + else: + self.session.rollback_transaction() + self._closed = True + self.on_close() + + def closed(self): + """ Indicator to show whether the transaction has been closed. + :returns: :const:`True` if closed, :const:`False` otherwise. + """ + return self._closed + + +class StatementResult(object): + """ A handler for the result of Cypher statement execution. Instances + of this class are typically constructed and returned by + :meth:`.Session.run` and :meth:`.Transaction.run`. + """ + + #: The statement text that was executed to produce this result. + statement = None + + #: Dictionary of parameters passed with the statement. + parameters = None + + zipper = zip + + def __init__(self, session, hydrant): + self._session = session + self._hydrant = hydrant + self._keys = None + self._records = deque() + self._summary = None + + def __iter__(self): + return self.records() + + @property + def session(self): + return self._session + + def attached(self): + """ Indicator for whether or not this result is still attached to + a :class:`.Session`. + + :returns: :const:`True` if still attached, :const:`False` otherwise + """ + return self._session and not self._session.closed() + + def detach(self): + """ Detach this result from its parent session by fetching the + remainder of this result from the network into the buffer. + + :returns: number of records fetched + """ + if self.attached(): + return self._session.detach(self) + else: + return 0 + + def keys(self): + """ The keys for the records in this result. + + :returns: tuple of key names + """ + if self._keys is not None: + return self._keys + if self.attached(): + self._session.send() + while self.attached() and self._keys is None: + self._session.fetch() + return self._keys + + def records(self): + """ Generator for records obtained from this result. + + :yields: iterable of :class:`.Record` objects + """ + records = self._records + next_record = records.popleft + while records: + yield next_record() + attached = self.attached + if attached(): + self._session.send() + while attached(): + self._session.fetch() + while records: + yield next_record() + + def summary(self): + """ Obtain the summary of this result, buffering any remaining records. + + :returns: The :class:`.ResultSummary` for this result + """ + self.detach() + return self._summary + + def consume(self): + """ Consume the remainder of this result and return the summary. + + :returns: The :class:`.ResultSummary` for this result + """ + if self.attached(): + for _ in self: + pass + return self.summary() + + def single(self): + """ Obtain the next and only remaining record from this result. + + A warning is generated if more than one record is available but + the first of these is still returned. + + :returns: the next :class:`.Record` or :const:`None` if none remain + :warns: if more than one record is available + """ + records = list(self) + size = len(records) + if size == 0: + return None + if size != 1: + warn("Expected a result with a single record, but this result contains %d" % size) + return records[0] + + def peek(self): + """ Obtain the next record from this result without consuming it. + This leaves the record in the buffer for further processing. + + :returns: the next :class:`.Record` or :const:`None` if none remain + """ + hydrate = self._hydrant.hydrate + zipper = self.zipper + keys = self.keys() + records = self._records + if records: + values = records[0] + return zipper(keys, hydrate(values)) + if not self.attached(): + return None + if self.attached(): + self._session.send() + while self.attached() and not records: + self._session.fetch() + if records: + values = records[0] + return zipper(keys, hydrate(values)) + return None + + def graph(self): + """ Return a Graph instance containing all the graph objects + in the result. After calling this method, the result becomes + detached, buffering all remaining records. + + :returns: result graph + """ + self.detach() + return self._hydrant.graph + + +class BoltStatementResult(StatementResult): + """ A handler for the result of Cypher statement execution. + """ + + @classmethod + def zipper(cls, k, v): + return Record(zip(k, v)) + + def __init__(self, session, run_response, pull_all_response): + from neobolt.exceptions import CypherError + + super(BoltStatementResult, self).__init__(session, PackStreamHydrator(session._connection.protocol_version)) + + all_metadata = {} + + def on_header(metadata): + # Called on receipt of the result header. + all_metadata.update(metadata) + self._keys = tuple(metadata.get("fields", ())) + + def on_records(records): + # Called on receipt of one or more result records. + self._records.extend(map(lambda record: self.zipper(self.keys(), self._hydrant.hydrate(record)), records)) + + def on_footer(metadata): + # Called on receipt of the result footer. + connection = self.session._connection + all_metadata.update(metadata, statement=self.statement, parameters=self.parameters, + server=connection.server, protocol_version=connection.protocol_version) + self._summary = BoltStatementResultSummary(**all_metadata) + self._session, session_ = None, self._session + session_.detach(self) + + def on_failure(metadata): + # Called on execution failure. + self.session.reset() + on_footer(metadata) + raise CypherError.hydrate(**metadata) + + run_response.on_success = on_header + run_response.on_failure = on_failure + + pull_all_response.on_records = on_records + pull_all_response.on_success = on_footer + pull_all_response.on_failure = on_failure + + def value(self, item=0, default=None): + """ Return the remainder of the result as a list of values. + + :param item: field to return for each remaining record + :param default: default value, used if the index of key is unavailable + :returns: list of individual values + """ + return [record.value(item, default) for record in self.records()] + + def values(self, *items): + """ Return the remainder of the result as a list of tuples. + + :param items: fields to return for each remaining record + :returns: list of value tuples + """ + return [record.values(*items) for record in self.records()] + + def data(self, *items): + """ Return the remainder of the result as a list of dictionaries. + + :param items: fields to return for each remaining record + :returns: list of dictionaries + """ + return [record.data(*items) for record in self.records()] + + +class BoltStatementResultSummary(object): + """ A summary of execution returned with a :class:`.StatementResult` object. + """ + + #: The version of Bolt protocol over which this result was obtained. + protocol_version = None + + #: The server on which this result was generated. + server = None + + #: The statement that was executed to produce this result. + statement = None + + #: Dictionary of parameters passed with the statement. + parameters = None + + #: The type of statement (``'r'`` = read-only, ``'rw'`` = read/write). + statement_type = None + + #: A set of statistical information held in a :class:`.Counters` instance. + counters = None + + #: A :class:`.Plan` instance + plan = None + + #: A :class:`.ProfiledPlan` instance + profile = None + + #: The time it took for the server to have the result available. + result_available_after = None + + #: The time it took for the server to consume the result. + result_consumed_after = None + + #: Notifications provide extra information for a user executing a statement. + #: They can be warnings about problematic queries or other valuable information that can be + #: presented in a client. + #: Unlike failures or errors, notifications do not affect the execution of a statement. + notifications = None + + def __init__(self, **metadata): + self.metadata = metadata + self.protocol_version = metadata.get("protocol_version") + self.server = metadata.get("server") + self.statement = metadata.get("statement") + self.parameters = metadata.get("parameters") + self.statement_type = metadata.get("type") + self.counters = SummaryCounters(metadata.get("stats", {})) + self.result_available_after = metadata.get("result_available_after") + self.result_consumed_after = metadata.get("result_consumed_after") + if "plan" in metadata: + self.plan = _make_plan(metadata["plan"]) + if "profile" in metadata: + self.profile = _make_plan(metadata["profile"]) + self.plan = self.profile + self.notifications = [] + for notification in metadata.get("notifications", []): + position = notification.get("position") + if position is not None: + position = Position(position["offset"], position["line"], position["column"]) + self.notifications.append(Notification(notification["code"], notification["title"], + notification["description"], notification["severity"], position)) + + +class SummaryCounters(object): + """ Set of statistics from a Cypher statement execution. + """ + + #: + nodes_created = 0 + + #: + nodes_deleted = 0 + + #: + relationships_created = 0 + + #: + relationships_deleted = 0 + + #: + properties_set = 0 + + #: + labels_added = 0 + + #: + labels_removed = 0 + + #: + indexes_added = 0 + + #: + indexes_removed = 0 + + #: + constraints_added = 0 + + #: + constraints_removed = 0 + + def __init__(self, statistics): + for key, value in dict(statistics).items(): + key = key.replace("-", "_") + setattr(self, key, value) + + def __repr__(self): + return repr(vars(self)) + + @property + def contains_updates(self): + return bool(self.nodes_created or self.nodes_deleted or + self.relationships_created or self.relationships_deleted or + self.properties_set or self.labels_added or self.labels_removed or + self.indexes_added or self.indexes_removed or + self.constraints_added or self.constraints_removed) + + +#: A plan describes how the database will execute your statement. +#: +#: operator_type: +#: the name of the operation performed by the plan +#: identifiers: +#: the list of identifiers used by this plan +#: arguments: +#: a dictionary of arguments used in the specific operation performed by the plan +#: children: +#: a list of sub-plans +Plan = namedtuple("Plan", ("operator_type", "identifiers", "arguments", "children")) + +#: A profiled plan describes how the database executed your statement. +#: +#: db_hits: +#: the number of times this part of the plan touched the underlying data stores +#: rows: +#: the number of records this part of the plan produced +ProfiledPlan = namedtuple("ProfiledPlan", Plan._fields + ("db_hits", "rows")) + +#: Representation for notifications found when executing a statement. A +#: notification can be visualized in a client pinpointing problems or +#: other information about the statement. +#: +#: code: +#: a notification code for the discovered issue. +#: title: +#: a short summary of the notification +#: description: +#: a long description of the notification +#: severity: +#: the severity level of the notification +#: position: +#: the position in the statement where this notification points to, if relevant. +Notification = namedtuple("Notification", ("code", "title", "description", "severity", "position")) + +#: A position within a statement, consisting of offset, line and column. +#: +#: offset: +#: the character offset referred to by this position; offset numbers start at 0 +#: line: +#: the line number referred to by the position; line numbers start at 1 +#: column: +#: the column number referred to by the position; column numbers start at 1 +Position = namedtuple("Position", ("offset", "line", "column")) + + +def _make_plan(plan_dict): + """ Construct a Plan or ProfiledPlan from a dictionary of metadata values. + + :param plan_dict: + :return: + """ + operator_type = plan_dict["operatorType"] + identifiers = plan_dict.get("identifiers", []) + arguments = plan_dict.get("args", []) + children = [_make_plan(child) for child in plan_dict.get("children", [])] + if "dbHits" in plan_dict or "rows" in plan_dict: + db_hits = plan_dict.get("dbHits", 0) + rows = plan_dict.get("rows", 0) + return ProfiledPlan(operator_type, identifiers, arguments, children, db_hits, rows) + else: + return Plan(operator_type, identifiers, arguments, children) + + +class Record(tuple, Mapping): + """ A :class:`.Record` is an immutable ordered collection of key-value + pairs. It is generally closer to a :py:class:`namedtuple` than to a + :py:class:`OrderedDict` inasmuch as iteration of the collection will + yield values rather than keys. + """ + + __keys = None + + def __new__(cls, iterable): + keys = [] + values = [] + for key, value in iter_items(iterable): + keys.append(key) + values.append(value) + inst = tuple.__new__(cls, values) + inst.__keys = tuple(keys) + return inst + + def __repr__(self): + return "<%s %s>" % (self.__class__.__name__, + " ".join("%s=%r" % (field, self[i]) for i, field in enumerate(self.__keys))) + + def __eq__(self, other): + return dict(self) == dict(other) + + def __ne__(self, other): + return not self.__eq__(other) + + def __hash__(self): + return reduce(xor_operator, map(hash, self.items())) + + def __getitem__(self, key): + if isinstance(key, slice): + keys = self.__keys[key] + values = super(Record, self).__getitem__(key) + return self.__class__(zip(keys, values)) + index = self.index(key) + if 0 <= index < len(self): + return super(Record, self).__getitem__(index) + else: + return None + + def __getslice__(self, start, stop): + key = slice(start, stop) + keys = self.__keys[key] + values = tuple(self)[key] + return self.__class__(zip(keys, values)) + + def get(self, key, default=None): + try: + index = self.__keys.index(ustr(key)) + except ValueError: + return default + if 0 <= index < len(self): + return super(Record, self).__getitem__(index) + else: + return default + + def index(self, key): + """ Return the index of the given item. + """ + if isinstance(key, integer): + if 0 <= key < len(self.__keys): + return key + raise IndexError(key) + elif isinstance(key, string): + try: + return self.__keys.index(key) + except ValueError: + raise KeyError(key) + else: + raise TypeError(key) + + def value(self, key=0, default=None): + """ Obtain a single value from the record by index or key. If no + index or key is specified, the first value is returned. If the + specified item does not exist, the default value is returned. + + :param key: + :param default: + :return: + """ + try: + index = self.index(key) + except (IndexError, KeyError): + return default + else: + return self[index] + + def keys(self): + """ Return the keys of the record. + + :return: list of key names + """ + return list(self.__keys) + + def values(self, *keys): + """ Return the values of the record, optionally filtering to + include only certain values by index or key. + + :param keys: indexes or keys of the items to include; if none + are provided, all values will be included + :return: list of values + """ + if keys: + d = [] + for key in keys: + try: + i = self.index(key) + except KeyError: + d.append(None) + else: + d.append(self[i]) + return d + return list(self) + + def items(self, *keys): + """ Return the fields of the record as a list of key and value tuples + + :return: + """ + if keys: + d = [] + for key in keys: + try: + i = self.index(key) + except KeyError: + d.append((key, None)) + else: + d.append((self.__keys[i], self[i])) + return d + return list((self.__keys[i], super(Record, self).__getitem__(i)) for i in range(len(self))) + + def data(self, *keys): + """ Return the keys and values of this record as a dictionary, + optionally including only certain values by index or key. Keys + provided in the items that are not in the record will be + inserted with a value of :const:`None`; indexes provided + that are out of bounds will trigger an :exc:`IndexError`. + + :param keys: indexes or keys of the items to include; if none + are provided, all values will be included + :return: dictionary of values, keyed by field name + :raises: :exc:`IndexError` if an out-of-bounds index is specified + """ + if keys: + d = {} + for key in keys: + try: + i = self.index(key) + except KeyError: + d[key] = None + else: + d[self.__keys[i]] = self[i] + return d + return dict(self) + + +class DriverError(Exception): + """ Raised when an error occurs while using a driver. + """ + + def __init__(self, driver, *args, **kwargs): + super(DriverError, self).__init__(*args, **kwargs) + self.driver = driver + + +class SessionError(Exception): + """ Raised when an error occurs while using a session. + """ + + def __init__(self, session, *args, **kwargs): + super(SessionError, self).__init__(*args, **kwargs) + self.session = session + + +class SessionExpired(SessionError): + """ Raised when no a session is no longer able to fulfil + the purpose described by its original parameters. + """ + + def __init__(self, session, *args, **kwargs): + super(SessionExpired, self).__init__(session, *args, **kwargs) + + +class TransactionError(Exception): + """ Raised when an error occurs while using a transaction. + """ + + def __init__(self, transaction, *args, **kwargs): + super(TransactionError, self).__init__(*args, **kwargs) + self.transaction = transaction + + +def basic_auth(user, password, realm=None): + """ Generate a basic auth token for a given user and password. + + :param user: user name + :param password: current password + :param realm: specifies the authentication provider + :return: auth token for use with :meth:`GraphDatabase.driver` + """ + from neobolt.security import AuthToken + return AuthToken("basic", user, password, realm) + + +def kerberos_auth(base64_encoded_ticket): + """ Generate a kerberos auth token with the base64 encoded ticket + + :param base64_encoded_ticket: a base64 encoded service ticket + :return: an authentication token that can be used to connect to Neo4j + """ + from neobolt.security import AuthToken + return AuthToken("kerberos", "", base64_encoded_ticket) + + +def custom_auth(principal, credentials, realm, scheme, **parameters): + """ Generate a basic auth token for a given user and password. + + :param principal: specifies who is being authenticated + :param credentials: authenticates the principal + :param realm: specifies the authentication provider + :param scheme: specifies the type of authentication + :param parameters: parameters passed along to the authentication provider + :return: auth token for use with :meth:`GraphDatabase.driver` + """ + from neobolt.security import AuthToken + return AuthToken(scheme, principal, credentials, realm, **parameters) + + +def fix_parameters(parameters, protocol_version, **kwargs): + if not parameters: + return {} + dehydrator = PackStreamDehydrator(protocol_version, **kwargs) + try: + dehydrated, = dehydrator.dehydrate([parameters]) + except TypeError as error: + value = error.args[0] + raise TypeError("Parameters of type {} are not supported".format(type(value).__name__)) + else: + return dehydrated + + +def iter_items(iterable): + """ Iterate through all items (key-value pairs) within an iterable + dictionary-like object. If the object has a `keys` method, this is + used along with `__getitem__` to yield each pair in turn. If no + `keys` method exists, each iterable element is assumed to be a + 2-tuple of key and value. + """ + if hasattr(iterable, "keys"): + for key in iterable.keys(): + yield key, iterable[key] + else: + for key, value in iterable: + yield key, value + + +def last_bookmark(b0, b1): + """ Return the latest of two bookmarks by looking for the maximum + integer value following the last colon in the bookmark string. + """ + n = [None, None] + _, _, n[0] = b0.rpartition(":") + _, _, n[1] = b1.rpartition(":") + for i in range(2): + try: + n[i] = int(n[i]) + except ValueError: + raise ValueError("Invalid bookmark: {}".format(b0)) + return b0 if n[0] > n[1] else b1 + + +def retry_delay_generator(initial_delay, multiplier, jitter_factor): + delay = initial_delay + while True: + jitter = jitter_factor * delay + yield delay - jitter + (2 * jitter * random()) + delay *= multiplier + + +def is_retriable_transient_error(error): + """ + :type error: TransientError + """ + return not (error.code in ("Neo.TransientError.Transaction.Terminated", + "Neo.TransientError.Transaction.LockClientStopped")) + + +from .v1.types import * diff --git a/neo4j/__main__.py b/neo4j/__main__.py index f8a4f8d83..5e037971a 100644 --- a/neo4j/__main__.py +++ b/neo4j/__main__.py @@ -26,7 +26,8 @@ from json import loads as json_loads from sys import stdout, stderr -from .util import Watcher +from neobolt.util import Watcher + from .v1 import GraphDatabase from neo4j.exceptions import CypherError diff --git a/neo4j/addressing.py b/neo4j/addressing.py deleted file mode 100644 index c4d073e46..000000000 --- a/neo4j/addressing.py +++ /dev/null @@ -1,143 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from collections import namedtuple -from socket import getaddrinfo, gaierror, SOCK_STREAM, IPPROTO_TCP - -from neo4j.compat import urlparse, parse_qs -from neo4j.exceptions import AddressError - - -VALID_IPv4_SEGMENTS = [str(i).encode("latin1") for i in range(0x100)] -VALID_IPv6_SEGMENT_CHARS = b"0123456789abcdef" - - -def is_ipv4_address(string): - if not isinstance(string, bytes): - string = str(string).encode("latin1") - segments = string.split(b".") - return len(segments) == 4 and all(segment in VALID_IPv4_SEGMENTS for segment in segments) - - -def is_ipv6_address(string): - if not isinstance(string, bytes): - string = str(string).encode("latin1") - segments = string.lower().split(b":") - return 3 <= len(segments) <= 8 and all(all(c in VALID_IPv6_SEGMENT_CHARS for c in segment) for segment in segments) - - -def is_ip_address(string): - return is_ipv4_address(string) or is_ipv6_address(string) - - -IPv4SocketAddress = namedtuple("Address", ["host", "port"]) -IPv6SocketAddress = namedtuple("Address", ["host", "port", "flow_info", "scope_id"]) - - -class SocketAddress(object): - - @classmethod - def from_socket(cls, socket): - address = socket.getpeername() - if len(address) == 2: - return IPv4SocketAddress(*address) - elif len(address) == 4: - return IPv6SocketAddress(*address) - else: - raise ValueError("Unsupported address {!r}".format(address)) - - @classmethod - def from_uri(cls, uri, default_port=0): - parsed = urlparse(uri) - if parsed.netloc.startswith("["): - return IPv6SocketAddress(parsed.hostname, parsed.port or default_port, 0, 0) - else: - return IPv4SocketAddress(parsed.hostname, parsed.port or default_port) - - @classmethod - def parse(cls, string, default_port=0): - """ Parse a string address, such as 'localhost:1234' or - '[::1]:7687'. - """ - return cls.from_uri("//{}".format(string), default_port) - - @classmethod - def parse_routing_context(cls, uri): - query = urlparse(uri).query - if not query: - return {} - - context = {} - parameters = parse_qs(query, True) - for key in parameters: - value_list = parameters[key] - if len(value_list) != 1: - raise ValueError("Duplicated query parameters with key '%s', value '%s' found in URL '%s'" % (key, value_list, uri)) - value = value_list[0] - if not value: - raise ValueError("Invalid parameters:'%s=%s' in URI '%s'." % (key, value, uri)) - context[key] = value - return context - - -class Resolver(object): - """ A Resolver instance stores a list of addresses, each in a tuple, and - provides methods to perform resolution on these, thereby replacing them - with the resolved values. - """ - - def __init__(self, custom_resolver=None): - self.addresses = [] - self.custom_resolver = custom_resolver - - def custom_resolve(self): - """ If a custom resolver is defined, perform custom resolution on - the contained addresses. - - :return: - """ - if not callable(self.custom_resolver): - return - new_addresses = [] - for address in self.addresses: - for new_address in self.custom_resolver(address): - new_addresses.append(new_address) - self.addresses = new_addresses - - def dns_resolve(self): - """ Perform DNS resolution on the contained addresses. - - :return: - """ - new_addresses = [] - for address in self.addresses: - try: - info = getaddrinfo(address[0], address[1], 0, SOCK_STREAM, IPPROTO_TCP) - except gaierror: - raise AddressError("Cannot resolve address {!r}".format(address)) - else: - for _, _, _, _, address in info: - if len(address) == 4 and address[3] != 0: - # skip any IPv6 addresses with a non-zero scope id - # as these appear to cause problems on some platforms - continue - new_addresses.append(address) - self.addresses = new_addresses diff --git a/neo4j/bolt/__init__.py b/neo4j/bolt/__init__.py deleted file mode 100644 index 7924fba86..000000000 --- a/neo4j/bolt/__init__.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from .cert import * -from .connection import * -from .response import * \ No newline at end of file diff --git a/neo4j/bolt/_io.c b/neo4j/bolt/_io.c deleted file mode 100644 index 365da8251..000000000 --- a/neo4j/bolt/_io.c +++ /dev/null @@ -1,9975 +0,0 @@ -/* Generated by Cython 0.27.3 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "name": "neo4j.bolt._io", - "sources": [ - "/home/technige/work/neo4j-python-driver/neo4j/bolt/_io.pyx" - ] - }, - "module_name": "neo4j.bolt._io" -} -END: Cython Metadata */ - -#define PY_SSIZE_T_CLEAN -#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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) - #error Cython requires Python 2.6+ or Python 3.3+. -#else -#define CYTHON_ABI "0_27_3" -#define CYTHON_FUTURE_DIVISION 0 -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !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 HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x02070000 - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #if PY_VERSION_HEX < 0x03050000 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #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_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #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_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) - #define CYTHON_USE_PYTYPE_LOOKUP 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #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 - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif - #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) - #endif - #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK -#endif -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, 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) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_PyCode_New(a, 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) - #define __Pyx_DefaultClassType PyType_Type -#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 -#if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL) - #ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#elif PY_VERSION_HEX >= 0x03060000 - #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() -#elif PY_VERSION_HEX >= 0x03000000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#else - #define __Pyx_PyThreadState_Current _PyThreadState_Current -#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 -#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #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) 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, ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#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 && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#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_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #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 -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef __Pyx_PyAsyncMethodsStruct - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; -#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(__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_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #if defined(__cplusplus) && __cplusplus >= 201103L - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #elif __has_cpp_attribute(gnu::fallthrough) - #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] - #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 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 - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - - -#define __PYX_ERR(f_index, lineno, Ln_error) \ -{ \ - __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ -} - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__neo4j__bolt___io -#define __PYX_HAVE_API__neo4j__bolt___io -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 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))) ) -#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 const char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#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 PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#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_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __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_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(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_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#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__ */ -static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } - -static PyObject *__pyx_m = NULL; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - - -static const char *__pyx_f[] = { - "neo4j/bolt/_io.pyx", - "stringsource", -}; - -/*--- Type declarations ---*/ -struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame; -struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer; -struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer; - -/* "neo4j/bolt/_io.pyx":30 - * - * - * cdef class MessageFrame(object): # <<<<<<<<<<<<<< - * - * cdef _view - */ -struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame { - PyObject_HEAD - struct __pyx_vtabstruct_5neo4j_4bolt_3_io_MessageFrame *__pyx_vtab; - PyObject *_view; - PyObject *_panes; - int _current_pane; - int _current_offset; -}; - - -/* "neo4j/bolt/_io.pyx":108 - * - * - * cdef class ChunkedInputBuffer(object): # <<<<<<<<<<<<<< - * - * cdef bytearray _data - */ -struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer { - PyObject_HEAD - struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_vtab; - PyObject *_data; - PyObject *_view; - int _extent; - int _origin; - int _limit; - struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *_frame; -}; - - -/* "neo4j/bolt/_io.pyx":257 - * - * - * cdef class ChunkedOutputBuffer(object): # <<<<<<<<<<<<<< - * - * cdef int _max_chunk_size - */ -struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer { - PyObject_HEAD - struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_vtab; - int _max_chunk_size; - PyObject *_data; - int _header; - int _start; - int _end; -}; - - - -/* "neo4j/bolt/_io.pyx":30 - * - * - * cdef class MessageFrame(object): # <<<<<<<<<<<<<< - * - * cdef _view - */ - -struct __pyx_vtabstruct_5neo4j_4bolt_3_io_MessageFrame { - PyObject *(*_next_pane)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *); - PyObject *(*panes)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *, int __pyx_skip_dispatch); - PyObject *(*read_int)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *, int __pyx_skip_dispatch); - PyObject *(*read)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *, int, int __pyx_skip_dispatch); - PyObject *(*close)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_5neo4j_4bolt_3_io_MessageFrame *__pyx_vtabptr_5neo4j_4bolt_3_io_MessageFrame; - - -/* "neo4j/bolt/_io.pyx":108 - * - * - * cdef class ChunkedInputBuffer(object): # <<<<<<<<<<<<<< - * - * cdef bytearray _data - */ - -struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer { - PyObject *(*capacity)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch); - PyObject *(*view)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch); - PyObject *(*load)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, PyObject *, int __pyx_skip_dispatch); - int (*receive)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, PyObject *, int, int __pyx_skip_dispatch); - int (*receive_message)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, PyObject *, int, int __pyx_skip_dispatch); - PyObject *(*_recycle)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *); - PyObject *(*frame)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch); - int (*frame_message)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch); - PyObject *(*discard_message)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_vtabptr_5neo4j_4bolt_3_io_ChunkedInputBuffer; - - -/* "neo4j/bolt/_io.pyx":257 - * - * - * cdef class ChunkedOutputBuffer(object): # <<<<<<<<<<<<<< - * - * cdef int _max_chunk_size - */ - -struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedOutputBuffer { - int (*max_chunk_size)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, int __pyx_skip_dispatch); - PyObject *(*clear)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, int __pyx_skip_dispatch); - PyObject *(*write)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, PyObject *, int __pyx_skip_dispatch); - PyObject *(*chunk)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, int __pyx_skip_dispatch); - PyObject *(*view)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_vtabptr_5neo4j_4bolt_3_io_ChunkedOutputBuffer; - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, 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; -#ifdef WITH_THREAD - #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__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #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) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #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_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) - -/* PyObjectGetAttrStr.proto */ -#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); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* 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); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* ArgTypeTest.proto */ -#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ - ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ - __Pyx__ArgTypeTest(obj, type, name, exact)) -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#endif - -/* 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 - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* PyObjectCallNoArg.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); -#else -#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) -#endif - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (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)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (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); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (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); -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); - -/* RaiseTooManyValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); - -/* RaiseNeedMoreValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); - -/* IterFinish.proto */ -static CYTHON_INLINE int __Pyx_IterFinish(void); - -/* UnpackItemEndCheck.proto */ -static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); - -/* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); - -/* SliceObject.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice( - PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop, - PyObject** py_start, PyObject** py_stop, PyObject** py_slice, - int has_cstart, int has_cstop, int wraparound); - -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; -#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#define __Pyx_PyErr_Occurred() 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 -#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 - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* SliceObject.proto */ -#define __Pyx_PyObject_DelSlice(obj, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound)\ - __Pyx_PyObject_SetSlice(obj, (PyObject*)NULL, cstart, cstop, py_start, py_stop, py_slice, has_cstart, has_cstop, wraparound) -static CYTHON_INLINE int __Pyx_PyObject_SetSlice( - PyObject* obj, PyObject* value, Py_ssize_t cstart, Py_ssize_t cstop, - PyObject** py_start, PyObject** py_stop, PyObject** py_slice, - int has_cstart, int has_cstop, int wraparound); - -/* WriteUnraisableException.proto */ -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename, - int full_traceback, int nogil); - -/* ListAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - Py_SIZE(list) = len+1; - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) -#endif - -/* SetVTable.proto */ -static int __Pyx_SetVtable(PyObject *dict, void *vtable); - -/* SetupReduce.proto */ -static int __Pyx_setup_reduce(PyObject* type_obj); - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* ImportFrom.proto */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); - -/* CLineInTraceback.proto */ -#ifdef CYTHON_CLINE_IN_TRACEBACK -#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) -#else -static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); -#endif - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* FastTypeChecks.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) -static CYTHON_INLINE int __Pyx_IsSubtype(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_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) -#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) -#endif - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame__next_pane(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_panes(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_read_int(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_read(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, int __pyx_v_n, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_close(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_capacity(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_view(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_load(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_b, int __pyx_skip_dispatch); /* proto*/ -static int __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_receive(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_socket, int __pyx_v_n, int __pyx_skip_dispatch); /* proto*/ -static int __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_receive_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_socket, int __pyx_v_n, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer__recycle(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_frame(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static int __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_frame_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_discard_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static int __pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_max_chunk_size(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_clear(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_write(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, PyObject *__pyx_v_b, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_chunk(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_view(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ - -/* Module declarations from 'neo4j.bolt._io' */ -static PyTypeObject *__pyx_ptype_5neo4j_4bolt_3_io_MessageFrame = 0; -static PyTypeObject *__pyx_ptype_5neo4j_4bolt_3_io_ChunkedInputBuffer = 0; -static PyTypeObject *__pyx_ptype_5neo4j_4bolt_3_io_ChunkedOutputBuffer = 0; -static PyObject *__pyx_v_5neo4j_4bolt_3_io__empty_view = 0; -#define __Pyx_MODULE_NAME "neo4j.bolt._io" -extern int __pyx_module_is_main_neo4j__bolt___io; -int __pyx_module_is_main_neo4j__bolt___io = 0; - -/* Implementation of 'neo4j.bolt._io' */ -static PyObject *__pyx_builtin_memoryview; -static PyObject *__pyx_builtin_TypeError; -static const char __pyx_k_H[] = ">H"; -static const char __pyx_k_n[] = "n"; -static const char __pyx_k__5[] = "\000\000"; -static const char __pyx_k__8[] = ""; -static const char __pyx_k_load[] = "load"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_name[] = "__name__"; -static const char __pyx_k_pack[] = "pack"; -static const char __pyx_k_read[] = "read"; -static const char __pyx_k_recv[] = "recv"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_view[] = "view"; -static const char __pyx_k_chunk[] = "chunk"; -static const char __pyx_k_clear[] = "clear"; -static const char __pyx_k_close[] = "close"; -static const char __pyx_k_frame[] = "frame"; -static const char __pyx_k_panes[] = "panes"; -static const char __pyx_k_write[] = "write"; -static const char __pyx_k_extend[] = "extend"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_reduce[] = "__reduce__"; -static const char __pyx_k_socket[] = "socket"; -static const char __pyx_k_struct[] = "struct"; -static const char __pyx_k_unpack[] = "unpack"; -static const char __pyx_k_receive[] = "receive"; -static const char __pyx_k_tobytes[] = "tobytes"; -static const char __pyx_k_capacity[] = "capacity"; -static const char __pyx_k_getstate[] = "__getstate__"; -static const char __pyx_k_read_int[] = "read_int"; -static const char __pyx_k_setstate[] = "__setstate__"; -static const char __pyx_k_TypeError[] = "TypeError"; -static const char __pyx_k_recv_into[] = "recv_into"; -static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; -static const char __pyx_k_memoryview[] = "memoryview"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; -static const char __pyx_k_struct_pack[] = "struct_pack"; -static const char __pyx_k_neo4j_compat[] = "neo4j.compat"; -static const char __pyx_k_frame_message[] = "frame_message"; -static const char __pyx_k_memoryview_at[] = "memoryview_at"; -static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; -static const char __pyx_k_struct_unpack[] = "struct_unpack"; -static const char __pyx_k_max_chunk_size[] = "max_chunk_size"; -static const char __pyx_k_discard_message[] = "discard_message"; -static const char __pyx_k_receive_message[] = "receive_message"; -static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; -static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; -static PyObject *__pyx_kp_s_H; -static PyObject *__pyx_n_s_TypeError; -static PyObject *__pyx_kp_b__5; -static PyObject *__pyx_kp_b__8; -static PyObject *__pyx_n_s_capacity; -static PyObject *__pyx_n_s_chunk; -static PyObject *__pyx_n_s_clear; -static PyObject *__pyx_n_s_cline_in_traceback; -static PyObject *__pyx_n_s_close; -static PyObject *__pyx_n_s_discard_message; -static PyObject *__pyx_n_s_extend; -static PyObject *__pyx_n_s_frame; -static PyObject *__pyx_n_s_frame_message; -static PyObject *__pyx_n_s_getstate; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_n_s_load; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_max_chunk_size; -static PyObject *__pyx_n_s_memoryview; -static PyObject *__pyx_n_s_memoryview_at; -static PyObject *__pyx_n_s_n; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_n_s_neo4j_compat; -static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; -static PyObject *__pyx_n_s_pack; -static PyObject *__pyx_n_s_panes; -static PyObject *__pyx_n_s_pyx_vtable; -static PyObject *__pyx_n_s_read; -static PyObject *__pyx_n_s_read_int; -static PyObject *__pyx_n_s_receive; -static PyObject *__pyx_n_s_receive_message; -static PyObject *__pyx_n_s_recv; -static PyObject *__pyx_n_s_recv_into; -static PyObject *__pyx_n_s_reduce; -static PyObject *__pyx_n_s_reduce_cython; -static PyObject *__pyx_n_s_reduce_ex; -static PyObject *__pyx_n_s_setstate; -static PyObject *__pyx_n_s_setstate_cython; -static PyObject *__pyx_n_s_socket; -static PyObject *__pyx_n_s_struct; -static PyObject *__pyx_n_s_struct_pack; -static PyObject *__pyx_n_s_struct_unpack; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_tobytes; -static PyObject *__pyx_n_s_unpack; -static PyObject *__pyx_n_s_view; -static PyObject *__pyx_n_s_write; -static int __pyx_pf_5neo4j_4bolt_3_io_12MessageFrame___cinit__(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, PyObject *__pyx_v_view, PyObject *__pyx_v_panes); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_2panes(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_4read_int(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_6read(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, int __pyx_v_n); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_8close(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static int __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer___cinit__(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_capacity); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_2__repr__(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_4capacity(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_6view(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_8load(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_b); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_10receive(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_socket, int __pyx_v_n); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_12receive_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_socket, int __pyx_v_n); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_14frame(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_16frame_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_18discard_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static int __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer___cinit__(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, int __pyx_v_capacity, int __pyx_v_max_chunk_size); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_2max_chunk_size(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_4clear(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_6write(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, PyObject *__pyx_v_b); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_8chunk(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_10view(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static PyObject *__pyx_tp_new_5neo4j_4bolt_3_io_MessageFrame(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_5neo4j_4bolt_3_io_ChunkedInputBuffer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tp_new_5neo4j_4bolt_3_io_ChunkedOutputBuffer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_int_0; -static PyObject *__pyx_int_524288; -static PyObject *__pyx_int_neg_1; -static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__3; -static PyObject *__pyx_tuple__4; -static PyObject *__pyx_tuple__6; -static PyObject *__pyx_tuple__7; -static PyObject *__pyx_tuple__9; - -/* "neo4j/bolt/_io.pyx":37 - * cdef int _current_offset - * - * def __cinit__(self, view, list panes): # <<<<<<<<<<<<<< - * self._view = view - * self._panes = panes - */ - -/* Python wrapper */ -static int __pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_view = 0; - PyObject *__pyx_v_panes = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_view,&__pyx_n_s_panes,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_view)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_panes)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, 1); __PYX_ERR(0, 37, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 37, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_view = values[0]; - __pyx_v_panes = ((PyObject*)values[1]); - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 37, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("neo4j.bolt._io.MessageFrame.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_panes), (&PyList_Type), 1, "panes", 1))) __PYX_ERR(0, 37, __pyx_L1_error) - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_12MessageFrame___cinit__(((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self), __pyx_v_view, __pyx_v_panes); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5neo4j_4bolt_3_io_12MessageFrame___cinit__(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, PyObject *__pyx_v_view, PyObject *__pyx_v_panes) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "neo4j/bolt/_io.pyx":38 - * - * def __cinit__(self, view, list panes): - * self._view = view # <<<<<<<<<<<<<< - * self._panes = panes - * if panes: - */ - __Pyx_INCREF(__pyx_v_view); - __Pyx_GIVEREF(__pyx_v_view); - __Pyx_GOTREF(__pyx_v_self->_view); - __Pyx_DECREF(__pyx_v_self->_view); - __pyx_v_self->_view = __pyx_v_view; - - /* "neo4j/bolt/_io.pyx":39 - * def __cinit__(self, view, list panes): - * self._view = view - * self._panes = panes # <<<<<<<<<<<<<< - * if panes: - * self._current_pane = 0 - */ - __Pyx_INCREF(__pyx_v_panes); - __Pyx_GIVEREF(__pyx_v_panes); - __Pyx_GOTREF(__pyx_v_self->_panes); - __Pyx_DECREF(__pyx_v_self->_panes); - __pyx_v_self->_panes = __pyx_v_panes; - - /* "neo4j/bolt/_io.pyx":40 - * self._view = view - * self._panes = panes - * if panes: # <<<<<<<<<<<<<< - * self._current_pane = 0 - * self._current_offset = 0 - */ - __pyx_t_1 = (__pyx_v_panes != Py_None) && (PyList_GET_SIZE(__pyx_v_panes) != 0); - if (__pyx_t_1) { - - /* "neo4j/bolt/_io.pyx":41 - * self._panes = panes - * if panes: - * self._current_pane = 0 # <<<<<<<<<<<<<< - * self._current_offset = 0 - * else: - */ - __pyx_v_self->_current_pane = 0; - - /* "neo4j/bolt/_io.pyx":42 - * if panes: - * self._current_pane = 0 - * self._current_offset = 0 # <<<<<<<<<<<<<< - * else: - * self._current_pane = -1 - */ - __pyx_v_self->_current_offset = 0; - - /* "neo4j/bolt/_io.pyx":40 - * self._view = view - * self._panes = panes - * if panes: # <<<<<<<<<<<<<< - * self._current_pane = 0 - * self._current_offset = 0 - */ - goto __pyx_L3; - } - - /* "neo4j/bolt/_io.pyx":44 - * self._current_offset = 0 - * else: - * self._current_pane = -1 # <<<<<<<<<<<<<< - * self._current_offset = -1 - * - */ - /*else*/ { - __pyx_v_self->_current_pane = -1; - - /* "neo4j/bolt/_io.pyx":45 - * else: - * self._current_pane = -1 - * self._current_offset = -1 # <<<<<<<<<<<<<< - * - * cdef _next_pane(self): - */ - __pyx_v_self->_current_offset = -1; - } - __pyx_L3:; - - /* "neo4j/bolt/_io.pyx":37 - * cdef int _current_offset - * - * def __cinit__(self, view, list panes): # <<<<<<<<<<<<<< - * self._view = view - * self._panes = panes - */ - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":47 - * self._current_offset = -1 - * - * cdef _next_pane(self): # <<<<<<<<<<<<<< - * self._current_pane += 1 - * if self._current_pane < len(self._panes): - */ - -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame__next_pane(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - Py_ssize_t __pyx_t_2; - int __pyx_t_3; - __Pyx_RefNannySetupContext("_next_pane", 0); - - /* "neo4j/bolt/_io.pyx":48 - * - * cdef _next_pane(self): - * self._current_pane += 1 # <<<<<<<<<<<<<< - * if self._current_pane < len(self._panes): - * self._current_offset = 0 - */ - __pyx_v_self->_current_pane = (__pyx_v_self->_current_pane + 1); - - /* "neo4j/bolt/_io.pyx":49 - * cdef _next_pane(self): - * self._current_pane += 1 - * if self._current_pane < len(self._panes): # <<<<<<<<<<<<<< - * self._current_offset = 0 - * else: - */ - __pyx_t_1 = __pyx_v_self->_panes; - __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, 49, __pyx_L1_error) - } - __pyx_t_2 = PyList_GET_SIZE(__pyx_t_1); if (unlikely(__pyx_t_2 == ((Py_ssize_t)-1))) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = ((__pyx_v_self->_current_pane < __pyx_t_2) != 0); - if (__pyx_t_3) { - - /* "neo4j/bolt/_io.pyx":50 - * self._current_pane += 1 - * if self._current_pane < len(self._panes): - * self._current_offset = 0 # <<<<<<<<<<<<<< - * else: - * self._current_pane = -1 - */ - __pyx_v_self->_current_offset = 0; - - /* "neo4j/bolt/_io.pyx":49 - * cdef _next_pane(self): - * self._current_pane += 1 - * if self._current_pane < len(self._panes): # <<<<<<<<<<<<<< - * self._current_offset = 0 - * else: - */ - goto __pyx_L3; - } - - /* "neo4j/bolt/_io.pyx":52 - * self._current_offset = 0 - * else: - * self._current_pane = -1 # <<<<<<<<<<<<<< - * self._current_offset = -1 - * - */ - /*else*/ { - __pyx_v_self->_current_pane = -1; - - /* "neo4j/bolt/_io.pyx":53 - * else: - * self._current_pane = -1 - * self._current_offset = -1 # <<<<<<<<<<<<<< - * - * cpdef panes(self): - */ - __pyx_v_self->_current_offset = -1; - } - __pyx_L3:; - - /* "neo4j/bolt/_io.pyx":47 - * self._current_offset = -1 - * - * cdef _next_pane(self): # <<<<<<<<<<<<<< - * self._current_pane += 1 - * if self._current_pane < len(self._panes): - */ - - /* function exit code */ - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.bolt._io.MessageFrame._next_pane", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":55 - * self._current_offset = -1 - * - * cpdef panes(self): # <<<<<<<<<<<<<< - * return self._panes - * - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_3panes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_panes(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__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; - __Pyx_RefNannySetupContext("panes", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_panes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_3panes)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 55, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":56 - * - * cpdef panes(self): - * return self._panes # <<<<<<<<<<<<<< - * - * cpdef read_int(self): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_self->_panes); - __pyx_r = __pyx_v_self->_panes; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":55 - * self._current_offset = -1 - * - * cpdef panes(self): # <<<<<<<<<<<<<< - * return self._panes - * - */ - - /* 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("neo4j.bolt._io.MessageFrame.panes", __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_5neo4j_4bolt_3_io_12MessageFrame_3panes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_3panes(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("panes (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_2panes(((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_2panes(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("panes", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_12MessageFrame_panes(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 55, __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("neo4j.bolt._io.MessageFrame.panes", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":58 - * return self._panes - * - * cpdef read_int(self): # <<<<<<<<<<<<<< - * cdef int p - * cdef int q - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_5read_int(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_read_int(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, int __pyx_skip_dispatch) { - int __pyx_v_p; - int __pyx_v_q; - int __pyx_v_size; - int __pyx_v_value; - 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; - PyObject *(*__pyx_t_6)(PyObject *); - int __pyx_t_7; - int __pyx_t_8; - PyObject *__pyx_t_9 = NULL; - __Pyx_RefNannySetupContext("read_int", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read_int); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_5read_int)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 58, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":64 - * cdef int value - * - * if self._current_pane == -1: # <<<<<<<<<<<<<< - * return -1 - * p, q = self._panes[self._current_pane] - */ - __pyx_t_5 = ((__pyx_v_self->_current_pane == -1L) != 0); - if (__pyx_t_5) { - - /* "neo4j/bolt/_io.pyx":65 - * - * if self._current_pane == -1: - * return -1 # <<<<<<<<<<<<<< - * p, q = self._panes[self._current_pane] - * size = q - p - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_int_neg_1); - __pyx_r = __pyx_int_neg_1; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":64 - * cdef int value - * - * if self._current_pane == -1: # <<<<<<<<<<<<<< - * return -1 - * p, q = self._panes[self._current_pane] - */ - } - - /* "neo4j/bolt/_io.pyx":66 - * if self._current_pane == -1: - * return -1 - * p, q = self._panes[self._current_pane] # <<<<<<<<<<<<<< - * size = q - p - * value = memoryview_at(self._view, p + self._current_offset) - */ - if (unlikely(__pyx_v_self->_panes == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 66, __pyx_L1_error) - } - __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->_panes, __pyx_v_self->_current_pane, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 66, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { - PyObject* sequence = __pyx_t_1; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 66, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_3 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_2 = PyList_GET_ITEM(sequence, 0); - __pyx_t_3 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 66, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 66, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - #endif - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 66, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = Py_TYPE(__pyx_t_4)->tp_iternext; - index = 0; __pyx_t_2 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_2)) goto __pyx_L4_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - index = 1; __pyx_t_3 = __pyx_t_6(__pyx_t_4); if (unlikely(!__pyx_t_3)) goto __pyx_L4_unpacking_failed; - __Pyx_GOTREF(__pyx_t_3); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_6(__pyx_t_4), 2) < 0) __PYX_ERR(0, 66, __pyx_L1_error) - __pyx_t_6 = NULL; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L5_unpacking_done; - __pyx_L4_unpacking_failed:; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 66, __pyx_L1_error) - __pyx_L5_unpacking_done:; - } - __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_3); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 66, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_v_p = __pyx_t_7; - __pyx_v_q = __pyx_t_8; - - /* "neo4j/bolt/_io.pyx":67 - * return -1 - * p, q = self._panes[self._current_pane] - * size = q - p # <<<<<<<<<<<<<< - * value = memoryview_at(self._view, p + self._current_offset) - * self._current_offset += 1 - */ - __pyx_v_size = (__pyx_v_q - __pyx_v_p); - - /* "neo4j/bolt/_io.pyx":68 - * p, q = self._panes[self._current_pane] - * size = q - p - * value = memoryview_at(self._view, p + self._current_offset) # <<<<<<<<<<<<<< - * self._current_offset += 1 - * if self._current_offset == size: - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_memoryview_at); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_p + __pyx_v_self->_current_offset)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self->_view, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_self->_view, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_v_self->_view); - __Pyx_GIVEREF(__pyx_v_self->_view); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_self->_view); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_value = __pyx_t_8; - - /* "neo4j/bolt/_io.pyx":69 - * size = q - p - * value = memoryview_at(self._view, p + self._current_offset) - * self._current_offset += 1 # <<<<<<<<<<<<<< - * if self._current_offset == size: - * self._next_pane() - */ - __pyx_v_self->_current_offset = (__pyx_v_self->_current_offset + 1); - - /* "neo4j/bolt/_io.pyx":70 - * value = memoryview_at(self._view, p + self._current_offset) - * self._current_offset += 1 - * if self._current_offset == size: # <<<<<<<<<<<<<< - * self._next_pane() - * return value - */ - __pyx_t_5 = ((__pyx_v_self->_current_offset == __pyx_v_size) != 0); - if (__pyx_t_5) { - - /* "neo4j/bolt/_io.pyx":71 - * self._current_offset += 1 - * if self._current_offset == size: - * self._next_pane() # <<<<<<<<<<<<<< - * return value - * - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self->__pyx_vtab)->_next_pane(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":70 - * value = memoryview_at(self._view, p + self._current_offset) - * self._current_offset += 1 - * if self._current_offset == size: # <<<<<<<<<<<<<< - * self._next_pane() - * return value - */ - } - - /* "neo4j/bolt/_io.pyx":72 - * if self._current_offset == size: - * self._next_pane() - * return value # <<<<<<<<<<<<<< - * - * cpdef read(self, int n): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":58 - * return self._panes - * - * cpdef read_int(self): # <<<<<<<<<<<<<< - * cdef int p - * cdef int q - */ - - /* 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_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("neo4j.bolt._io.MessageFrame.read_int", __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_5neo4j_4bolt_3_io_12MessageFrame_5read_int(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_5read_int(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("read_int (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_4read_int(((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_4read_int(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("read_int", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_12MessageFrame_read_int(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 58, __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("neo4j.bolt._io.MessageFrame.read_int", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":74 - * return value - * - * cpdef read(self, int n): # <<<<<<<<<<<<<< - * cdef int p - * cdef int q - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_7read(PyObject *__pyx_v_self, PyObject *__pyx_arg_n); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_read(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, int __pyx_v_n, int __pyx_skip_dispatch) { - int __pyx_v_p; - int __pyx_v_q; - int __pyx_v_size; - int __pyx_v_start; - int __pyx_v_end; - int __pyx_v_remaining; - PyObject *__pyx_v_value = 0; - 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; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - int __pyx_t_8; - PyObject *(*__pyx_t_9)(PyObject *); - int __pyx_t_10; - int __pyx_t_11; - Py_ssize_t __pyx_t_12; - __Pyx_RefNannySetupContext("read", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_read); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_7read)) { - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_5) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_3}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":83 - * cdef bytearray value - * - * if n == 0 or self._current_pane == -1: # <<<<<<<<<<<<<< - * return _empty_view - * p, q = self._panes[self._current_pane] - */ - __pyx_t_8 = ((__pyx_v_n == 0) != 0); - if (!__pyx_t_8) { - } else { - __pyx_t_7 = __pyx_t_8; - goto __pyx_L4_bool_binop_done; - } - __pyx_t_8 = ((__pyx_v_self->_current_pane == -1L) != 0); - __pyx_t_7 = __pyx_t_8; - __pyx_L4_bool_binop_done:; - if (__pyx_t_7) { - - /* "neo4j/bolt/_io.pyx":84 - * - * if n == 0 or self._current_pane == -1: - * return _empty_view # <<<<<<<<<<<<<< - * p, q = self._panes[self._current_pane] - * size = q - p - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_5neo4j_4bolt_3_io__empty_view); - __pyx_r = __pyx_v_5neo4j_4bolt_3_io__empty_view; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":83 - * cdef bytearray value - * - * if n == 0 or self._current_pane == -1: # <<<<<<<<<<<<<< - * return _empty_view - * p, q = self._panes[self._current_pane] - */ - } - - /* "neo4j/bolt/_io.pyx":85 - * if n == 0 or self._current_pane == -1: - * return _empty_view - * p, q = self._panes[self._current_pane] # <<<<<<<<<<<<<< - * size = q - p - * remaining = size - self._current_offset - */ - if (unlikely(__pyx_v_self->_panes == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 85, __pyx_L1_error) - } - __pyx_t_1 = __Pyx_GetItemInt_List(__pyx_v_self->_panes, __pyx_v_self->_current_pane, int, 1, __Pyx_PyInt_From_int, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { - PyObject* sequence = __pyx_t_1; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 85, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_2 = PyList_GET_ITEM(sequence, 0); - __pyx_t_4 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_6 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; - index = 0; __pyx_t_2 = __pyx_t_9(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L6_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - index = 1; __pyx_t_4 = __pyx_t_9(__pyx_t_6); if (unlikely(!__pyx_t_4)) goto __pyx_L6_unpacking_failed; - __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_6), 2) < 0) __PYX_ERR(0, 85, __pyx_L1_error) - __pyx_t_9 = NULL; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - goto __pyx_L7_unpacking_done; - __pyx_L6_unpacking_failed:; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_9 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 85, __pyx_L1_error) - __pyx_L7_unpacking_done:; - } - __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_p = __pyx_t_10; - __pyx_v_q = __pyx_t_11; - - /* "neo4j/bolt/_io.pyx":86 - * return _empty_view - * p, q = self._panes[self._current_pane] - * size = q - p # <<<<<<<<<<<<<< - * remaining = size - self._current_offset - * if n <= remaining: - */ - __pyx_v_size = (__pyx_v_q - __pyx_v_p); - - /* "neo4j/bolt/_io.pyx":87 - * p, q = self._panes[self._current_pane] - * size = q - p - * remaining = size - self._current_offset # <<<<<<<<<<<<<< - * if n <= remaining: - * start = p + self._current_offset - */ - __pyx_v_remaining = (__pyx_v_size - __pyx_v_self->_current_offset); - - /* "neo4j/bolt/_io.pyx":88 - * size = q - p - * remaining = size - self._current_offset - * if n <= remaining: # <<<<<<<<<<<<<< - * start = p + self._current_offset - * end = start + n - */ - __pyx_t_7 = ((__pyx_v_n <= __pyx_v_remaining) != 0); - if (__pyx_t_7) { - - /* "neo4j/bolt/_io.pyx":89 - * remaining = size - self._current_offset - * if n <= remaining: - * start = p + self._current_offset # <<<<<<<<<<<<<< - * end = start + n - * if n < remaining: - */ - __pyx_v_start = (__pyx_v_p + __pyx_v_self->_current_offset); - - /* "neo4j/bolt/_io.pyx":90 - * if n <= remaining: - * start = p + self._current_offset - * end = start + n # <<<<<<<<<<<<<< - * if n < remaining: - * self._current_offset += n - */ - __pyx_v_end = (__pyx_v_start + __pyx_v_n); - - /* "neo4j/bolt/_io.pyx":91 - * start = p + self._current_offset - * end = start + n - * if n < remaining: # <<<<<<<<<<<<<< - * self._current_offset += n - * else: - */ - __pyx_t_7 = ((__pyx_v_n < __pyx_v_remaining) != 0); - if (__pyx_t_7) { - - /* "neo4j/bolt/_io.pyx":92 - * end = start + n - * if n < remaining: - * self._current_offset += n # <<<<<<<<<<<<<< - * else: - * self._next_pane() - */ - __pyx_v_self->_current_offset = (__pyx_v_self->_current_offset + __pyx_v_n); - - /* "neo4j/bolt/_io.pyx":91 - * start = p + self._current_offset - * end = start + n - * if n < remaining: # <<<<<<<<<<<<<< - * self._current_offset += n - * else: - */ - goto __pyx_L9; - } - - /* "neo4j/bolt/_io.pyx":94 - * self._current_offset += n - * else: - * self._next_pane() # <<<<<<<<<<<<<< - * return memoryview(self._view[start:end]) - * start = p + self._current_offset - */ - /*else*/ { - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self->__pyx_vtab)->_next_pane(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - __pyx_L9:; - - /* "neo4j/bolt/_io.pyx":95 - * else: - * self._next_pane() - * return memoryview(self._view[start:end]) # <<<<<<<<<<<<<< - * start = p + self._current_offset - * end = q - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_self->_view, __pyx_v_start, __pyx_v_end, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":88 - * size = q - p - * remaining = size - self._current_offset - * if n <= remaining: # <<<<<<<<<<<<<< - * start = p + self._current_offset - * end = start + n - */ - } - - /* "neo4j/bolt/_io.pyx":96 - * self._next_pane() - * return memoryview(self._view[start:end]) - * start = p + self._current_offset # <<<<<<<<<<<<<< - * end = q - * value = bytearray(self._view[start:end]) - */ - __pyx_v_start = (__pyx_v_p + __pyx_v_self->_current_offset); - - /* "neo4j/bolt/_io.pyx":97 - * return memoryview(self._view[start:end]) - * start = p + self._current_offset - * end = q # <<<<<<<<<<<<<< - * value = bytearray(self._view[start:end]) - * self._next_pane() - */ - __pyx_v_end = __pyx_v_q; - - /* "neo4j/bolt/_io.pyx":98 - * start = p + self._current_offset - * end = q - * value = bytearray(self._view[start:end]) # <<<<<<<<<<<<<< - * self._next_pane() - * if len(value) < n and self._current_pane >= 0: - */ - __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_self->_view, __pyx_v_start, __pyx_v_end, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 98, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyByteArray_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 98, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_value = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":99 - * end = q - * value = bytearray(self._view[start:end]) - * self._next_pane() # <<<<<<<<<<<<<< - * if len(value) < n and self._current_pane >= 0: - * value.extend(self.read(n - (end - start))) - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self->__pyx_vtab)->_next_pane(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":100 - * value = bytearray(self._view[start:end]) - * self._next_pane() - * if len(value) < n and self._current_pane >= 0: # <<<<<<<<<<<<<< - * value.extend(self.read(n - (end - start))) - * return value - */ - __pyx_t_12 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 100, __pyx_L1_error) - __pyx_t_8 = ((__pyx_t_12 < __pyx_v_n) != 0); - if (__pyx_t_8) { - } else { - __pyx_t_7 = __pyx_t_8; - goto __pyx_L11_bool_binop_done; - } - __pyx_t_8 = ((__pyx_v_self->_current_pane >= 0) != 0); - __pyx_t_7 = __pyx_t_8; - __pyx_L11_bool_binop_done:; - if (__pyx_t_7) { - - /* "neo4j/bolt/_io.pyx":101 - * self._next_pane() - * if len(value) < n and self._current_pane >= 0: - * value.extend(self.read(n - (end - start))) # <<<<<<<<<<<<<< - * return value - * - */ - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_extend); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, (__pyx_v_n - (__pyx_v_end - __pyx_v_start)), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_6) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - { - __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":100 - * value = bytearray(self._view[start:end]) - * self._next_pane() - * if len(value) < n and self._current_pane >= 0: # <<<<<<<<<<<<<< - * value.extend(self.read(n - (end - start))) - * return value - */ - } - - /* "neo4j/bolt/_io.pyx":102 - * if len(value) < n and self._current_pane >= 0: - * value.extend(self.read(n - (end - start))) - * return value # <<<<<<<<<<<<<< - * - * cpdef close(self): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_value); - __pyx_r = __pyx_v_value; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":74 - * return value - * - * cpdef read(self, int n): # <<<<<<<<<<<<<< - * cdef int p - * cdef int q - */ - - /* 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_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_AddTraceback("neo4j.bolt._io.MessageFrame.read", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_value); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_7read(PyObject *__pyx_v_self, PyObject *__pyx_arg_n); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_7read(PyObject *__pyx_v_self, PyObject *__pyx_arg_n) { - int __pyx_v_n; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("read (wrapper)", 0); - assert(__pyx_arg_n); { - __pyx_v_n = __Pyx_PyInt_As_int(__pyx_arg_n); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 74, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L3_error:; - __Pyx_AddTraceback("neo4j.bolt._io.MessageFrame.read", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_6read(((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self), ((int)__pyx_v_n)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_6read(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, int __pyx_v_n) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("read", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_12MessageFrame_read(__pyx_v_self, __pyx_v_n, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __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("neo4j.bolt._io.MessageFrame.read", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":104 - * return value - * - * cpdef close(self): # <<<<<<<<<<<<<< - * self._view = None - * - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_9close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_close(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__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; - __Pyx_RefNannySetupContext("close", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_close); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_9close)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 104, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":105 - * - * cpdef close(self): - * self._view = None # <<<<<<<<<<<<<< - * - * - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->_view); - __Pyx_DECREF(__pyx_v_self->_view); - __pyx_v_self->_view = Py_None; - - /* "neo4j/bolt/_io.pyx":104 - * return value - * - * cpdef close(self): # <<<<<<<<<<<<<< - * self._view = None - * - */ - - /* 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("neo4j.bolt._io.MessageFrame.close", __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_5neo4j_4bolt_3_io_12MessageFrame_9close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_9close(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("close (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_8close(((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_8close(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("close", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_12MessageFrame_close(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 104, __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("neo4j.bolt._io.MessageFrame.close", __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): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_11__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_10__reduce_cython__(((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_10__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __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(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.bolt._io.MessageFrame.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_13__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_12__setstate_cython__(((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_12MessageFrame_12__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __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(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.bolt._io.MessageFrame.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":117 - * cdef MessageFrame _frame - * - * def __cinit__(self, capacity=524288): # <<<<<<<<<<<<<< - * self._data = bytearray(capacity) - * self._view = memoryview(self._data) - */ - -/* Python wrapper */ -static int __pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_capacity = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_capacity,0}; - PyObject* values[1] = {0}; - values[0] = ((PyObject *)__pyx_int_524288); - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_capacity); - if (value) { values[0] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 117, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - __pyx_v_capacity = values[0]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 117, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedInputBuffer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer___cinit__(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self), __pyx_v_capacity); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer___cinit__(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_capacity) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "neo4j/bolt/_io.pyx":118 - * - * def __cinit__(self, capacity=524288): - * self._data = bytearray(capacity) # <<<<<<<<<<<<<< - * self._view = memoryview(self._data) - * self._extent = 0 # end position of all loaded data - */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_capacity); - __Pyx_GIVEREF(__pyx_v_capacity); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_capacity); - __pyx_t_2 = __Pyx_PyObject_Call(((PyObject *)(&PyByteArray_Type)), __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(__pyx_v_self->_data); - __Pyx_DECREF(__pyx_v_self->_data); - __pyx_v_self->_data = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/bolt/_io.pyx":119 - * def __cinit__(self, capacity=524288): - * self._data = bytearray(capacity) - * self._view = memoryview(self._data) # <<<<<<<<<<<<<< - * self._extent = 0 # end position of all loaded data - * self._origin = 0 # start position of current frame - */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 119, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_self->_data); - __Pyx_GIVEREF(__pyx_v_self->_data); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->_data); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 119, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->_view); - __Pyx_DECREF(__pyx_v_self->_view); - __pyx_v_self->_view = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":120 - * self._data = bytearray(capacity) - * self._view = memoryview(self._data) - * self._extent = 0 # end position of all loaded data # <<<<<<<<<<<<<< - * self._origin = 0 # start position of current frame - * self._limit = -1 # end position of current frame - */ - __pyx_v_self->_extent = 0; - - /* "neo4j/bolt/_io.pyx":121 - * self._view = memoryview(self._data) - * self._extent = 0 # end position of all loaded data - * self._origin = 0 # start position of current frame # <<<<<<<<<<<<<< - * self._limit = -1 # end position of current frame - * self._frame = None # frame object - */ - __pyx_v_self->_origin = 0; - - /* "neo4j/bolt/_io.pyx":122 - * self._extent = 0 # end position of all loaded data - * self._origin = 0 # start position of current frame - * self._limit = -1 # end position of current frame # <<<<<<<<<<<<<< - * self._frame = None # frame object - * - */ - __pyx_v_self->_limit = -1; - - /* "neo4j/bolt/_io.pyx":123 - * self._origin = 0 # start position of current frame - * self._limit = -1 # end position of current frame - * self._frame = None # frame object # <<<<<<<<<<<<<< - * - * def __repr__(self): - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->_frame); - __Pyx_DECREF(((PyObject *)__pyx_v_self->_frame)); - __pyx_v_self->_frame = ((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)Py_None); - - /* "neo4j/bolt/_io.pyx":117 - * cdef MessageFrame _frame - * - * def __cinit__(self, capacity=524288): # <<<<<<<<<<<<<< - * self._data = bytearray(capacity) - * self._view = memoryview(self._data) - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedInputBuffer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":125 - * self._frame = None # frame object - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return repr(self.view().tobytes()) - * - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_3__repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_3__repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_2__repr__(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_2__repr__(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - __Pyx_RefNannySetupContext("__repr__", 0); - - /* "neo4j/bolt/_io.pyx":126 - * - * def __repr__(self): - * return repr(self.view().tobytes()) # <<<<<<<<<<<<<< - * - * cpdef capacity(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self->__pyx_vtab)->view(__pyx_v_self, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_2) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 126, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = PyObject_Repr(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_3; - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":125 - * self._frame = None # frame object - * - * def __repr__(self): # <<<<<<<<<<<<<< - * return repr(self.view().tobytes()) - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedInputBuffer.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":128 - * return repr(self.view().tobytes()) - * - * cpdef capacity(self): # <<<<<<<<<<<<<< - * return len(self._view) - * - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_5capacity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_capacity(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__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; - Py_ssize_t __pyx_t_5; - __Pyx_RefNannySetupContext("capacity", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_capacity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_5capacity)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 128, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":129 - * - * cpdef capacity(self): - * return len(self._view) # <<<<<<<<<<<<<< - * - * cpdef view(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_v_self->_view; - __Pyx_INCREF(__pyx_t_1); - __pyx_t_5 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_5 == ((Py_ssize_t)-1))) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":128 - * return repr(self.view().tobytes()) - * - * cpdef capacity(self): # <<<<<<<<<<<<<< - * return len(self._view) - * - */ - - /* 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("neo4j.bolt._io.ChunkedInputBuffer.capacity", __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_5neo4j_4bolt_3_io_18ChunkedInputBuffer_5capacity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_5capacity(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("capacity (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_4capacity(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_4capacity(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("capacity", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_capacity(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __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("neo4j.bolt._io.ChunkedInputBuffer.capacity", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":131 - * return len(self._view) - * - * cpdef view(self): # <<<<<<<<<<<<<< - * return memoryview(self._view[:self._extent]) - * - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_7view(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_view(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__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; - __Pyx_RefNannySetupContext("view", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_view); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_7view)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":132 - * - * cpdef view(self): - * return memoryview(self._view[:self._extent]) # <<<<<<<<<<<<<< - * - * cpdef load(self, b): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_self->_view, 0, __pyx_v_self->_extent, NULL, NULL, NULL, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":131 - * return len(self._view) - * - * cpdef view(self): # <<<<<<<<<<<<<< - * return memoryview(self._view[:self._extent]) - * - */ - - /* 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("neo4j.bolt._io.ChunkedInputBuffer.view", __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_5neo4j_4bolt_3_io_18ChunkedInputBuffer_7view(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_7view(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("view (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_6view(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_6view(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("view", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_view(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __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("neo4j.bolt._io.ChunkedInputBuffer.view", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":134 - * return memoryview(self._view[:self._extent]) - * - * cpdef load(self, b): # <<<<<<<<<<<<<< - * """ - * - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_9load(PyObject *__pyx_v_self, PyObject *__pyx_v_b); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_load(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_b, int __pyx_skip_dispatch) { - PyObject *__pyx_v_n = NULL; - PyObject *__pyx_v_new_extent = NULL; - PyObject *__pyx_v_overflow = NULL; - 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; - Py_ssize_t __pyx_t_6; - int __pyx_t_7; - int __pyx_t_8; - __Pyx_RefNannySetupContext("load", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_load); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_9load)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_b); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_b}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_b}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_INCREF(__pyx_v_b); - __Pyx_GIVEREF(__pyx_v_b); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_b); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":139 - * Note: may modify buffer size - * """ - * n = len(b) # <<<<<<<<<<<<<< - * new_extent = self._extent + n - * overflow = new_extent - len(self._data) - */ - __pyx_t_6 = PyObject_Length(__pyx_v_b); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 139, __pyx_L1_error) - __pyx_t_1 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_n = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":140 - * """ - * n = len(b) - * new_extent = self._extent + n # <<<<<<<<<<<<<< - * overflow = new_extent - len(self._data) - * if overflow > 0: - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_extent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_new_extent = __pyx_t_2; - __pyx_t_2 = 0; - - /* "neo4j/bolt/_io.pyx":141 - * n = len(b) - * new_extent = self._extent + n - * overflow = new_extent - len(self._data) # <<<<<<<<<<<<<< - * if overflow > 0: - * if self._recycle(): - */ - __pyx_t_2 = __pyx_v_self->_data; - __Pyx_INCREF(__pyx_t_2); - __pyx_t_6 = PyObject_Length(__pyx_t_2); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyInt_FromSsize_t(__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyNumber_Subtract(__pyx_v_new_extent, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 141, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_overflow = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":142 - * new_extent = self._extent + n - * overflow = new_extent - len(self._data) - * if overflow > 0: # <<<<<<<<<<<<<< - * if self._recycle(): - * return self.load(b) - */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_overflow, __pyx_int_0, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 142, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_7) { - - /* "neo4j/bolt/_io.pyx":143 - * overflow = new_extent - len(self._data) - * if overflow > 0: - * if self._recycle(): # <<<<<<<<<<<<<< - * return self.load(b) - * self._view = None - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self->__pyx_vtab)->_recycle(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 143, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_7) { - - /* "neo4j/bolt/_io.pyx":144 - * if overflow > 0: - * if self._recycle(): - * return self.load(b) # <<<<<<<<<<<<<< - * self._view = None - * new_extent = self._extent + n - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self->__pyx_vtab)->load(__pyx_v_self, __pyx_v_b, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":143 - * overflow = new_extent - len(self._data) - * if overflow > 0: - * if self._recycle(): # <<<<<<<<<<<<<< - * return self.load(b) - * self._view = None - */ - } - - /* "neo4j/bolt/_io.pyx":145 - * if self._recycle(): - * return self.load(b) - * self._view = None # <<<<<<<<<<<<<< - * new_extent = self._extent + n - * self._data[self._extent:new_extent] = b - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->_view); - __Pyx_DECREF(__pyx_v_self->_view); - __pyx_v_self->_view = Py_None; - - /* "neo4j/bolt/_io.pyx":146 - * return self.load(b) - * self._view = None - * new_extent = self._extent + n # <<<<<<<<<<<<<< - * self._data[self._extent:new_extent] = b - * self._view = memoryview(self._data) - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_extent); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Add(__pyx_t_1, __pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF_SET(__pyx_v_new_extent, __pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/bolt/_io.pyx":147 - * self._view = None - * new_extent = self._extent + n - * self._data[self._extent:new_extent] = b # <<<<<<<<<<<<<< - * self._view = memoryview(self._data) - * else: - */ - if (unlikely(__pyx_v_self->_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 147, __pyx_L1_error) - } - __pyx_t_6 = __Pyx_PyIndex_AsSsize_t(__pyx_v_new_extent); if (unlikely((__pyx_t_6 == (Py_ssize_t)-1) && PyErr_Occurred())) __PYX_ERR(0, 147, __pyx_L1_error) - if (__Pyx_PyObject_SetSlice(__pyx_v_self->_data, __pyx_v_b, __pyx_v_self->_extent, __pyx_t_6, NULL, NULL, NULL, 1, 1, 1) < 0) __PYX_ERR(0, 147, __pyx_L1_error) - - /* "neo4j/bolt/_io.pyx":148 - * new_extent = self._extent + n - * self._data[self._extent:new_extent] = b - * self._view = memoryview(self._data) # <<<<<<<<<<<<<< - * else: - * self._view[self._extent:new_extent] = b - */ - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_self->_data); - __Pyx_GIVEREF(__pyx_v_self->_data); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->_data); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 148, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->_view); - __Pyx_DECREF(__pyx_v_self->_view); - __pyx_v_self->_view = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":142 - * new_extent = self._extent + n - * overflow = new_extent - len(self._data) - * if overflow > 0: # <<<<<<<<<<<<<< - * if self._recycle(): - * return self.load(b) - */ - goto __pyx_L3; - } - - /* "neo4j/bolt/_io.pyx":150 - * self._view = memoryview(self._data) - * else: - * self._view[self._extent:new_extent] = b # <<<<<<<<<<<<<< - * self._extent = new_extent - * - */ - /*else*/ { - if (__Pyx_PyObject_SetSlice(__pyx_v_self->_view, __pyx_v_b, __pyx_v_self->_extent, 0, NULL, &__pyx_v_new_extent, NULL, 1, 0, 1) < 0) __PYX_ERR(0, 150, __pyx_L1_error) - } - __pyx_L3:; - - /* "neo4j/bolt/_io.pyx":151 - * else: - * self._view[self._extent:new_extent] = b - * self._extent = new_extent # <<<<<<<<<<<<<< - * - * cpdef int receive(self, socket, int n): - */ - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_v_new_extent); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 151, __pyx_L1_error) - __pyx_v_self->_extent = __pyx_t_8; - - /* "neo4j/bolt/_io.pyx":134 - * return memoryview(self._view[:self._extent]) - * - * cpdef load(self, b): # <<<<<<<<<<<<<< - * """ - * - */ - - /* 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("neo4j.bolt._io.ChunkedInputBuffer.load", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_n); - __Pyx_XDECREF(__pyx_v_new_extent); - __Pyx_XDECREF(__pyx_v_overflow); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_9load(PyObject *__pyx_v_self, PyObject *__pyx_v_b); /*proto*/ -static char __pyx_doc_5neo4j_4bolt_3_io_18ChunkedInputBuffer_8load[] = "\n\n Note: may modify buffer size\n "; -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_9load(PyObject *__pyx_v_self, PyObject *__pyx_v_b) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("load (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_8load(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self), ((PyObject *)__pyx_v_b)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_8load(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_b) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("load", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_load(__pyx_v_self, __pyx_v_b, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 134, __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("neo4j.bolt._io.ChunkedInputBuffer.load", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":153 - * self._extent = new_extent - * - * cpdef int receive(self, socket, int n): # <<<<<<<<<<<<<< - * """ - * - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_11receive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_receive(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_socket, int __pyx_v_n, int __pyx_skip_dispatch) { - int __pyx_v_new_extent; - int __pyx_v_overflow; - PyObject *__pyx_v_data = 0; - int __pyx_v_data_size; - 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; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - Py_ssize_t __pyx_t_8; - int __pyx_t_9; - __Pyx_RefNannySetupContext("receive", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_receive); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_11receive)) { - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; - __pyx_t_6 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_6 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_socket, __pyx_t_3}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_socket, __pyx_t_3}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_v_socket); - __Pyx_GIVEREF(__pyx_v_socket); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_socket); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_6; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":163 - * cdef int data_size - * - * new_extent = self._extent + n # <<<<<<<<<<<<<< - * overflow = new_extent - len(self._data) - * if overflow > 0: - */ - __pyx_v_new_extent = (__pyx_v_self->_extent + __pyx_v_n); - - /* "neo4j/bolt/_io.pyx":164 - * - * new_extent = self._extent + n - * overflow = new_extent - len(self._data) # <<<<<<<<<<<<<< - * if overflow > 0: - * if self._recycle(): - */ - __pyx_t_1 = __pyx_v_self->_data; - __Pyx_INCREF(__pyx_t_1); - __pyx_t_8 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 164, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_overflow = (__pyx_v_new_extent - __pyx_t_8); - - /* "neo4j/bolt/_io.pyx":165 - * new_extent = self._extent + n - * overflow = new_extent - len(self._data) - * if overflow > 0: # <<<<<<<<<<<<<< - * if self._recycle(): - * return self.receive(socket, n) - */ - __pyx_t_9 = ((__pyx_v_overflow > 0) != 0); - if (__pyx_t_9) { - - /* "neo4j/bolt/_io.pyx":166 - * overflow = new_extent - len(self._data) - * if overflow > 0: - * if self._recycle(): # <<<<<<<<<<<<<< - * return self.receive(socket, n) - * self._view = None - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self->__pyx_vtab)->_recycle(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_9) { - - /* "neo4j/bolt/_io.pyx":167 - * if overflow > 0: - * if self._recycle(): - * return self.receive(socket, n) # <<<<<<<<<<<<<< - * self._view = None - * data = socket.recv(n) - */ - __pyx_r = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self->__pyx_vtab)->receive(__pyx_v_self, __pyx_v_socket, __pyx_v_n, 0); - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":166 - * overflow = new_extent - len(self._data) - * if overflow > 0: - * if self._recycle(): # <<<<<<<<<<<<<< - * return self.receive(socket, n) - * self._view = None - */ - } - - /* "neo4j/bolt/_io.pyx":168 - * if self._recycle(): - * return self.receive(socket, n) - * self._view = None # <<<<<<<<<<<<<< - * data = socket.recv(n) - * data_size = len(data) - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->_view); - __Pyx_DECREF(__pyx_v_self->_view); - __pyx_v_self->_view = Py_None; - - /* "neo4j/bolt/_io.pyx":169 - * return self.receive(socket, n) - * self._view = None - * data = socket.recv(n) # <<<<<<<<<<<<<< - * data_size = len(data) - * new_extent = self._extent + data_size - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_socket, __pyx_n_s_recv); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_7) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_7, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 169, __pyx_L1_error) - __pyx_v_data = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":170 - * self._view = None - * data = socket.recv(n) - * data_size = len(data) # <<<<<<<<<<<<<< - * new_extent = self._extent + data_size - * self._data[self._extent:new_extent] = data - */ - if (unlikely(__pyx_v_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 170, __pyx_L1_error) - } - __pyx_t_8 = PyBytes_GET_SIZE(__pyx_v_data); if (unlikely(__pyx_t_8 == ((Py_ssize_t)-1))) __PYX_ERR(0, 170, __pyx_L1_error) - __pyx_v_data_size = __pyx_t_8; - - /* "neo4j/bolt/_io.pyx":171 - * data = socket.recv(n) - * data_size = len(data) - * new_extent = self._extent + data_size # <<<<<<<<<<<<<< - * self._data[self._extent:new_extent] = data - * self._view = memoryview(self._data) - */ - __pyx_v_new_extent = (__pyx_v_self->_extent + __pyx_v_data_size); - - /* "neo4j/bolt/_io.pyx":172 - * data_size = len(data) - * new_extent = self._extent + data_size - * self._data[self._extent:new_extent] = data # <<<<<<<<<<<<<< - * self._view = memoryview(self._data) - * else: - */ - if (unlikely(__pyx_v_self->_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 172, __pyx_L1_error) - } - if (__Pyx_PyObject_SetSlice(__pyx_v_self->_data, __pyx_v_data, __pyx_v_self->_extent, __pyx_v_new_extent, NULL, NULL, NULL, 1, 1, 1) < 0) __PYX_ERR(0, 172, __pyx_L1_error) - - /* "neo4j/bolt/_io.pyx":173 - * new_extent = self._extent + data_size - * self._data[self._extent:new_extent] = data - * self._view = memoryview(self._data) # <<<<<<<<<<<<<< - * else: - * data_size = socket.recv_into(self._view[self._extent:new_extent]) - */ - __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_v_self->_data); - __Pyx_GIVEREF(__pyx_v_self->_data); - PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_self->_data); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_1, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 173, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GIVEREF(__pyx_t_2); - __Pyx_GOTREF(__pyx_v_self->_view); - __Pyx_DECREF(__pyx_v_self->_view); - __pyx_v_self->_view = __pyx_t_2; - __pyx_t_2 = 0; - - /* "neo4j/bolt/_io.pyx":165 - * new_extent = self._extent + n - * overflow = new_extent - len(self._data) - * if overflow > 0: # <<<<<<<<<<<<<< - * if self._recycle(): - * return self.receive(socket, n) - */ - goto __pyx_L3; - } - - /* "neo4j/bolt/_io.pyx":175 - * self._view = memoryview(self._data) - * else: - * data_size = socket.recv_into(self._view[self._extent:new_extent]) # <<<<<<<<<<<<<< - * new_extent = self._extent + data_size - * self._extent = new_extent - */ - /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_socket, __pyx_n_s_recv_into); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_self->_view, __pyx_v_self->_extent, __pyx_v_new_extent, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_data_size = __pyx_t_6; - - /* "neo4j/bolt/_io.pyx":176 - * else: - * data_size = socket.recv_into(self._view[self._extent:new_extent]) - * new_extent = self._extent + data_size # <<<<<<<<<<<<<< - * self._extent = new_extent - * return data_size - */ - __pyx_v_new_extent = (__pyx_v_self->_extent + __pyx_v_data_size); - } - __pyx_L3:; - - /* "neo4j/bolt/_io.pyx":177 - * data_size = socket.recv_into(self._view[self._extent:new_extent]) - * new_extent = self._extent + data_size - * self._extent = new_extent # <<<<<<<<<<<<<< - * return data_size - * - */ - __pyx_v_self->_extent = __pyx_v_new_extent; - - /* "neo4j/bolt/_io.pyx":178 - * new_extent = self._extent + data_size - * self._extent = new_extent - * return data_size # <<<<<<<<<<<<<< - * - * cpdef bint receive_message(self, socket, int n): - */ - __pyx_r = __pyx_v_data_size; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":153 - * self._extent = new_extent - * - * cpdef int receive(self, socket, int n): # <<<<<<<<<<<<<< - * """ - * - */ - - /* 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_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_WriteUnraisable("neo4j.bolt._io.ChunkedInputBuffer.receive", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_data); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_11receive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5neo4j_4bolt_3_io_18ChunkedInputBuffer_10receive[] = "\n\n Note: may modify buffer size, should error if frame exists\n "; -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_11receive(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_socket = 0; - int __pyx_v_n; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("receive (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_socket,&__pyx_n_s_n,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_socket)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("receive", 1, 2, 2, 1); __PYX_ERR(0, 153, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "receive") < 0)) __PYX_ERR(0, 153, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_socket = values[0]; - __pyx_v_n = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 153, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("receive", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 153, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedInputBuffer.receive", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_10receive(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self), __pyx_v_socket, __pyx_v_n); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_10receive(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_socket, int __pyx_v_n) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("receive", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_receive(__pyx_v_self, __pyx_v_socket, __pyx_v_n, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __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("neo4j.bolt._io.ChunkedInputBuffer.receive", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":180 - * return data_size - * - * cpdef bint receive_message(self, socket, int n): # <<<<<<<<<<<<<< - * """ - * - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_13receive_message(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_receive_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_socket, int __pyx_v_n, int __pyx_skip_dispatch) { - int __pyx_v_received; - PyObject *__pyx_v_frame_message = NULL; - PyObject *__pyx_v_receive = NULL; - 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; - PyObject *__pyx_t_5 = NULL; - int __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - int __pyx_t_9; - __Pyx_RefNannySetupContext("receive_message", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_receive_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_13receive_message)) { - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_4 = __pyx_t_1; __pyx_t_5 = NULL; - __pyx_t_6 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_6 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_socket, __pyx_t_3}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_socket, __pyx_t_3}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_v_socket); - __Pyx_GIVEREF(__pyx_v_socket); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_6, __pyx_v_socket); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_6, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_8; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":189 - * cdef int received - * - * frame_message = self.frame_message # <<<<<<<<<<<<<< - * receive = self.receive - * while not frame_message(): - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_frame_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 189, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_frame_message = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":190 - * - * frame_message = self.frame_message - * receive = self.receive # <<<<<<<<<<<<<< - * while not frame_message(): - * received = receive(socket, n) - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_receive); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 190, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_receive = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":191 - * frame_message = self.frame_message - * receive = self.receive - * while not frame_message(): # <<<<<<<<<<<<<< - * received = receive(socket, n) - * if received == 0: - */ - while (1) { - __Pyx_INCREF(__pyx_v_frame_message); - __pyx_t_2 = __pyx_v_frame_message; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (__pyx_t_4) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 191, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 191, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = ((!__pyx_t_8) != 0); - if (!__pyx_t_9) break; - - /* "neo4j/bolt/_io.pyx":192 - * receive = self.receive - * while not frame_message(): - * received = receive(socket, n) # <<<<<<<<<<<<<< - * if received == 0: - * return False - */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_v_receive); - __pyx_t_4 = __pyx_v_receive; __pyx_t_7 = NULL; - __pyx_t_6 = 0; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_6 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_socket, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_v_socket, __pyx_t_2}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_6, 2+__pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - { - __pyx_t_3 = PyTuple_New(2+__pyx_t_6); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_7); __pyx_t_7 = NULL; - } - __Pyx_INCREF(__pyx_v_socket); - __Pyx_GIVEREF(__pyx_v_socket); - PyTuple_SET_ITEM(__pyx_t_3, 0+__pyx_t_6, __pyx_v_socket); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_3, 1+__pyx_t_6, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_6 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_6 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 192, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_received = __pyx_t_6; - - /* "neo4j/bolt/_io.pyx":193 - * while not frame_message(): - * received = receive(socket, n) - * if received == 0: # <<<<<<<<<<<<<< - * return False - * return True - */ - __pyx_t_9 = ((__pyx_v_received == 0) != 0); - if (__pyx_t_9) { - - /* "neo4j/bolt/_io.pyx":194 - * received = receive(socket, n) - * if received == 0: - * return False # <<<<<<<<<<<<<< - * return True - * - */ - __pyx_r = 0; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":193 - * while not frame_message(): - * received = receive(socket, n) - * if received == 0: # <<<<<<<<<<<<<< - * return False - * return True - */ - } - } - - /* "neo4j/bolt/_io.pyx":195 - * if received == 0: - * return False - * return True # <<<<<<<<<<<<<< - * - * cdef _recycle(self): - */ - __pyx_r = 1; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":180 - * return data_size - * - * cpdef bint receive_message(self, socket, int n): # <<<<<<<<<<<<<< - * """ - * - */ - - /* 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_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_WriteUnraisable("neo4j.bolt._io.ChunkedInputBuffer.receive_message", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_frame_message); - __Pyx_XDECREF(__pyx_v_receive); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_13receive_message(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_5neo4j_4bolt_3_io_18ChunkedInputBuffer_12receive_message[] = "\n\n :param socket:\n :param n:\n :return:\n "; -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_13receive_message(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_socket = 0; - int __pyx_v_n; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("receive_message (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_socket,&__pyx_n_s_n,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_socket)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("receive_message", 1, 2, 2, 1); __PYX_ERR(0, 180, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "receive_message") < 0)) __PYX_ERR(0, 180, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_socket = values[0]; - __pyx_v_n = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_n == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 180, __pyx_L3_error) - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("receive_message", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 180, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedInputBuffer.receive_message", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_12receive_message(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self), __pyx_v_socket, __pyx_v_n); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_12receive_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, PyObject *__pyx_v_socket, int __pyx_v_n) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("receive_message", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_receive_message(__pyx_v_self, __pyx_v_socket, __pyx_v_n, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __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("neo4j.bolt._io.ChunkedInputBuffer.receive_message", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":197 - * return True - * - * cdef _recycle(self): # <<<<<<<<<<<<<< - * """ Reclaim buffer space before the origin. - * - */ - -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer__recycle(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self) { - int __pyx_v_origin; - int __pyx_v_available; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - __Pyx_RefNannySetupContext("_recycle", 0); - - /* "neo4j/bolt/_io.pyx":205 - * cdef int available - * - * origin = self._origin # <<<<<<<<<<<<<< - * if origin == 0: - * return False - */ - __pyx_t_1 = __pyx_v_self->_origin; - __pyx_v_origin = __pyx_t_1; - - /* "neo4j/bolt/_io.pyx":206 - * - * origin = self._origin - * if origin == 0: # <<<<<<<<<<<<<< - * return False - * available = self._extent - origin - */ - __pyx_t_2 = ((__pyx_v_origin == 0) != 0); - if (__pyx_t_2) { - - /* "neo4j/bolt/_io.pyx":207 - * origin = self._origin - * if origin == 0: - * return False # <<<<<<<<<<<<<< - * available = self._extent - origin - * self._data[:available] = self._data[origin:self._extent] - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_False); - __pyx_r = Py_False; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":206 - * - * origin = self._origin - * if origin == 0: # <<<<<<<<<<<<<< - * return False - * available = self._extent - origin - */ - } - - /* "neo4j/bolt/_io.pyx":208 - * if origin == 0: - * return False - * available = self._extent - origin # <<<<<<<<<<<<<< - * self._data[:available] = self._data[origin:self._extent] - * self._extent = available - */ - __pyx_v_available = (__pyx_v_self->_extent - __pyx_v_origin); - - /* "neo4j/bolt/_io.pyx":209 - * return False - * available = self._extent - origin - * self._data[:available] = self._data[origin:self._extent] # <<<<<<<<<<<<<< - * self._extent = available - * self._origin = 0 - */ - if (unlikely(__pyx_v_self->_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 209, __pyx_L1_error) - } - __pyx_t_3 = PySequence_GetSlice(__pyx_v_self->_data, __pyx_v_origin, __pyx_v_self->_extent); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - if (unlikely(__pyx_v_self->_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 209, __pyx_L1_error) - } - if (__Pyx_PyObject_SetSlice(__pyx_v_self->_data, __pyx_t_3, 0, __pyx_v_available, NULL, NULL, NULL, 0, 1, 1) < 0) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "neo4j/bolt/_io.pyx":210 - * available = self._extent - origin - * self._data[:available] = self._data[origin:self._extent] - * self._extent = available # <<<<<<<<<<<<<< - * self._origin = 0 - * #log_debug("Recycled %d bytes" % origin) - */ - __pyx_v_self->_extent = __pyx_v_available; - - /* "neo4j/bolt/_io.pyx":211 - * self._data[:available] = self._data[origin:self._extent] - * self._extent = available - * self._origin = 0 # <<<<<<<<<<<<<< - * #log_debug("Recycled %d bytes" % origin) - * return True - */ - __pyx_v_self->_origin = 0; - - /* "neo4j/bolt/_io.pyx":213 - * self._origin = 0 - * #log_debug("Recycled %d bytes" % origin) - * return True # <<<<<<<<<<<<<< - * - * cpdef frame(self): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_True); - __pyx_r = Py_True; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":197 - * return True - * - * cdef _recycle(self): # <<<<<<<<<<<<<< - * """ Reclaim buffer space before the origin. - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_3); - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedInputBuffer._recycle", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":215 - * return True - * - * cpdef frame(self): # <<<<<<<<<<<<<< - * return self._frame - * - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_15frame(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_frame(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__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; - __Pyx_RefNannySetupContext("frame", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_frame); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_15frame)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":216 - * - * cpdef frame(self): - * return self._frame # <<<<<<<<<<<<<< - * - * cpdef bint frame_message(self): - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(((PyObject *)__pyx_v_self->_frame)); - __pyx_r = ((PyObject *)__pyx_v_self->_frame); - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":215 - * return True - * - * cpdef frame(self): # <<<<<<<<<<<<<< - * return self._frame - * - */ - - /* 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("neo4j.bolt._io.ChunkedInputBuffer.frame", __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_5neo4j_4bolt_3_io_18ChunkedInputBuffer_15frame(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_15frame(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("frame (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_14frame(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_14frame(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("frame", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_frame(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __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("neo4j.bolt._io.ChunkedInputBuffer.frame", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":218 - * return self._frame - * - * cpdef bint frame_message(self): # <<<<<<<<<<<<<< - * """ Construct a frame around the first complete message in the buffer. - * """ - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_17frame_message(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static int __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_frame_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, int __pyx_skip_dispatch) { - PyObject *__pyx_v_panes = 0; - int __pyx_v_origin; - int __pyx_v_p; - int __pyx_v_extent; - int __pyx_v_available; - int __pyx_v_chunk_size; - int __pyx_v_q; - 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; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *(*__pyx_t_9)(PyObject *); - int __pyx_t_10; - __Pyx_RefNannySetupContext("frame_message", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_frame_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_17frame_message)) { - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_5; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":229 - * cdef int q - * - * if self._frame is not None: # <<<<<<<<<<<<<< - * self.discard_message() - * panes = [] - */ - __pyx_t_5 = (((PyObject *)__pyx_v_self->_frame) != Py_None); - __pyx_t_6 = (__pyx_t_5 != 0); - if (__pyx_t_6) { - - /* "neo4j/bolt/_io.pyx":230 - * - * if self._frame is not None: - * self.discard_message() # <<<<<<<<<<<<<< - * panes = [] - * p = origin = self._origin - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self->__pyx_vtab)->discard_message(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":229 - * cdef int q - * - * if self._frame is not None: # <<<<<<<<<<<<<< - * self.discard_message() - * panes = [] - */ - } - - /* "neo4j/bolt/_io.pyx":231 - * if self._frame is not None: - * self.discard_message() - * panes = [] # <<<<<<<<<<<<<< - * p = origin = self._origin - * extent = self._extent - */ - __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_panes = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":232 - * self.discard_message() - * panes = [] - * p = origin = self._origin # <<<<<<<<<<<<<< - * extent = self._extent - * while p < extent: - */ - __pyx_t_7 = __pyx_v_self->_origin; - __pyx_v_p = __pyx_t_7; - __pyx_v_origin = __pyx_t_7; - - /* "neo4j/bolt/_io.pyx":233 - * panes = [] - * p = origin = self._origin - * extent = self._extent # <<<<<<<<<<<<<< - * while p < extent: - * available = extent - p - */ - __pyx_t_7 = __pyx_v_self->_extent; - __pyx_v_extent = __pyx_t_7; - - /* "neo4j/bolt/_io.pyx":234 - * p = origin = self._origin - * extent = self._extent - * while p < extent: # <<<<<<<<<<<<<< - * available = extent - p - * if available < 2: - */ - while (1) { - __pyx_t_6 = ((__pyx_v_p < __pyx_v_extent) != 0); - if (!__pyx_t_6) break; - - /* "neo4j/bolt/_io.pyx":235 - * extent = self._extent - * while p < extent: - * available = extent - p # <<<<<<<<<<<<<< - * if available < 2: - * break - */ - __pyx_v_available = (__pyx_v_extent - __pyx_v_p); - - /* "neo4j/bolt/_io.pyx":236 - * while p < extent: - * available = extent - p - * if available < 2: # <<<<<<<<<<<<<< - * break - * chunk_size, = struct_unpack(">H", self._view[p:(p + 2)]) - */ - __pyx_t_6 = ((__pyx_v_available < 2) != 0); - if (__pyx_t_6) { - - /* "neo4j/bolt/_io.pyx":237 - * available = extent - p - * if available < 2: - * break # <<<<<<<<<<<<<< - * chunk_size, = struct_unpack(">H", self._view[p:(p + 2)]) - * p += 2 - */ - goto __pyx_L5_break; - - /* "neo4j/bolt/_io.pyx":236 - * while p < extent: - * available = extent - p - * if available < 2: # <<<<<<<<<<<<<< - * break - * chunk_size, = struct_unpack(">H", self._view[p:(p + 2)]) - */ - } - - /* "neo4j/bolt/_io.pyx":238 - * if available < 2: - * break - * chunk_size, = struct_unpack(">H", self._view[p:(p + 2)]) # <<<<<<<<<<<<<< - * p += 2 - * if chunk_size == 0: - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyObject_GetSlice(__pyx_v_self->_view, __pyx_v_p, (__pyx_v_p + 2), NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_H, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_H, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_kp_s_H); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) { - PyObject* sequence = __pyx_t_1; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 238, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_2 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_2); - #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - #endif - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_8 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext; - index = 0; __pyx_t_2 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L7_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 1) < 0) __PYX_ERR(0, 238, __pyx_L1_error) - __pyx_t_9 = NULL; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - goto __pyx_L8_unpacking_done; - __pyx_L7_unpacking_failed:; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_9 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 238, __pyx_L1_error) - __pyx_L8_unpacking_done:; - } - __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_chunk_size = __pyx_t_7; - - /* "neo4j/bolt/_io.pyx":239 - * break - * chunk_size, = struct_unpack(">H", self._view[p:(p + 2)]) - * p += 2 # <<<<<<<<<<<<<< - * if chunk_size == 0: - * self._limit = p - */ - __pyx_v_p = (__pyx_v_p + 2); - - /* "neo4j/bolt/_io.pyx":240 - * chunk_size, = struct_unpack(">H", self._view[p:(p + 2)]) - * p += 2 - * if chunk_size == 0: # <<<<<<<<<<<<<< - * self._limit = p - * self._frame = MessageFrame(memoryview(self._view[origin:self._limit]), panes) - */ - __pyx_t_6 = ((__pyx_v_chunk_size == 0) != 0); - if (__pyx_t_6) { - - /* "neo4j/bolt/_io.pyx":241 - * p += 2 - * if chunk_size == 0: - * self._limit = p # <<<<<<<<<<<<<< - * self._frame = MessageFrame(memoryview(self._view[origin:self._limit]), panes) - * return True - */ - __pyx_v_self->_limit = __pyx_v_p; - - /* "neo4j/bolt/_io.pyx":242 - * if chunk_size == 0: - * self._limit = p - * self._frame = MessageFrame(memoryview(self._view[origin:self._limit]), panes) # <<<<<<<<<<<<<< - * return True - * q = p + chunk_size - */ - __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_self->_view, __pyx_v_origin, __pyx_v_self->_limit, NULL, NULL, NULL, 1, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __Pyx_INCREF(__pyx_v_panes); - __Pyx_GIVEREF(__pyx_v_panes); - PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_panes); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)__pyx_ptype_5neo4j_4bolt_3_io_MessageFrame), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->_frame); - __Pyx_DECREF(((PyObject *)__pyx_v_self->_frame)); - __pyx_v_self->_frame = ((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)__pyx_t_1); - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":243 - * self._limit = p - * self._frame = MessageFrame(memoryview(self._view[origin:self._limit]), panes) - * return True # <<<<<<<<<<<<<< - * q = p + chunk_size - * panes.append((p - origin, q - origin)) - */ - __pyx_r = 1; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":240 - * chunk_size, = struct_unpack(">H", self._view[p:(p + 2)]) - * p += 2 - * if chunk_size == 0: # <<<<<<<<<<<<<< - * self._limit = p - * self._frame = MessageFrame(memoryview(self._view[origin:self._limit]), panes) - */ - } - - /* "neo4j/bolt/_io.pyx":244 - * self._frame = MessageFrame(memoryview(self._view[origin:self._limit]), panes) - * return True - * q = p + chunk_size # <<<<<<<<<<<<<< - * panes.append((p - origin, q - origin)) - * p = q - */ - __pyx_v_q = (__pyx_v_p + __pyx_v_chunk_size); - - /* "neo4j/bolt/_io.pyx":245 - * return True - * q = p + chunk_size - * panes.append((p - origin, q - origin)) # <<<<<<<<<<<<<< - * p = q - * return False - */ - __pyx_t_1 = __Pyx_PyInt_From_int((__pyx_v_p - __pyx_v_origin)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 245, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = __Pyx_PyInt_From_int((__pyx_v_q - __pyx_v_origin)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 245, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 245, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_t_2); - __pyx_t_1 = 0; - __pyx_t_2 = 0; - __pyx_t_10 = __Pyx_PyList_Append(__pyx_v_panes, __pyx_t_8); if (unlikely(__pyx_t_10 == ((int)-1))) __PYX_ERR(0, 245, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - - /* "neo4j/bolt/_io.pyx":246 - * q = p + chunk_size - * panes.append((p - origin, q - origin)) - * p = q # <<<<<<<<<<<<<< - * return False - * - */ - __pyx_v_p = __pyx_v_q; - } - __pyx_L5_break:; - - /* "neo4j/bolt/_io.pyx":247 - * panes.append((p - origin, q - origin)) - * p = q - * return False # <<<<<<<<<<<<<< - * - * cpdef discard_message(self): - */ - __pyx_r = 0; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":218 - * return self._frame - * - * cpdef bint frame_message(self): # <<<<<<<<<<<<<< - * """ Construct a frame around the first complete message in the buffer. - * """ - */ - - /* 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_XDECREF(__pyx_t_8); - __Pyx_WriteUnraisable("neo4j.bolt._io.ChunkedInputBuffer.frame_message", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_panes); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_17frame_message(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static char __pyx_doc_5neo4j_4bolt_3_io_18ChunkedInputBuffer_16frame_message[] = " Construct a frame around the first complete message in the buffer.\n "; -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_17frame_message(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("frame_message (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_16frame_message(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_16frame_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("frame_message", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_frame_message(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 218, __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("neo4j.bolt._io.ChunkedInputBuffer.frame_message", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":249 - * return False - * - * cpdef discard_message(self): # <<<<<<<<<<<<<< - * if self._frame is not None: - * self._frame.close() - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_19discard_message(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_discard_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__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; - int __pyx_t_5; - int __pyx_t_6; - int __pyx_t_7; - __Pyx_RefNannySetupContext("discard_message", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_discard_message); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_19discard_message)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":250 - * - * cpdef discard_message(self): - * if self._frame is not None: # <<<<<<<<<<<<<< - * self._frame.close() - * self._origin = self._limit - */ - __pyx_t_5 = (((PyObject *)__pyx_v_self->_frame) != Py_None); - __pyx_t_6 = (__pyx_t_5 != 0); - if (__pyx_t_6) { - - /* "neo4j/bolt/_io.pyx":251 - * cpdef discard_message(self): - * if self._frame is not None: - * self._frame.close() # <<<<<<<<<<<<<< - * self._origin = self._limit - * self._limit = -1 - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_MessageFrame *)__pyx_v_self->_frame->__pyx_vtab)->close(__pyx_v_self->_frame, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":252 - * if self._frame is not None: - * self._frame.close() - * self._origin = self._limit # <<<<<<<<<<<<<< - * self._limit = -1 - * self._frame = None - */ - __pyx_t_7 = __pyx_v_self->_limit; - __pyx_v_self->_origin = __pyx_t_7; - - /* "neo4j/bolt/_io.pyx":253 - * self._frame.close() - * self._origin = self._limit - * self._limit = -1 # <<<<<<<<<<<<<< - * self._frame = None - * - */ - __pyx_v_self->_limit = -1; - - /* "neo4j/bolt/_io.pyx":254 - * self._origin = self._limit - * self._limit = -1 - * self._frame = None # <<<<<<<<<<<<<< - * - * - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->_frame); - __Pyx_DECREF(((PyObject *)__pyx_v_self->_frame)); - __pyx_v_self->_frame = ((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)Py_None); - - /* "neo4j/bolt/_io.pyx":250 - * - * cpdef discard_message(self): - * if self._frame is not None: # <<<<<<<<<<<<<< - * self._frame.close() - * self._origin = self._limit - */ - } - - /* "neo4j/bolt/_io.pyx":249 - * return False - * - * cpdef discard_message(self): # <<<<<<<<<<<<<< - * if self._frame is not None: - * self._frame.close() - */ - - /* 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("neo4j.bolt._io.ChunkedInputBuffer.discard_message", __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_5neo4j_4bolt_3_io_18ChunkedInputBuffer_19discard_message(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_19discard_message(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("discard_message (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_18discard_message(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_18discard_message(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("discard_message", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_discard_message(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 249, __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("neo4j.bolt._io.ChunkedInputBuffer.discard_message", __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): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_21__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_20__reduce_cython__(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_20__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __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(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedInputBuffer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_23__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_22__setstate_cython__(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_18ChunkedInputBuffer_22__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __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(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedInputBuffer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":265 - * cdef int _end - * - * def __cinit__(self, int capacity=1048576, int max_chunk_size=16384): # <<<<<<<<<<<<<< - * self._max_chunk_size = max_chunk_size - * self._header = 0 - */ - -/* Python wrapper */ -static int __pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_v_capacity; - int __pyx_v_max_chunk_size; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_capacity,&__pyx_n_s_max_chunk_size,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_capacity); - if (value) { values[0] = value; kw_args--; } - } - CYTHON_FALLTHROUGH; - case 1: - if (kw_args > 0) { - PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_max_chunk_size); - if (value) { values[1] = value; kw_args--; } - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 265, __pyx_L3_error) - } - } else { - switch (PyTuple_GET_SIZE(__pyx_args)) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - } - if (values[0]) { - __pyx_v_capacity = __Pyx_PyInt_As_int(values[0]); if (unlikely((__pyx_v_capacity == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 265, __pyx_L3_error) - } else { - __pyx_v_capacity = ((int)0x100000); - } - if (values[1]) { - __pyx_v_max_chunk_size = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_max_chunk_size == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 265, __pyx_L3_error) - } else { - __pyx_v_max_chunk_size = ((int)0x4000); - } - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 0, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 265, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedOutputBuffer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer___cinit__(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self), __pyx_v_capacity, __pyx_v_max_chunk_size); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer___cinit__(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, int __pyx_v_capacity, int __pyx_v_max_chunk_size) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "neo4j/bolt/_io.pyx":266 - * - * def __cinit__(self, int capacity=1048576, int max_chunk_size=16384): - * self._max_chunk_size = max_chunk_size # <<<<<<<<<<<<<< - * self._header = 0 - * self._start = 2 - */ - __pyx_v_self->_max_chunk_size = __pyx_v_max_chunk_size; - - /* "neo4j/bolt/_io.pyx":267 - * def __cinit__(self, int capacity=1048576, int max_chunk_size=16384): - * self._max_chunk_size = max_chunk_size - * self._header = 0 # <<<<<<<<<<<<<< - * self._start = 2 - * self._end = 2 - */ - __pyx_v_self->_header = 0; - - /* "neo4j/bolt/_io.pyx":268 - * self._max_chunk_size = max_chunk_size - * self._header = 0 - * self._start = 2 # <<<<<<<<<<<<<< - * self._end = 2 - * self._data = bytearray(capacity) - */ - __pyx_v_self->_start = 2; - - /* "neo4j/bolt/_io.pyx":269 - * self._header = 0 - * self._start = 2 - * self._end = 2 # <<<<<<<<<<<<<< - * self._data = bytearray(capacity) - * - */ - __pyx_v_self->_end = 2; - - /* "neo4j/bolt/_io.pyx":270 - * self._start = 2 - * self._end = 2 - * self._data = bytearray(capacity) # <<<<<<<<<<<<<< - * - * cpdef int max_chunk_size(self): - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_capacity); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyByteArray_Type)), __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->_data); - __Pyx_DECREF(__pyx_v_self->_data); - __pyx_v_self->_data = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":265 - * cdef int _end - * - * def __cinit__(self, int capacity=1048576, int max_chunk_size=16384): # <<<<<<<<<<<<<< - * self._max_chunk_size = max_chunk_size - * self._header = 0 - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedOutputBuffer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":272 - * self._data = bytearray(capacity) - * - * cpdef int max_chunk_size(self): # <<<<<<<<<<<<<< - * return self._max_chunk_size - * - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_3max_chunk_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static int __pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_max_chunk_size(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, int __pyx_skip_dispatch) { - 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; - int __pyx_t_5; - __Pyx_RefNannySetupContext("max_chunk_size", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_max_chunk_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_3max_chunk_size)) { - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 272, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_5 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 272, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_5; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":273 - * - * cpdef int max_chunk_size(self): - * return self._max_chunk_size # <<<<<<<<<<<<<< - * - * cpdef clear(self): - */ - __pyx_r = __pyx_v_self->_max_chunk_size; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":272 - * self._data = bytearray(capacity) - * - * cpdef int max_chunk_size(self): # <<<<<<<<<<<<<< - * return self._max_chunk_size - * - */ - - /* 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_WriteUnraisable("neo4j.bolt._io.ChunkedOutputBuffer.max_chunk_size", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_3max_chunk_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_3max_chunk_size(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("max_chunk_size (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_2max_chunk_size(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_2max_chunk_size(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("max_chunk_size", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_max_chunk_size(__pyx_v_self, 1)); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __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("neo4j.bolt._io.ChunkedOutputBuffer.max_chunk_size", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":275 - * return self._max_chunk_size - * - * cpdef clear(self): # <<<<<<<<<<<<<< - * self._header = 0 - * self._start = 2 - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_5clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_clear(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__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; - __Pyx_RefNannySetupContext("clear", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_clear); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_5clear)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 275, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":276 - * - * cpdef clear(self): - * self._header = 0 # <<<<<<<<<<<<<< - * self._start = 2 - * self._end = 2 - */ - __pyx_v_self->_header = 0; - - /* "neo4j/bolt/_io.pyx":277 - * cpdef clear(self): - * self._header = 0 - * self._start = 2 # <<<<<<<<<<<<<< - * self._end = 2 - * self._data[0:2] = b"\x00\x00" - */ - __pyx_v_self->_start = 2; - - /* "neo4j/bolt/_io.pyx":278 - * self._header = 0 - * self._start = 2 - * self._end = 2 # <<<<<<<<<<<<<< - * self._data[0:2] = b"\x00\x00" - * - */ - __pyx_v_self->_end = 2; - - /* "neo4j/bolt/_io.pyx":279 - * self._start = 2 - * self._end = 2 - * self._data[0:2] = b"\x00\x00" # <<<<<<<<<<<<<< - * - * cpdef write(self, bytes b): - */ - if (unlikely(__pyx_v_self->_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 279, __pyx_L1_error) - } - if (__Pyx_PyObject_SetSlice(__pyx_v_self->_data, __pyx_kp_b__5, 0, 2, NULL, NULL, NULL, 1, 1, 1) < 0) __PYX_ERR(0, 279, __pyx_L1_error) - - /* "neo4j/bolt/_io.pyx":275 - * return self._max_chunk_size - * - * cpdef clear(self): # <<<<<<<<<<<<<< - * self._header = 0 - * self._start = 2 - */ - - /* 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("neo4j.bolt._io.ChunkedOutputBuffer.clear", __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_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_5clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_5clear(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("clear (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_4clear(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_4clear(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("clear", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_clear(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __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("neo4j.bolt._io.ChunkedOutputBuffer.clear", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":281 - * self._data[0:2] = b"\x00\x00" - * - * cpdef write(self, bytes b): # <<<<<<<<<<<<<< - * cdef bytearray data - * cdef int new_data_size - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_7write(PyObject *__pyx_v_self, PyObject *__pyx_v_b); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_write(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, PyObject *__pyx_v_b, int __pyx_skip_dispatch) { - PyObject *__pyx_v_data = 0; - int __pyx_v_new_data_size; - int __pyx_v_chunk_size; - int __pyx_v_chunk_remaining; - int __pyx_v_new_end; - int __pyx_v_new_chunk_size; - PyObject *__pyx_v_max_chunk_size = NULL; - 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; - Py_ssize_t __pyx_t_6; - int __pyx_t_7; - int __pyx_t_8; - __Pyx_RefNannySetupContext("write", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_write); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_7write)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_b); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_b}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_b}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_INCREF(__pyx_v_b); - __Pyx_GIVEREF(__pyx_v_b); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_b); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":289 - * cdef int new_chunk_size - * - * data = self._data # <<<<<<<<<<<<<< - * new_data_size = len(b) - * chunk_size = self._end - self._start - */ - __pyx_t_1 = __pyx_v_self->_data; - __Pyx_INCREF(__pyx_t_1); - __pyx_v_data = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":290 - * - * data = self._data - * new_data_size = len(b) # <<<<<<<<<<<<<< - * chunk_size = self._end - self._start - * max_chunk_size = self._max_chunk_size - */ - if (unlikely(__pyx_v_b == Py_None)) { - PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 290, __pyx_L1_error) - } - __pyx_t_6 = PyBytes_GET_SIZE(__pyx_v_b); if (unlikely(__pyx_t_6 == ((Py_ssize_t)-1))) __PYX_ERR(0, 290, __pyx_L1_error) - __pyx_v_new_data_size = __pyx_t_6; - - /* "neo4j/bolt/_io.pyx":291 - * data = self._data - * new_data_size = len(b) - * chunk_size = self._end - self._start # <<<<<<<<<<<<<< - * max_chunk_size = self._max_chunk_size - * chunk_remaining = max_chunk_size - chunk_size - */ - __pyx_v_chunk_size = (__pyx_v_self->_end - __pyx_v_self->_start); - - /* "neo4j/bolt/_io.pyx":292 - * new_data_size = len(b) - * chunk_size = self._end - self._start - * max_chunk_size = self._max_chunk_size # <<<<<<<<<<<<<< - * chunk_remaining = max_chunk_size - chunk_size - * if new_data_size > max_chunk_size: - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_self->_max_chunk_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 292, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_v_max_chunk_size = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":293 - * chunk_size = self._end - self._start - * max_chunk_size = self._max_chunk_size - * chunk_remaining = max_chunk_size - chunk_size # <<<<<<<<<<<<<< - * if new_data_size > max_chunk_size: - * self.write(b[:chunk_remaining]) - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_chunk_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyNumber_Subtract(__pyx_v_max_chunk_size, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 293, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_chunk_remaining = __pyx_t_7; - - /* "neo4j/bolt/_io.pyx":294 - * max_chunk_size = self._max_chunk_size - * chunk_remaining = max_chunk_size - chunk_size - * if new_data_size > max_chunk_size: # <<<<<<<<<<<<<< - * self.write(b[:chunk_remaining]) - * self.chunk() - */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_new_data_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = PyObject_RichCompare(__pyx_t_2, __pyx_v_max_chunk_size, Py_GT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_8) { - - /* "neo4j/bolt/_io.pyx":295 - * chunk_remaining = max_chunk_size - chunk_size - * if new_data_size > max_chunk_size: - * self.write(b[:chunk_remaining]) # <<<<<<<<<<<<<< - * self.chunk() - * self.write(b[chunk_remaining:]) - */ - if (unlikely(__pyx_v_b == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 295, __pyx_L1_error) - } - __pyx_t_1 = PySequence_GetSlice(__pyx_v_b, 0, __pyx_v_chunk_remaining); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 295, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, ((PyObject*)__pyx_t_1), 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 295, __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; - - /* "neo4j/bolt/_io.pyx":296 - * if new_data_size > max_chunk_size: - * self.write(b[:chunk_remaining]) - * self.chunk() # <<<<<<<<<<<<<< - * self.write(b[chunk_remaining:]) - * return - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self->__pyx_vtab)->chunk(__pyx_v_self, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/bolt/_io.pyx":297 - * self.write(b[:chunk_remaining]) - * self.chunk() - * self.write(b[chunk_remaining:]) # <<<<<<<<<<<<<< - * return - * if new_data_size > chunk_remaining: - */ - if (unlikely(__pyx_v_b == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 297, __pyx_L1_error) - } - __pyx_t_2 = PySequence_GetSlice(__pyx_v_b, __pyx_v_chunk_remaining, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self->__pyx_vtab)->write(__pyx_v_self, ((PyObject*)__pyx_t_2), 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 297, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":298 - * self.chunk() - * self.write(b[chunk_remaining:]) - * return # <<<<<<<<<<<<<< - * if new_data_size > chunk_remaining: - * self.chunk() - */ - __Pyx_XDECREF(__pyx_r); - __pyx_r = Py_None; __Pyx_INCREF(Py_None); - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":294 - * max_chunk_size = self._max_chunk_size - * chunk_remaining = max_chunk_size - chunk_size - * if new_data_size > max_chunk_size: # <<<<<<<<<<<<<< - * self.write(b[:chunk_remaining]) - * self.chunk() - */ - } - - /* "neo4j/bolt/_io.pyx":299 - * self.write(b[chunk_remaining:]) - * return - * if new_data_size > chunk_remaining: # <<<<<<<<<<<<<< - * self.chunk() - * new_end = self._end + new_data_size - */ - __pyx_t_8 = ((__pyx_v_new_data_size > __pyx_v_chunk_remaining) != 0); - if (__pyx_t_8) { - - /* "neo4j/bolt/_io.pyx":300 - * return - * if new_data_size > chunk_remaining: - * self.chunk() # <<<<<<<<<<<<<< - * new_end = self._end + new_data_size - * new_chunk_size = new_end - self._start - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self->__pyx_vtab)->chunk(__pyx_v_self, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":299 - * self.write(b[chunk_remaining:]) - * return - * if new_data_size > chunk_remaining: # <<<<<<<<<<<<<< - * self.chunk() - * new_end = self._end + new_data_size - */ - } - - /* "neo4j/bolt/_io.pyx":301 - * if new_data_size > chunk_remaining: - * self.chunk() - * new_end = self._end + new_data_size # <<<<<<<<<<<<<< - * new_chunk_size = new_end - self._start - * data[self._end:new_end] = b - */ - __pyx_v_new_end = (__pyx_v_self->_end + __pyx_v_new_data_size); - - /* "neo4j/bolt/_io.pyx":302 - * self.chunk() - * new_end = self._end + new_data_size - * new_chunk_size = new_end - self._start # <<<<<<<<<<<<<< - * data[self._end:new_end] = b - * self._end = new_end - */ - __pyx_v_new_chunk_size = (__pyx_v_new_end - __pyx_v_self->_start); - - /* "neo4j/bolt/_io.pyx":303 - * new_end = self._end + new_data_size - * new_chunk_size = new_end - self._start - * data[self._end:new_end] = b # <<<<<<<<<<<<<< - * self._end = new_end - * data[self._header:(self._header + 2)] = struct_pack(">H", new_chunk_size) - */ - if (unlikely(__pyx_v_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 303, __pyx_L1_error) - } - if (__Pyx_PyObject_SetSlice(__pyx_v_data, __pyx_v_b, __pyx_v_self->_end, __pyx_v_new_end, NULL, NULL, NULL, 1, 1, 1) < 0) __PYX_ERR(0, 303, __pyx_L1_error) - - /* "neo4j/bolt/_io.pyx":304 - * new_chunk_size = new_end - self._start - * data[self._end:new_end] = b - * self._end = new_end # <<<<<<<<<<<<<< - * data[self._header:(self._header + 2)] = struct_pack(">H", new_chunk_size) - * - */ - __pyx_v_self->_end = __pyx_v_new_end; - - /* "neo4j/bolt/_io.pyx":305 - * data[self._end:new_end] = b - * self._end = new_end - * data[self._header:(self._header + 2)] = struct_pack(">H", new_chunk_size) # <<<<<<<<<<<<<< - * - * cpdef chunk(self): - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_pack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_new_chunk_size); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_H, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_H, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_4 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_kp_s_H); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_7, __pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_7, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if (unlikely(__pyx_v_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 305, __pyx_L1_error) - } - if (__Pyx_PyObject_SetSlice(__pyx_v_data, __pyx_t_1, __pyx_v_self->_header, (__pyx_v_self->_header + 2), NULL, NULL, NULL, 1, 1, 1) < 0) __PYX_ERR(0, 305, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":281 - * self._data[0:2] = b"\x00\x00" - * - * cpdef write(self, bytes b): # <<<<<<<<<<<<<< - * cdef bytearray data - * cdef int new_data_size - */ - - /* 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("neo4j.bolt._io.ChunkedOutputBuffer.write", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_data); - __Pyx_XDECREF(__pyx_v_max_chunk_size); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_7write(PyObject *__pyx_v_self, PyObject *__pyx_v_b); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_7write(PyObject *__pyx_v_self, PyObject *__pyx_v_b) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("write (wrapper)", 0); - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_b), (&PyBytes_Type), 1, "b", 1))) __PYX_ERR(0, 281, __pyx_L1_error) - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_6write(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self), ((PyObject*)__pyx_v_b)); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_6write(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, PyObject *__pyx_v_b) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("write", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_write(__pyx_v_self, __pyx_v_b, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __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("neo4j.bolt._io.ChunkedOutputBuffer.write", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":307 - * data[self._header:(self._header + 2)] = struct_pack(">H", new_chunk_size) - * - * cpdef chunk(self): # <<<<<<<<<<<<<< - * self._header = self._end - * self._start = self._header + 2 - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_9chunk(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_chunk(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__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; - int __pyx_t_5; - __Pyx_RefNannySetupContext("chunk", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_chunk); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_9chunk)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 307, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":308 - * - * cpdef chunk(self): - * self._header = self._end # <<<<<<<<<<<<<< - * self._start = self._header + 2 - * self._end = self._start - */ - __pyx_t_5 = __pyx_v_self->_end; - __pyx_v_self->_header = __pyx_t_5; - - /* "neo4j/bolt/_io.pyx":309 - * cpdef chunk(self): - * self._header = self._end - * self._start = self._header + 2 # <<<<<<<<<<<<<< - * self._end = self._start - * self._data[self._header:self._start] = b"\x00\x00" - */ - __pyx_v_self->_start = (__pyx_v_self->_header + 2); - - /* "neo4j/bolt/_io.pyx":310 - * self._header = self._end - * self._start = self._header + 2 - * self._end = self._start # <<<<<<<<<<<<<< - * self._data[self._header:self._start] = b"\x00\x00" - * - */ - __pyx_t_5 = __pyx_v_self->_start; - __pyx_v_self->_end = __pyx_t_5; - - /* "neo4j/bolt/_io.pyx":311 - * self._start = self._header + 2 - * self._end = self._start - * self._data[self._header:self._start] = b"\x00\x00" # <<<<<<<<<<<<<< - * - * cpdef view(self): - */ - if (unlikely(__pyx_v_self->_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 311, __pyx_L1_error) - } - if (__Pyx_PyObject_SetSlice(__pyx_v_self->_data, __pyx_kp_b__5, __pyx_v_self->_header, __pyx_v_self->_start, NULL, NULL, NULL, 1, 1, 1) < 0) __PYX_ERR(0, 311, __pyx_L1_error) - - /* "neo4j/bolt/_io.pyx":307 - * data[self._header:(self._header + 2)] = struct_pack(">H", new_chunk_size) - * - * cpdef chunk(self): # <<<<<<<<<<<<<< - * self._header = self._end - * self._start = self._header + 2 - */ - - /* 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("neo4j.bolt._io.ChunkedOutputBuffer.chunk", __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_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_9chunk(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_9chunk(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("chunk (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_8chunk(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_8chunk(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("chunk", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_chunk(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 307, __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("neo4j.bolt._io.ChunkedOutputBuffer.chunk", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/bolt/_io.pyx":313 - * self._data[self._header:self._start] = b"\x00\x00" - * - * cpdef view(self): # <<<<<<<<<<<<<< - * cdef int end - * cdef int chunk_size - */ - -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_11view(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_view(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, int __pyx_skip_dispatch) { - int __pyx_v_end; - int __pyx_v_chunk_size; - 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; - __Pyx_RefNannySetupContext("view", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_view); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_11view)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 313, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/bolt/_io.pyx":317 - * cdef int chunk_size - * - * end = self._end # <<<<<<<<<<<<<< - * chunk_size = end - self._start - * if chunk_size == 0: - */ - __pyx_t_5 = __pyx_v_self->_end; - __pyx_v_end = __pyx_t_5; - - /* "neo4j/bolt/_io.pyx":318 - * - * end = self._end - * chunk_size = end - self._start # <<<<<<<<<<<<<< - * if chunk_size == 0: - * return memoryview(self._data[:self._header]) - */ - __pyx_v_chunk_size = (__pyx_v_end - __pyx_v_self->_start); - - /* "neo4j/bolt/_io.pyx":319 - * end = self._end - * chunk_size = end - self._start - * if chunk_size == 0: # <<<<<<<<<<<<<< - * return memoryview(self._data[:self._header]) - * else: - */ - __pyx_t_6 = ((__pyx_v_chunk_size == 0) != 0); - if (__pyx_t_6) { - - /* "neo4j/bolt/_io.pyx":320 - * chunk_size = end - self._start - * if chunk_size == 0: - * return memoryview(self._data[:self._header]) # <<<<<<<<<<<<<< - * else: - * return memoryview(self._data[:end]) - */ - __Pyx_XDECREF(__pyx_r); - if (unlikely(__pyx_v_self->_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 320, __pyx_L1_error) - } - __pyx_t_1 = PySequence_GetSlice(__pyx_v_self->_data, 0, __pyx_v_self->_header); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/bolt/_io.pyx":319 - * end = self._end - * chunk_size = end - self._start - * if chunk_size == 0: # <<<<<<<<<<<<<< - * return memoryview(self._data[:self._header]) - * else: - */ - } - - /* "neo4j/bolt/_io.pyx":322 - * return memoryview(self._data[:self._header]) - * else: - * return memoryview(self._data[:end]) # <<<<<<<<<<<<<< - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - if (unlikely(__pyx_v_self->_data == Py_None)) { - PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable"); - __PYX_ERR(0, 322, __pyx_L1_error) - } - __pyx_t_1 = PySequence_GetSlice(__pyx_v_self->_data, 0, __pyx_v_end); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 322, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 322, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - } - - /* "neo4j/bolt/_io.pyx":313 - * self._data[self._header:self._start] = b"\x00\x00" - * - * cpdef view(self): # <<<<<<<<<<<<<< - * cdef int end - * cdef int chunk_size - */ - - /* 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("neo4j.bolt._io.ChunkedOutputBuffer.view", __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_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_11view(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_11view(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("view (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_10view(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_10view(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("view", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_view(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 313, __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("neo4j.bolt._io.ChunkedOutputBuffer.view", __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): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_12__reduce_cython__(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __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(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedOutputBuffer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_14__setstate_cython__(((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __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(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.bolt._io.ChunkedOutputBuffer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -static struct __pyx_vtabstruct_5neo4j_4bolt_3_io_MessageFrame __pyx_vtable_5neo4j_4bolt_3_io_MessageFrame; - -static PyObject *__pyx_tp_new_5neo4j_4bolt_3_io_MessageFrame(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)o); - p->__pyx_vtab = __pyx_vtabptr_5neo4j_4bolt_3_io_MessageFrame; - p->_view = Py_None; Py_INCREF(Py_None); - p->_panes = ((PyObject*)Py_None); Py_INCREF(Py_None); - if (unlikely(__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_1__cinit__(o, a, k) < 0)) goto bad; - return o; - bad: - Py_DECREF(o); o = 0; - return NULL; -} - -static void __pyx_tp_dealloc_5neo4j_4bolt_3_io_MessageFrame(PyObject *o) { - struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *p = (struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)o; - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - Py_CLEAR(p->_view); - Py_CLEAR(p->_panes); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_5neo4j_4bolt_3_io_MessageFrame(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *p = (struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)o; - if (p->_view) { - e = (*v)(p->_view, a); if (e) return e; - } - if (p->_panes) { - e = (*v)(p->_panes, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_5neo4j_4bolt_3_io_MessageFrame(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *p = (struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)o; - tmp = ((PyObject*)p->_view); - p->_view = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_panes); - p->_panes = ((PyObject*)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyMethodDef __pyx_methods_5neo4j_4bolt_3_io_MessageFrame[] = { - {"panes", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_3panes, METH_NOARGS, 0}, - {"read_int", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_5read_int, METH_NOARGS, 0}, - {"read", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_7read, METH_O, 0}, - {"close", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_9close, METH_NOARGS, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_11__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_12MessageFrame_13__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_5neo4j_4bolt_3_io_MessageFrame = { - PyVarObject_HEAD_INIT(0, 0) - "neo4j.bolt._io.MessageFrame", /*tp_name*/ - sizeof(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5neo4j_4bolt_3_io_MessageFrame, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 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_5neo4j_4bolt_3_io_MessageFrame, /*tp_traverse*/ - __pyx_tp_clear_5neo4j_4bolt_3_io_MessageFrame, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_5neo4j_4bolt_3_io_MessageFrame, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_5neo4j_4bolt_3_io_MessageFrame, /*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 PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; -static struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedInputBuffer __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer; - -static PyObject *__pyx_tp_new_5neo4j_4bolt_3_io_ChunkedInputBuffer(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)o); - p->__pyx_vtab = __pyx_vtabptr_5neo4j_4bolt_3_io_ChunkedInputBuffer; - p->_data = ((PyObject*)Py_None); Py_INCREF(Py_None); - p->_view = Py_None; Py_INCREF(Py_None); - p->_frame = ((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)Py_None); Py_INCREF(Py_None); - if (unlikely(__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_1__cinit__(o, a, k) < 0)) goto bad; - return o; - bad: - Py_DECREF(o); o = 0; - return NULL; -} - -static void __pyx_tp_dealloc_5neo4j_4bolt_3_io_ChunkedInputBuffer(PyObject *o) { - struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *p = (struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)o; - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - Py_CLEAR(p->_data); - Py_CLEAR(p->_view); - Py_CLEAR(p->_frame); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_5neo4j_4bolt_3_io_ChunkedInputBuffer(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *p = (struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)o; - if (p->_view) { - e = (*v)(p->_view, a); if (e) return e; - } - if (p->_frame) { - e = (*v)(((PyObject *)p->_frame), a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_5neo4j_4bolt_3_io_ChunkedInputBuffer(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *p = (struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *)o; - tmp = ((PyObject*)p->_view); - p->_view = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_frame); - p->_frame = ((struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyMethodDef __pyx_methods_5neo4j_4bolt_3_io_ChunkedInputBuffer[] = { - {"capacity", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_5capacity, METH_NOARGS, 0}, - {"view", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_7view, METH_NOARGS, 0}, - {"load", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_9load, METH_O, __pyx_doc_5neo4j_4bolt_3_io_18ChunkedInputBuffer_8load}, - {"receive", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_11receive, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5neo4j_4bolt_3_io_18ChunkedInputBuffer_10receive}, - {"receive_message", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_13receive_message, METH_VARARGS|METH_KEYWORDS, __pyx_doc_5neo4j_4bolt_3_io_18ChunkedInputBuffer_12receive_message}, - {"frame", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_15frame, METH_NOARGS, 0}, - {"frame_message", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_17frame_message, METH_NOARGS, __pyx_doc_5neo4j_4bolt_3_io_18ChunkedInputBuffer_16frame_message}, - {"discard_message", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_19discard_message, METH_NOARGS, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_21__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_23__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_5neo4j_4bolt_3_io_ChunkedInputBuffer = { - PyVarObject_HEAD_INIT(0, 0) - "neo4j.bolt._io.ChunkedInputBuffer", /*tp_name*/ - sizeof(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5neo4j_4bolt_3_io_ChunkedInputBuffer, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - __pyx_pw_5neo4j_4bolt_3_io_18ChunkedInputBuffer_3__repr__, /*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_5neo4j_4bolt_3_io_ChunkedInputBuffer, /*tp_traverse*/ - __pyx_tp_clear_5neo4j_4bolt_3_io_ChunkedInputBuffer, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_5neo4j_4bolt_3_io_ChunkedInputBuffer, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_5neo4j_4bolt_3_io_ChunkedInputBuffer, /*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 PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; -static struct __pyx_vtabstruct_5neo4j_4bolt_3_io_ChunkedOutputBuffer __pyx_vtable_5neo4j_4bolt_3_io_ChunkedOutputBuffer; - -static PyObject *__pyx_tp_new_5neo4j_4bolt_3_io_ChunkedOutputBuffer(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)o); - p->__pyx_vtab = __pyx_vtabptr_5neo4j_4bolt_3_io_ChunkedOutputBuffer; - p->_data = ((PyObject*)Py_None); Py_INCREF(Py_None); - if (unlikely(__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_1__cinit__(o, a, k) < 0)) goto bad; - return o; - bad: - Py_DECREF(o); o = 0; - return NULL; -} - -static void __pyx_tp_dealloc_5neo4j_4bolt_3_io_ChunkedOutputBuffer(PyObject *o) { - struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *p = (struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *)o; - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - Py_CLEAR(p->_data); - (*Py_TYPE(o)->tp_free)(o); -} - -static PyMethodDef __pyx_methods_5neo4j_4bolt_3_io_ChunkedOutputBuffer[] = { - {"max_chunk_size", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_3max_chunk_size, METH_NOARGS, 0}, - {"clear", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_5clear, METH_NOARGS, 0}, - {"write", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_7write, METH_O, 0}, - {"chunk", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_9chunk, METH_NOARGS, 0}, - {"view", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_11view, METH_NOARGS, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_13__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_15__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_5neo4j_4bolt_3_io_ChunkedOutputBuffer = { - PyVarObject_HEAD_INIT(0, 0) - "neo4j.bolt._io.ChunkedOutputBuffer", /*tp_name*/ - sizeof(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5neo4j_4bolt_3_io_ChunkedOutputBuffer, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 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_5neo4j_4bolt_3_io_ChunkedOutputBuffer, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_5neo4j_4bolt_3_io_ChunkedOutputBuffer, /*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 PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static PyMethodDef __pyx_methods[] = { - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -#if CYTHON_PEP489_MULTI_PHASE_INIT -static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec__io(PyObject* module); /*proto*/ -static PyModuleDef_Slot __pyx_moduledef_slots[] = { - {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec__io}, - {0, NULL} -}; -#endif - -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - "_io", - 0, /* m_doc */ - #if CYTHON_PEP489_MULTI_PHASE_INIT - 0, /* m_size */ - #else - -1, /* m_size */ - #endif - __pyx_methods /* m_methods */, - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_moduledef_slots, /* m_slots */ - #else - NULL, /* m_reload */ - #endif - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 0}, - {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_kp_b__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 0, 0}, - {&__pyx_kp_b__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 0, 0, 0}, - {&__pyx_n_s_capacity, __pyx_k_capacity, sizeof(__pyx_k_capacity), 0, 0, 1, 1}, - {&__pyx_n_s_chunk, __pyx_k_chunk, sizeof(__pyx_k_chunk), 0, 0, 1, 1}, - {&__pyx_n_s_clear, __pyx_k_clear, sizeof(__pyx_k_clear), 0, 0, 1, 1}, - {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1}, - {&__pyx_n_s_discard_message, __pyx_k_discard_message, sizeof(__pyx_k_discard_message), 0, 0, 1, 1}, - {&__pyx_n_s_extend, __pyx_k_extend, sizeof(__pyx_k_extend), 0, 0, 1, 1}, - {&__pyx_n_s_frame, __pyx_k_frame, sizeof(__pyx_k_frame), 0, 0, 1, 1}, - {&__pyx_n_s_frame_message, __pyx_k_frame_message, sizeof(__pyx_k_frame_message), 0, 0, 1, 1}, - {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_load, __pyx_k_load, sizeof(__pyx_k_load), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_max_chunk_size, __pyx_k_max_chunk_size, sizeof(__pyx_k_max_chunk_size), 0, 0, 1, 1}, - {&__pyx_n_s_memoryview, __pyx_k_memoryview, sizeof(__pyx_k_memoryview), 0, 0, 1, 1}, - {&__pyx_n_s_memoryview_at, __pyx_k_memoryview_at, sizeof(__pyx_k_memoryview_at), 0, 0, 1, 1}, - {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_neo4j_compat, __pyx_k_neo4j_compat, sizeof(__pyx_k_neo4j_compat), 0, 0, 1, 1}, - {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, - {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, - {&__pyx_n_s_panes, __pyx_k_panes, sizeof(__pyx_k_panes), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, - {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1}, - {&__pyx_n_s_read_int, __pyx_k_read_int, sizeof(__pyx_k_read_int), 0, 0, 1, 1}, - {&__pyx_n_s_receive, __pyx_k_receive, sizeof(__pyx_k_receive), 0, 0, 1, 1}, - {&__pyx_n_s_receive_message, __pyx_k_receive_message, sizeof(__pyx_k_receive_message), 0, 0, 1, 1}, - {&__pyx_n_s_recv, __pyx_k_recv, sizeof(__pyx_k_recv), 0, 0, 1, 1}, - {&__pyx_n_s_recv_into, __pyx_k_recv_into, sizeof(__pyx_k_recv_into), 0, 0, 1, 1}, - {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, - {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, - {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, - {&__pyx_n_s_socket, __pyx_k_socket, sizeof(__pyx_k_socket), 0, 0, 1, 1}, - {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, - {&__pyx_n_s_struct_pack, __pyx_k_struct_pack, sizeof(__pyx_k_struct_pack), 0, 0, 1, 1}, - {&__pyx_n_s_struct_unpack, __pyx_k_struct_unpack, sizeof(__pyx_k_struct_unpack), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_tobytes, __pyx_k_tobytes, sizeof(__pyx_k_tobytes), 0, 0, 1, 1}, - {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1}, - {&__pyx_n_s_view, __pyx_k_view, sizeof(__pyx_k_view), 0, 0, 1, 1}, - {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_memoryview = __Pyx_GetBuiltinName(__pyx_n_s_memoryview); if (!__pyx_builtin_memoryview) __PYX_ERR(0, 27, __pyx_L1_error) - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple_)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__7); - __Pyx_GIVEREF(__pyx_tuple__7); - - /* "neo4j/bolt/_io.pyx":27 - * - * - * cdef _empty_view = memoryview(b"") # <<<<<<<<<<<<<< - * - * - */ - __pyx_tuple__9 = PyTuple_Pack(1, __pyx_kp_b__8); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__9); - __Pyx_GIVEREF(__pyx_tuple__9); - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_524288 = PyInt_FromLong(524288L); if (unlikely(!__pyx_int_524288)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_neg_1 = PyInt_FromLong(-1); if (unlikely(!__pyx_int_neg_1)) __PYX_ERR(0, 1, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC init_io(void); /*proto*/ -PyMODINIT_FUNC init_io(void) -#else -PyMODINIT_FUNC PyInit__io(void); /*proto*/ -PyMODINIT_FUNC PyInit__io(void) -#if CYTHON_PEP489_MULTI_PHASE_INIT -{ - return PyModuleDef_Init(&__pyx_moduledef); -} -static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { - PyObject *value = PyObject_GetAttrString(spec, from_name); - int result = 0; - if (likely(value)) { - result = PyDict_SetItemString(moddict, to_name, value); - Py_DECREF(value); - } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - result = -1; - } - return result; -} -static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { - PyObject *module = NULL, *moddict, *modname; - 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__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; - return module; -bad: - Py_XDECREF(module); - return NULL; -} - - -static int __pyx_pymod_exec__io(PyObject *__pyx_pyinit_module) -#endif -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannyDeclarations - #if CYTHON_PEP489_MULTI_PHASE_INIT - if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; - #endif - #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("PyMODINIT_FUNC PyInit__io(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_AsyncGen_USED - if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ - PyEval_InitThreads(); - #endif - #endif - /*--- Module creation code ---*/ - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_m = __pyx_pyinit_module; - Py_INCREF(__pyx_m); - #else - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("_io", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - #if CYTHON_COMPILING_IN_PYPY - Py_INCREF(__pyx_b); - #endif - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_neo4j__bolt___io) { - if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "neo4j.bolt._io")) { - if (unlikely(PyDict_SetItemString(modules, "neo4j.bolt._io", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global init code ---*/ - __pyx_v_5neo4j_4bolt_3_io__empty_view = Py_None; Py_INCREF(Py_None); - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - __pyx_vtabptr_5neo4j_4bolt_3_io_MessageFrame = &__pyx_vtable_5neo4j_4bolt_3_io_MessageFrame; - __pyx_vtable_5neo4j_4bolt_3_io_MessageFrame._next_pane = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *))__pyx_f_5neo4j_4bolt_3_io_12MessageFrame__next_pane; - __pyx_vtable_5neo4j_4bolt_3_io_MessageFrame.panes = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_panes; - __pyx_vtable_5neo4j_4bolt_3_io_MessageFrame.read_int = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_read_int; - __pyx_vtable_5neo4j_4bolt_3_io_MessageFrame.read = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *, int, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_read; - __pyx_vtable_5neo4j_4bolt_3_io_MessageFrame.close = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_MessageFrame *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_12MessageFrame_close; - if (PyType_Ready(&__pyx_type_5neo4j_4bolt_3_io_MessageFrame) < 0) __PYX_ERR(0, 30, __pyx_L1_error) - __pyx_type_5neo4j_4bolt_3_io_MessageFrame.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_5neo4j_4bolt_3_io_MessageFrame.tp_dict, __pyx_vtabptr_5neo4j_4bolt_3_io_MessageFrame) < 0) __PYX_ERR(0, 30, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "MessageFrame", (PyObject *)&__pyx_type_5neo4j_4bolt_3_io_MessageFrame) < 0) __PYX_ERR(0, 30, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5neo4j_4bolt_3_io_MessageFrame) < 0) __PYX_ERR(0, 30, __pyx_L1_error) - __pyx_ptype_5neo4j_4bolt_3_io_MessageFrame = &__pyx_type_5neo4j_4bolt_3_io_MessageFrame; - __pyx_vtabptr_5neo4j_4bolt_3_io_ChunkedInputBuffer = &__pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer.capacity = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_capacity; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer.view = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_view; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer.load = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, PyObject *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_load; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer.receive = (int (*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, PyObject *, int, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_receive; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer.receive_message = (int (*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, PyObject *, int, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_receive_message; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer._recycle = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *))__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer__recycle; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer.frame = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_frame; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer.frame_message = (int (*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_frame_message; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedInputBuffer.discard_message = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedInputBuffer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_18ChunkedInputBuffer_discard_message; - if (PyType_Ready(&__pyx_type_5neo4j_4bolt_3_io_ChunkedInputBuffer) < 0) __PYX_ERR(0, 108, __pyx_L1_error) - __pyx_type_5neo4j_4bolt_3_io_ChunkedInputBuffer.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_5neo4j_4bolt_3_io_ChunkedInputBuffer.tp_dict, __pyx_vtabptr_5neo4j_4bolt_3_io_ChunkedInputBuffer) < 0) __PYX_ERR(0, 108, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "ChunkedInputBuffer", (PyObject *)&__pyx_type_5neo4j_4bolt_3_io_ChunkedInputBuffer) < 0) __PYX_ERR(0, 108, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5neo4j_4bolt_3_io_ChunkedInputBuffer) < 0) __PYX_ERR(0, 108, __pyx_L1_error) - __pyx_ptype_5neo4j_4bolt_3_io_ChunkedInputBuffer = &__pyx_type_5neo4j_4bolt_3_io_ChunkedInputBuffer; - __pyx_vtabptr_5neo4j_4bolt_3_io_ChunkedOutputBuffer = &__pyx_vtable_5neo4j_4bolt_3_io_ChunkedOutputBuffer; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedOutputBuffer.max_chunk_size = (int (*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_max_chunk_size; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedOutputBuffer.clear = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_clear; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedOutputBuffer.write = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, PyObject *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_write; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedOutputBuffer.chunk = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_chunk; - __pyx_vtable_5neo4j_4bolt_3_io_ChunkedOutputBuffer.view = (PyObject *(*)(struct __pyx_obj_5neo4j_4bolt_3_io_ChunkedOutputBuffer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_4bolt_3_io_19ChunkedOutputBuffer_view; - if (PyType_Ready(&__pyx_type_5neo4j_4bolt_3_io_ChunkedOutputBuffer) < 0) __PYX_ERR(0, 257, __pyx_L1_error) - __pyx_type_5neo4j_4bolt_3_io_ChunkedOutputBuffer.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_5neo4j_4bolt_3_io_ChunkedOutputBuffer.tp_dict, __pyx_vtabptr_5neo4j_4bolt_3_io_ChunkedOutputBuffer) < 0) __PYX_ERR(0, 257, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "ChunkedOutputBuffer", (PyObject *)&__pyx_type_5neo4j_4bolt_3_io_ChunkedOutputBuffer) < 0) __PYX_ERR(0, 257, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5neo4j_4bolt_3_io_ChunkedOutputBuffer) < 0) __PYX_ERR(0, 257, __pyx_L1_error) - __pyx_ptype_5neo4j_4bolt_3_io_ChunkedOutputBuffer = &__pyx_type_5neo4j_4bolt_3_io_ChunkedOutputBuffer; - /*--- Type import code ---*/ - /*--- Variable import code ---*/ - /*--- Function import code ---*/ - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "neo4j/bolt/_io.pyx":22 - * - * - * from struct import pack as struct_pack, unpack as struct_unpack # <<<<<<<<<<<<<< - * - * from neo4j.compat import memoryview_at - */ - __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_pack); - __Pyx_GIVEREF(__pyx_n_s_pack); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pack); - __Pyx_INCREF(__pyx_n_s_unpack); - __Pyx_GIVEREF(__pyx_n_s_unpack); - PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_unpack); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_struct, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_struct_pack, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_unpack); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_struct_unpack, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/bolt/_io.pyx":24 - * from struct import pack as struct_pack, unpack as struct_unpack - * - * from neo4j.compat import memoryview_at # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_memoryview_at); - __Pyx_GIVEREF(__pyx_n_s_memoryview_at); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_memoryview_at); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_neo4j_compat, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_memoryview_at); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_memoryview_at, __pyx_t_2) < 0) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":27 - * - * - * cdef _empty_view = memoryview(b"") # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_memoryview, __pyx_tuple__9, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_XGOTREF(__pyx_v_5neo4j_4bolt_3_io__empty_view); - __Pyx_DECREF_SET(__pyx_v_5neo4j_4bolt_3_io__empty_view, __pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __pyx_t_1 = 0; - - /* "neo4j/bolt/_io.pyx":1 - * #!/usr/bin/env python # <<<<<<<<<<<<<< - * # -*- encoding: utf-8 -*- - * - */ - __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init neo4j.bolt._io", 0, __pyx_lineno, __pyx_filename); - } - Py_DECREF(__pyx_m); __pyx_m = 0; - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init neo4j.bolt._io"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if CYTHON_PEP489_MULTI_PHASE_INIT - return (__pyx_m != NULL) ? 0 : -1; - #elif PY_MAJOR_VERSION >= 3 - return __pyx_m; - #else - return; - #endif -} - -/* --- 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((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* 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); -} - -/* RaiseDoubleKeywords */ -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ -static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - 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; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* ArgTypeTest */ -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - else if (exact) { - #if PY_MAJOR_VERSION == 2 - if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} - -/* PyCFunctionFastCall */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); - } -} -#endif - -/* PyFunctionFastCall */ -#if CYTHON_FAST_PYCALL -#include "frameobject.h" -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = f->f_localsplus; - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCall */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = func->ob_type->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" 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 = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" 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 - -/* PyObjectCallOneArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* PyObjectCallNoArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, NULL, 0); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); - } - } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* GetItemInt */ - static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!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, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if 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((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); -} - -/* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { - PyErr_Format(PyExc_ValueError, - "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", - index, (index == 1) ? "" : "s"); -} - -/* IterFinish */ - static CYTHON_INLINE int __Pyx_IterFinish(void) { -#if CYTHON_FAST_THREAD_STATE - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* exc_type = tstate->curexc_type; - if (unlikely(exc_type)) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { - PyObject *exc_value, *exc_tb; - exc_value = tstate->curexc_value; - exc_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; - Py_DECREF(exc_type); - Py_XDECREF(exc_value); - Py_XDECREF(exc_tb); - return 0; - } else { - return -1; - } - } - return 0; -#else - if (unlikely(PyErr_Occurred())) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { - PyErr_Clear(); - return 0; - } else { - return -1; - } - } - return 0; -#endif -} - -/* UnpackItemEndCheck */ - static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { - if (unlikely(retval)) { - Py_DECREF(retval); - __Pyx_RaiseTooManyValuesError(expected); - return -1; - } else { - return __Pyx_IterFinish(); - } - return 0; -} - -/* GetModuleGlobalName */ - static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS - result = PyDict_GetItem(__pyx_d, name); - if (likely(result)) { - Py_INCREF(result); - } else { -#else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); - } - return result; -} - -/* SliceObject */ - static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj, - Py_ssize_t cstart, Py_ssize_t cstop, - PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, - int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { -#if CYTHON_USE_TYPE_SLOTS - PyMappingMethods* mp; -#if PY_MAJOR_VERSION < 3 - PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; - if (likely(ms && ms->sq_slice)) { - if (!has_cstart) { - if (_py_start && (*_py_start != Py_None)) { - cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); - if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; - } else - cstart = 0; - } - if (!has_cstop) { - if (_py_stop && (*_py_stop != Py_None)) { - cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); - if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; - } else - cstop = PY_SSIZE_T_MAX; - } - if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { - Py_ssize_t l = ms->sq_length(obj); - if (likely(l >= 0)) { - if (cstop < 0) { - cstop += l; - if (cstop < 0) cstop = 0; - } - if (cstart < 0) { - cstart += l; - if (cstart < 0) cstart = 0; - } - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - goto bad; - PyErr_Clear(); - } - } - return ms->sq_slice(obj, cstart, cstop); - } -#endif - mp = Py_TYPE(obj)->tp_as_mapping; - if (likely(mp && mp->mp_subscript)) -#endif - { - PyObject* result; - PyObject *py_slice, *py_start, *py_stop; - if (_py_slice) { - py_slice = *_py_slice; - } else { - PyObject* owned_start = NULL; - PyObject* owned_stop = NULL; - if (_py_start) { - py_start = *_py_start; - } else { - if (has_cstart) { - owned_start = py_start = PyInt_FromSsize_t(cstart); - if (unlikely(!py_start)) goto bad; - } else - py_start = Py_None; - } - if (_py_stop) { - py_stop = *_py_stop; - } else { - if (has_cstop) { - owned_stop = py_stop = PyInt_FromSsize_t(cstop); - if (unlikely(!py_stop)) { - Py_XDECREF(owned_start); - goto bad; - } - } else - py_stop = Py_None; - } - py_slice = PySlice_New(py_start, py_stop, Py_None); - Py_XDECREF(owned_start); - Py_XDECREF(owned_stop); - if (unlikely(!py_slice)) goto bad; - } -#if CYTHON_USE_TYPE_SLOTS - result = mp->mp_subscript(obj, py_slice); -#else - result = PyObject_GetItem(obj, py_slice); -#endif - if (!_py_slice) { - Py_DECREF(py_slice); - } - return result; - } - PyErr_Format(PyExc_TypeError, - "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name); -bad: - return NULL; -} - -/* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - 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); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *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 - -/* RaiseException */ - #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -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 CYTHON_COMPILING_IN_PYPY - 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); -#else - 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); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* SliceObject */ - static CYTHON_INLINE int __Pyx_PyObject_SetSlice(PyObject* obj, PyObject* value, - Py_ssize_t cstart, Py_ssize_t cstop, - PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice, - int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) { -#if CYTHON_USE_TYPE_SLOTS - PyMappingMethods* mp; -#if PY_MAJOR_VERSION < 3 - PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence; - if (likely(ms && ms->sq_ass_slice)) { - if (!has_cstart) { - if (_py_start && (*_py_start != Py_None)) { - cstart = __Pyx_PyIndex_AsSsize_t(*_py_start); - if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; - } else - cstart = 0; - } - if (!has_cstop) { - if (_py_stop && (*_py_stop != Py_None)) { - cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop); - if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad; - } else - cstop = PY_SSIZE_T_MAX; - } - if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) { - Py_ssize_t l = ms->sq_length(obj); - if (likely(l >= 0)) { - if (cstop < 0) { - cstop += l; - if (cstop < 0) cstop = 0; - } - if (cstart < 0) { - cstart += l; - if (cstart < 0) cstart = 0; - } - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - goto bad; - PyErr_Clear(); - } - } - return ms->sq_ass_slice(obj, cstart, cstop, value); - } -#endif - mp = Py_TYPE(obj)->tp_as_mapping; - if (likely(mp && mp->mp_ass_subscript)) -#endif - { - int result; - PyObject *py_slice, *py_start, *py_stop; - if (_py_slice) { - py_slice = *_py_slice; - } else { - PyObject* owned_start = NULL; - PyObject* owned_stop = NULL; - if (_py_start) { - py_start = *_py_start; - } else { - if (has_cstart) { - owned_start = py_start = PyInt_FromSsize_t(cstart); - if (unlikely(!py_start)) goto bad; - } else - py_start = Py_None; - } - if (_py_stop) { - py_stop = *_py_stop; - } else { - if (has_cstop) { - owned_stop = py_stop = PyInt_FromSsize_t(cstop); - if (unlikely(!py_stop)) { - Py_XDECREF(owned_start); - goto bad; - } - } else - py_stop = Py_None; - } - py_slice = PySlice_New(py_start, py_stop, Py_None); - Py_XDECREF(owned_start); - Py_XDECREF(owned_stop); - if (unlikely(!py_slice)) goto bad; - } -#if CYTHON_USE_TYPE_SLOTS - result = mp->mp_ass_subscript(obj, py_slice, value); -#else - result = value ? PyObject_SetItem(obj, py_slice, value) : PyObject_DelItem(obj, py_slice); -#endif - if (!_py_slice) { - Py_DECREF(py_slice); - } - return result; - } - PyErr_Format(PyExc_TypeError, - "'%.200s' object does not support slice %.10s", - Py_TYPE(obj)->tp_name, value ? "assignment" : "deletion"); -bad: - return -1; -} - -/* WriteUnraisableException */ - static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, - int full_traceback, CYTHON_UNUSED int nogil) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_PyThreadState_declare -#ifdef WITH_THREAD - PyGILState_STATE state; - if (nogil) - state = PyGILState_Ensure(); -#ifdef _MSC_VER - else state = (PyGILState_STATE)-1; -#endif -#endif - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - if (full_traceback) { - Py_XINCREF(old_exc); - Py_XINCREF(old_val); - Py_XINCREF(old_tb); - __Pyx_ErrRestore(old_exc, old_val, old_tb); - PyErr_PrintEx(1); - } - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -#ifdef WITH_THREAD - if (nogil) - PyGILState_Release(state); -#endif -} - -/* SetVTable */ - static int __Pyx_SetVtable(PyObject *dict, void *vtable) { -#if PY_VERSION_HEX >= 0x02070000 - PyObject *ob = PyCapsule_New(vtable, 0, 0); -#else - PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); -#endif - if (!ob) - goto bad; - if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) - goto bad; - Py_DECREF(ob); - return 0; -bad: - Py_XDECREF(ob); - return -1; -} - -/* SetupReduce */ - static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { - int ret; - PyObject *name_attr; - name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_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_reduce_ex = NULL; - PyObject *reduce = NULL; - PyObject *reduce_ex = NULL; - PyObject *reduce_cython = NULL; - PyObject *setstate = NULL; - PyObject *setstate_cython = NULL; -#if CYTHON_USE_PYTYPE_LOOKUP - if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; -#else - if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; -#endif -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; -#else - object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; -#endif - reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; - if (reduce_ex == object_reduce_ex) { -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; -#else - object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; -#endif - reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; - if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; - setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); - if (!setstate) PyErr_Clear(); - if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; - } - PyType_Modified((PyTypeObject*)type_obj); - } - } - goto GOOD; -BAD: - if (!PyErr_Occurred()) - PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); - ret = -1; -GOOD: -#if !CYTHON_USE_PYTYPE_LOOKUP - Py_XDECREF(object_reduce); - Py_XDECREF(object_reduce_ex); -#endif - Py_XDECREF(reduce); - Py_XDECREF(reduce_ex); - Py_XDECREF(reduce_cython); - Py_XDECREF(setstate); - Py_XDECREF(setstate_cython); - return ret; -} - -/* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_MAJOR_VERSION < 3 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if (strchr(__Pyx_MODULE_NAME, '.')) { - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_MAJOR_VERSION < 3 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_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)) { - PyErr_Format(PyExc_ImportError, - #if PY_MAJOR_VERSION < 3 - "cannot import name %.230s", PyString_AS_STRING(name)); - #else - "cannot import name %S", name); - #endif - } - return value; -} - -/* CLineInTraceback */ - #ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { - PyObject *use_cline; - PyObject *ptype, *pvalue, *ptraceback; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict; -#endif - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); -#if CYTHON_COMPILING_IN_CPYTHON - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (likely(cython_runtime_dict)) { - use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); - } else -#endif - { - PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); - if (use_cline_obj) { - use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; - Py_DECREF(use_cline_obj); - } else { - PyErr_Clear(); - use_cline = NULL; - } - } - if (!use_cline) { - c_line = 0; - PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); - } - else if (PyObject_Not(use_cline) != 0) { - c_line = 0; - } - __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 PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_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(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - 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; - 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) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); - } - py_frame = PyFrame_New( - tstate, /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __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); -} - -/* 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;\ - } - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - 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 - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - 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; -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } 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 PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - 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 - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - 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; -} - -/* FastTypeChecks */ - #if CYTHON_COMPILING_IN_CPYTHON -static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { - while (a) { - a = a->tp_base; - 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); -} -#if PY_MAJOR_VERSION == 2 -static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { - PyObject *exception, *value, *tb; - int res; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&exception, &value, &tb); - res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - if (!res) { - res = PyObject_IsSubclass(err, exc_type2); - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - } - __Pyx_ErrRestore(exception, value, tb); - return res; -} -#else -static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { - int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; - if (!res) { - res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); - } - return res; -} -#endif -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { - if (likely(err == exc_type)) return 1; - if (likely(PyExceptionClass_Check(err))) { - return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); - } - return PyErr_GivenExceptionMatches(err, exc_type); -} -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { - if (likely(err == exc_type1 || err == exc_type2)) return 1; - if (likely(PyExceptionClass_Check(err))) { - return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); - } - return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); -} -#endif - -/* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { - char ctversion[4], rtversion[4]; - PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); - if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { - char message[200]; - PyOS_snprintf(message, sizeof(message), - "compiletime version %s of module '%.100s' " - "does not match runtime version %s", - ctversion, __Pyx_MODULE_NAME, rtversion); - return PyErr_WarnEx(NULL, message, 1); - } - return 0; -} - -/* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - if (PyObject_Hash(*t->p) == -1) - PyErr_Clear(); - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -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_DEFAULT -#if !CYTHON_PEP393_ENABLED -static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -} -#else -static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; -#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_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { - return __Pyx_PyUnicode_AsStringAndSize(o, length); - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - 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 PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { -#if PY_MAJOR_VERSION >= 3 - if (PyLong_Check(result)) { - if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, - "__int__ returned non-int (type %.200s). " - "The ability to return an instance of a strict subclass of int " - "is deprecated, and may be removed in a future version of Python.", - Py_TYPE(result)->tp_name)) { - Py_DECREF(result); - return NULL; - } - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - type_name, type_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x) || PyLong_Check(x))) -#else - if (likely(PyLong_Check(x))) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = m->nb_int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = m->nb_long(x); - } - #else - if (likely(m && m->nb_int)) { - name = "int"; - res = m->nb_int(x); - } - #endif -#else - if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { - res = PyNumber_Int(x); - } -#endif - if (likely(res)) { -#if PY_MAJOR_VERSION < 3 - if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { -#else - if (unlikely(!PyLong_CheckExact(res))) { -#endif - return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); - } - } - 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 PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(x); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - 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 = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/neo4j/bolt/_io.pyx b/neo4j/bolt/_io.pyx deleted file mode 100644 index 21e119e5b..000000000 --- a/neo4j/bolt/_io.pyx +++ /dev/null @@ -1,322 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from struct import pack as struct_pack, unpack as struct_unpack - -from neo4j.compat import memoryview_at - - -cdef _empty_view = memoryview(b"") - - -cdef class MessageFrame(object): - - cdef _view - cdef list _panes - cdef int _current_pane - cdef int _current_offset - - def __cinit__(self, view, list panes): - self._view = view - self._panes = panes - if panes: - self._current_pane = 0 - self._current_offset = 0 - else: - self._current_pane = -1 - self._current_offset = -1 - - cdef _next_pane(self): - self._current_pane += 1 - if self._current_pane < len(self._panes): - self._current_offset = 0 - else: - self._current_pane = -1 - self._current_offset = -1 - - cpdef panes(self): - return self._panes - - cpdef read_int(self): - cdef int p - cdef int q - cdef int size - cdef int value - - if self._current_pane == -1: - return -1 - p, q = self._panes[self._current_pane] - size = q - p - value = memoryview_at(self._view, p + self._current_offset) - self._current_offset += 1 - if self._current_offset == size: - self._next_pane() - return value - - cpdef read(self, int n): - cdef int p - cdef int q - cdef int size - cdef int start - cdef int end - cdef int remaining - cdef bytearray value - - if n == 0 or self._current_pane == -1: - return _empty_view - p, q = self._panes[self._current_pane] - size = q - p - remaining = size - self._current_offset - if n <= remaining: - start = p + self._current_offset - end = start + n - if n < remaining: - self._current_offset += n - else: - self._next_pane() - return memoryview(self._view[start:end]) - start = p + self._current_offset - end = q - value = bytearray(self._view[start:end]) - self._next_pane() - if len(value) < n and self._current_pane >= 0: - value.extend(self.read(n - (end - start))) - return value - - cpdef close(self): - self._view = None - - -cdef class ChunkedInputBuffer(object): - - cdef bytearray _data - cdef _view - cdef int _extent - cdef int _origin - cdef int _limit - cdef MessageFrame _frame - - def __cinit__(self, capacity=524288): - self._data = bytearray(capacity) - self._view = memoryview(self._data) - self._extent = 0 # end position of all loaded data - self._origin = 0 # start position of current frame - self._limit = -1 # end position of current frame - self._frame = None # frame object - - def __repr__(self): - return repr(self.view().tobytes()) - - cpdef capacity(self): - return len(self._view) - - cpdef view(self): - return memoryview(self._view[:self._extent]) - - cpdef load(self, b): - """ - - Note: may modify buffer size - """ - n = len(b) - new_extent = self._extent + n - overflow = new_extent - len(self._data) - if overflow > 0: - if self._recycle(): - return self.load(b) - self._view = None - new_extent = self._extent + n - self._data[self._extent:new_extent] = b - self._view = memoryview(self._data) - else: - self._view[self._extent:new_extent] = b - self._extent = new_extent - - cpdef int receive(self, socket, int n): - """ - - Note: may modify buffer size, should error if frame exists - """ - cdef int new_extent - cdef int overflow - cdef bytes data - cdef int data_size - - new_extent = self._extent + n - overflow = new_extent - len(self._data) - if overflow > 0: - if self._recycle(): - return self.receive(socket, n) - self._view = None - data = socket.recv(n) - data_size = len(data) - new_extent = self._extent + data_size - self._data[self._extent:new_extent] = data - self._view = memoryview(self._data) - else: - data_size = socket.recv_into(self._view[self._extent:new_extent]) - new_extent = self._extent + data_size - self._extent = new_extent - return data_size - - cpdef bint receive_message(self, socket, int n): - """ - - :param socket: - :param n: - :return: - """ - cdef int received - - frame_message = self.frame_message - receive = self.receive - while not frame_message(): - received = receive(socket, n) - if received == 0: - return False - return True - - cdef _recycle(self): - """ Reclaim buffer space before the origin. - - Note: modifies buffer size - """ - cdef int origin - cdef int available - - origin = self._origin - if origin == 0: - return False - available = self._extent - origin - self._data[:available] = self._data[origin:self._extent] - self._extent = available - self._origin = 0 - #log_debug("Recycled %d bytes" % origin) - return True - - cpdef frame(self): - return self._frame - - cpdef bint frame_message(self): - """ Construct a frame around the first complete message in the buffer. - """ - cdef list panes - cdef int origin - cdef int p - cdef int extent - cdef int available - cdef int chunk_size - cdef int q - - if self._frame is not None: - self.discard_message() - panes = [] - p = origin = self._origin - extent = self._extent - while p < extent: - available = extent - p - if available < 2: - break - chunk_size, = struct_unpack(">H", self._view[p:(p + 2)]) - p += 2 - if chunk_size == 0: - self._limit = p - self._frame = MessageFrame(memoryview(self._view[origin:self._limit]), panes) - return True - q = p + chunk_size - panes.append((p - origin, q - origin)) - p = q - return False - - cpdef discard_message(self): - if self._frame is not None: - self._frame.close() - self._origin = self._limit - self._limit = -1 - self._frame = None - - -cdef class ChunkedOutputBuffer(object): - - cdef int _max_chunk_size - cdef bytearray _data - cdef int _header - cdef int _start - cdef int _end - - def __cinit__(self, int capacity=1048576, int max_chunk_size=16384): - self._max_chunk_size = max_chunk_size - self._header = 0 - self._start = 2 - self._end = 2 - self._data = bytearray(capacity) - - cpdef int max_chunk_size(self): - return self._max_chunk_size - - cpdef clear(self): - self._header = 0 - self._start = 2 - self._end = 2 - self._data[0:2] = b"\x00\x00" - - cpdef write(self, bytes b): - cdef bytearray data - cdef int new_data_size - cdef int chunk_size - cdef int chunk_remaining - cdef int new_end - cdef int new_chunk_size - - data = self._data - new_data_size = len(b) - chunk_size = self._end - self._start - max_chunk_size = self._max_chunk_size - chunk_remaining = max_chunk_size - chunk_size - if new_data_size > max_chunk_size: - self.write(b[:chunk_remaining]) - self.chunk() - self.write(b[chunk_remaining:]) - return - if new_data_size > chunk_remaining: - self.chunk() - new_end = self._end + new_data_size - new_chunk_size = new_end - self._start - data[self._end:new_end] = b - self._end = new_end - data[self._header:(self._header + 2)] = struct_pack(">H", new_chunk_size) - - cpdef chunk(self): - self._header = self._end - self._start = self._header + 2 - self._end = self._start - self._data[self._header:self._start] = b"\x00\x00" - - cpdef view(self): - cdef int end - cdef int chunk_size - - end = self._end - chunk_size = end - self._start - if chunk_size == 0: - return memoryview(self._data[:self._header]) - else: - return memoryview(self._data[:end]) \ No newline at end of file diff --git a/neo4j/bolt/cert.py b/neo4j/bolt/cert.py deleted file mode 100644 index f1ce8f81a..000000000 --- a/neo4j/bolt/cert.py +++ /dev/null @@ -1,74 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from genericpath import isfile -from base64 import b64encode -from os import makedirs, open as os_open, write as os_write, close as os_close, O_CREAT, O_APPEND, O_WRONLY -from os.path import dirname, join as path_join, expanduser - - -KNOWN_HOSTS = path_join(expanduser("~"), ".neo4j", "known_hosts") - - -class CertificateStore(object): - - def match_or_trust(self, host, der_encoded_certificate): - """ Check whether the supplied certificate matches that stored for the - specified host. If it does, return ``True``, if it doesn't, return - ``False``. If no entry for that host is found, add it to the store - and return ``True``. - - :arg host: - :arg der_encoded_certificate: - :return: - """ - raise NotImplementedError() - - -class PersonalCertificateStore(CertificateStore): - - def __init__(self, path=None): - self.path = path or KNOWN_HOSTS - - def match_or_trust(self, host, der_encoded_certificate): - base64_encoded_certificate = b64encode(der_encoded_certificate) - if isfile(self.path): - with open(self.path) as f_in: - for line in f_in: - known_host, _, known_cert = line.strip().partition(":") - known_cert = known_cert.encode("utf-8") - if host == known_host: - return base64_encoded_certificate == known_cert - # First use (no hosts match) - try: - makedirs(dirname(self.path)) - except OSError: - pass - f_out = os_open(self.path, O_CREAT | O_APPEND | O_WRONLY, 0o600) # TODO: Windows - if isinstance(host, bytes): - os_write(f_out, host) - else: - os_write(f_out, host.encode("utf-8")) - os_write(f_out, b":") - os_write(f_out, base64_encoded_certificate) - os_write(f_out, b"\n") - os_close(f_out) - return True diff --git a/neo4j/bolt/connection.py b/neo4j/bolt/connection.py deleted file mode 100644 index 4e41e88fe..000000000 --- a/neo4j/bolt/connection.py +++ /dev/null @@ -1,701 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -""" -This module contains the low-level functionality required for speaking -Bolt. It is not intended to be used directly by driver users. Instead, -the `session` module provides the main user-facing abstractions. -""" - -from __future__ import division - -import logging -from collections import deque -from select import select -from socket import socket, SOL_SOCKET, SO_KEEPALIVE, SHUT_RDWR, error as SocketError, timeout as SocketTimeout, AF_INET, AF_INET6 -from struct import pack as struct_pack, unpack as struct_unpack -from threading import RLock, Condition - -from neo4j.addressing import SocketAddress, Resolver -from neo4j.bolt.cert import KNOWN_HOSTS -from neo4j.bolt.response import InitResponse, ResetResponse -from neo4j.compat.ssl import SSL_AVAILABLE, HAS_SNI, SSLError -from neo4j.exceptions import ClientError, ProtocolError, SecurityError, ServiceUnavailable -from neo4j.packstream import Packer, Unpacker -from neo4j.util import import_best as _import_best -from neo4j.compat import perf_counter -from neo4j.config import default_config, INFINITE, TRUST_ON_FIRST_USE - -ChunkedInputBuffer = _import_best("neo4j.bolt._io", "neo4j.bolt.io").ChunkedInputBuffer -ChunkedOutputBuffer = _import_best("neo4j.bolt._io", "neo4j.bolt.io").ChunkedOutputBuffer - -DEFAULT_PORT = 7687 -MAGIC_PREAMBLE = 0x6060B017 - - -# Signature bytes for each message type -INIT = b"\x01" # 0000 0001 // INIT -RESET = b"\x0F" # 0000 1111 // RESET -RUN = b"\x10" # 0001 0000 // RUN -DISCARD_ALL = b"\x2F" # 0010 1111 // DISCARD * -PULL_ALL = b"\x3F" # 0011 1111 // PULL * -SUCCESS = b"\x70" # 0111 0000 // SUCCESS -RECORD = b"\x71" # 0111 0001 // RECORD -IGNORED = b"\x7E" # 0111 1110 // IGNORED -FAILURE = b"\x7F" # 0111 1111 // FAILURE - -DETAIL = {RECORD} -SUMMARY = {SUCCESS, IGNORED, FAILURE} - -# Set up logger -log = logging.getLogger("neo4j.bolt") -log_debug = log.debug -log_info = log.info -log_warning = log.warning -log_error = log.error - - -class ServerInfo(object): - - address = None - - version = None - - def __init__(self, address): - self.address = address - - def product(self): - if not self.version: - return None - value, _, _ = self.version.partition("/") - return value - - def version_info(self): - if not self.version: - return None - _, _, value = self.version.partition("/") - value = value.replace("-", ".").split(".") - for i, v in enumerate(value): - try: - value[i] = int(v) - except ValueError: - pass - return tuple(value) - - def supports_statement_reuse(self): - if not self.version: - return False - if self.product() != "Neo4j": - return False - return self.version_info() >= (3, 2) - - def supports_bytes(self): - if not self.version: - return False - if self.product() != "Neo4j": - return False - return self.version_info() >= (3, 2) - - -class ConnectionErrorHandler(object): - """ A handler for send and receive errors. - """ - - def __init__(self, handlers_by_error_class=None): - if handlers_by_error_class is None: - handlers_by_error_class = {} - - self.handlers_by_error_class = handlers_by_error_class - self.known_errors = tuple(handlers_by_error_class.keys()) - - def handle(self, error, address): - try: - error_class = error.__class__ - handler = self.handlers_by_error_class[error_class] - handler(address) - except KeyError: - pass - - -class Connection(object): - """ Server connection for Bolt protocol v1. - - A :class:`.Connection` should be constructed following a - successful Bolt handshake and takes the socket over which - the handshake was carried out. - - .. note:: logs at INFO level - """ - - #: The protocol version in use on this connection - protocol_version = 0 - - #: Server details for this connection - server = None - - in_use = False - - _closed = False - - _defunct = False - - #: The pool of which this connection is a member - pool = None - - #: Error class used for raising connection errors - Error = ServiceUnavailable - - _supports_statement_reuse = False - - _last_run_statement = None - - def __init__(self, address, sock, protocol_version, error_handler, **config): - self.address = address - self.socket = sock - self.protocol_version = protocol_version - self.error_handler = error_handler - self.server = ServerInfo(SocketAddress.from_socket(sock)) - self.input_buffer = ChunkedInputBuffer() - self.output_buffer = ChunkedOutputBuffer() - self.packer = Packer(self.output_buffer) - self.unpacker = Unpacker() - self.responses = deque() - self._max_connection_lifetime = config.get("max_connection_lifetime", default_config["max_connection_lifetime"]) - self._creation_timestamp = perf_counter() - - # Determine the user agent and ensure it is a Unicode value - user_agent = config.get("user_agent", default_config["user_agent"]) - if isinstance(user_agent, bytes): - user_agent = user_agent.decode("UTF-8") - self.user_agent = user_agent - - # Determine auth details - auth = config.get("auth") - if not auth: - self.auth_dict = {} - elif isinstance(auth, tuple) and 2 <= len(auth) <= 3: - from neo4j.v1 import basic_auth - self.auth_dict = vars(basic_auth(*auth)) - else: - try: - self.auth_dict = vars(auth) - except (KeyError, TypeError): - raise TypeError("Cannot determine auth details from %r" % auth) - - # Pick up the server certificate, if any - self.der_encoded_server_certificate = config.get("der_encoded_server_certificate") - - def init(self): - response = InitResponse(self) - self.append(INIT, (self.user_agent, self.auth_dict), response=response) - self.sync() - - self._supports_statement_reuse = self.server.supports_statement_reuse() - self.packer.supports_bytes = self.server.supports_bytes() - - def __del__(self): - try: - self.close() - except (AttributeError, TypeError): - pass - - def append(self, signature, fields=(), response=None): - """ Add a message to the outgoing queue. - - :arg signature: the signature of the message - :arg fields: the fields of the message as a tuple - :arg response: a response object to handle callbacks - """ - if signature == RUN: - if self._supports_statement_reuse: - statement = fields[0] - if statement.upper() not in ("BEGIN", "COMMIT", "ROLLBACK"): - if statement == self._last_run_statement: - fields = ("",) + fields[1:] - else: - self._last_run_statement = statement - log_debug("C: RUN %r", fields) - elif signature == PULL_ALL: - log_debug("C: PULL_ALL %r", fields) - elif signature == DISCARD_ALL: - log_debug("C: DISCARD_ALL %r", fields) - elif signature == RESET: - log_debug("C: RESET %r", fields) - elif signature == INIT: - log_debug("C: INIT (%r, {...})", fields[0]) - else: - raise ValueError("Unknown message signature") - self.packer.pack_struct(signature, fields) - self.output_buffer.chunk() - self.output_buffer.chunk() - self.responses.append(response) - - def reset(self): - """ Add a RESET message to the outgoing queue, send - it and consume all remaining messages. - """ - self.append(RESET, response=ResetResponse(self)) - self.sync() - - def send(self): - try: - self._send() - except self.error_handler.known_errors as error: - self.error_handler.handle(error, self.address) - raise error - - def _send(self): - """ Send all queued messages to the server. - """ - data = self.output_buffer.view() - if not data: - return - if self.closed(): - raise self.Error("Failed to write to closed connection {!r}".format(self.server.address)) - if self.defunct(): - raise self.Error("Failed to write to defunct connection {!r}".format(self.server.address)) - self.socket.sendall(data) - self.output_buffer.clear() - - def fetch(self): - try: - return self._fetch() - except self.error_handler.known_errors as error: - self.error_handler.handle(error, self.address) - raise error - - def _fetch(self): - """ Receive at least one message from the server, if available. - - :return: 2-tuple of number of detail messages and number of summary messages fetched - """ - if self.closed(): - raise self.Error("Failed to read from closed connection {!r}".format(self.server.address)) - if self.defunct(): - raise self.Error("Failed to read from defunct connection {!r}".format(self.server.address)) - if not self.responses: - return 0, 0 - - self._receive() - - details, summary_signature, summary_metadata = self._unpack() - - if details: - log_debug("S: RECORD * %d", len(details)) # TODO - self.responses[0].on_records(details) - - if summary_signature is None: - return len(details), 0 - - response = self.responses.popleft() - response.complete = True - if summary_signature == SUCCESS: - log_debug("S: SUCCESS (%r)", summary_metadata) - response.on_success(summary_metadata or {}) - elif summary_signature == IGNORED: - self._last_run_statement = None - log_debug("S: IGNORED (%r)", summary_metadata) - response.on_ignored(summary_metadata or {}) - elif summary_signature == FAILURE: - self._last_run_statement = None - log_debug("S: FAILURE (%r)", summary_metadata) - response.on_failure(summary_metadata or {}) - else: - self._last_run_statement = None - raise ProtocolError("Unexpected response message with signature %02X" % summary_signature) - - return len(details), 1 - - def _receive(self): - try: - received = self.input_buffer.receive_message(self.socket, 8192) - except SocketError: - received = False - if not received: - self._defunct = True - self.close() - raise self.Error("Failed to read from defunct connection {!r}".format(self.server.address)) - - def _unpack(self): - unpacker = self.unpacker - input_buffer = self.input_buffer - - details = [] - summary_signature = None - summary_metadata = None - more = True - while more: - unpacker.attach(input_buffer.frame()) - size, signature = unpacker.unpack_structure_header() - if size > 1: - raise ProtocolError("Expected one field") - if signature == RECORD: - data = unpacker.unpack_list() - details.append(data) - more = input_buffer.frame_message() - else: - summary_signature = signature - summary_metadata = unpacker.unpack_map() - more = False - return details, summary_signature, summary_metadata - - def timedout(self): - return 0 <= self._max_connection_lifetime <= perf_counter() - self._creation_timestamp - - def sync(self): - """ Send and fetch all outstanding messages. - - :return: 2-tuple of number of detail messages and number of summary messages fetched - """ - self.send() - detail_count = summary_count = 0 - while self.responses: - response = self.responses[0] - while not response.complete: - detail_delta, summary_delta = self.fetch() - detail_count += detail_delta - summary_count += summary_delta - return detail_count, summary_count - - def close(self): - """ Close the connection. - """ - if not self.closed(): - log_debug("~~ [CLOSE]") - self.socket.close() - self._closed = True - - def closed(self): - return self._closed - - def defunct(self): - return self._defunct - - -class ConnectionPool(object): - """ A collection of connections to one or more server addresses. - """ - - _closed = False - - def __init__(self, connector, connection_error_handler, **config): - self.connector = connector - self.connection_error_handler = connection_error_handler - self.connections = {} - self.lock = RLock() - self.cond = Condition(self.lock) - self._max_connection_pool_size = config.get("max_connection_pool_size", default_config["max_connection_pool_size"]) - self._connection_acquisition_timeout = config.get("connection_acquisition_timeout", default_config["connection_acquisition_timeout"]) - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - self.close() - - def acquire_direct(self, address): - """ Acquire a connection to a given address from the pool. - The address supplied should always be an IP address, not - a host name. - - This method is thread safe. - """ - if self.closed(): - raise ServiceUnavailable("Connection pool closed") - with self.lock: - try: - connections = self.connections[address] - except KeyError: - connections = self.connections[address] = deque() - - connection_acquisition_start_timestamp = perf_counter() - while True: - # try to find a free connection in pool - for connection in list(connections): - if connection.closed() or connection.defunct() or connection.timedout(): - connections.remove(connection) - continue - if not connection.in_use: - connection.in_use = True - return connection - # all connections in pool are in-use - can_create_new_connection = self._max_connection_pool_size == INFINITE or len(connections) < self._max_connection_pool_size - if can_create_new_connection: - try: - connection = self.connector(address, self.connection_error_handler) - except ServiceUnavailable: - self.remove(address) - raise - else: - connection.pool = self - connection.in_use = True - connections.append(connection) - return connection - - # failed to obtain a connection from pool because the pool is full and no free connection in the pool - span_timeout = self._connection_acquisition_timeout - (perf_counter() - connection_acquisition_start_timestamp) - if span_timeout > 0: - self.cond.wait(span_timeout) - # if timed out, then we throw error. This time computation is needed, as with python 2.7, we cannot - # tell if the condition is notified or timed out when we come to this line - if self._connection_acquisition_timeout <= (perf_counter() - connection_acquisition_start_timestamp): - raise ClientError("Failed to obtain a connection from pool within {!r}s".format( - self._connection_acquisition_timeout)) - else: - raise ClientError("Failed to obtain a connection from pool within {!r}s".format(self._connection_acquisition_timeout)) - - def acquire(self, access_mode=None): - """ Acquire a connection to a server that can satisfy a set of parameters. - - :param access_mode: - """ - - def release(self, connection): - """ Release a connection back into the pool. - This method is thread safe. - """ - with self.lock: - connection.in_use = False - self.cond.notify_all() - - def in_use_connection_count(self, address): - """ Count the number of connections currently in use to a given - address. - """ - try: - connections = self.connections[address] - except KeyError: - return 0 - else: - return sum(1 if connection.in_use else 0 for connection in connections) - - def deactivate(self, address): - """ Deactivate an address from the connection pool, if present, closing - all idle connection to that address - """ - with self.lock: - try: - connections = self.connections[address] - except KeyError: # already removed from the connection pool - return - for conn in list(connections): - if not conn.in_use: - connections.remove(conn) - try: - conn.close() - except IOError: - pass - if not connections: - self.remove(address) - - def remove(self, address): - """ Remove an address from the connection pool, if present, closing - all connections to that address. - """ - with self.lock: - for connection in self.connections.pop(address, ()): - try: - connection.close() - except IOError: - pass - - def close(self): - """ Close all connections and empty the pool. - This method is thread safe. - """ - if self._closed: - return - try: - with self.lock: - if not self._closed: - self._closed = True - for address in list(self.connections): - self.remove(address) - except TypeError as e: - pass - - def closed(self): - """ Return :const:`True` if this pool is closed, :const:`False` - otherwise. - """ - with self.lock: - return self._closed - - -def _force_close(s): - try: - s.close() - except: - pass - - -def _connect(resolved_address, **config): - """ - - :param resolved_address: - :param config: - :return: socket object - """ - s = None - try: - if len(resolved_address) == 2: - s = socket(AF_INET) - elif len(resolved_address) == 4: - s = socket(AF_INET6) - else: - raise ValueError("Unsupported address {!r}".format(resolved_address)) - t = s.gettimeout() - s.settimeout(config.get("connection_timeout", default_config["connection_timeout"])) - log_debug("~~ [CONNECT] %s", resolved_address) - s.connect(resolved_address) - s.settimeout(t) - s.setsockopt(SOL_SOCKET, SO_KEEPALIVE, 1 if config.get("keep_alive", default_config["keep_alive"]) else 0) - except SocketTimeout: - _force_close(s) - raise ServiceUnavailable("Timed out trying to establish connection to {!r}".format(resolved_address)) - except SocketError as error: - _force_close(s) - if error.errno in (61, 99, 111, 10061): - raise ServiceUnavailable("Failed to establish connection to {!r} (reason {})".format(resolved_address, error.errno)) - else: - raise - except ConnectionResetError: - raise ServiceUnavailable("Failed to establish connection to {!r}".format(resolved_address)) - else: - return s - - -def _secure(s, host, ssl_context, **config): - # Secure the connection if an SSL context has been provided - if ssl_context and SSL_AVAILABLE: - log_debug("~~ [SECURE] %s", host) - try: - s = ssl_context.wrap_socket(s, server_hostname=host if HAS_SNI and host else None) - except SSLError as cause: - _force_close(s) - error = SecurityError("Failed to establish secure connection to {!r}".format(cause.args[1])) - error.__cause__ = cause - raise error - else: - # Check that the server provides a certificate - der_encoded_server_certificate = s.getpeercert(binary_form=True) - if der_encoded_server_certificate is None: - _force_close(s) - raise ProtocolError("When using a secure socket, the server should always " - "provide a certificate") - trust = config.get("trust", default_config["trust"]) - if trust == TRUST_ON_FIRST_USE: - from neo4j.bolt.cert import PersonalCertificateStore - store = PersonalCertificateStore() - if not store.match_or_trust(host, der_encoded_server_certificate): - _force_close(s) - raise ProtocolError("Server certificate does not match known certificate " - "for %r; check details in file %r" % (host, KNOWN_HOSTS)) - else: - der_encoded_server_certificate = None - return s, der_encoded_server_certificate - - -def _handshake(s, resolved_address, der_encoded_server_certificate, error_handler, **config): - """ - - :param s: - :return: - """ - - # Send details of the protocol versions supported - supported_versions = [2, 1, 0, 0] - handshake = [MAGIC_PREAMBLE] + supported_versions - log_debug("C: [HANDSHAKE] 0x%X %r", MAGIC_PREAMBLE, supported_versions) - data = b"".join(struct_pack(">I", num) for num in handshake) - s.sendall(data) - - # Handle the handshake response - ready_to_read, _, _ = select((s,), (), (), 0) - while not ready_to_read: - ready_to_read, _, _ = select((s,), (), (), 0) - try: - data = s.recv(4) - except ConnectionResetError: - raise ServiceUnavailable("Failed to read any data from server {!r} after connected".format(resolved_address)) - data_size = len(data) - if data_size == 0: - # If no data is returned after a successful select - # response, the server has closed the connection - log_error("S: [CLOSE]") - s.close() - raise ProtocolError("Connection to %r closed without handshake response" % (resolved_address,)) - if data_size != 4: - # Some garbled data has been received - log_error("S: @*#!") - s.close() - raise ProtocolError("Expected four byte handshake response, received %r instead" % data) - agreed_version, = struct_unpack(">I", data) - log_debug("S: [HANDSHAKE] %d", agreed_version) - if agreed_version == 0: - log_debug("~~ [CLOSE]") - s.shutdown(SHUT_RDWR) - s.close() - elif agreed_version in (1, 2): - connection = Connection(resolved_address, s, agreed_version, - der_encoded_server_certificate=der_encoded_server_certificate, - error_handler=error_handler, **config) - connection.init() - return connection - elif agreed_version == 0x48545450: - log_error("S: [CLOSE]") - s.close() - raise ServiceUnavailable("Cannot to connect to Bolt service on {!r} " - "(looks like HTTP)".format(resolved_address)) - else: - log_error("S: [CLOSE]") - s.close() - raise ProtocolError("Unknown Bolt protocol version: {}".format(agreed_version)) - - -def connect(address, ssl_context=None, error_handler=None, **config): - """ Connect and perform a handshake and return a valid Connection object, assuming - a protocol version can be agreed. - """ - - last_error = None - # Establish a connection to the host and port specified - # Catches refused connections see: - # https://docs.python.org/2/library/errno.html - log_debug("~~ [RESOLVE] %s", address) - resolver = Resolver(custom_resolver=config.get("resolver")) - resolver.addresses.append(address) - resolver.custom_resolve() - resolver.dns_resolve() - for resolved_address in resolver.addresses: - log_debug("~~ [RESOLVED] %s -> %s", address, resolved_address) - try: - s = _connect(resolved_address, **config) - s, der_encoded_server_certificate = _secure(s, address[0], ssl_context, **config) - connection = _handshake(s, resolved_address, der_encoded_server_certificate, error_handler, **config) - except Exception as error: - last_error = error - else: - return connection - if last_error is None: - raise ServiceUnavailable("Failed to resolve addresses for %s" % address) - else: - raise last_error diff --git a/neo4j/bolt/io.py b/neo4j/bolt/io.py deleted file mode 100644 index a415f262d..000000000 --- a/neo4j/bolt/io.py +++ /dev/null @@ -1,277 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from struct import pack as struct_pack, unpack as struct_unpack - -from neo4j.compat import memoryview_at - - -_empty_view = memoryview(b"") - - -class MessageFrame(object): - - _current_pane = -1 - _current_offset = -1 - - def __init__(self, view, panes): - self._view = view - self._panes = panes - if panes: - self._current_pane = 0 - self._current_offset = 0 - - def close(self): - self._view = None - - def _next_pane(self): - self._current_pane += 1 - if self._current_pane < len(self._panes): - self._current_offset = 0 - else: - self._current_pane = -1 - self._current_offset = -1 - - def panes(self): - return self._panes - - def read_int(self): - if self._current_pane == -1: - return -1 - p, q = self._panes[self._current_pane] - size = q - p - value = memoryview_at(self._view, p + self._current_offset) - self._current_offset += 1 - if self._current_offset == size: - self._next_pane() - return value - - def read(self, n): - if n == 0 or self._current_pane == -1: - return _empty_view - value = None - is_memoryview = False - offset = 0 - - to_read = n - while to_read > 0 and self._current_pane >= 0: - p, q = self._panes[self._current_pane] - size = q - p - remaining = size - self._current_offset - start = p + self._current_offset - if to_read <= remaining: - end = start + to_read - if to_read < remaining: - self._current_offset += to_read - else: - self._next_pane() - else: - end = q - self._next_pane() - - read = end - start - if value: - if is_memoryview: - new_value = bytearray(n) - new_value[:offset] = value[:offset] - value = new_value - is_memoryview = False - value[offset:offset+read] = self._view[start:end] - else: - value = memoryview(self._view[start:end]) - is_memoryview = True - offset += read - to_read -= read - return value - - -class ChunkedInputBuffer(object): - - def __init__(self, capacity=524288): - self._data = bytearray(capacity) - self._view = memoryview(self._data) - self._extent = 0 # end position of all loaded data - self._origin = 0 # start position of current frame - self._limit = -1 # end position of current frame - self._frame = None # frame object - - def __repr__(self): - return repr(self.view().tobytes()) - - def capacity(self): - return len(self._view) - - def view(self): - return memoryview(self._view[:self._extent]) - - def load(self, b): - """ - - Note: may modify buffer size - """ - n = len(b) - new_extent = self._extent + n - overflow = new_extent - len(self._data) - if overflow > 0: - if self._recycle(): - return self.load(b) - self._view = None - new_extent = self._extent + n - self._data[self._extent:new_extent] = b - self._view = memoryview(self._data) - else: - self._view[self._extent:new_extent] = b - self._extent = new_extent - - def receive(self, socket, n): - """ - - Note: may modify buffer size, should error if frame exists - """ - new_extent = self._extent + n - overflow = new_extent - len(self._data) - if overflow > 0: - if self._recycle(): - return self.receive(socket, n) - self._view = None - data = socket.recv(n) - data_size = len(data) - new_extent = self._extent + data_size - self._data[self._extent:new_extent] = data - self._view = memoryview(self._data) - else: - data_size = socket.recv_into(self._view[self._extent:new_extent]) - new_extent = self._extent + data_size - self._extent = new_extent - return data_size - - def receive_message(self, socket, n): - """ - - :param socket: - :param n: - :return: - """ - while not self.frame_message(): - received = self.receive(socket, n) - if received == 0: - return False - return True - - def _recycle(self): - """ Reclaim buffer space before the origin. - - Note: modifies buffer size - """ - origin = self._origin - if origin == 0: - return False - available = self._extent - origin - self._data[:available] = self._data[origin:self._extent] - self._extent = available - self._origin = 0 - #log_debug("Recycled %d bytes" % origin) - return True - - def frame(self): - return self._frame - - def frame_message(self): - """ Construct a frame around the first complete message in the buffer. - """ - if self._frame is not None: - self.discard_message() - panes = [] - p = origin = self._origin - extent = self._extent - while p < extent: - available = extent - p - if available < 2: - break - chunk_size, = struct_unpack(">H", self._view[p:(p + 2)]) - p += 2 - if chunk_size == 0: - self._limit = p - self._frame = MessageFrame(memoryview(self._view[origin:self._limit]), panes) - return True - q = p + chunk_size - panes.append((p - origin, q - origin)) - p = q - return False - - def discard_message(self): - if self._frame is not None: - self._frame.close() - self._origin = self._limit - self._limit = -1 - self._frame = None - - -class ChunkedOutputBuffer(object): - - def __init__(self, capacity=1048576, max_chunk_size=16384): - self._max_chunk_size = max_chunk_size - self._header = 0 - self._start = 2 - self._end = 2 - self._data = bytearray(capacity) - - def max_chunk_size(self): - return self._max_chunk_size - - def clear(self): - self._header = 0 - self._start = 2 - self._end = 2 - self._data[0:2] = b"\x00\x00" - - def write(self, b): - to_write = len(b) - max_chunk_size = self._max_chunk_size - pos = 0 - while to_write > 0: - chunk_size = self._end - self._start - remaining = max_chunk_size - chunk_size - if remaining == 0 or remaining < to_write <= max_chunk_size: - self.chunk() - else: - wrote = min(to_write, remaining) - new_end = self._end + wrote - self._data[self._end:new_end] = b[pos:pos+wrote] - self._end = new_end - pos += wrote - new_chunk_size = self._end - self._start - self._data[self._header:(self._header + 2)] = struct_pack(">H", new_chunk_size) - to_write -= wrote - - def chunk(self): - self._header = self._end - self._start = self._header + 2 - self._end = self._start - self._data[self._header:self._start] = b"\x00\x00" - - def view(self): - end = self._end - chunk_size = end - self._start - if chunk_size == 0: - return memoryview(self._data[:self._header]) - else: - return memoryview(self._data[:end]) diff --git a/neo4j/bolt/response.py b/neo4j/bolt/response.py deleted file mode 100644 index 057027796..000000000 --- a/neo4j/bolt/response.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from neo4j.exceptions import AuthError, ServiceUnavailable, ProtocolError - - -class Response(object): - """ Subscriber object for a full response (zero or - more detail messages followed by one summary message). - """ - - def __init__(self, connection): - self.connection = connection - self.complete = False - - def on_records(self, records): - """ Called when one or more RECORD messages have been received. - """ - - def on_success(self, metadata): - """ Called when a SUCCESS message has been received. - """ - - def on_failure(self, metadata): - """ Called when a FAILURE message has been received. - """ - - def on_ignored(self, metadata=None): - """ Called when an IGNORED message has been received. - """ - - -class InitResponse(Response): - - def on_success(self, metadata): - super(InitResponse, self).on_success(metadata) - self.connection.server.version = metadata.get("server") - - def on_failure(self, metadata): - code = metadata.get("code") - message = metadata.get("message", "Connection initialisation failed") - if code == "Neo.ClientError.Security.Unauthorized": - raise AuthError(message) - else: - raise ServiceUnavailable(message) - - -class ResetResponse(Response): - - def on_failure(self, metadata): - raise ProtocolError("RESET failed") diff --git a/neo4j/compat/collections.py b/neo4j/compat/collections.py deleted file mode 100644 index f8780ae4b..000000000 --- a/neo4j/compat/collections.py +++ /dev/null @@ -1,28 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import absolute_import - -try: - from collections.abc import MutableSet -except ImportError: - from collections import MutableSet, OrderedDict -else: - from collections import OrderedDict diff --git a/neo4j/compat/ssl.py b/neo4j/compat/ssl.py deleted file mode 100644 index ac113325d..000000000 --- a/neo4j/compat/ssl.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from __future__ import absolute_import - -try: - from ssl import SSLContext, PROTOCOL_SSLv23, OP_NO_SSLv2, CERT_REQUIRED, HAS_SNI, SSLError -except ImportError: - SSL_AVAILABLE = False - SSLContext = None - PROTOCOL_SSLv23 = None - OP_NO_SSLv2 = None - CERT_REQUIRED = None - HAS_SNI = None - SSLError = None -else: - SSL_AVAILABLE = True diff --git a/neo4j/exceptions.py b/neo4j/exceptions.py index c276c23d1..c9eecfa70 100644 --- a/neo4j/exceptions.py +++ b/neo4j/exceptions.py @@ -24,170 +24,4 @@ """ -class AddressError(Exception): - """ Raised when a network address is invalid. - """ - - -class ProtocolError(Exception): - """ Raised when an unexpected or unsupported protocol event occurs. - """ - - -class ServiceUnavailable(Exception): - """ Raised when no database service is available. - """ - - -class SecurityError(Exception): - """ Raised when an action is denied due to security settings. - """ - - -class CypherError(Exception): - """ Raised when the Cypher engine returns an error to the client. - """ - - message = None - code = None - classification = None - category = None - title = None - metadata = None - - @classmethod - def hydrate(cls, message=None, code=None, **metadata): - message = message or "An unknown error occurred." - code = code or "Neo.DatabaseError.General.UnknownError" - try: - _, classification, category, title = code.split(".") - except ValueError: - classification = "DatabaseError" - category = "General" - title = "UnknownError" - - error_class = cls._extract_error_class(classification, code) - - inst = error_class(message) - inst.message = message - inst.code = code - inst.classification = classification - inst.category = category - inst.title = title - inst.metadata = metadata - return inst - - @classmethod - def _extract_error_class(cls, classification, code): - if classification == "ClientError": - try: - return client_errors[code] - except KeyError: - return ClientError - - elif classification == "TransientError": - try: - return transient_errors[code] - except KeyError: - return TransientError - - elif classification == "DatabaseError": - return DatabaseError - - else: - return cls - - -class ClientError(CypherError): - """ The Client sent a bad request - changing the request might yield a successful outcome. - """ - - -class DatabaseError(CypherError): - """ The database failed to service the request. - """ - - -class TransientError(CypherError): - """ The database cannot service the request right now, retrying later might yield a successful outcome. - """ - - -class DatabaseUnavailableError(TransientError): - """ - """ - - -class ConstraintError(ClientError): - """ - """ - - -class CypherSyntaxError(ClientError): - """ - """ - - -class CypherTypeError(ClientError): - """ - """ - - -class NotALeaderError(ClientError): - """ - """ - - -class Forbidden(ClientError, SecurityError): - """ - """ - - -class ForbiddenOnReadOnlyDatabaseError(Forbidden): - """ - """ - - -class AuthError(ClientError, SecurityError): - """ Raised when authentication failure occurs. - """ - - -client_errors = { - - # ConstraintError - "Neo.ClientError.Schema.ConstraintValidationFailed": ConstraintError, - "Neo.ClientError.Schema.ConstraintViolation": ConstraintError, - "Neo.ClientError.Statement.ConstraintVerificationFailed": ConstraintError, - "Neo.ClientError.Statement.ConstraintViolation": ConstraintError, - - # CypherSyntaxError - "Neo.ClientError.Statement.InvalidSyntax": CypherSyntaxError, - "Neo.ClientError.Statement.SyntaxError": CypherSyntaxError, - - # CypherTypeError - "Neo.ClientError.Procedure.TypeError": CypherTypeError, - "Neo.ClientError.Statement.InvalidType": CypherTypeError, - "Neo.ClientError.Statement.TypeError": CypherTypeError, - - # Forbidden - "Neo.ClientError.General.ForbiddenOnReadOnlyDatabase": ForbiddenOnReadOnlyDatabaseError, - "Neo.ClientError.General.ReadOnly": Forbidden, - "Neo.ClientError.Schema.ForbiddenOnConstraintIndex": Forbidden, - "Neo.ClientError.Schema.IndexBelongsToConstraint": Forbidden, - "Neo.ClientError.Security.Forbidden": Forbidden, - "Neo.ClientError.Transaction.ForbiddenDueToTransactionType": Forbidden, - - # AuthError - "Neo.ClientError.Security.AuthorizationFailed": AuthError, - "Neo.ClientError.Security.Unauthorized": AuthError, - - # NotALeaderError - "Neo.ClientError.Cluster.NotALeader": NotALeaderError -} - -transient_errors = { - - # DatabaseUnavailableError - "Neo.TransientError.General.DatabaseUnavailable": DatabaseUnavailableError -} +from neobolt.exceptions import * diff --git a/neo4j/meta.py b/neo4j/meta.py index 9bb07a58f..40595fe0e 100644 --- a/neo4j/meta.py +++ b/neo4j/meta.py @@ -21,3 +21,25 @@ # This version number will be automatically set in release-prepare build. version = "1.7.0.dev0" + + +def deprecated(message): + """ Decorator for deprecating functions and methods. + + :: + + @deprecated("'foo' has been deprecated in favour of 'bar'") + def foo(x): + pass + + """ + def f__(f): + def f_(*args, **kwargs): + from warnings import warn + warn(message, category=DeprecationWarning, stacklevel=2) + return f(*args, **kwargs) + f_.__name__ = f.__name__ + f_.__doc__ = f.__doc__ + f_.__dict__.update(f.__dict__) + return f_ + return f__ diff --git a/neo4j/packstream/__init__.py b/neo4j/packstream/__init__.py deleted file mode 100644 index a2c43106f..000000000 --- a/neo4j/packstream/__init__.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from neo4j.util import import_best as _import_best - -from .structure import Structure - -Packer = _import_best("neo4j.packstream._packer", "neo4j.packstream.packer").Packer -Unpacker = _import_best("neo4j.packstream._unpacker", "neo4j.packstream.unpacker").Unpacker diff --git a/neo4j/packstream/_packer.c b/neo4j/packstream/_packer.c deleted file mode 100644 index 42f0d951e..000000000 --- a/neo4j/packstream/_packer.c +++ /dev/null @@ -1,12195 +0,0 @@ -/* Generated by Cython 0.27.3 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "name": "neo4j.packstream._packer", - "sources": [ - "/home/technige/work/neo4j-python-driver/neo4j/packstream/_packer.pyx" - ] - }, - "module_name": "neo4j.packstream._packer" -} -END: Cython Metadata */ - -#define PY_SSIZE_T_CLEAN -#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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) - #error Cython requires Python 2.6+ or Python 3.3+. -#else -#define CYTHON_ABI "0_27_3" -#define CYTHON_FUTURE_DIVISION 0 -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !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 HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x02070000 - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #if PY_VERSION_HEX < 0x03050000 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #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_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #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_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) - #define CYTHON_USE_PYTYPE_LOOKUP 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #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 - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif - #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) - #endif - #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK -#endif -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, 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) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_PyCode_New(a, 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) - #define __Pyx_DefaultClassType PyType_Type -#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 -#if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL) - #ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#elif PY_VERSION_HEX >= 0x03060000 - #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() -#elif PY_VERSION_HEX >= 0x03000000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#else - #define __Pyx_PyThreadState_Current _PyThreadState_Current -#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 -#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #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) 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, ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#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 && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#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_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #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 -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef __Pyx_PyAsyncMethodsStruct - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; -#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(__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_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #if defined(__cplusplus) && __cplusplus >= 201103L - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #elif __has_cpp_attribute(gnu::fallthrough) - #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] - #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 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 - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - - -#define __PYX_ERR(f_index, lineno, Ln_error) \ -{ \ - __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ -} - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__neo4j__packstream___packer -#define __PYX_HAVE_API__neo4j__packstream___packer -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 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))) ) -#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 const char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#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 PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#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_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __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_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(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_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#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__ */ -static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } - -static PyObject *__pyx_m = NULL; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - - -static const char *__pyx_f[] = { - "neo4j/packstream/_packer.pyx", - "stringsource", -}; - -/*--- Type declarations ---*/ -struct __pyx_obj_5neo4j_10packstream_7_packer_Packer; - -/* "neo4j/packstream/_packer.pyx":34 - * - * - * cdef class Packer(object): # <<<<<<<<<<<<<< - * - * cdef public bint supports_bytes - */ -struct __pyx_obj_5neo4j_10packstream_7_packer_Packer { - PyObject_HEAD - struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *__pyx_vtab; - int supports_bytes; - PyObject *stream; - PyObject *_write; -}; - - - -struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer { - PyObject *(*pack_raw)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, PyObject *); - PyObject *(*pack)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, PyObject *, int __pyx_skip_dispatch); - PyObject *(*_pack)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, PyObject *); - PyObject *(*pack_bytes_header)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int); - PyObject *(*pack_string_header)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int); - PyObject *(*pack_list_header)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int); - PyObject *(*pack_list_stream_header)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int __pyx_skip_dispatch); - PyObject *(*pack_map_header)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int); - PyObject *(*pack_map_stream_header)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int __pyx_skip_dispatch); - PyObject *(*pack_struct)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, PyObject *, PyObject *, int __pyx_skip_dispatch); - PyObject *(*pack_end_of_stream)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int __pyx_skip_dispatch); -}; -static struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *__pyx_vtabptr_5neo4j_10packstream_7_packer_Packer; - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, 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; -#ifdef WITH_THREAD - #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__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #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) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #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_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) - -/* PyObjectGetAttrStr.proto */ -#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); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* RaiseDoubleKeywords.proto */ -static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); - -/* ParseKeywords.proto */ -static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\ - PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\ - const char* function_name); - -/* 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); - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#endif - -/* 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 - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); - -/* PyIntBinop.proto */ -#if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, long intval, int inplace); -#else -#define __Pyx_PyInt_RemainderObjC(op1, op2, intval, inplace)\ - (inplace ? PyNumber_InPlaceRemainder(op1, op2) : PyNumber_Remainder(op1, op2)) -#endif - -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; -#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#define __Pyx_PyErr_Occurred() 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 -#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 - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* PyObjectCallNoArg.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); -#else -#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) -#endif - -/* RaiseTooManyValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); - -/* RaiseNeedMoreValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); - -/* IterFinish.proto */ -static CYTHON_INLINE int __Pyx_IterFinish(void); - -/* UnpackItemEndCheck.proto */ -static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (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)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (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); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (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); -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); - -/* ArgTypeTest.proto */ -#define __Pyx_ArgTypeTest(obj, type, none_allowed, name, exact)\ - ((likely((Py_TYPE(obj) == type) | (none_allowed && (obj == Py_None)))) ? 1 :\ - __Pyx__ArgTypeTest(obj, type, name, exact)) -static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact); - -/* SetVTable.proto */ -static int __Pyx_SetVtable(PyObject *dict, void *vtable); - -/* SetupReduce.proto */ -static int __Pyx_setup_reduce(PyObject* type_obj); - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* ImportFrom.proto */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); - -/* CLineInTraceback.proto */ -#ifdef CYTHON_CLINE_IN_TRACEBACK -#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) -#else -static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); -#endif - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* FastTypeChecks.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) -static CYTHON_INLINE int __Pyx_IsSubtype(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_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) -#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) -#endif - -/* CStringEquals.proto */ -static CYTHON_INLINE int __Pyx_StrEq(const char *, const char *); - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_raw(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_data); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_value, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer__pack(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_value); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_bytes_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_v_size); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_string_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_v_size); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_list_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_v_size); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_list_stream_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_map_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_v_size); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_map_stream_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_struct(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_signature, PyObject *__pyx_v_fields, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_end_of_stream(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ - -/* Module declarations from 'neo4j.packstream._packer' */ -static PyTypeObject *__pyx_ptype_5neo4j_10packstream_7_packer_Packer = 0; -static PyObject *__pyx_v_5neo4j_10packstream_7_packer_INT64_HI = 0; -static PyObject *__pyx_v_5neo4j_10packstream_7_packer_INT64_LO = 0; -#define __Pyx_MODULE_NAME "neo4j.packstream._packer" -extern int __pyx_module_is_main_neo4j__packstream___packer; -int __pyx_module_is_main_neo4j__packstream___packer = 0; - -/* Implementation of 'neo4j.packstream._packer' */ -static PyObject *__pyx_builtin_OverflowError; -static PyObject *__pyx_builtin_ValueError; -static PyObject *__pyx_builtin_TypeError; -static const char __pyx_k_[] = "\300"; -static const char __pyx_k_I[] = ">I"; -static const char __pyx_k_d[] = ">d"; -static const char __pyx_k_i[] = ">i"; -static const char __pyx_k_q[] = ">q"; -static const char __pyx_k__3[] = "\303"; -static const char __pyx_k__5[] = "\302"; -static const char __pyx_k__7[] = "\301"; -static const char __pyx_k__9[] = "\310"; -static const char __pyx_k__11[] = "\311"; -static const char __pyx_k__13[] = "\312"; -static const char __pyx_k__15[] = "\313"; -static const char __pyx_k__19[] = "\314"; -static const char __pyx_k__21[] = "\315"; -static const char __pyx_k__23[] = "\316"; -static const char __pyx_k__26[] = "\200"; -static const char __pyx_k__28[] = "\201"; -static const char __pyx_k__30[] = "\202"; -static const char __pyx_k__32[] = "\203"; -static const char __pyx_k__34[] = "\204"; -static const char __pyx_k__36[] = "\205"; -static const char __pyx_k__38[] = "\206"; -static const char __pyx_k__40[] = "\207"; -static const char __pyx_k__42[] = "\210"; -static const char __pyx_k__44[] = "\211"; -static const char __pyx_k__46[] = "\212"; -static const char __pyx_k__48[] = "\213"; -static const char __pyx_k__50[] = "\214"; -static const char __pyx_k__52[] = "\215"; -static const char __pyx_k__54[] = "\216"; -static const char __pyx_k__56[] = "\217"; -static const char __pyx_k__58[] = "\320"; -static const char __pyx_k__60[] = "\321"; -static const char __pyx_k__62[] = "\322"; -static const char __pyx_k__65[] = "\220"; -static const char __pyx_k__67[] = "\221"; -static const char __pyx_k__69[] = "\222"; -static const char __pyx_k__71[] = "\223"; -static const char __pyx_k__73[] = "\224"; -static const char __pyx_k__75[] = "\225"; -static const char __pyx_k__77[] = "\226"; -static const char __pyx_k__79[] = "\227"; -static const char __pyx_k__81[] = "\230"; -static const char __pyx_k__83[] = "\231"; -static const char __pyx_k__85[] = "\232"; -static const char __pyx_k__87[] = "\233"; -static const char __pyx_k__89[] = "\234"; -static const char __pyx_k__91[] = "\235"; -static const char __pyx_k__93[] = "\236"; -static const char __pyx_k__95[] = "\237"; -static const char __pyx_k__97[] = "\324"; -static const char __pyx_k__99[] = "\325"; -static const char __pyx_k_tag[] = "tag"; -static const char __pyx_k__101[] = "\326"; -static const char __pyx_k__104[] = "\327"; -static const char __pyx_k__106[] = "\240"; -static const char __pyx_k__108[] = "\241"; -static const char __pyx_k__110[] = "\242"; -static const char __pyx_k__112[] = "\243"; -static const char __pyx_k__114[] = "\244"; -static const char __pyx_k__116[] = "\245"; -static const char __pyx_k__118[] = "\246"; -static const char __pyx_k__120[] = "\247"; -static const char __pyx_k__122[] = "\250"; -static const char __pyx_k__124[] = "\251"; -static const char __pyx_k__126[] = "\252"; -static const char __pyx_k__128[] = "\253"; -static const char __pyx_k__130[] = "\254"; -static const char __pyx_k__132[] = "\255"; -static const char __pyx_k__134[] = "\256"; -static const char __pyx_k__136[] = "\257"; -static const char __pyx_k__138[] = "\330"; -static const char __pyx_k__140[] = "\331"; -static const char __pyx_k__142[] = "\332"; -static const char __pyx_k__145[] = "\333"; -static const char __pyx_k__148[] = "\260"; -static const char __pyx_k__150[] = "\261"; -static const char __pyx_k__152[] = "\262"; -static const char __pyx_k__154[] = "\263"; -static const char __pyx_k__156[] = "\264"; -static const char __pyx_k__158[] = "\265"; -static const char __pyx_k__160[] = "\266"; -static const char __pyx_k__162[] = "\267"; -static const char __pyx_k__164[] = "\270"; -static const char __pyx_k__166[] = "\271"; -static const char __pyx_k__168[] = "\272"; -static const char __pyx_k__170[] = "\273"; -static const char __pyx_k__172[] = "\274"; -static const char __pyx_k__174[] = "\275"; -static const char __pyx_k__176[] = "\276"; -static const char __pyx_k__178[] = "\277"; -static const char __pyx_k__180[] = "\334"; -static const char __pyx_k__182[] = "\335"; -static const char __pyx_k__185[] = "\337"; -static const char __pyx_k__189[] = "*"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_name[] = "__name__"; -static const char __pyx_k_pack[] = "pack"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_items[] = "items"; -static const char __pyx_k_utf_8[] = "utf-8"; -static const char __pyx_k_write[] = "write"; -static const char __pyx_k_encode[] = "encode"; -static const char __pyx_k_fields[] = "fields"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_reduce[] = "__reduce__"; -static const char __pyx_k_stream[] = "stream"; -static const char __pyx_k_string[] = "string"; -static const char __pyx_k_struct[] = "struct"; -static const char __pyx_k_integer[] = "integer"; -static const char __pyx_k_getstate[] = "__getstate__"; -static const char __pyx_k_setstate[] = "__setstate__"; -static const char __pyx_k_Structure[] = "Structure"; -static const char __pyx_k_TypeError[] = "TypeError"; -static const char __pyx_k_constants[] = "constants"; -static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; -static const char __pyx_k_signature[] = "signature"; -static const char __pyx_k_structure[] = "structure"; -static const char __pyx_k_ValueError[] = "ValueError"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; -static const char __pyx_k_pack_struct[] = "pack_struct"; -static const char __pyx_k_struct_pack[] = "struct_pack"; -static const char __pyx_k_neo4j_compat[] = "neo4j.compat"; -static const char __pyx_k_OverflowError[] = "OverflowError"; -static const char __pyx_k_PACKED_UINT_8[] = "PACKED_UINT_8"; -static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; -static const char __pyx_k_PACKED_UINT_16[] = "PACKED_UINT_16"; -static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; -static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_pack_end_of_stream[] = "pack_end_of_stream"; -static const char __pyx_k_Integer_s_out_of_range[] = "Integer %s out of range"; -static const char __pyx_k_pack_map_stream_header[] = "pack_map_stream_header"; -static const char __pyx_k_pack_list_stream_header[] = "pack_list_stream_header"; -static const char __pyx_k_Structure_size_out_of_range[] = "Structure size out of range"; -static const char __pyx_k_Map_header_size_out_of_range[] = "Map header size out of range"; -static const char __pyx_k_List_header_size_out_of_range[] = "List header size out of range"; -static const char __pyx_k_Bytes_header_size_out_of_range[] = "Bytes header size out of range"; -static const char __pyx_k_String_header_size_out_of_range[] = "String header size out of range"; -static const char __pyx_k_This_PackSteam_channel_does_not[] = "This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)"; -static const char __pyx_k_Structure_signature_must_be_a_si[] = "Structure signature must be a single byte value"; -static const char __pyx_k_Values_of_type_s_are_not_support[] = "Values of type %s are not supported"; -static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; -static PyObject *__pyx_kp_b_; -static PyObject *__pyx_kp_s_Bytes_header_size_out_of_range; -static PyObject *__pyx_kp_s_I; -static PyObject *__pyx_kp_s_Integer_s_out_of_range; -static PyObject *__pyx_kp_s_List_header_size_out_of_range; -static PyObject *__pyx_kp_s_Map_header_size_out_of_range; -static PyObject *__pyx_n_s_OverflowError; -static PyObject *__pyx_n_s_PACKED_UINT_16; -static PyObject *__pyx_n_s_PACKED_UINT_8; -static PyObject *__pyx_kp_s_String_header_size_out_of_range; -static PyObject *__pyx_n_s_Structure; -static PyObject *__pyx_kp_s_Structure_signature_must_be_a_si; -static PyObject *__pyx_kp_s_Structure_size_out_of_range; -static PyObject *__pyx_kp_s_This_PackSteam_channel_does_not; -static PyObject *__pyx_n_s_TypeError; -static PyObject *__pyx_n_s_ValueError; -static PyObject *__pyx_kp_s_Values_of_type_s_are_not_support; -static PyObject *__pyx_kp_b__101; -static PyObject *__pyx_kp_b__104; -static PyObject *__pyx_kp_b__106; -static PyObject *__pyx_kp_b__108; -static PyObject *__pyx_kp_b__11; -static PyObject *__pyx_kp_b__110; -static PyObject *__pyx_kp_b__112; -static PyObject *__pyx_kp_b__114; -static PyObject *__pyx_kp_b__116; -static PyObject *__pyx_kp_b__118; -static PyObject *__pyx_kp_b__120; -static PyObject *__pyx_kp_b__122; -static PyObject *__pyx_kp_b__124; -static PyObject *__pyx_kp_b__126; -static PyObject *__pyx_kp_b__128; -static PyObject *__pyx_kp_b__13; -static PyObject *__pyx_kp_b__130; -static PyObject *__pyx_kp_b__132; -static PyObject *__pyx_kp_b__134; -static PyObject *__pyx_kp_b__136; -static PyObject *__pyx_kp_b__138; -static PyObject *__pyx_kp_b__140; -static PyObject *__pyx_kp_b__142; -static PyObject *__pyx_kp_b__145; -static PyObject *__pyx_kp_b__148; -static PyObject *__pyx_kp_b__15; -static PyObject *__pyx_kp_b__150; -static PyObject *__pyx_kp_b__152; -static PyObject *__pyx_kp_b__154; -static PyObject *__pyx_kp_b__156; -static PyObject *__pyx_kp_b__158; -static PyObject *__pyx_kp_b__160; -static PyObject *__pyx_kp_b__162; -static PyObject *__pyx_kp_b__164; -static PyObject *__pyx_kp_b__166; -static PyObject *__pyx_kp_b__168; -static PyObject *__pyx_kp_b__170; -static PyObject *__pyx_kp_b__172; -static PyObject *__pyx_kp_b__174; -static PyObject *__pyx_kp_b__176; -static PyObject *__pyx_kp_b__178; -static PyObject *__pyx_kp_b__180; -static PyObject *__pyx_kp_b__182; -static PyObject *__pyx_kp_b__185; -static PyObject *__pyx_n_s__189; -static PyObject *__pyx_kp_b__19; -static PyObject *__pyx_kp_b__21; -static PyObject *__pyx_kp_b__23; -static PyObject *__pyx_kp_b__26; -static PyObject *__pyx_kp_b__28; -static PyObject *__pyx_kp_b__3; -static PyObject *__pyx_kp_b__30; -static PyObject *__pyx_kp_b__32; -static PyObject *__pyx_kp_b__34; -static PyObject *__pyx_kp_b__36; -static PyObject *__pyx_kp_b__38; -static PyObject *__pyx_kp_b__40; -static PyObject *__pyx_kp_b__42; -static PyObject *__pyx_kp_b__44; -static PyObject *__pyx_kp_b__46; -static PyObject *__pyx_kp_b__48; -static PyObject *__pyx_kp_b__5; -static PyObject *__pyx_kp_b__50; -static PyObject *__pyx_kp_b__52; -static PyObject *__pyx_kp_b__54; -static PyObject *__pyx_kp_b__56; -static PyObject *__pyx_kp_b__58; -static PyObject *__pyx_kp_b__60; -static PyObject *__pyx_kp_b__62; -static PyObject *__pyx_kp_b__65; -static PyObject *__pyx_kp_b__67; -static PyObject *__pyx_kp_b__69; -static PyObject *__pyx_kp_b__7; -static PyObject *__pyx_kp_b__71; -static PyObject *__pyx_kp_b__73; -static PyObject *__pyx_kp_b__75; -static PyObject *__pyx_kp_b__77; -static PyObject *__pyx_kp_b__79; -static PyObject *__pyx_kp_b__81; -static PyObject *__pyx_kp_b__83; -static PyObject *__pyx_kp_b__85; -static PyObject *__pyx_kp_b__87; -static PyObject *__pyx_kp_b__89; -static PyObject *__pyx_kp_b__9; -static PyObject *__pyx_kp_b__91; -static PyObject *__pyx_kp_b__93; -static PyObject *__pyx_kp_b__95; -static PyObject *__pyx_kp_b__97; -static PyObject *__pyx_kp_b__99; -static PyObject *__pyx_n_s_cline_in_traceback; -static PyObject *__pyx_n_s_constants; -static PyObject *__pyx_kp_s_d; -static PyObject *__pyx_n_s_encode; -static PyObject *__pyx_n_s_fields; -static PyObject *__pyx_n_s_getstate; -static PyObject *__pyx_kp_s_i; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_n_s_integer; -static PyObject *__pyx_n_s_items; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_n_s_neo4j_compat; -static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; -static PyObject *__pyx_n_s_pack; -static PyObject *__pyx_n_s_pack_end_of_stream; -static PyObject *__pyx_n_s_pack_list_stream_header; -static PyObject *__pyx_n_s_pack_map_stream_header; -static PyObject *__pyx_n_s_pack_struct; -static PyObject *__pyx_n_s_pyx_vtable; -static PyObject *__pyx_kp_s_q; -static PyObject *__pyx_n_s_reduce; -static PyObject *__pyx_n_s_reduce_cython; -static PyObject *__pyx_n_s_reduce_ex; -static PyObject *__pyx_n_s_setstate; -static PyObject *__pyx_n_s_setstate_cython; -static PyObject *__pyx_n_s_signature; -static PyObject *__pyx_n_s_stream; -static PyObject *__pyx_n_s_string; -static PyObject *__pyx_n_s_struct; -static PyObject *__pyx_n_s_struct_pack; -static PyObject *__pyx_n_s_structure; -static PyObject *__pyx_n_s_tag; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_kp_s_utf_8; -static PyObject *__pyx_n_s_write; -static int __pyx_pf_5neo4j_10packstream_7_packer_6Packer___cinit__(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_stream); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_2pack(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_4pack_list_stream_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_6pack_map_stream_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_8pack_struct(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_signature, PyObject *__pyx_v_fields); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_10pack_end_of_stream(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_14supports_bytes___get__(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self); /* proto */ -static int __pyx_pf_5neo4j_10packstream_7_packer_6Packer_14supports_bytes_2__set__(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_value); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static PyObject *__pyx_tp_new_5neo4j_10packstream_7_packer_Packer(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_int_128; -static PyObject *__pyx_int_256; -static PyObject *__pyx_int_32768; -static PyObject *__pyx_int_65536; -static PyObject *__pyx_int_2147483648; -static PyObject *__pyx_int_4294967296; -static PyObject *__pyx_int_9223372036854775808; -static PyObject *__pyx_int_neg_16; -static PyObject *__pyx_int_neg_128; -static PyObject *__pyx_int_neg_32768; -static PyObject *__pyx_int_neg_2147483648; -static PyObject *__pyx_int_neg_9223372036854775808; -static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__4; -static PyObject *__pyx_tuple__6; -static PyObject *__pyx_tuple__8; -static PyObject *__pyx_tuple__10; -static PyObject *__pyx_tuple__12; -static PyObject *__pyx_tuple__14; -static PyObject *__pyx_tuple__16; -static PyObject *__pyx_tuple__17; -static PyObject *__pyx_tuple__18; -static PyObject *__pyx_tuple__20; -static PyObject *__pyx_tuple__22; -static PyObject *__pyx_tuple__24; -static PyObject *__pyx_tuple__25; -static PyObject *__pyx_tuple__27; -static PyObject *__pyx_tuple__29; -static PyObject *__pyx_tuple__31; -static PyObject *__pyx_tuple__33; -static PyObject *__pyx_tuple__35; -static PyObject *__pyx_tuple__37; -static PyObject *__pyx_tuple__39; -static PyObject *__pyx_tuple__41; -static PyObject *__pyx_tuple__43; -static PyObject *__pyx_tuple__45; -static PyObject *__pyx_tuple__47; -static PyObject *__pyx_tuple__49; -static PyObject *__pyx_tuple__51; -static PyObject *__pyx_tuple__53; -static PyObject *__pyx_tuple__55; -static PyObject *__pyx_tuple__57; -static PyObject *__pyx_tuple__59; -static PyObject *__pyx_tuple__61; -static PyObject *__pyx_tuple__63; -static PyObject *__pyx_tuple__64; -static PyObject *__pyx_tuple__66; -static PyObject *__pyx_tuple__68; -static PyObject *__pyx_tuple__70; -static PyObject *__pyx_tuple__72; -static PyObject *__pyx_tuple__74; -static PyObject *__pyx_tuple__76; -static PyObject *__pyx_tuple__78; -static PyObject *__pyx_tuple__80; -static PyObject *__pyx_tuple__82; -static PyObject *__pyx_tuple__84; -static PyObject *__pyx_tuple__86; -static PyObject *__pyx_tuple__88; -static PyObject *__pyx_tuple__90; -static PyObject *__pyx_tuple__92; -static PyObject *__pyx_tuple__94; -static PyObject *__pyx_tuple__96; -static PyObject *__pyx_tuple__98; -static PyObject *__pyx_tuple__100; -static PyObject *__pyx_tuple__102; -static PyObject *__pyx_tuple__103; -static PyObject *__pyx_tuple__105; -static PyObject *__pyx_tuple__107; -static PyObject *__pyx_tuple__109; -static PyObject *__pyx_tuple__111; -static PyObject *__pyx_tuple__113; -static PyObject *__pyx_tuple__115; -static PyObject *__pyx_tuple__117; -static PyObject *__pyx_tuple__119; -static PyObject *__pyx_tuple__121; -static PyObject *__pyx_tuple__123; -static PyObject *__pyx_tuple__125; -static PyObject *__pyx_tuple__127; -static PyObject *__pyx_tuple__129; -static PyObject *__pyx_tuple__131; -static PyObject *__pyx_tuple__133; -static PyObject *__pyx_tuple__135; -static PyObject *__pyx_tuple__137; -static PyObject *__pyx_tuple__139; -static PyObject *__pyx_tuple__141; -static PyObject *__pyx_tuple__143; -static PyObject *__pyx_tuple__144; -static PyObject *__pyx_tuple__146; -static PyObject *__pyx_tuple__147; -static PyObject *__pyx_tuple__149; -static PyObject *__pyx_tuple__151; -static PyObject *__pyx_tuple__153; -static PyObject *__pyx_tuple__155; -static PyObject *__pyx_tuple__157; -static PyObject *__pyx_tuple__159; -static PyObject *__pyx_tuple__161; -static PyObject *__pyx_tuple__163; -static PyObject *__pyx_tuple__165; -static PyObject *__pyx_tuple__167; -static PyObject *__pyx_tuple__169; -static PyObject *__pyx_tuple__171; -static PyObject *__pyx_tuple__173; -static PyObject *__pyx_tuple__175; -static PyObject *__pyx_tuple__177; -static PyObject *__pyx_tuple__179; -static PyObject *__pyx_tuple__181; -static PyObject *__pyx_tuple__183; -static PyObject *__pyx_tuple__184; -static PyObject *__pyx_tuple__186; -static PyObject *__pyx_tuple__187; -static PyObject *__pyx_tuple__188; - -/* "neo4j/packstream/_packer.pyx":41 - * cdef _write - * - * def __cinit__(self, stream): # <<<<<<<<<<<<<< - * self.supports_bytes = False - * self.stream = stream - */ - -/* Python wrapper */ -static int __pyx_pw_5neo4j_10packstream_7_packer_6Packer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5neo4j_10packstream_7_packer_6Packer_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_stream = 0; - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_stream,0}; - PyObject* values[1] = {0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_stream)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) __PYX_ERR(0, 41, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 1) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - } - __pyx_v_stream = values[0]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 1, 1, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 41, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return -1; - __pyx_L4_argument_unpacking_done:; - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer___cinit__(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self), __pyx_v_stream); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5neo4j_10packstream_7_packer_6Packer___cinit__(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_stream) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "neo4j/packstream/_packer.pyx":42 - * - * def __cinit__(self, stream): - * self.supports_bytes = False # <<<<<<<<<<<<<< - * self.stream = stream - * self._write = self.stream.write - */ - __pyx_v_self->supports_bytes = 0; - - /* "neo4j/packstream/_packer.pyx":43 - * def __cinit__(self, stream): - * self.supports_bytes = False - * self.stream = stream # <<<<<<<<<<<<<< - * self._write = self.stream.write - * - */ - __Pyx_INCREF(__pyx_v_stream); - __Pyx_GIVEREF(__pyx_v_stream); - __Pyx_GOTREF(__pyx_v_self->stream); - __Pyx_DECREF(__pyx_v_self->stream); - __pyx_v_self->stream = __pyx_v_stream; - - /* "neo4j/packstream/_packer.pyx":44 - * self.supports_bytes = False - * self.stream = stream - * self._write = self.stream.write # <<<<<<<<<<<<<< - * - * cdef pack_raw(self, data): - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->stream, __pyx_n_s_write); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_GIVEREF(__pyx_t_1); - __Pyx_GOTREF(__pyx_v_self->_write); - __Pyx_DECREF(__pyx_v_self->_write); - __pyx_v_self->_write = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":41 - * cdef _write - * - * def __cinit__(self, stream): # <<<<<<<<<<<<<< - * self.supports_bytes = False - * self.stream = stream - */ - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":46 - * self._write = self.stream.write - * - * cdef pack_raw(self, data): # <<<<<<<<<<<<<< - * self._write(data) - * - */ - -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_raw(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_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; - __Pyx_RefNannySetupContext("pack_raw", 0); - - /* "neo4j/packstream/_packer.pyx":47 - * - * cdef pack_raw(self, data): - * self._write(data) # <<<<<<<<<<<<<< - * - * cpdef pack(self, value): - */ - __Pyx_INCREF(__pyx_v_self->_write); - __pyx_t_2 = __pyx_v_self->_write; __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_data); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_data}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_v_data}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_INCREF(__pyx_v_data); - __Pyx_GIVEREF(__pyx_v_data); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_data); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":46 - * self._write = self.stream.write - * - * cdef pack_raw(self, data): # <<<<<<<<<<<<<< - * self._write(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("neo4j.packstream._packer.Packer.pack_raw", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":49 - * self._write(data) - * - * cpdef pack(self, value): # <<<<<<<<<<<<<< - * return self._pack(value) - * - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_3pack(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_value, 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; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("pack", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_3pack)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_value); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_value}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_value}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_value); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_packer.pyx":50 - * - * cpdef pack(self, value): - * return self._pack(value) # <<<<<<<<<<<<<< - * - * cdef _pack(self, value): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->_pack(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_packer.pyx":49 - * self._write(data) - * - * cpdef pack(self, value): # <<<<<<<<<<<<<< - * return self._pack(value) - * - */ - - /* 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_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.pack", __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_5neo4j_10packstream_7_packer_6Packer_3pack(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_3pack(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("pack (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer_2pack(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_2pack(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_value) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("pack", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_7_packer_6Packer_pack(__pyx_v_self, __pyx_v_value, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __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("neo4j.packstream._packer.Packer.pack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":52 - * return self._pack(value) - * - * cdef _pack(self, value): # <<<<<<<<<<<<<< - * write = self._write - * - */ - -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer__pack(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_value) { - PyObject *__pyx_v_write = NULL; - PyObject *__pyx_v_value_bytes = NULL; - PyObject *__pyx_v_item = NULL; - PyObject *__pyx_v_key = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - Py_ssize_t __pyx_t_9; - PyObject *(*__pyx_t_10)(PyObject *); - PyObject *(*__pyx_t_11)(PyObject *); - __Pyx_RefNannySetupContext("_pack", 0); - - /* "neo4j/packstream/_packer.pyx":53 - * - * cdef _pack(self, value): - * write = self._write # <<<<<<<<<<<<<< - * - * # None - */ - __pyx_t_1 = __pyx_v_self->_write; - __Pyx_INCREF(__pyx_t_1); - __pyx_v_write = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":56 - * - * # None - * if value is None: # <<<<<<<<<<<<<< - * write(b"\xC0") # NULL - * - */ - __pyx_t_2 = (__pyx_v_value == Py_None); - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":57 - * # None - * if value is None: - * write(b"\xC0") # NULL # <<<<<<<<<<<<<< - * - * # Boolean - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 57, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":56 - * - * # None - * if value is None: # <<<<<<<<<<<<<< - * write(b"\xC0") # NULL - * - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":60 - * - * # Boolean - * elif value is True: # <<<<<<<<<<<<<< - * write(b"\xC3") - * elif value is False: - */ - __pyx_t_3 = (__pyx_v_value == Py_True); - __pyx_t_2 = (__pyx_t_3 != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":61 - * # Boolean - * elif value is True: - * write(b"\xC3") # <<<<<<<<<<<<<< - * elif value is False: - * write(b"\xC2") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":60 - * - * # Boolean - * elif value is True: # <<<<<<<<<<<<<< - * write(b"\xC3") - * elif value is False: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":62 - * elif value is True: - * write(b"\xC3") - * elif value is False: # <<<<<<<<<<<<<< - * write(b"\xC2") - * - */ - __pyx_t_2 = (__pyx_v_value == Py_False); - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":63 - * write(b"\xC3") - * elif value is False: - * write(b"\xC2") # <<<<<<<<<<<<<< - * - * # Float (only double precision is supported) - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":62 - * elif value is True: - * write(b"\xC3") - * elif value is False: # <<<<<<<<<<<<<< - * write(b"\xC2") - * - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":66 - * - * # Float (only double precision is supported) - * elif isinstance(value, float): # <<<<<<<<<<<<<< - * write(b"\xC1") - * write(struct_pack(">d", value)) - */ - __pyx_t_3 = PyFloat_Check(__pyx_v_value); - __pyx_t_2 = (__pyx_t_3 != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":67 - * # Float (only double precision is supported) - * elif isinstance(value, float): - * write(b"\xC1") # <<<<<<<<<<<<<< - * write(struct_pack(">d", value)) - * - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 67, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":68 - * elif isinstance(value, float): - * write(b"\xC1") - * write(struct_pack(">d", value)) # <<<<<<<<<<<<<< - * - * # Integer - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_pack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_d, __pyx_v_value}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_d, __pyx_v_value}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_4); - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_d); - __Pyx_GIVEREF(__pyx_kp_s_d); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_d); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_5 = __pyx_v_write; __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_8) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 68, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":66 - * - * # Float (only double precision is supported) - * elif isinstance(value, float): # <<<<<<<<<<<<<< - * write(b"\xC1") - * write(struct_pack(">d", value)) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":71 - * - * # Integer - * elif isinstance(value, integer): # <<<<<<<<<<<<<< - * if -0x10 <= value < 0x80: - * write(PACKED_UINT_8[value % 0x100]) - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_integer); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 71, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_2 = PyObject_IsInstance(__pyx_v_value, __pyx_t_1); if (unlikely(__pyx_t_2 == ((int)-1))) __PYX_ERR(0, 71, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":72 - * # Integer - * elif isinstance(value, integer): - * if -0x10 <= value < 0x80: # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x80 <= value < -0x10: - */ - __pyx_t_1 = PyObject_RichCompare(__pyx_int_neg_16, __pyx_v_value, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error) - if (__Pyx_PyObject_IsTrue(__pyx_t_1)) { - __Pyx_DECREF(__pyx_t_1); - __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_128, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 72, __pyx_L1_error) - } - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 72, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":73 - * elif isinstance(value, integer): - * if -0x10 <= value < 0x80: - * write(PACKED_UINT_8[value % 0x100]) # <<<<<<<<<<<<<< - * elif -0x80 <= value < -0x10: - * write(b"\xC8") - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_RemainderObjC(__pyx_v_value, __pyx_int_256, 0x100, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyObject_GetItem(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_6 = __pyx_v_write; __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - } - } - if (!__pyx_t_5) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 73, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 73, __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; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":72 - * # Integer - * elif isinstance(value, integer): - * if -0x10 <= value < 0x80: # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x80 <= value < -0x10: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":74 - * if -0x10 <= value < 0x80: - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x80 <= value < -0x10: # <<<<<<<<<<<<<< - * write(b"\xC8") - * write(PACKED_UINT_8[value % 0x100]) - */ - __pyx_t_1 = PyObject_RichCompare(__pyx_int_neg_128, __pyx_v_value, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error) - if (__Pyx_PyObject_IsTrue(__pyx_t_1)) { - __Pyx_DECREF(__pyx_t_1); - __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_neg_16, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 74, __pyx_L1_error) - } - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 74, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":75 - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x80 <= value < -0x10: - * write(b"\xC8") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x8000 <= value < 0x8000: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":76 - * elif -0x80 <= value < -0x10: - * write(b"\xC8") - * write(PACKED_UINT_8[value % 0x100]) # <<<<<<<<<<<<<< - * elif -0x8000 <= value < 0x8000: - * write(b"\xC9") - */ - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = __Pyx_PyInt_RemainderObjC(__pyx_v_value, __pyx_int_256, 0x100, 0); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_4 = PyObject_GetItem(__pyx_t_6, __pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_8 = __pyx_v_write; __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_8); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_8, function); - } - } - if (!__pyx_t_6) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_8)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_8)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_8, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":74 - * if -0x10 <= value < 0x80: - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x80 <= value < -0x10: # <<<<<<<<<<<<<< - * write(b"\xC8") - * write(PACKED_UINT_8[value % 0x100]) - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":77 - * write(b"\xC8") - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x8000 <= value < 0x8000: # <<<<<<<<<<<<<< - * write(b"\xC9") - * write(PACKED_UINT_16[value % 0x10000]) - */ - __pyx_t_1 = PyObject_RichCompare(__pyx_int_neg_32768, __pyx_v_value, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error) - if (__Pyx_PyObject_IsTrue(__pyx_t_1)) { - __Pyx_DECREF(__pyx_t_1); - __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_32768, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 77, __pyx_L1_error) - } - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 77, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":78 - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x8000 <= value < 0x8000: - * write(b"\xC9") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[value % 0x10000]) - * elif -0x80000000 <= value < 0x80000000: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 78, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":79 - * elif -0x8000 <= value < 0x8000: - * write(b"\xC9") - * write(PACKED_UINT_16[value % 0x10000]) # <<<<<<<<<<<<<< - * elif -0x80000000 <= value < 0x80000000: - * write(b"\xCA") - */ - __pyx_t_8 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_16); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_5 = __Pyx_PyInt_RemainderObjC(__pyx_v_value, __pyx_int_65536, 0x10000, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = PyObject_GetItem(__pyx_t_8, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_5 = __pyx_v_write; __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_8) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 79, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":77 - * write(b"\xC8") - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x8000 <= value < 0x8000: # <<<<<<<<<<<<<< - * write(b"\xC9") - * write(PACKED_UINT_16[value % 0x10000]) - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":80 - * write(b"\xC9") - * write(PACKED_UINT_16[value % 0x10000]) - * elif -0x80000000 <= value < 0x80000000: # <<<<<<<<<<<<<< - * write(b"\xCA") - * write(struct_pack(">i", value)) - */ - __pyx_t_1 = PyObject_RichCompare(__pyx_int_neg_2147483648, __pyx_v_value, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) - if (__Pyx_PyObject_IsTrue(__pyx_t_1)) { - __Pyx_DECREF(__pyx_t_1); - __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_int_2147483648, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 80, __pyx_L1_error) - } - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 80, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":81 - * write(PACKED_UINT_16[value % 0x10000]) - * elif -0x80000000 <= value < 0x80000000: - * write(b"\xCA") # <<<<<<<<<<<<<< - * write(struct_pack(">i", value)) - * elif INT64_LO <= value < INT64_HI: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__14, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 81, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":82 - * elif -0x80000000 <= value < 0x80000000: - * write(b"\xCA") - * write(struct_pack(">i", value)) # <<<<<<<<<<<<<< - * elif INT64_LO <= value < INT64_HI: - * write(b"\xCB") - */ - __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_pack); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_i, __pyx_v_value}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_5); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_i, __pyx_v_value}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_5); - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_i); - __Pyx_GIVEREF(__pyx_kp_s_i); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_i); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_6 = __pyx_v_write; __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - } - } - if (!__pyx_t_8) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_5}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_6)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_5}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_6, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_8); __pyx_t_8 = NULL; - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 82, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":80 - * write(b"\xC9") - * write(PACKED_UINT_16[value % 0x10000]) - * elif -0x80000000 <= value < 0x80000000: # <<<<<<<<<<<<<< - * write(b"\xCA") - * write(struct_pack(">i", value)) - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":83 - * write(b"\xCA") - * write(struct_pack(">i", value)) - * elif INT64_LO <= value < INT64_HI: # <<<<<<<<<<<<<< - * write(b"\xCB") - * write(struct_pack(">q", value)) - */ - __pyx_t_1 = PyObject_RichCompare(__pyx_v_5neo4j_10packstream_7_packer_INT64_LO, __pyx_v_value, Py_LE); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) - if (__Pyx_PyObject_IsTrue(__pyx_t_1)) { - __Pyx_DECREF(__pyx_t_1); - __pyx_t_1 = PyObject_RichCompare(__pyx_v_value, __pyx_v_5neo4j_10packstream_7_packer_INT64_HI, Py_LT); __Pyx_XGOTREF(__pyx_t_1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 83, __pyx_L1_error) - } - __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 83, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":84 - * write(struct_pack(">i", value)) - * elif INT64_LO <= value < INT64_HI: - * write(b"\xCB") # <<<<<<<<<<<<<< - * write(struct_pack(">q", value)) - * else: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__16, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":85 - * elif INT64_LO <= value < INT64_HI: - * write(b"\xCB") - * write(struct_pack(">q", value)) # <<<<<<<<<<<<<< - * else: - * raise OverflowError("Integer %s out of range" % value) - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_pack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_q, __pyx_v_value}; - __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_q, __pyx_v_value}; - __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_6); - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_q); - __Pyx_GIVEREF(__pyx_kp_s_q); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_q); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_v_value); - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_4 = __pyx_v_write; __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - } - } - if (!__pyx_t_8) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_8); __pyx_t_8 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 85, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":83 - * write(b"\xCA") - * write(struct_pack(">i", value)) - * elif INT64_LO <= value < INT64_HI: # <<<<<<<<<<<<<< - * write(b"\xCB") - * write(struct_pack(">q", value)) - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":87 - * write(struct_pack(">q", value)) - * else: - * raise OverflowError("Integer %s out of range" % value) # <<<<<<<<<<<<<< - * - * # String - */ - /*else*/ { - __pyx_t_1 = __Pyx_PyString_Format(__pyx_kp_s_Integer_s_out_of_range, __pyx_v_value); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_OverflowError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 87, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_1, 0, 0, 0); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __PYX_ERR(0, 87, __pyx_L1_error) - } - __pyx_L4:; - - /* "neo4j/packstream/_packer.pyx":71 - * - * # Integer - * elif isinstance(value, integer): # <<<<<<<<<<<<<< - * if -0x10 <= value < 0x80: - * write(PACKED_UINT_8[value % 0x100]) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":90 - * - * # String - * elif isinstance(value, string): # <<<<<<<<<<<<<< - * if isinstance(value, bytes): - * value_bytes = value - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_string); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = (__pyx_t_3 != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":91 - * # String - * elif isinstance(value, string): - * if isinstance(value, bytes): # <<<<<<<<<<<<<< - * value_bytes = value - * else: - */ - __pyx_t_2 = PyBytes_Check(__pyx_v_value); - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":92 - * elif isinstance(value, string): - * if isinstance(value, bytes): - * value_bytes = value # <<<<<<<<<<<<<< - * else: - * value_bytes = value.encode("utf-8") - */ - __Pyx_INCREF(__pyx_v_value); - __pyx_v_value_bytes = __pyx_v_value; - - /* "neo4j/packstream/_packer.pyx":91 - * # String - * elif isinstance(value, string): - * if isinstance(value, bytes): # <<<<<<<<<<<<<< - * value_bytes = value - * else: - */ - goto __pyx_L5; - } - - /* "neo4j/packstream/_packer.pyx":94 - * value_bytes = value - * else: - * value_bytes = value.encode("utf-8") # <<<<<<<<<<<<<< - * self.pack_string_header(len(value_bytes)) - * self.pack_raw(value_bytes) - */ - /*else*/ { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 94, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__17, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 94, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_v_value_bytes = __pyx_t_4; - __pyx_t_4 = 0; - } - __pyx_L5:; - - /* "neo4j/packstream/_packer.pyx":95 - * else: - * value_bytes = value.encode("utf-8") - * self.pack_string_header(len(value_bytes)) # <<<<<<<<<<<<<< - * self.pack_raw(value_bytes) - * - */ - __pyx_t_9 = PyObject_Length(__pyx_v_value_bytes); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 95, __pyx_L1_error) - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->pack_string_header(__pyx_v_self, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 95, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":96 - * value_bytes = value.encode("utf-8") - * self.pack_string_header(len(value_bytes)) - * self.pack_raw(value_bytes) # <<<<<<<<<<<<<< - * - * # Bytes (deliberately listed after String since in - */ - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->pack_raw(__pyx_v_self, __pyx_v_value_bytes); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":90 - * - * # String - * elif isinstance(value, string): # <<<<<<<<<<<<<< - * if isinstance(value, bytes): - * value_bytes = value - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":100 - * # Bytes (deliberately listed after String since in - * # Python 2, bytes should be treated as a String) - * elif isinstance(value, bytes): # <<<<<<<<<<<<<< - * self.pack_bytes_header(len(value)) - * self.pack_raw(value) - */ - __pyx_t_3 = PyBytes_Check(__pyx_v_value); - __pyx_t_2 = (__pyx_t_3 != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":101 - * # Python 2, bytes should be treated as a String) - * elif isinstance(value, bytes): - * self.pack_bytes_header(len(value)) # <<<<<<<<<<<<<< - * self.pack_raw(value) - * elif isinstance(value, bytearray): - */ - __pyx_t_9 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 101, __pyx_L1_error) - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->pack_bytes_header(__pyx_v_self, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 101, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":102 - * elif isinstance(value, bytes): - * self.pack_bytes_header(len(value)) - * self.pack_raw(value) # <<<<<<<<<<<<<< - * elif isinstance(value, bytearray): - * self.pack_bytes_header(len(value)) - */ - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->pack_raw(__pyx_v_self, __pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":100 - * # Bytes (deliberately listed after String since in - * # Python 2, bytes should be treated as a String) - * elif isinstance(value, bytes): # <<<<<<<<<<<<<< - * self.pack_bytes_header(len(value)) - * self.pack_raw(value) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":103 - * self.pack_bytes_header(len(value)) - * self.pack_raw(value) - * elif isinstance(value, bytearray): # <<<<<<<<<<<<<< - * self.pack_bytes_header(len(value)) - * self.pack_raw(bytes(value)) - */ - __pyx_t_2 = PyByteArray_Check(__pyx_v_value); - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":104 - * self.pack_raw(value) - * elif isinstance(value, bytearray): - * self.pack_bytes_header(len(value)) # <<<<<<<<<<<<<< - * self.pack_raw(bytes(value)) - * - */ - __pyx_t_9 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 104, __pyx_L1_error) - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->pack_bytes_header(__pyx_v_self, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 104, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":105 - * elif isinstance(value, bytearray): - * self.pack_bytes_header(len(value)) - * self.pack_raw(bytes(value)) # <<<<<<<<<<<<<< - * - * # List - */ - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 105, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_v_value); - __Pyx_GIVEREF(__pyx_v_value); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_value); - __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)(&PyBytes_Type)), __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 105, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->pack_raw(__pyx_v_self, __pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 105, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":103 - * self.pack_bytes_header(len(value)) - * self.pack_raw(value) - * elif isinstance(value, bytearray): # <<<<<<<<<<<<<< - * self.pack_bytes_header(len(value)) - * self.pack_raw(bytes(value)) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":108 - * - * # List - * elif isinstance(value, list): # <<<<<<<<<<<<<< - * self.pack_list_header(len(value)) - * for item in value: - */ - __pyx_t_3 = PyList_Check(__pyx_v_value); - __pyx_t_2 = (__pyx_t_3 != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":109 - * # List - * elif isinstance(value, list): - * self.pack_list_header(len(value)) # <<<<<<<<<<<<<< - * for item in value: - * self._pack(item) - */ - __pyx_t_9 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 109, __pyx_L1_error) - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->pack_list_header(__pyx_v_self, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":110 - * elif isinstance(value, list): - * self.pack_list_header(len(value)) - * for item in value: # <<<<<<<<<<<<<< - * self._pack(item) - * - */ - if (likely(PyList_CheckExact(__pyx_v_value)) || PyTuple_CheckExact(__pyx_v_value)) { - __pyx_t_4 = __pyx_v_value; __Pyx_INCREF(__pyx_t_4); __pyx_t_9 = 0; - __pyx_t_10 = NULL; - } else { - __pyx_t_9 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_v_value); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 110, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 110, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_10)) { - if (likely(PyList_CheckExact(__pyx_t_4))) { - if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 110, __pyx_L1_error) - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - #endif - } else { - if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_4)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_9); __Pyx_INCREF(__pyx_t_1); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 110, __pyx_L1_error) - #else - __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 110, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - #endif - } - } else { - __pyx_t_1 = __pyx_t_10(__pyx_t_4); - if (unlikely(!__pyx_t_1)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 110, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_1); - } - __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_1); - __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":111 - * self.pack_list_header(len(value)) - * for item in value: - * self._pack(item) # <<<<<<<<<<<<<< - * - * # Map - */ - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->_pack(__pyx_v_self, __pyx_v_item); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":110 - * elif isinstance(value, list): - * self.pack_list_header(len(value)) - * for item in value: # <<<<<<<<<<<<<< - * self._pack(item) - * - */ - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":108 - * - * # List - * elif isinstance(value, list): # <<<<<<<<<<<<<< - * self.pack_list_header(len(value)) - * for item in value: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":114 - * - * # Map - * elif isinstance(value, dict): # <<<<<<<<<<<<<< - * self.pack_map_header(len(value)) - * for key, item in value.items(): - */ - __pyx_t_2 = PyDict_Check(__pyx_v_value); - __pyx_t_3 = (__pyx_t_2 != 0); - if (__pyx_t_3) { - - /* "neo4j/packstream/_packer.pyx":115 - * # Map - * elif isinstance(value, dict): - * self.pack_map_header(len(value)) # <<<<<<<<<<<<<< - * for key, item in value.items(): - * self._pack(key) - */ - __pyx_t_9 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_9 == ((Py_ssize_t)-1))) __PYX_ERR(0, 115, __pyx_L1_error) - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->pack_map_header(__pyx_v_self, __pyx_t_9); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":116 - * elif isinstance(value, dict): - * self.pack_map_header(len(value)) - * for key, item in value.items(): # <<<<<<<<<<<<<< - * self._pack(key) - * self._pack(item) - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_items); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_1); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_1, function); - } - } - if (__pyx_t_5) { - __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else { - __pyx_t_4 = __Pyx_PyObject_CallNoArg(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (likely(PyList_CheckExact(__pyx_t_4)) || PyTuple_CheckExact(__pyx_t_4)) { - __pyx_t_1 = __pyx_t_4; __Pyx_INCREF(__pyx_t_1); __pyx_t_9 = 0; - __pyx_t_10 = NULL; - } else { - __pyx_t_9 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_10 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 116, __pyx_L1_error) - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - for (;;) { - if (likely(!__pyx_t_10)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_9 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 116, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } else { - if (__pyx_t_9 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_4 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_9); __Pyx_INCREF(__pyx_t_4); __pyx_t_9++; if (unlikely(0 < 0)) __PYX_ERR(0, 116, __pyx_L1_error) - #else - __pyx_t_4 = PySequence_ITEM(__pyx_t_1, __pyx_t_9); __pyx_t_9++; if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - } - } else { - __pyx_t_4 = __pyx_t_10(__pyx_t_1); - if (unlikely(!__pyx_t_4)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 116, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_4); - } - if ((likely(PyTuple_CheckExact(__pyx_t_4))) || (PyList_CheckExact(__pyx_t_4))) { - PyObject* sequence = __pyx_t_4; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 116, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_5 = PyList_GET_ITEM(sequence, 0); - __pyx_t_6 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - #endif - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_8 = PyObject_GetIter(__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 116, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_11 = Py_TYPE(__pyx_t_8)->tp_iternext; - index = 0; __pyx_t_5 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L10_unpacking_failed; - __Pyx_GOTREF(__pyx_t_5); - index = 1; __pyx_t_6 = __pyx_t_11(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L10_unpacking_failed; - __Pyx_GOTREF(__pyx_t_6); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_8), 2) < 0) __PYX_ERR(0, 116, __pyx_L1_error) - __pyx_t_11 = NULL; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - goto __pyx_L11_unpacking_done; - __pyx_L10_unpacking_failed:; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_11 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 116, __pyx_L1_error) - __pyx_L11_unpacking_done:; - } - __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_5); - __pyx_t_5 = 0; - __Pyx_XDECREF_SET(__pyx_v_item, __pyx_t_6); - __pyx_t_6 = 0; - - /* "neo4j/packstream/_packer.pyx":117 - * self.pack_map_header(len(value)) - * for key, item in value.items(): - * self._pack(key) # <<<<<<<<<<<<<< - * self._pack(item) - * - */ - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->_pack(__pyx_v_self, __pyx_v_key); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":118 - * for key, item in value.items(): - * self._pack(key) - * self._pack(item) # <<<<<<<<<<<<<< - * - * # Structure - */ - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->_pack(__pyx_v_self, __pyx_v_item); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - - /* "neo4j/packstream/_packer.pyx":116 - * elif isinstance(value, dict): - * self.pack_map_header(len(value)) - * for key, item in value.items(): # <<<<<<<<<<<<<< - * self._pack(key) - * self._pack(item) - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":114 - * - * # Map - * elif isinstance(value, dict): # <<<<<<<<<<<<<< - * self.pack_map_header(len(value)) - * for key, item in value.items(): - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":121 - * - * # Structure - * elif isinstance(value, Structure): # <<<<<<<<<<<<<< - * self.pack_struct(value.tag, value.fields) - * - */ - __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_Structure); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_IsInstance(__pyx_v_value, __pyx_t_1); if (unlikely(__pyx_t_3 == ((int)-1))) __PYX_ERR(0, 121, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = (__pyx_t_3 != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":122 - * # Structure - * elif isinstance(value, Structure): - * self.pack_struct(value.tag, value.fields) # <<<<<<<<<<<<<< - * - * # Other - */ - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_tag); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 122, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) __PYX_ERR(0, 122, __pyx_L1_error) - __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_value, __pyx_n_s_fields); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 122, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->pack_struct(__pyx_v_self, ((PyObject*)__pyx_t_1), __pyx_t_4, 0); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 122, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - - /* "neo4j/packstream/_packer.pyx":121 - * - * # Structure - * elif isinstance(value, Structure): # <<<<<<<<<<<<<< - * self.pack_struct(value.tag, value.fields) - * - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":126 - * # Other - * else: - * raise ValueError("Values of type %s are not supported" % type(value)) # <<<<<<<<<<<<<< - * - * cdef pack_bytes_header(self, int size): - */ - /*else*/ { - __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Values_of_type_s_are_not_support, ((PyObject *)Py_TYPE(__pyx_v_value))); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 126, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_Raise(__pyx_t_6, 0, 0, 0); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __PYX_ERR(0, 126, __pyx_L1_error) - } - __pyx_L3:; - - /* "neo4j/packstream/_packer.pyx":52 - * return self._pack(value) - * - * cdef _pack(self, value): # <<<<<<<<<<<<<< - * write = self._write - * - */ - - /* 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_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer._pack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_write); - __Pyx_XDECREF(__pyx_v_value_bytes); - __Pyx_XDECREF(__pyx_v_item); - __Pyx_XDECREF(__pyx_v_key); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":128 - * raise ValueError("Values of type %s are not supported" % type(value)) - * - * cdef pack_bytes_header(self, int size): # <<<<<<<<<<<<<< - * if not self.supports_bytes: - * raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") - */ - -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_bytes_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_v_size) { - PyObject *__pyx_v_write = 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; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("pack_bytes_header", 0); - - /* "neo4j/packstream/_packer.pyx":129 - * - * cdef pack_bytes_header(self, int size): - * if not self.supports_bytes: # <<<<<<<<<<<<<< - * raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") - * write = self._write - */ - __pyx_t_1 = ((!(__pyx_v_self->supports_bytes != 0)) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_packer.pyx":130 - * cdef pack_bytes_header(self, int size): - * if not self.supports_bytes: - * raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") # <<<<<<<<<<<<<< - * write = self._write - * if size < 0x100: - */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__18, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 130, __pyx_L1_error) - - /* "neo4j/packstream/_packer.pyx":129 - * - * cdef pack_bytes_header(self, int size): - * if not self.supports_bytes: # <<<<<<<<<<<<<< - * raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") - * write = self._write - */ - } - - /* "neo4j/packstream/_packer.pyx":131 - * if not self.supports_bytes: - * raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") - * write = self._write # <<<<<<<<<<<<<< - * if size < 0x100: - * write(b"\xCC") - */ - __pyx_t_2 = __pyx_v_self->_write; - __Pyx_INCREF(__pyx_t_2); - __pyx_v_write = __pyx_t_2; - __pyx_t_2 = 0; - - /* "neo4j/packstream/_packer.pyx":132 - * raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") - * write = self._write - * if size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xCC") - * write(PACKED_UINT_8[size]) - */ - __pyx_t_1 = ((__pyx_v_size < 0x100) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_packer.pyx":133 - * write = self._write - * if size < 0x100: - * write(b"\xCC") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__20, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_packer.pyx":134 - * if size < 0x100: - * write(b"\xCC") - * write(PACKED_UINT_8[size]) # <<<<<<<<<<<<<< - * elif size < 0x10000: - * write(b"\xCD") - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_size, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_3 = __pyx_v_write; __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_5) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 134, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_packer.pyx":132 - * raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") - * write = self._write - * if size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xCC") - * write(PACKED_UINT_8[size]) - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":135 - * write(b"\xCC") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xCD") - * write(PACKED_UINT_16[size]) - */ - __pyx_t_1 = ((__pyx_v_size < 0x10000) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_packer.pyx":136 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xCD") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__22, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_packer.pyx":137 - * elif size < 0x10000: - * write(b"\xCD") - * write(PACKED_UINT_16[size]) # <<<<<<<<<<<<<< - * elif size < 0x100000000: - * write(b"\xCE") - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_size, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_3 = __pyx_v_write; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_packer.pyx":135 - * write(b"\xCC") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xCD") - * write(PACKED_UINT_16[size]) - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":138 - * write(b"\xCD") - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: # <<<<<<<<<<<<<< - * write(b"\xCE") - * write(struct_pack(">I", size)) - */ - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_2, __pyx_int_4294967296, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 138, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_1) { - - /* "neo4j/packstream/_packer.pyx":139 - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - * write(b"\xCE") # <<<<<<<<<<<<<< - * write(struct_pack(">I", size)) - * else: - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__24, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "neo4j/packstream/_packer.pyx":140 - * elif size < 0x100000000: - * write(b"\xCE") - * write(struct_pack(">I", size)) # <<<<<<<<<<<<<< - * else: - * raise OverflowError("Bytes header size out of range") - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_pack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_5 = __pyx_v_write; __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_8) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_2}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_2}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "neo4j/packstream/_packer.pyx":138 - * write(b"\xCD") - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: # <<<<<<<<<<<<<< - * write(b"\xCE") - * write(struct_pack(">I", size)) - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":142 - * write(struct_pack(">I", size)) - * else: - * raise OverflowError("Bytes header size out of range") # <<<<<<<<<<<<<< - * - * cdef pack_string_header(self, int size): - */ - /*else*/ { - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OverflowError, __pyx_tuple__25, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 142, __pyx_L1_error) - } - __pyx_L4:; - - /* "neo4j/packstream/_packer.pyx":128 - * raise ValueError("Values of type %s are not supported" % type(value)) - * - * cdef pack_bytes_header(self, int size): # <<<<<<<<<<<<<< - * if not self.supports_bytes: - * raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") - */ - - /* 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_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.pack_bytes_header", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_write); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":144 - * raise OverflowError("Bytes header size out of range") - * - * cdef pack_string_header(self, int size): # <<<<<<<<<<<<<< - * write = self._write - * if size == 0x00: - */ - -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_string_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_v_size) { - PyObject *__pyx_v_write = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("pack_string_header", 0); - - /* "neo4j/packstream/_packer.pyx":145 - * - * cdef pack_string_header(self, int size): - * write = self._write # <<<<<<<<<<<<<< - * if size == 0x00: - * write(b"\x80") - */ - __pyx_t_1 = __pyx_v_self->_write; - __Pyx_INCREF(__pyx_t_1); - __pyx_v_write = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":146 - * cdef pack_string_header(self, int size): - * write = self._write - * if size == 0x00: # <<<<<<<<<<<<<< - * write(b"\x80") - * elif size == 0x01: - */ - __pyx_t_2 = ((__pyx_v_size == 0x00) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":147 - * write = self._write - * if size == 0x00: - * write(b"\x80") # <<<<<<<<<<<<<< - * elif size == 0x01: - * write(b"\x81") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__27, NULL); 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; - - /* "neo4j/packstream/_packer.pyx":146 - * cdef pack_string_header(self, int size): - * write = self._write - * if size == 0x00: # <<<<<<<<<<<<<< - * write(b"\x80") - * elif size == 0x01: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":148 - * if size == 0x00: - * write(b"\x80") - * elif size == 0x01: # <<<<<<<<<<<<<< - * write(b"\x81") - * elif size == 0x02: - */ - __pyx_t_2 = ((__pyx_v_size == 0x01) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":149 - * write(b"\x80") - * elif size == 0x01: - * write(b"\x81") # <<<<<<<<<<<<<< - * elif size == 0x02: - * write(b"\x82") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__29, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":148 - * if size == 0x00: - * write(b"\x80") - * elif size == 0x01: # <<<<<<<<<<<<<< - * write(b"\x81") - * elif size == 0x02: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":150 - * elif size == 0x01: - * write(b"\x81") - * elif size == 0x02: # <<<<<<<<<<<<<< - * write(b"\x82") - * elif size == 0x03: - */ - __pyx_t_2 = ((__pyx_v_size == 0x02) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":151 - * write(b"\x81") - * elif size == 0x02: - * write(b"\x82") # <<<<<<<<<<<<<< - * elif size == 0x03: - * write(b"\x83") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__31, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":150 - * elif size == 0x01: - * write(b"\x81") - * elif size == 0x02: # <<<<<<<<<<<<<< - * write(b"\x82") - * elif size == 0x03: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":152 - * elif size == 0x02: - * write(b"\x82") - * elif size == 0x03: # <<<<<<<<<<<<<< - * write(b"\x83") - * elif size == 0x04: - */ - __pyx_t_2 = ((__pyx_v_size == 0x03) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":153 - * write(b"\x82") - * elif size == 0x03: - * write(b"\x83") # <<<<<<<<<<<<<< - * elif size == 0x04: - * write(b"\x84") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__33, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":152 - * elif size == 0x02: - * write(b"\x82") - * elif size == 0x03: # <<<<<<<<<<<<<< - * write(b"\x83") - * elif size == 0x04: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":154 - * elif size == 0x03: - * write(b"\x83") - * elif size == 0x04: # <<<<<<<<<<<<<< - * write(b"\x84") - * elif size == 0x05: - */ - __pyx_t_2 = ((__pyx_v_size == 0x04) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":155 - * write(b"\x83") - * elif size == 0x04: - * write(b"\x84") # <<<<<<<<<<<<<< - * elif size == 0x05: - * write(b"\x85") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__35, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":154 - * elif size == 0x03: - * write(b"\x83") - * elif size == 0x04: # <<<<<<<<<<<<<< - * write(b"\x84") - * elif size == 0x05: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":156 - * elif size == 0x04: - * write(b"\x84") - * elif size == 0x05: # <<<<<<<<<<<<<< - * write(b"\x85") - * elif size == 0x06: - */ - __pyx_t_2 = ((__pyx_v_size == 0x05) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":157 - * write(b"\x84") - * elif size == 0x05: - * write(b"\x85") # <<<<<<<<<<<<<< - * elif size == 0x06: - * write(b"\x86") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__37, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 157, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":156 - * elif size == 0x04: - * write(b"\x84") - * elif size == 0x05: # <<<<<<<<<<<<<< - * write(b"\x85") - * elif size == 0x06: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":158 - * elif size == 0x05: - * write(b"\x85") - * elif size == 0x06: # <<<<<<<<<<<<<< - * write(b"\x86") - * elif size == 0x07: - */ - __pyx_t_2 = ((__pyx_v_size == 0x06) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":159 - * write(b"\x85") - * elif size == 0x06: - * write(b"\x86") # <<<<<<<<<<<<<< - * elif size == 0x07: - * write(b"\x87") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__39, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":158 - * elif size == 0x05: - * write(b"\x85") - * elif size == 0x06: # <<<<<<<<<<<<<< - * write(b"\x86") - * elif size == 0x07: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":160 - * elif size == 0x06: - * write(b"\x86") - * elif size == 0x07: # <<<<<<<<<<<<<< - * write(b"\x87") - * elif size == 0x08: - */ - __pyx_t_2 = ((__pyx_v_size == 0x07) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":161 - * write(b"\x86") - * elif size == 0x07: - * write(b"\x87") # <<<<<<<<<<<<<< - * elif size == 0x08: - * write(b"\x88") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__41, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":160 - * elif size == 0x06: - * write(b"\x86") - * elif size == 0x07: # <<<<<<<<<<<<<< - * write(b"\x87") - * elif size == 0x08: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":162 - * elif size == 0x07: - * write(b"\x87") - * elif size == 0x08: # <<<<<<<<<<<<<< - * write(b"\x88") - * elif size == 0x09: - */ - __pyx_t_2 = ((__pyx_v_size == 0x08) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":163 - * write(b"\x87") - * elif size == 0x08: - * write(b"\x88") # <<<<<<<<<<<<<< - * elif size == 0x09: - * write(b"\x89") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__43, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":162 - * elif size == 0x07: - * write(b"\x87") - * elif size == 0x08: # <<<<<<<<<<<<<< - * write(b"\x88") - * elif size == 0x09: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":164 - * elif size == 0x08: - * write(b"\x88") - * elif size == 0x09: # <<<<<<<<<<<<<< - * write(b"\x89") - * elif size == 0x0A: - */ - __pyx_t_2 = ((__pyx_v_size == 0x09) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":165 - * write(b"\x88") - * elif size == 0x09: - * write(b"\x89") # <<<<<<<<<<<<<< - * elif size == 0x0A: - * write(b"\x8A") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__45, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":164 - * elif size == 0x08: - * write(b"\x88") - * elif size == 0x09: # <<<<<<<<<<<<<< - * write(b"\x89") - * elif size == 0x0A: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":166 - * elif size == 0x09: - * write(b"\x89") - * elif size == 0x0A: # <<<<<<<<<<<<<< - * write(b"\x8A") - * elif size == 0x0B: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0A) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":167 - * write(b"\x89") - * elif size == 0x0A: - * write(b"\x8A") # <<<<<<<<<<<<<< - * elif size == 0x0B: - * write(b"\x8B") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__47, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":166 - * elif size == 0x09: - * write(b"\x89") - * elif size == 0x0A: # <<<<<<<<<<<<<< - * write(b"\x8A") - * elif size == 0x0B: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":168 - * elif size == 0x0A: - * write(b"\x8A") - * elif size == 0x0B: # <<<<<<<<<<<<<< - * write(b"\x8B") - * elif size == 0x0C: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0B) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":169 - * write(b"\x8A") - * elif size == 0x0B: - * write(b"\x8B") # <<<<<<<<<<<<<< - * elif size == 0x0C: - * write(b"\x8C") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__49, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":168 - * elif size == 0x0A: - * write(b"\x8A") - * elif size == 0x0B: # <<<<<<<<<<<<<< - * write(b"\x8B") - * elif size == 0x0C: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":170 - * elif size == 0x0B: - * write(b"\x8B") - * elif size == 0x0C: # <<<<<<<<<<<<<< - * write(b"\x8C") - * elif size == 0x0D: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0C) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":171 - * write(b"\x8B") - * elif size == 0x0C: - * write(b"\x8C") # <<<<<<<<<<<<<< - * elif size == 0x0D: - * write(b"\x8D") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__51, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 171, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":170 - * elif size == 0x0B: - * write(b"\x8B") - * elif size == 0x0C: # <<<<<<<<<<<<<< - * write(b"\x8C") - * elif size == 0x0D: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":172 - * elif size == 0x0C: - * write(b"\x8C") - * elif size == 0x0D: # <<<<<<<<<<<<<< - * write(b"\x8D") - * elif size == 0x0E: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0D) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":173 - * write(b"\x8C") - * elif size == 0x0D: - * write(b"\x8D") # <<<<<<<<<<<<<< - * elif size == 0x0E: - * write(b"\x8E") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__53, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 173, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":172 - * elif size == 0x0C: - * write(b"\x8C") - * elif size == 0x0D: # <<<<<<<<<<<<<< - * write(b"\x8D") - * elif size == 0x0E: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":174 - * elif size == 0x0D: - * write(b"\x8D") - * elif size == 0x0E: # <<<<<<<<<<<<<< - * write(b"\x8E") - * elif size == 0x0F: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0E) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":175 - * write(b"\x8D") - * elif size == 0x0E: - * write(b"\x8E") # <<<<<<<<<<<<<< - * elif size == 0x0F: - * write(b"\x8F") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__55, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":174 - * elif size == 0x0D: - * write(b"\x8D") - * elif size == 0x0E: # <<<<<<<<<<<<<< - * write(b"\x8E") - * elif size == 0x0F: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":176 - * elif size == 0x0E: - * write(b"\x8E") - * elif size == 0x0F: # <<<<<<<<<<<<<< - * write(b"\x8F") - * elif size < 0x100: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0F) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":177 - * write(b"\x8E") - * elif size == 0x0F: - * write(b"\x8F") # <<<<<<<<<<<<<< - * elif size < 0x100: - * write(b"\xD0") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__57, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":176 - * elif size == 0x0E: - * write(b"\x8E") - * elif size == 0x0F: # <<<<<<<<<<<<<< - * write(b"\x8F") - * elif size < 0x100: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":178 - * elif size == 0x0F: - * write(b"\x8F") - * elif size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xD0") - * write(PACKED_UINT_8[size]) - */ - __pyx_t_2 = ((__pyx_v_size < 0x100) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":179 - * write(b"\x8F") - * elif size < 0x100: - * write(b"\xD0") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__59, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 179, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":180 - * elif size < 0x100: - * write(b"\xD0") - * write(PACKED_UINT_8[size]) # <<<<<<<<<<<<<< - * elif size < 0x10000: - * write(b"\xD1") - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_size, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_3 = __pyx_v_write; __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_5) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 180, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":178 - * elif size == 0x0F: - * write(b"\x8F") - * elif size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xD0") - * write(PACKED_UINT_8[size]) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":181 - * write(b"\xD0") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xD1") - * write(PACKED_UINT_16[size]) - */ - __pyx_t_2 = ((__pyx_v_size < 0x10000) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":182 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xD1") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__61, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":183 - * elif size < 0x10000: - * write(b"\xD1") - * write(PACKED_UINT_16[size]) # <<<<<<<<<<<<<< - * elif size < 0x100000000: - * write(b"\xD2") - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_size, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_3 = __pyx_v_write; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 183, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":181 - * write(b"\xD0") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xD1") - * write(PACKED_UINT_16[size]) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":184 - * write(b"\xD1") - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: # <<<<<<<<<<<<<< - * write(b"\xD2") - * write(struct_pack(">I", size)) - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_4294967296, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":185 - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - * write(b"\xD2") # <<<<<<<<<<<<<< - * write(struct_pack(">I", size)) - * else: - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__63, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "neo4j/packstream/_packer.pyx":186 - * elif size < 0x100000000: - * write(b"\xD2") - * write(struct_pack(">I", size)) # <<<<<<<<<<<<<< - * else: - * raise OverflowError("String header size out of range") - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_pack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_5 = __pyx_v_write; __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_8) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 186, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "neo4j/packstream/_packer.pyx":184 - * write(b"\xD1") - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: # <<<<<<<<<<<<<< - * write(b"\xD2") - * write(struct_pack(">I", size)) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":188 - * write(struct_pack(">I", size)) - * else: - * raise OverflowError("String header size out of range") # <<<<<<<<<<<<<< - * - * cdef pack_list_header(self, int size): - */ - /*else*/ { - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OverflowError, __pyx_tuple__64, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 188, __pyx_L1_error) - } - __pyx_L3:; - - /* "neo4j/packstream/_packer.pyx":144 - * raise OverflowError("Bytes header size out of range") - * - * cdef pack_string_header(self, int size): # <<<<<<<<<<<<<< - * write = self._write - * if size == 0x00: - */ - - /* 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_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.pack_string_header", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_write); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":190 - * raise OverflowError("String header size out of range") - * - * cdef pack_list_header(self, int size): # <<<<<<<<<<<<<< - * write = self._write - * if size == 0x00: - */ - -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_list_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_v_size) { - PyObject *__pyx_v_write = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("pack_list_header", 0); - - /* "neo4j/packstream/_packer.pyx":191 - * - * cdef pack_list_header(self, int size): - * write = self._write # <<<<<<<<<<<<<< - * if size == 0x00: - * write(b"\x90") - */ - __pyx_t_1 = __pyx_v_self->_write; - __Pyx_INCREF(__pyx_t_1); - __pyx_v_write = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":192 - * cdef pack_list_header(self, int size): - * write = self._write - * if size == 0x00: # <<<<<<<<<<<<<< - * write(b"\x90") - * elif size == 0x01: - */ - __pyx_t_2 = ((__pyx_v_size == 0x00) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":193 - * write = self._write - * if size == 0x00: - * write(b"\x90") # <<<<<<<<<<<<<< - * elif size == 0x01: - * write(b"\x91") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__66, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":192 - * cdef pack_list_header(self, int size): - * write = self._write - * if size == 0x00: # <<<<<<<<<<<<<< - * write(b"\x90") - * elif size == 0x01: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":194 - * if size == 0x00: - * write(b"\x90") - * elif size == 0x01: # <<<<<<<<<<<<<< - * write(b"\x91") - * elif size == 0x02: - */ - __pyx_t_2 = ((__pyx_v_size == 0x01) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":195 - * write(b"\x90") - * elif size == 0x01: - * write(b"\x91") # <<<<<<<<<<<<<< - * elif size == 0x02: - * write(b"\x92") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__68, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":194 - * if size == 0x00: - * write(b"\x90") - * elif size == 0x01: # <<<<<<<<<<<<<< - * write(b"\x91") - * elif size == 0x02: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":196 - * elif size == 0x01: - * write(b"\x91") - * elif size == 0x02: # <<<<<<<<<<<<<< - * write(b"\x92") - * elif size == 0x03: - */ - __pyx_t_2 = ((__pyx_v_size == 0x02) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":197 - * write(b"\x91") - * elif size == 0x02: - * write(b"\x92") # <<<<<<<<<<<<<< - * elif size == 0x03: - * write(b"\x93") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__70, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":196 - * elif size == 0x01: - * write(b"\x91") - * elif size == 0x02: # <<<<<<<<<<<<<< - * write(b"\x92") - * elif size == 0x03: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":198 - * elif size == 0x02: - * write(b"\x92") - * elif size == 0x03: # <<<<<<<<<<<<<< - * write(b"\x93") - * elif size == 0x04: - */ - __pyx_t_2 = ((__pyx_v_size == 0x03) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":199 - * write(b"\x92") - * elif size == 0x03: - * write(b"\x93") # <<<<<<<<<<<<<< - * elif size == 0x04: - * write(b"\x94") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__72, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":198 - * elif size == 0x02: - * write(b"\x92") - * elif size == 0x03: # <<<<<<<<<<<<<< - * write(b"\x93") - * elif size == 0x04: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":200 - * elif size == 0x03: - * write(b"\x93") - * elif size == 0x04: # <<<<<<<<<<<<<< - * write(b"\x94") - * elif size == 0x05: - */ - __pyx_t_2 = ((__pyx_v_size == 0x04) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":201 - * write(b"\x93") - * elif size == 0x04: - * write(b"\x94") # <<<<<<<<<<<<<< - * elif size == 0x05: - * write(b"\x95") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__74, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":200 - * elif size == 0x03: - * write(b"\x93") - * elif size == 0x04: # <<<<<<<<<<<<<< - * write(b"\x94") - * elif size == 0x05: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":202 - * elif size == 0x04: - * write(b"\x94") - * elif size == 0x05: # <<<<<<<<<<<<<< - * write(b"\x95") - * elif size == 0x06: - */ - __pyx_t_2 = ((__pyx_v_size == 0x05) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":203 - * write(b"\x94") - * elif size == 0x05: - * write(b"\x95") # <<<<<<<<<<<<<< - * elif size == 0x06: - * write(b"\x96") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__76, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":202 - * elif size == 0x04: - * write(b"\x94") - * elif size == 0x05: # <<<<<<<<<<<<<< - * write(b"\x95") - * elif size == 0x06: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":204 - * elif size == 0x05: - * write(b"\x95") - * elif size == 0x06: # <<<<<<<<<<<<<< - * write(b"\x96") - * elif size == 0x07: - */ - __pyx_t_2 = ((__pyx_v_size == 0x06) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":205 - * write(b"\x95") - * elif size == 0x06: - * write(b"\x96") # <<<<<<<<<<<<<< - * elif size == 0x07: - * write(b"\x97") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__78, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":204 - * elif size == 0x05: - * write(b"\x95") - * elif size == 0x06: # <<<<<<<<<<<<<< - * write(b"\x96") - * elif size == 0x07: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":206 - * elif size == 0x06: - * write(b"\x96") - * elif size == 0x07: # <<<<<<<<<<<<<< - * write(b"\x97") - * elif size == 0x08: - */ - __pyx_t_2 = ((__pyx_v_size == 0x07) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":207 - * write(b"\x96") - * elif size == 0x07: - * write(b"\x97") # <<<<<<<<<<<<<< - * elif size == 0x08: - * write(b"\x98") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__80, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":206 - * elif size == 0x06: - * write(b"\x96") - * elif size == 0x07: # <<<<<<<<<<<<<< - * write(b"\x97") - * elif size == 0x08: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":208 - * elif size == 0x07: - * write(b"\x97") - * elif size == 0x08: # <<<<<<<<<<<<<< - * write(b"\x98") - * elif size == 0x09: - */ - __pyx_t_2 = ((__pyx_v_size == 0x08) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":209 - * write(b"\x97") - * elif size == 0x08: - * write(b"\x98") # <<<<<<<<<<<<<< - * elif size == 0x09: - * write(b"\x99") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__82, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":208 - * elif size == 0x07: - * write(b"\x97") - * elif size == 0x08: # <<<<<<<<<<<<<< - * write(b"\x98") - * elif size == 0x09: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":210 - * elif size == 0x08: - * write(b"\x98") - * elif size == 0x09: # <<<<<<<<<<<<<< - * write(b"\x99") - * elif size == 0x0A: - */ - __pyx_t_2 = ((__pyx_v_size == 0x09) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":211 - * write(b"\x98") - * elif size == 0x09: - * write(b"\x99") # <<<<<<<<<<<<<< - * elif size == 0x0A: - * write(b"\x9A") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__84, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":210 - * elif size == 0x08: - * write(b"\x98") - * elif size == 0x09: # <<<<<<<<<<<<<< - * write(b"\x99") - * elif size == 0x0A: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":212 - * elif size == 0x09: - * write(b"\x99") - * elif size == 0x0A: # <<<<<<<<<<<<<< - * write(b"\x9A") - * elif size == 0x0B: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0A) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":213 - * write(b"\x99") - * elif size == 0x0A: - * write(b"\x9A") # <<<<<<<<<<<<<< - * elif size == 0x0B: - * write(b"\x9B") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__86, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 213, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":212 - * elif size == 0x09: - * write(b"\x99") - * elif size == 0x0A: # <<<<<<<<<<<<<< - * write(b"\x9A") - * elif size == 0x0B: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":214 - * elif size == 0x0A: - * write(b"\x9A") - * elif size == 0x0B: # <<<<<<<<<<<<<< - * write(b"\x9B") - * elif size == 0x0C: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0B) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":215 - * write(b"\x9A") - * elif size == 0x0B: - * write(b"\x9B") # <<<<<<<<<<<<<< - * elif size == 0x0C: - * write(b"\x9C") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__88, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":214 - * elif size == 0x0A: - * write(b"\x9A") - * elif size == 0x0B: # <<<<<<<<<<<<<< - * write(b"\x9B") - * elif size == 0x0C: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":216 - * elif size == 0x0B: - * write(b"\x9B") - * elif size == 0x0C: # <<<<<<<<<<<<<< - * write(b"\x9C") - * elif size == 0x0D: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0C) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":217 - * write(b"\x9B") - * elif size == 0x0C: - * write(b"\x9C") # <<<<<<<<<<<<<< - * elif size == 0x0D: - * write(b"\x9D") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__90, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":216 - * elif size == 0x0B: - * write(b"\x9B") - * elif size == 0x0C: # <<<<<<<<<<<<<< - * write(b"\x9C") - * elif size == 0x0D: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":218 - * elif size == 0x0C: - * write(b"\x9C") - * elif size == 0x0D: # <<<<<<<<<<<<<< - * write(b"\x9D") - * elif size == 0x0E: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0D) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":219 - * write(b"\x9C") - * elif size == 0x0D: - * write(b"\x9D") # <<<<<<<<<<<<<< - * elif size == 0x0E: - * write(b"\x9E") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__92, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 219, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":218 - * elif size == 0x0C: - * write(b"\x9C") - * elif size == 0x0D: # <<<<<<<<<<<<<< - * write(b"\x9D") - * elif size == 0x0E: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":220 - * elif size == 0x0D: - * write(b"\x9D") - * elif size == 0x0E: # <<<<<<<<<<<<<< - * write(b"\x9E") - * elif size == 0x0F: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0E) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":221 - * write(b"\x9D") - * elif size == 0x0E: - * write(b"\x9E") # <<<<<<<<<<<<<< - * elif size == 0x0F: - * write(b"\x9F") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__94, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":220 - * elif size == 0x0D: - * write(b"\x9D") - * elif size == 0x0E: # <<<<<<<<<<<<<< - * write(b"\x9E") - * elif size == 0x0F: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":222 - * elif size == 0x0E: - * write(b"\x9E") - * elif size == 0x0F: # <<<<<<<<<<<<<< - * write(b"\x9F") - * elif size < 0x100: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0F) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":223 - * write(b"\x9E") - * elif size == 0x0F: - * write(b"\x9F") # <<<<<<<<<<<<<< - * elif size < 0x100: - * write(b"\xD4") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__96, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":222 - * elif size == 0x0E: - * write(b"\x9E") - * elif size == 0x0F: # <<<<<<<<<<<<<< - * write(b"\x9F") - * elif size < 0x100: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":224 - * elif size == 0x0F: - * write(b"\x9F") - * elif size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xD4") - * write(PACKED_UINT_8[size]) - */ - __pyx_t_2 = ((__pyx_v_size < 0x100) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":225 - * write(b"\x9F") - * elif size < 0x100: - * write(b"\xD4") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__98, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 225, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":226 - * elif size < 0x100: - * write(b"\xD4") - * write(PACKED_UINT_8[size]) # <<<<<<<<<<<<<< - * elif size < 0x10000: - * write(b"\xD5") - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_size, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_3 = __pyx_v_write; __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_5) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":224 - * elif size == 0x0F: - * write(b"\x9F") - * elif size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xD4") - * write(PACKED_UINT_8[size]) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":227 - * write(b"\xD4") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xD5") - * write(PACKED_UINT_16[size]) - */ - __pyx_t_2 = ((__pyx_v_size < 0x10000) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":228 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xD5") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__100, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 228, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":229 - * elif size < 0x10000: - * write(b"\xD5") - * write(PACKED_UINT_16[size]) # <<<<<<<<<<<<<< - * elif size < 0x100000000: - * write(b"\xD6") - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_size, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_3 = __pyx_v_write; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 229, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":227 - * write(b"\xD4") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xD5") - * write(PACKED_UINT_16[size]) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":230 - * write(b"\xD5") - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: # <<<<<<<<<<<<<< - * write(b"\xD6") - * write(struct_pack(">I", size)) - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 230, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_4294967296, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 230, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 230, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":231 - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - * write(b"\xD6") # <<<<<<<<<<<<<< - * write(struct_pack(">I", size)) - * else: - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__102, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 231, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "neo4j/packstream/_packer.pyx":232 - * elif size < 0x100000000: - * write(b"\xD6") - * write(struct_pack(">I", size)) # <<<<<<<<<<<<<< - * else: - * raise OverflowError("List header size out of range") - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_pack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_5 = __pyx_v_write; __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_8) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 232, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "neo4j/packstream/_packer.pyx":230 - * write(b"\xD5") - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: # <<<<<<<<<<<<<< - * write(b"\xD6") - * write(struct_pack(">I", size)) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":234 - * write(struct_pack(">I", size)) - * else: - * raise OverflowError("List header size out of range") # <<<<<<<<<<<<<< - * - * cpdef pack_list_stream_header(self): - */ - /*else*/ { - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OverflowError, __pyx_tuple__103, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 234, __pyx_L1_error) - } - __pyx_L3:; - - /* "neo4j/packstream/_packer.pyx":190 - * raise OverflowError("String header size out of range") - * - * cdef pack_list_header(self, int size): # <<<<<<<<<<<<<< - * write = self._write - * if size == 0x00: - */ - - /* 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_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.pack_list_header", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_write); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":236 - * raise OverflowError("List header size out of range") - * - * cpdef pack_list_stream_header(self): # <<<<<<<<<<<<<< - * self._write(b"\xD7") - * - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_5pack_list_stream_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_list_stream_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__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; - __Pyx_RefNannySetupContext("pack_list_stream_header", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pack_list_stream_header); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_5pack_list_stream_header)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_packer.pyx":237 - * - * cpdef pack_list_stream_header(self): - * self._write(b"\xD7") # <<<<<<<<<<<<<< - * - * cdef pack_map_header(self, int size): - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_self->_write, __pyx_tuple__105, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":236 - * raise OverflowError("List header size out of range") - * - * cpdef pack_list_stream_header(self): # <<<<<<<<<<<<<< - * self._write(b"\xD7") - * - */ - - /* 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("neo4j.packstream._packer.Packer.pack_list_stream_header", __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_5neo4j_10packstream_7_packer_6Packer_5pack_list_stream_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_5pack_list_stream_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("pack_list_stream_header (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer_4pack_list_stream_header(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_4pack_list_stream_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("pack_list_stream_header", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_list_stream_header(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __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("neo4j.packstream._packer.Packer.pack_list_stream_header", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":239 - * self._write(b"\xD7") - * - * cdef pack_map_header(self, int size): # <<<<<<<<<<<<<< - * write = self._write - * if size == 0x00: - */ - -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_map_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, int __pyx_v_size) { - PyObject *__pyx_v_write = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - int __pyx_t_2; - PyObject *__pyx_t_3 = NULL; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - __Pyx_RefNannySetupContext("pack_map_header", 0); - - /* "neo4j/packstream/_packer.pyx":240 - * - * cdef pack_map_header(self, int size): - * write = self._write # <<<<<<<<<<<<<< - * if size == 0x00: - * write(b"\xA0") - */ - __pyx_t_1 = __pyx_v_self->_write; - __Pyx_INCREF(__pyx_t_1); - __pyx_v_write = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":241 - * cdef pack_map_header(self, int size): - * write = self._write - * if size == 0x00: # <<<<<<<<<<<<<< - * write(b"\xA0") - * elif size == 0x01: - */ - __pyx_t_2 = ((__pyx_v_size == 0x00) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":242 - * write = self._write - * if size == 0x00: - * write(b"\xA0") # <<<<<<<<<<<<<< - * elif size == 0x01: - * write(b"\xA1") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__107, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":241 - * cdef pack_map_header(self, int size): - * write = self._write - * if size == 0x00: # <<<<<<<<<<<<<< - * write(b"\xA0") - * elif size == 0x01: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":243 - * if size == 0x00: - * write(b"\xA0") - * elif size == 0x01: # <<<<<<<<<<<<<< - * write(b"\xA1") - * elif size == 0x02: - */ - __pyx_t_2 = ((__pyx_v_size == 0x01) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":244 - * write(b"\xA0") - * elif size == 0x01: - * write(b"\xA1") # <<<<<<<<<<<<<< - * elif size == 0x02: - * write(b"\xA2") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__109, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":243 - * if size == 0x00: - * write(b"\xA0") - * elif size == 0x01: # <<<<<<<<<<<<<< - * write(b"\xA1") - * elif size == 0x02: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":245 - * elif size == 0x01: - * write(b"\xA1") - * elif size == 0x02: # <<<<<<<<<<<<<< - * write(b"\xA2") - * elif size == 0x03: - */ - __pyx_t_2 = ((__pyx_v_size == 0x02) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":246 - * write(b"\xA1") - * elif size == 0x02: - * write(b"\xA2") # <<<<<<<<<<<<<< - * elif size == 0x03: - * write(b"\xA3") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__111, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":245 - * elif size == 0x01: - * write(b"\xA1") - * elif size == 0x02: # <<<<<<<<<<<<<< - * write(b"\xA2") - * elif size == 0x03: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":247 - * elif size == 0x02: - * write(b"\xA2") - * elif size == 0x03: # <<<<<<<<<<<<<< - * write(b"\xA3") - * elif size == 0x04: - */ - __pyx_t_2 = ((__pyx_v_size == 0x03) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":248 - * write(b"\xA2") - * elif size == 0x03: - * write(b"\xA3") # <<<<<<<<<<<<<< - * elif size == 0x04: - * write(b"\xA4") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__113, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":247 - * elif size == 0x02: - * write(b"\xA2") - * elif size == 0x03: # <<<<<<<<<<<<<< - * write(b"\xA3") - * elif size == 0x04: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":249 - * elif size == 0x03: - * write(b"\xA3") - * elif size == 0x04: # <<<<<<<<<<<<<< - * write(b"\xA4") - * elif size == 0x05: - */ - __pyx_t_2 = ((__pyx_v_size == 0x04) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":250 - * write(b"\xA3") - * elif size == 0x04: - * write(b"\xA4") # <<<<<<<<<<<<<< - * elif size == 0x05: - * write(b"\xA5") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__115, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 250, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":249 - * elif size == 0x03: - * write(b"\xA3") - * elif size == 0x04: # <<<<<<<<<<<<<< - * write(b"\xA4") - * elif size == 0x05: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":251 - * elif size == 0x04: - * write(b"\xA4") - * elif size == 0x05: # <<<<<<<<<<<<<< - * write(b"\xA5") - * elif size == 0x06: - */ - __pyx_t_2 = ((__pyx_v_size == 0x05) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":252 - * write(b"\xA4") - * elif size == 0x05: - * write(b"\xA5") # <<<<<<<<<<<<<< - * elif size == 0x06: - * write(b"\xA6") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__117, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":251 - * elif size == 0x04: - * write(b"\xA4") - * elif size == 0x05: # <<<<<<<<<<<<<< - * write(b"\xA5") - * elif size == 0x06: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":253 - * elif size == 0x05: - * write(b"\xA5") - * elif size == 0x06: # <<<<<<<<<<<<<< - * write(b"\xA6") - * elif size == 0x07: - */ - __pyx_t_2 = ((__pyx_v_size == 0x06) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":254 - * write(b"\xA5") - * elif size == 0x06: - * write(b"\xA6") # <<<<<<<<<<<<<< - * elif size == 0x07: - * write(b"\xA7") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__119, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":253 - * elif size == 0x05: - * write(b"\xA5") - * elif size == 0x06: # <<<<<<<<<<<<<< - * write(b"\xA6") - * elif size == 0x07: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":255 - * elif size == 0x06: - * write(b"\xA6") - * elif size == 0x07: # <<<<<<<<<<<<<< - * write(b"\xA7") - * elif size == 0x08: - */ - __pyx_t_2 = ((__pyx_v_size == 0x07) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":256 - * write(b"\xA6") - * elif size == 0x07: - * write(b"\xA7") # <<<<<<<<<<<<<< - * elif size == 0x08: - * write(b"\xA8") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__121, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":255 - * elif size == 0x06: - * write(b"\xA6") - * elif size == 0x07: # <<<<<<<<<<<<<< - * write(b"\xA7") - * elif size == 0x08: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":257 - * elif size == 0x07: - * write(b"\xA7") - * elif size == 0x08: # <<<<<<<<<<<<<< - * write(b"\xA8") - * elif size == 0x09: - */ - __pyx_t_2 = ((__pyx_v_size == 0x08) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":258 - * write(b"\xA7") - * elif size == 0x08: - * write(b"\xA8") # <<<<<<<<<<<<<< - * elif size == 0x09: - * write(b"\xA9") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__123, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 258, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":257 - * elif size == 0x07: - * write(b"\xA7") - * elif size == 0x08: # <<<<<<<<<<<<<< - * write(b"\xA8") - * elif size == 0x09: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":259 - * elif size == 0x08: - * write(b"\xA8") - * elif size == 0x09: # <<<<<<<<<<<<<< - * write(b"\xA9") - * elif size == 0x0A: - */ - __pyx_t_2 = ((__pyx_v_size == 0x09) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":260 - * write(b"\xA8") - * elif size == 0x09: - * write(b"\xA9") # <<<<<<<<<<<<<< - * elif size == 0x0A: - * write(b"\xAA") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__125, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":259 - * elif size == 0x08: - * write(b"\xA8") - * elif size == 0x09: # <<<<<<<<<<<<<< - * write(b"\xA9") - * elif size == 0x0A: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":261 - * elif size == 0x09: - * write(b"\xA9") - * elif size == 0x0A: # <<<<<<<<<<<<<< - * write(b"\xAA") - * elif size == 0x0B: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0A) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":262 - * write(b"\xA9") - * elif size == 0x0A: - * write(b"\xAA") # <<<<<<<<<<<<<< - * elif size == 0x0B: - * write(b"\xAB") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__127, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":261 - * elif size == 0x09: - * write(b"\xA9") - * elif size == 0x0A: # <<<<<<<<<<<<<< - * write(b"\xAA") - * elif size == 0x0B: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":263 - * elif size == 0x0A: - * write(b"\xAA") - * elif size == 0x0B: # <<<<<<<<<<<<<< - * write(b"\xAB") - * elif size == 0x0C: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0B) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":264 - * write(b"\xAA") - * elif size == 0x0B: - * write(b"\xAB") # <<<<<<<<<<<<<< - * elif size == 0x0C: - * write(b"\xAC") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__129, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 264, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":263 - * elif size == 0x0A: - * write(b"\xAA") - * elif size == 0x0B: # <<<<<<<<<<<<<< - * write(b"\xAB") - * elif size == 0x0C: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":265 - * elif size == 0x0B: - * write(b"\xAB") - * elif size == 0x0C: # <<<<<<<<<<<<<< - * write(b"\xAC") - * elif size == 0x0D: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0C) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":266 - * write(b"\xAB") - * elif size == 0x0C: - * write(b"\xAC") # <<<<<<<<<<<<<< - * elif size == 0x0D: - * write(b"\xAD") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__131, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 266, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":265 - * elif size == 0x0B: - * write(b"\xAB") - * elif size == 0x0C: # <<<<<<<<<<<<<< - * write(b"\xAC") - * elif size == 0x0D: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":267 - * elif size == 0x0C: - * write(b"\xAC") - * elif size == 0x0D: # <<<<<<<<<<<<<< - * write(b"\xAD") - * elif size == 0x0E: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0D) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":268 - * write(b"\xAC") - * elif size == 0x0D: - * write(b"\xAD") # <<<<<<<<<<<<<< - * elif size == 0x0E: - * write(b"\xAE") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__133, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":267 - * elif size == 0x0C: - * write(b"\xAC") - * elif size == 0x0D: # <<<<<<<<<<<<<< - * write(b"\xAD") - * elif size == 0x0E: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":269 - * elif size == 0x0D: - * write(b"\xAD") - * elif size == 0x0E: # <<<<<<<<<<<<<< - * write(b"\xAE") - * elif size == 0x0F: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0E) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":270 - * write(b"\xAD") - * elif size == 0x0E: - * write(b"\xAE") # <<<<<<<<<<<<<< - * elif size == 0x0F: - * write(b"\xAF") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__135, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":269 - * elif size == 0x0D: - * write(b"\xAD") - * elif size == 0x0E: # <<<<<<<<<<<<<< - * write(b"\xAE") - * elif size == 0x0F: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":271 - * elif size == 0x0E: - * write(b"\xAE") - * elif size == 0x0F: # <<<<<<<<<<<<<< - * write(b"\xAF") - * elif size < 0x100: - */ - __pyx_t_2 = ((__pyx_v_size == 0x0F) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":272 - * write(b"\xAE") - * elif size == 0x0F: - * write(b"\xAF") # <<<<<<<<<<<<<< - * elif size < 0x100: - * write(b"\xD8") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__137, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 272, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":271 - * elif size == 0x0E: - * write(b"\xAE") - * elif size == 0x0F: # <<<<<<<<<<<<<< - * write(b"\xAF") - * elif size < 0x100: - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":273 - * elif size == 0x0F: - * write(b"\xAF") - * elif size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xD8") - * write(PACKED_UINT_8[size]) - */ - __pyx_t_2 = ((__pyx_v_size < 0x100) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":274 - * write(b"\xAF") - * elif size < 0x100: - * write(b"\xD8") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__139, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":275 - * elif size < 0x100: - * write(b"\xD8") - * write(PACKED_UINT_8[size]) # <<<<<<<<<<<<<< - * elif size < 0x10000: - * write(b"\xD9") - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_8); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_size, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_3 = __pyx_v_write; __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_5) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_5, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 275, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":273 - * elif size == 0x0F: - * write(b"\xAF") - * elif size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xD8") - * write(PACKED_UINT_8[size]) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":276 - * write(b"\xD8") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xD9") - * write(PACKED_UINT_16[size]) - */ - __pyx_t_2 = ((__pyx_v_size < 0x10000) != 0); - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":277 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xD9") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__141, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 277, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":278 - * elif size < 0x10000: - * write(b"\xD9") - * write(PACKED_UINT_16[size]) # <<<<<<<<<<<<<< - * elif size < 0x100000000: - * write(b"\xDA") - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_16); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = __Pyx_GetItemInt(__pyx_t_3, __pyx_v_size, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_3 = __pyx_v_write; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 278, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":276 - * write(b"\xD8") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xD9") - * write(PACKED_UINT_16[size]) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":279 - * write(b"\xD9") - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: # <<<<<<<<<<<<<< - * write(b"\xDA") - * write(struct_pack(">I", size)) - */ - __pyx_t_1 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_3 = PyObject_RichCompare(__pyx_t_1, __pyx_int_4294967296, Py_LT); __Pyx_XGOTREF(__pyx_t_3); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 279, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (__pyx_t_2) { - - /* "neo4j/packstream/_packer.pyx":280 - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - * write(b"\xDA") # <<<<<<<<<<<<<< - * write(struct_pack(">I", size)) - * else: - */ - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__143, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "neo4j/packstream/_packer.pyx":281 - * elif size < 0x100000000: - * write(b"\xDA") - * write(struct_pack(">I", size)) # <<<<<<<<<<<<<< - * else: - * raise OverflowError("Map header size out of range") - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_pack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_4 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_6}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_5 = __pyx_v_write; __pyx_t_8 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (!__pyx_t_8) { - __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_GOTREF(__pyx_t_3); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[2] = {__pyx_t_8, __pyx_t_1}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); __pyx_t_8 = NULL; - __Pyx_GIVEREF(__pyx_t_1); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_1); - __pyx_t_1 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 281, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - - /* "neo4j/packstream/_packer.pyx":279 - * write(b"\xD9") - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: # <<<<<<<<<<<<<< - * write(b"\xDA") - * write(struct_pack(">I", size)) - */ - goto __pyx_L3; - } - - /* "neo4j/packstream/_packer.pyx":283 - * write(struct_pack(">I", size)) - * else: - * raise OverflowError("Map header size out of range") # <<<<<<<<<<<<<< - * - * cpdef pack_map_stream_header(self): - */ - /*else*/ { - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OverflowError, __pyx_tuple__144, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_Raise(__pyx_t_3, 0, 0, 0); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __PYX_ERR(0, 283, __pyx_L1_error) - } - __pyx_L3:; - - /* "neo4j/packstream/_packer.pyx":239 - * self._write(b"\xD7") - * - * cdef pack_map_header(self, int size): # <<<<<<<<<<<<<< - * write = self._write - * if size == 0x00: - */ - - /* 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_3); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.pack_map_header", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_write); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":285 - * raise OverflowError("Map header size out of range") - * - * cpdef pack_map_stream_header(self): # <<<<<<<<<<<<<< - * self._write(b"\xDB") - * - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_7pack_map_stream_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_map_stream_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__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; - __Pyx_RefNannySetupContext("pack_map_stream_header", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pack_map_stream_header); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_7pack_map_stream_header)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 285, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_packer.pyx":286 - * - * cpdef pack_map_stream_header(self): - * self._write(b"\xDB") # <<<<<<<<<<<<<< - * - * cpdef pack_struct(self, bytes signature, fields): - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_self->_write, __pyx_tuple__146, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 286, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":285 - * raise OverflowError("Map header size out of range") - * - * cpdef pack_map_stream_header(self): # <<<<<<<<<<<<<< - * self._write(b"\xDB") - * - */ - - /* 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("neo4j.packstream._packer.Packer.pack_map_stream_header", __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_5neo4j_10packstream_7_packer_6Packer_7pack_map_stream_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_7pack_map_stream_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("pack_map_stream_header (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer_6pack_map_stream_header(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_6pack_map_stream_header(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("pack_map_stream_header", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_map_stream_header(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 285, __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("neo4j.packstream._packer.Packer.pack_map_stream_header", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":288 - * self._write(b"\xDB") - * - * cpdef pack_struct(self, bytes signature, fields): # <<<<<<<<<<<<<< - * if len(signature) != 1: - * raise ValueError("Structure signature must be a single byte value") - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_9pack_struct(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_struct(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_signature, PyObject *__pyx_v_fields, int __pyx_skip_dispatch) { - PyObject *__pyx_v_write = NULL; - Py_ssize_t __pyx_v_size; - PyObject *__pyx_v_field = NULL; - 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; - PyObject *__pyx_t_6 = NULL; - Py_ssize_t __pyx_t_7; - int __pyx_t_8; - PyObject *(*__pyx_t_9)(PyObject *); - __Pyx_RefNannySetupContext("pack_struct", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pack_struct); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_9pack_struct)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - __pyx_t_5 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - __pyx_t_5 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_signature, __pyx_v_fields}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_signature, __pyx_v_fields}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_5, 2+__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_6 = PyTuple_New(2+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_v_signature); - __Pyx_GIVEREF(__pyx_v_signature); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_signature); - __Pyx_INCREF(__pyx_v_fields); - __Pyx_GIVEREF(__pyx_v_fields); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_fields); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 288, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_packer.pyx":289 - * - * cpdef pack_struct(self, bytes signature, fields): - * if len(signature) != 1: # <<<<<<<<<<<<<< - * raise ValueError("Structure signature must be a single byte value") - * write = self._write - */ - if (unlikely(__pyx_v_signature == Py_None)) { - PyErr_SetString(PyExc_TypeError, "object of type 'NoneType' has no len()"); - __PYX_ERR(0, 289, __pyx_L1_error) - } - __pyx_t_7 = PyBytes_GET_SIZE(__pyx_v_signature); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 289, __pyx_L1_error) - __pyx_t_8 = ((__pyx_t_7 != 1) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":290 - * cpdef pack_struct(self, bytes signature, fields): - * if len(signature) != 1: - * raise ValueError("Structure signature must be a single byte value") # <<<<<<<<<<<<<< - * write = self._write - * size = len(fields) - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__147, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 290, __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, 290, __pyx_L1_error) - - /* "neo4j/packstream/_packer.pyx":289 - * - * cpdef pack_struct(self, bytes signature, fields): - * if len(signature) != 1: # <<<<<<<<<<<<<< - * raise ValueError("Structure signature must be a single byte value") - * write = self._write - */ - } - - /* "neo4j/packstream/_packer.pyx":291 - * if len(signature) != 1: - * raise ValueError("Structure signature must be a single byte value") - * write = self._write # <<<<<<<<<<<<<< - * size = len(fields) - * if size == 0x00: - */ - __pyx_t_1 = __pyx_v_self->_write; - __Pyx_INCREF(__pyx_t_1); - __pyx_v_write = __pyx_t_1; - __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":292 - * raise ValueError("Structure signature must be a single byte value") - * write = self._write - * size = len(fields) # <<<<<<<<<<<<<< - * if size == 0x00: - * write(b"\xB0") - */ - __pyx_t_7 = PyObject_Length(__pyx_v_fields); if (unlikely(__pyx_t_7 == ((Py_ssize_t)-1))) __PYX_ERR(0, 292, __pyx_L1_error) - __pyx_v_size = __pyx_t_7; - - /* "neo4j/packstream/_packer.pyx":293 - * write = self._write - * size = len(fields) - * if size == 0x00: # <<<<<<<<<<<<<< - * write(b"\xB0") - * elif size == 0x01: - */ - __pyx_t_8 = ((__pyx_v_size == 0x00) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":294 - * size = len(fields) - * if size == 0x00: - * write(b"\xB0") # <<<<<<<<<<<<<< - * elif size == 0x01: - * write(b"\xB1") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__149, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":293 - * write = self._write - * size = len(fields) - * if size == 0x00: # <<<<<<<<<<<<<< - * write(b"\xB0") - * elif size == 0x01: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":295 - * if size == 0x00: - * write(b"\xB0") - * elif size == 0x01: # <<<<<<<<<<<<<< - * write(b"\xB1") - * elif size == 0x02: - */ - __pyx_t_8 = ((__pyx_v_size == 0x01) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":296 - * write(b"\xB0") - * elif size == 0x01: - * write(b"\xB1") # <<<<<<<<<<<<<< - * elif size == 0x02: - * write(b"\xB2") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__151, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":295 - * if size == 0x00: - * write(b"\xB0") - * elif size == 0x01: # <<<<<<<<<<<<<< - * write(b"\xB1") - * elif size == 0x02: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":297 - * elif size == 0x01: - * write(b"\xB1") - * elif size == 0x02: # <<<<<<<<<<<<<< - * write(b"\xB2") - * elif size == 0x03: - */ - __pyx_t_8 = ((__pyx_v_size == 0x02) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":298 - * write(b"\xB1") - * elif size == 0x02: - * write(b"\xB2") # <<<<<<<<<<<<<< - * elif size == 0x03: - * write(b"\xB3") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__153, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 298, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":297 - * elif size == 0x01: - * write(b"\xB1") - * elif size == 0x02: # <<<<<<<<<<<<<< - * write(b"\xB2") - * elif size == 0x03: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":299 - * elif size == 0x02: - * write(b"\xB2") - * elif size == 0x03: # <<<<<<<<<<<<<< - * write(b"\xB3") - * elif size == 0x04: - */ - __pyx_t_8 = ((__pyx_v_size == 0x03) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":300 - * write(b"\xB2") - * elif size == 0x03: - * write(b"\xB3") # <<<<<<<<<<<<<< - * elif size == 0x04: - * write(b"\xB4") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__155, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 300, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":299 - * elif size == 0x02: - * write(b"\xB2") - * elif size == 0x03: # <<<<<<<<<<<<<< - * write(b"\xB3") - * elif size == 0x04: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":301 - * elif size == 0x03: - * write(b"\xB3") - * elif size == 0x04: # <<<<<<<<<<<<<< - * write(b"\xB4") - * elif size == 0x05: - */ - __pyx_t_8 = ((__pyx_v_size == 0x04) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":302 - * write(b"\xB3") - * elif size == 0x04: - * write(b"\xB4") # <<<<<<<<<<<<<< - * elif size == 0x05: - * write(b"\xB5") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__157, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 302, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":301 - * elif size == 0x03: - * write(b"\xB3") - * elif size == 0x04: # <<<<<<<<<<<<<< - * write(b"\xB4") - * elif size == 0x05: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":303 - * elif size == 0x04: - * write(b"\xB4") - * elif size == 0x05: # <<<<<<<<<<<<<< - * write(b"\xB5") - * elif size == 0x06: - */ - __pyx_t_8 = ((__pyx_v_size == 0x05) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":304 - * write(b"\xB4") - * elif size == 0x05: - * write(b"\xB5") # <<<<<<<<<<<<<< - * elif size == 0x06: - * write(b"\xB6") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__159, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 304, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":303 - * elif size == 0x04: - * write(b"\xB4") - * elif size == 0x05: # <<<<<<<<<<<<<< - * write(b"\xB5") - * elif size == 0x06: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":305 - * elif size == 0x05: - * write(b"\xB5") - * elif size == 0x06: # <<<<<<<<<<<<<< - * write(b"\xB6") - * elif size == 0x07: - */ - __pyx_t_8 = ((__pyx_v_size == 0x06) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":306 - * write(b"\xB5") - * elif size == 0x06: - * write(b"\xB6") # <<<<<<<<<<<<<< - * elif size == 0x07: - * write(b"\xB7") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__161, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":305 - * elif size == 0x05: - * write(b"\xB5") - * elif size == 0x06: # <<<<<<<<<<<<<< - * write(b"\xB6") - * elif size == 0x07: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":307 - * elif size == 0x06: - * write(b"\xB6") - * elif size == 0x07: # <<<<<<<<<<<<<< - * write(b"\xB7") - * elif size == 0x08: - */ - __pyx_t_8 = ((__pyx_v_size == 0x07) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":308 - * write(b"\xB6") - * elif size == 0x07: - * write(b"\xB7") # <<<<<<<<<<<<<< - * elif size == 0x08: - * write(b"\xB8") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__163, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":307 - * elif size == 0x06: - * write(b"\xB6") - * elif size == 0x07: # <<<<<<<<<<<<<< - * write(b"\xB7") - * elif size == 0x08: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":309 - * elif size == 0x07: - * write(b"\xB7") - * elif size == 0x08: # <<<<<<<<<<<<<< - * write(b"\xB8") - * elif size == 0x09: - */ - __pyx_t_8 = ((__pyx_v_size == 0x08) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":310 - * write(b"\xB7") - * elif size == 0x08: - * write(b"\xB8") # <<<<<<<<<<<<<< - * elif size == 0x09: - * write(b"\xB9") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__165, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":309 - * elif size == 0x07: - * write(b"\xB7") - * elif size == 0x08: # <<<<<<<<<<<<<< - * write(b"\xB8") - * elif size == 0x09: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":311 - * elif size == 0x08: - * write(b"\xB8") - * elif size == 0x09: # <<<<<<<<<<<<<< - * write(b"\xB9") - * elif size == 0x0A: - */ - __pyx_t_8 = ((__pyx_v_size == 0x09) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":312 - * write(b"\xB8") - * elif size == 0x09: - * write(b"\xB9") # <<<<<<<<<<<<<< - * elif size == 0x0A: - * write(b"\xBA") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__167, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 312, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":311 - * elif size == 0x08: - * write(b"\xB8") - * elif size == 0x09: # <<<<<<<<<<<<<< - * write(b"\xB9") - * elif size == 0x0A: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":313 - * elif size == 0x09: - * write(b"\xB9") - * elif size == 0x0A: # <<<<<<<<<<<<<< - * write(b"\xBA") - * elif size == 0x0B: - */ - __pyx_t_8 = ((__pyx_v_size == 0x0A) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":314 - * write(b"\xB9") - * elif size == 0x0A: - * write(b"\xBA") # <<<<<<<<<<<<<< - * elif size == 0x0B: - * write(b"\xBB") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__169, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 314, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":313 - * elif size == 0x09: - * write(b"\xB9") - * elif size == 0x0A: # <<<<<<<<<<<<<< - * write(b"\xBA") - * elif size == 0x0B: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":315 - * elif size == 0x0A: - * write(b"\xBA") - * elif size == 0x0B: # <<<<<<<<<<<<<< - * write(b"\xBB") - * elif size == 0x0C: - */ - __pyx_t_8 = ((__pyx_v_size == 0x0B) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":316 - * write(b"\xBA") - * elif size == 0x0B: - * write(b"\xBB") # <<<<<<<<<<<<<< - * elif size == 0x0C: - * write(b"\xBC") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__171, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 316, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":315 - * elif size == 0x0A: - * write(b"\xBA") - * elif size == 0x0B: # <<<<<<<<<<<<<< - * write(b"\xBB") - * elif size == 0x0C: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":317 - * elif size == 0x0B: - * write(b"\xBB") - * elif size == 0x0C: # <<<<<<<<<<<<<< - * write(b"\xBC") - * elif size == 0x0D: - */ - __pyx_t_8 = ((__pyx_v_size == 0x0C) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":318 - * write(b"\xBB") - * elif size == 0x0C: - * write(b"\xBC") # <<<<<<<<<<<<<< - * elif size == 0x0D: - * write(b"\xBD") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__173, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":317 - * elif size == 0x0B: - * write(b"\xBB") - * elif size == 0x0C: # <<<<<<<<<<<<<< - * write(b"\xBC") - * elif size == 0x0D: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":319 - * elif size == 0x0C: - * write(b"\xBC") - * elif size == 0x0D: # <<<<<<<<<<<<<< - * write(b"\xBD") - * elif size == 0x0E: - */ - __pyx_t_8 = ((__pyx_v_size == 0x0D) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":320 - * write(b"\xBC") - * elif size == 0x0D: - * write(b"\xBD") # <<<<<<<<<<<<<< - * elif size == 0x0E: - * write(b"\xBE") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__175, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":319 - * elif size == 0x0C: - * write(b"\xBC") - * elif size == 0x0D: # <<<<<<<<<<<<<< - * write(b"\xBD") - * elif size == 0x0E: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":321 - * elif size == 0x0D: - * write(b"\xBD") - * elif size == 0x0E: # <<<<<<<<<<<<<< - * write(b"\xBE") - * elif size == 0x0F: - */ - __pyx_t_8 = ((__pyx_v_size == 0x0E) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":322 - * write(b"\xBD") - * elif size == 0x0E: - * write(b"\xBE") # <<<<<<<<<<<<<< - * elif size == 0x0F: - * write(b"\xBF") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__177, NULL); 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; - - /* "neo4j/packstream/_packer.pyx":321 - * elif size == 0x0D: - * write(b"\xBD") - * elif size == 0x0E: # <<<<<<<<<<<<<< - * write(b"\xBE") - * elif size == 0x0F: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":323 - * elif size == 0x0E: - * write(b"\xBE") - * elif size == 0x0F: # <<<<<<<<<<<<<< - * write(b"\xBF") - * elif size < 0x100: - */ - __pyx_t_8 = ((__pyx_v_size == 0x0F) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":324 - * write(b"\xBE") - * elif size == 0x0F: - * write(b"\xBF") # <<<<<<<<<<<<<< - * elif size < 0x100: - * write(b"\xDC") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__179, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 324, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":323 - * elif size == 0x0E: - * write(b"\xBE") - * elif size == 0x0F: # <<<<<<<<<<<<<< - * write(b"\xBF") - * elif size < 0x100: - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":325 - * elif size == 0x0F: - * write(b"\xBF") - * elif size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xDC") - * write(PACKED_UINT_8[size]) - */ - __pyx_t_8 = ((__pyx_v_size < 0x100) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":326 - * write(b"\xBF") - * elif size < 0x100: - * write(b"\xDC") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__181, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 326, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":327 - * elif size < 0x100: - * write(b"\xDC") - * write(PACKED_UINT_8[size]) # <<<<<<<<<<<<<< - * elif size < 0x10000: - * write(b"\xDD") - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 327, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_size, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 327, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_2 = __pyx_v_write; __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_6) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 327, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 327, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":325 - * elif size == 0x0F: - * write(b"\xBF") - * elif size < 0x100: # <<<<<<<<<<<<<< - * write(b"\xDC") - * write(PACKED_UINT_8[size]) - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":328 - * write(b"\xDC") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xDD") - * write(PACKED_UINT_16[size]) - */ - __pyx_t_8 = ((__pyx_v_size < 0x10000) != 0); - if (__pyx_t_8) { - - /* "neo4j/packstream/_packer.pyx":329 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xDD") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * else: - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_write, __pyx_tuple__183, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 329, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":330 - * elif size < 0x10000: - * write(b"\xDD") - * write(PACKED_UINT_16[size]) # <<<<<<<<<<<<<< - * else: - * raise OverflowError("Structure size out of range") - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_PACKED_UINT_16); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 330, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, __pyx_v_size, Py_ssize_t, 1, PyInt_FromSsize_t, 0, 1, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 330, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_INCREF(__pyx_v_write); - __pyx_t_2 = __pyx_v_write; __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_3, __pyx_t_4}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 330, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL; - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 330, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":328 - * write(b"\xDC") - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: # <<<<<<<<<<<<<< - * write(b"\xDD") - * write(PACKED_UINT_16[size]) - */ - goto __pyx_L4; - } - - /* "neo4j/packstream/_packer.pyx":332 - * write(PACKED_UINT_16[size]) - * else: - * raise OverflowError("Structure size out of range") # <<<<<<<<<<<<<< - * write(signature) - * for field in fields: - */ - /*else*/ { - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_OverflowError, __pyx_tuple__184, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 332, __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, 332, __pyx_L1_error) - } - __pyx_L4:; - - /* "neo4j/packstream/_packer.pyx":333 - * else: - * raise OverflowError("Structure size out of range") - * write(signature) # <<<<<<<<<<<<<< - * for field in fields: - * self._pack(field) - */ - __Pyx_INCREF(__pyx_v_write); - __pyx_t_2 = __pyx_v_write; __pyx_t_6 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_6) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_signature); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_signature}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_6, __pyx_v_signature}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else - #endif - { - __pyx_t_4 = PyTuple_New(1+1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_6); __pyx_t_6 = NULL; - __Pyx_INCREF(__pyx_v_signature); - __Pyx_GIVEREF(__pyx_v_signature); - PyTuple_SET_ITEM(__pyx_t_4, 0+1, __pyx_v_signature); - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 333, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":334 - * raise OverflowError("Structure size out of range") - * write(signature) - * for field in fields: # <<<<<<<<<<<<<< - * self._pack(field) - * - */ - if (likely(PyList_CheckExact(__pyx_v_fields)) || PyTuple_CheckExact(__pyx_v_fields)) { - __pyx_t_1 = __pyx_v_fields; __Pyx_INCREF(__pyx_t_1); __pyx_t_7 = 0; - __pyx_t_9 = NULL; - } else { - __pyx_t_7 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_v_fields); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 334, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_t_9 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 334, __pyx_L1_error) - } - for (;;) { - if (likely(!__pyx_t_9)) { - if (likely(PyList_CheckExact(__pyx_t_1))) { - if (__pyx_t_7 >= PyList_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 334, __pyx_L1_error) - #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - #endif - } else { - if (__pyx_t_7 >= PyTuple_GET_SIZE(__pyx_t_1)) break; - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_7); __Pyx_INCREF(__pyx_t_2); __pyx_t_7++; if (unlikely(0 < 0)) __PYX_ERR(0, 334, __pyx_L1_error) - #else - __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_7); __pyx_t_7++; if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 334, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - #endif - } - } else { - __pyx_t_2 = __pyx_t_9(__pyx_t_1); - if (unlikely(!__pyx_t_2)) { - PyObject* exc_type = PyErr_Occurred(); - if (exc_type) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear(); - else __PYX_ERR(0, 334, __pyx_L1_error) - } - break; - } - __Pyx_GOTREF(__pyx_t_2); - } - __Pyx_XDECREF_SET(__pyx_v_field, __pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_packer.pyx":335 - * write(signature) - * for field in fields: - * self._pack(field) # <<<<<<<<<<<<<< - * - * cpdef pack_end_of_stream(self): - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self->__pyx_vtab)->_pack(__pyx_v_self, __pyx_v_field); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 335, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_packer.pyx":334 - * raise OverflowError("Structure size out of range") - * write(signature) - * for field in fields: # <<<<<<<<<<<<<< - * self._pack(field) - * - */ - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":288 - * self._write(b"\xDB") - * - * cpdef pack_struct(self, bytes signature, fields): # <<<<<<<<<<<<<< - * if len(signature) != 1: - * raise ValueError("Structure signature must be a single byte value") - */ - - /* 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_6); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.pack_struct", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_write); - __Pyx_XDECREF(__pyx_v_field); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_9pack_struct(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_9pack_struct(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_signature = 0; - PyObject *__pyx_v_fields = 0; - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("pack_struct (wrapper)", 0); - { - static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_signature,&__pyx_n_s_fields,0}; - PyObject* values[2] = {0,0}; - if (unlikely(__pyx_kwds)) { - Py_ssize_t kw_args; - const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args); - switch (pos_args) { - case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - CYTHON_FALLTHROUGH; - case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - CYTHON_FALLTHROUGH; - case 0: break; - default: goto __pyx_L5_argtuple_error; - } - kw_args = PyDict_Size(__pyx_kwds); - switch (pos_args) { - case 0: - if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_signature)) != 0)) kw_args--; - else goto __pyx_L5_argtuple_error; - CYTHON_FALLTHROUGH; - case 1: - if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_fields)) != 0)) kw_args--; - else { - __Pyx_RaiseArgtupleInvalid("pack_struct", 1, 2, 2, 1); __PYX_ERR(0, 288, __pyx_L3_error) - } - } - if (unlikely(kw_args > 0)) { - if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "pack_struct") < 0)) __PYX_ERR(0, 288, __pyx_L3_error) - } - } else if (PyTuple_GET_SIZE(__pyx_args) != 2) { - goto __pyx_L5_argtuple_error; - } else { - values[0] = PyTuple_GET_ITEM(__pyx_args, 0); - values[1] = PyTuple_GET_ITEM(__pyx_args, 1); - } - __pyx_v_signature = ((PyObject*)values[0]); - __pyx_v_fields = values[1]; - } - goto __pyx_L4_argument_unpacking_done; - __pyx_L5_argtuple_error:; - __Pyx_RaiseArgtupleInvalid("pack_struct", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 288, __pyx_L3_error) - __pyx_L3_error:; - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.pack_struct", __pyx_clineno, __pyx_lineno, __pyx_filename); - __Pyx_RefNannyFinishContext(); - return NULL; - __pyx_L4_argument_unpacking_done:; - if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_signature), (&PyBytes_Type), 1, "signature", 1))) __PYX_ERR(0, 288, __pyx_L1_error) - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer_8pack_struct(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self), __pyx_v_signature, __pyx_v_fields); - - /* function exit code */ - goto __pyx_L0; - __pyx_L1_error:; - __pyx_r = NULL; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_8pack_struct(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_signature, PyObject *__pyx_v_fields) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("pack_struct", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_struct(__pyx_v_self, __pyx_v_signature, __pyx_v_fields, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 288, __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("neo4j.packstream._packer.Packer.pack_struct", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":337 - * self._pack(field) - * - * cpdef pack_end_of_stream(self): # <<<<<<<<<<<<<< - * self._write(b"\xDF") - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_11pack_end_of_stream(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_end_of_stream(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__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; - __Pyx_RefNannySetupContext("pack_end_of_stream", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_pack_end_of_stream); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_11pack_end_of_stream)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 337, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_packer.pyx":338 - * - * cpdef pack_end_of_stream(self): - * self._write(b"\xDF") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_v_self->_write, __pyx_tuple__186, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 338, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":337 - * self._pack(field) - * - * cpdef pack_end_of_stream(self): # <<<<<<<<<<<<<< - * self._write(b"\xDF") - */ - - /* 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("neo4j.packstream._packer.Packer.pack_end_of_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_5neo4j_10packstream_7_packer_6Packer_11pack_end_of_stream(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_11pack_end_of_stream(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("pack_end_of_stream (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer_10pack_end_of_stream(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_10pack_end_of_stream(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("pack_end_of_stream", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_end_of_stream(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 337, __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("neo4j.packstream._packer.Packer.pack_end_of_stream", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_packer.pyx":36 - * cdef class Packer(object): - * - * cdef public bint supports_bytes # <<<<<<<<<<<<<< - * - * cdef stream - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_14supports_bytes_1__get__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_14supports_bytes_1__get__(PyObject *__pyx_v_self) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__get__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer_14supports_bytes___get__(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_14supports_bytes___get__(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__get__", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->supports_bytes); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 36, __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("neo4j.packstream._packer.Packer.supports_bytes.__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_5neo4j_10packstream_7_packer_6Packer_14supports_bytes_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/ -static int __pyx_pw_5neo4j_10packstream_7_packer_6Packer_14supports_bytes_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__set__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer_14supports_bytes_2__set__(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self), ((PyObject *)__pyx_v_value)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5neo4j_10packstream_7_packer_6Packer_14supports_bytes_2__set__(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, PyObject *__pyx_v_value) { - int __pyx_r; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - __Pyx_RefNannySetupContext("__set__", 0); - __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 36, __pyx_L1_error) - __pyx_v_self->supports_bytes = __pyx_t_1; - - /* function exit code */ - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.supports_bytes.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = -1; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer_12__reduce_cython__(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__187, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __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(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_7_packer_6Packer_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_7_packer_6Packer_14__setstate_cython__(((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_7_packer_6Packer_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__188, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __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(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.packstream._packer.Packer.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -static struct __pyx_vtabstruct_5neo4j_10packstream_7_packer_Packer __pyx_vtable_5neo4j_10packstream_7_packer_Packer; - -static PyObject *__pyx_tp_new_5neo4j_10packstream_7_packer_Packer(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)o); - p->__pyx_vtab = __pyx_vtabptr_5neo4j_10packstream_7_packer_Packer; - p->stream = Py_None; Py_INCREF(Py_None); - p->_write = Py_None; Py_INCREF(Py_None); - if (unlikely(__pyx_pw_5neo4j_10packstream_7_packer_6Packer_1__cinit__(o, a, k) < 0)) goto bad; - return o; - bad: - Py_DECREF(o); o = 0; - return NULL; -} - -static void __pyx_tp_dealloc_5neo4j_10packstream_7_packer_Packer(PyObject *o) { - struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *p = (struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)o; - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - Py_CLEAR(p->stream); - Py_CLEAR(p->_write); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_5neo4j_10packstream_7_packer_Packer(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *p = (struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)o; - if (p->stream) { - e = (*v)(p->stream, a); if (e) return e; - } - if (p->_write) { - e = (*v)(p->_write, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_5neo4j_10packstream_7_packer_Packer(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *p = (struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *)o; - tmp = ((PyObject*)p->stream); - p->stream = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - tmp = ((PyObject*)p->_write); - p->_write = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyObject *__pyx_getprop_5neo4j_10packstream_7_packer_6Packer_supports_bytes(PyObject *o, CYTHON_UNUSED void *x) { - return __pyx_pw_5neo4j_10packstream_7_packer_6Packer_14supports_bytes_1__get__(o); -} - -static int __pyx_setprop_5neo4j_10packstream_7_packer_6Packer_supports_bytes(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) { - if (v) { - return __pyx_pw_5neo4j_10packstream_7_packer_6Packer_14supports_bytes_3__set__(o, v); - } - else { - PyErr_SetString(PyExc_NotImplementedError, "__del__"); - return -1; - } -} - -static PyMethodDef __pyx_methods_5neo4j_10packstream_7_packer_Packer[] = { - {"pack", (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_3pack, METH_O, 0}, - {"pack_list_stream_header", (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_5pack_list_stream_header, METH_NOARGS, 0}, - {"pack_map_stream_header", (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_7pack_map_stream_header, METH_NOARGS, 0}, - {"pack_struct", (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_9pack_struct, METH_VARARGS|METH_KEYWORDS, 0}, - {"pack_end_of_stream", (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_11pack_end_of_stream, METH_NOARGS, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_13__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_5neo4j_10packstream_7_packer_6Packer_15__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static struct PyGetSetDef __pyx_getsets_5neo4j_10packstream_7_packer_Packer[] = { - {(char *)"supports_bytes", __pyx_getprop_5neo4j_10packstream_7_packer_6Packer_supports_bytes, __pyx_setprop_5neo4j_10packstream_7_packer_6Packer_supports_bytes, (char *)0, 0}, - {0, 0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_5neo4j_10packstream_7_packer_Packer = { - PyVarObject_HEAD_INIT(0, 0) - "neo4j.packstream._packer.Packer", /*tp_name*/ - sizeof(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5neo4j_10packstream_7_packer_Packer, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 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_5neo4j_10packstream_7_packer_Packer, /*tp_traverse*/ - __pyx_tp_clear_5neo4j_10packstream_7_packer_Packer, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_5neo4j_10packstream_7_packer_Packer, /*tp_methods*/ - 0, /*tp_members*/ - __pyx_getsets_5neo4j_10packstream_7_packer_Packer, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_5neo4j_10packstream_7_packer_Packer, /*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 PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static PyMethodDef __pyx_methods[] = { - {0, 0, 0, 0} -}; - -static int __pyx_import_star_set(PyObject *o, PyObject* py_name, char *name) { - static const char* internal_type_names[] = { - "Packer", - 0 - }; - const char** type_name = internal_type_names; - while (*type_name) { - if (__Pyx_StrEq(name, *type_name)) { - PyErr_Format(PyExc_TypeError, "Cannot overwrite C type %s", name); - goto bad; - } - type_name++; - } - if (0); - else if (__Pyx_StrEq(name, "INT64_HI")) { - Py_INCREF(o); - Py_DECREF(__pyx_v_5neo4j_10packstream_7_packer_INT64_HI); - __pyx_v_5neo4j_10packstream_7_packer_INT64_HI = o; - } - else if (__Pyx_StrEq(name, "INT64_LO")) { - Py_INCREF(o); - Py_DECREF(__pyx_v_5neo4j_10packstream_7_packer_INT64_LO); - __pyx_v_5neo4j_10packstream_7_packer_INT64_LO = o; - } - else { - if (PyObject_SetAttr(__pyx_m, py_name, o) < 0) goto bad; - } - return 0; - bad: - return -1; -} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -static int -__Pyx_import_all_from(PyObject *locals, PyObject *v) -{ - PyObject *all = PyObject_GetAttrString(v, "__all__"); - PyObject *dict, *name, *value; - int skip_leading_underscores = 0; - int pos, err; - - if (all == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_Clear(); - dict = PyObject_GetAttrString(v, "__dict__"); - if (dict == NULL) { - if (!PyErr_ExceptionMatches(PyExc_AttributeError)) - return -1; - PyErr_SetString(PyExc_ImportError, - "from-import-* object has no __dict__ and no __all__"); - return -1; - } -#if PY_MAJOR_VERSION < 3 - all = PyObject_CallMethod(dict, (char *)"keys", NULL); -#else - all = PyMapping_Keys(dict); -#endif - Py_DECREF(dict); - if (all == NULL) - return -1; - skip_leading_underscores = 1; - } - - for (pos = 0, err = 0; ; pos++) { - name = PySequence_GetItem(all, pos); - if (name == NULL) { - if (!PyErr_ExceptionMatches(PyExc_IndexError)) - err = -1; - else - PyErr_Clear(); - break; - } - if (skip_leading_underscores && -#if PY_MAJOR_VERSION < 3 - PyString_Check(name) && - PyString_AS_STRING(name)[0] == '_') -#else - PyUnicode_Check(name) && - PyUnicode_AS_UNICODE(name)[0] == '_') -#endif - { - Py_DECREF(name); - continue; - } - value = PyObject_GetAttr(v, name); - if (value == NULL) - err = -1; - else if (PyDict_CheckExact(locals)) - err = PyDict_SetItem(locals, name, value); - else - err = PyObject_SetItem(locals, name, value); - Py_DECREF(name); - Py_XDECREF(value); - if (err != 0) - break; - } - Py_DECREF(all); - return err; -} - - -static int __pyx_import_star(PyObject* m) { - - int i; - int ret = -1; - char* s; - PyObject *locals = 0; - PyObject *list = 0; -#if PY_MAJOR_VERSION >= 3 - PyObject *utf8_name = 0; -#endif - PyObject *name; - PyObject *item; - - locals = PyDict_New(); if (!locals) goto bad; - if (__Pyx_import_all_from(locals, m) < 0) goto bad; - list = PyDict_Items(locals); if (!list) goto bad; - - for(i=0; i= 3 - utf8_name = PyUnicode_AsUTF8String(name); - if (!utf8_name) goto bad; - s = PyBytes_AS_STRING(utf8_name); - if (__pyx_import_star_set(item, name, s) < 0) goto bad; - Py_DECREF(utf8_name); utf8_name = 0; -#else - s = PyString_AsString(name); - if (!s) goto bad; - if (__pyx_import_star_set(item, name, s) < 0) goto bad; -#endif - } - ret = 0; - -bad: - Py_XDECREF(locals); - Py_XDECREF(list); -#if PY_MAJOR_VERSION >= 3 - Py_XDECREF(utf8_name); -#endif - return ret; -} - - - -#if PY_MAJOR_VERSION >= 3 -#if CYTHON_PEP489_MULTI_PHASE_INIT -static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec__packer(PyObject* module); /*proto*/ -static PyModuleDef_Slot __pyx_moduledef_slots[] = { - {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec__packer}, - {0, NULL} -}; -#endif - -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - "_packer", - 0, /* m_doc */ - #if CYTHON_PEP489_MULTI_PHASE_INIT - 0, /* m_size */ - #else - -1, /* m_size */ - #endif - __pyx_methods /* m_methods */, - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_moduledef_slots, /* m_slots */ - #else - NULL, /* m_reload */ - #endif - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp_b_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 0, 0}, - {&__pyx_kp_s_Bytes_header_size_out_of_range, __pyx_k_Bytes_header_size_out_of_range, sizeof(__pyx_k_Bytes_header_size_out_of_range), 0, 0, 1, 0}, - {&__pyx_kp_s_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 0, 1, 0}, - {&__pyx_kp_s_Integer_s_out_of_range, __pyx_k_Integer_s_out_of_range, sizeof(__pyx_k_Integer_s_out_of_range), 0, 0, 1, 0}, - {&__pyx_kp_s_List_header_size_out_of_range, __pyx_k_List_header_size_out_of_range, sizeof(__pyx_k_List_header_size_out_of_range), 0, 0, 1, 0}, - {&__pyx_kp_s_Map_header_size_out_of_range, __pyx_k_Map_header_size_out_of_range, sizeof(__pyx_k_Map_header_size_out_of_range), 0, 0, 1, 0}, - {&__pyx_n_s_OverflowError, __pyx_k_OverflowError, sizeof(__pyx_k_OverflowError), 0, 0, 1, 1}, - {&__pyx_n_s_PACKED_UINT_16, __pyx_k_PACKED_UINT_16, sizeof(__pyx_k_PACKED_UINT_16), 0, 0, 1, 1}, - {&__pyx_n_s_PACKED_UINT_8, __pyx_k_PACKED_UINT_8, sizeof(__pyx_k_PACKED_UINT_8), 0, 0, 1, 1}, - {&__pyx_kp_s_String_header_size_out_of_range, __pyx_k_String_header_size_out_of_range, sizeof(__pyx_k_String_header_size_out_of_range), 0, 0, 1, 0}, - {&__pyx_n_s_Structure, __pyx_k_Structure, sizeof(__pyx_k_Structure), 0, 0, 1, 1}, - {&__pyx_kp_s_Structure_signature_must_be_a_si, __pyx_k_Structure_signature_must_be_a_si, sizeof(__pyx_k_Structure_signature_must_be_a_si), 0, 0, 1, 0}, - {&__pyx_kp_s_Structure_size_out_of_range, __pyx_k_Structure_size_out_of_range, sizeof(__pyx_k_Structure_size_out_of_range), 0, 0, 1, 0}, - {&__pyx_kp_s_This_PackSteam_channel_does_not, __pyx_k_This_PackSteam_channel_does_not, sizeof(__pyx_k_This_PackSteam_channel_does_not), 0, 0, 1, 0}, - {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1}, - {&__pyx_kp_s_Values_of_type_s_are_not_support, __pyx_k_Values_of_type_s_are_not_support, sizeof(__pyx_k_Values_of_type_s_are_not_support), 0, 0, 1, 0}, - {&__pyx_kp_b__101, __pyx_k__101, sizeof(__pyx_k__101), 0, 0, 0, 0}, - {&__pyx_kp_b__104, __pyx_k__104, sizeof(__pyx_k__104), 0, 0, 0, 0}, - {&__pyx_kp_b__106, __pyx_k__106, sizeof(__pyx_k__106), 0, 0, 0, 0}, - {&__pyx_kp_b__108, __pyx_k__108, sizeof(__pyx_k__108), 0, 0, 0, 0}, - {&__pyx_kp_b__11, __pyx_k__11, sizeof(__pyx_k__11), 0, 0, 0, 0}, - {&__pyx_kp_b__110, __pyx_k__110, sizeof(__pyx_k__110), 0, 0, 0, 0}, - {&__pyx_kp_b__112, __pyx_k__112, sizeof(__pyx_k__112), 0, 0, 0, 0}, - {&__pyx_kp_b__114, __pyx_k__114, sizeof(__pyx_k__114), 0, 0, 0, 0}, - {&__pyx_kp_b__116, __pyx_k__116, sizeof(__pyx_k__116), 0, 0, 0, 0}, - {&__pyx_kp_b__118, __pyx_k__118, sizeof(__pyx_k__118), 0, 0, 0, 0}, - {&__pyx_kp_b__120, __pyx_k__120, sizeof(__pyx_k__120), 0, 0, 0, 0}, - {&__pyx_kp_b__122, __pyx_k__122, sizeof(__pyx_k__122), 0, 0, 0, 0}, - {&__pyx_kp_b__124, __pyx_k__124, sizeof(__pyx_k__124), 0, 0, 0, 0}, - {&__pyx_kp_b__126, __pyx_k__126, sizeof(__pyx_k__126), 0, 0, 0, 0}, - {&__pyx_kp_b__128, __pyx_k__128, sizeof(__pyx_k__128), 0, 0, 0, 0}, - {&__pyx_kp_b__13, __pyx_k__13, sizeof(__pyx_k__13), 0, 0, 0, 0}, - {&__pyx_kp_b__130, __pyx_k__130, sizeof(__pyx_k__130), 0, 0, 0, 0}, - {&__pyx_kp_b__132, __pyx_k__132, sizeof(__pyx_k__132), 0, 0, 0, 0}, - {&__pyx_kp_b__134, __pyx_k__134, sizeof(__pyx_k__134), 0, 0, 0, 0}, - {&__pyx_kp_b__136, __pyx_k__136, sizeof(__pyx_k__136), 0, 0, 0, 0}, - {&__pyx_kp_b__138, __pyx_k__138, sizeof(__pyx_k__138), 0, 0, 0, 0}, - {&__pyx_kp_b__140, __pyx_k__140, sizeof(__pyx_k__140), 0, 0, 0, 0}, - {&__pyx_kp_b__142, __pyx_k__142, sizeof(__pyx_k__142), 0, 0, 0, 0}, - {&__pyx_kp_b__145, __pyx_k__145, sizeof(__pyx_k__145), 0, 0, 0, 0}, - {&__pyx_kp_b__148, __pyx_k__148, sizeof(__pyx_k__148), 0, 0, 0, 0}, - {&__pyx_kp_b__15, __pyx_k__15, sizeof(__pyx_k__15), 0, 0, 0, 0}, - {&__pyx_kp_b__150, __pyx_k__150, sizeof(__pyx_k__150), 0, 0, 0, 0}, - {&__pyx_kp_b__152, __pyx_k__152, sizeof(__pyx_k__152), 0, 0, 0, 0}, - {&__pyx_kp_b__154, __pyx_k__154, sizeof(__pyx_k__154), 0, 0, 0, 0}, - {&__pyx_kp_b__156, __pyx_k__156, sizeof(__pyx_k__156), 0, 0, 0, 0}, - {&__pyx_kp_b__158, __pyx_k__158, sizeof(__pyx_k__158), 0, 0, 0, 0}, - {&__pyx_kp_b__160, __pyx_k__160, sizeof(__pyx_k__160), 0, 0, 0, 0}, - {&__pyx_kp_b__162, __pyx_k__162, sizeof(__pyx_k__162), 0, 0, 0, 0}, - {&__pyx_kp_b__164, __pyx_k__164, sizeof(__pyx_k__164), 0, 0, 0, 0}, - {&__pyx_kp_b__166, __pyx_k__166, sizeof(__pyx_k__166), 0, 0, 0, 0}, - {&__pyx_kp_b__168, __pyx_k__168, sizeof(__pyx_k__168), 0, 0, 0, 0}, - {&__pyx_kp_b__170, __pyx_k__170, sizeof(__pyx_k__170), 0, 0, 0, 0}, - {&__pyx_kp_b__172, __pyx_k__172, sizeof(__pyx_k__172), 0, 0, 0, 0}, - {&__pyx_kp_b__174, __pyx_k__174, sizeof(__pyx_k__174), 0, 0, 0, 0}, - {&__pyx_kp_b__176, __pyx_k__176, sizeof(__pyx_k__176), 0, 0, 0, 0}, - {&__pyx_kp_b__178, __pyx_k__178, sizeof(__pyx_k__178), 0, 0, 0, 0}, - {&__pyx_kp_b__180, __pyx_k__180, sizeof(__pyx_k__180), 0, 0, 0, 0}, - {&__pyx_kp_b__182, __pyx_k__182, sizeof(__pyx_k__182), 0, 0, 0, 0}, - {&__pyx_kp_b__185, __pyx_k__185, sizeof(__pyx_k__185), 0, 0, 0, 0}, - {&__pyx_n_s__189, __pyx_k__189, sizeof(__pyx_k__189), 0, 0, 1, 1}, - {&__pyx_kp_b__19, __pyx_k__19, sizeof(__pyx_k__19), 0, 0, 0, 0}, - {&__pyx_kp_b__21, __pyx_k__21, sizeof(__pyx_k__21), 0, 0, 0, 0}, - {&__pyx_kp_b__23, __pyx_k__23, sizeof(__pyx_k__23), 0, 0, 0, 0}, - {&__pyx_kp_b__26, __pyx_k__26, sizeof(__pyx_k__26), 0, 0, 0, 0}, - {&__pyx_kp_b__28, __pyx_k__28, sizeof(__pyx_k__28), 0, 0, 0, 0}, - {&__pyx_kp_b__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 0, 0}, - {&__pyx_kp_b__30, __pyx_k__30, sizeof(__pyx_k__30), 0, 0, 0, 0}, - {&__pyx_kp_b__32, __pyx_k__32, sizeof(__pyx_k__32), 0, 0, 0, 0}, - {&__pyx_kp_b__34, __pyx_k__34, sizeof(__pyx_k__34), 0, 0, 0, 0}, - {&__pyx_kp_b__36, __pyx_k__36, sizeof(__pyx_k__36), 0, 0, 0, 0}, - {&__pyx_kp_b__38, __pyx_k__38, sizeof(__pyx_k__38), 0, 0, 0, 0}, - {&__pyx_kp_b__40, __pyx_k__40, sizeof(__pyx_k__40), 0, 0, 0, 0}, - {&__pyx_kp_b__42, __pyx_k__42, sizeof(__pyx_k__42), 0, 0, 0, 0}, - {&__pyx_kp_b__44, __pyx_k__44, sizeof(__pyx_k__44), 0, 0, 0, 0}, - {&__pyx_kp_b__46, __pyx_k__46, sizeof(__pyx_k__46), 0, 0, 0, 0}, - {&__pyx_kp_b__48, __pyx_k__48, sizeof(__pyx_k__48), 0, 0, 0, 0}, - {&__pyx_kp_b__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 0, 0}, - {&__pyx_kp_b__50, __pyx_k__50, sizeof(__pyx_k__50), 0, 0, 0, 0}, - {&__pyx_kp_b__52, __pyx_k__52, sizeof(__pyx_k__52), 0, 0, 0, 0}, - {&__pyx_kp_b__54, __pyx_k__54, sizeof(__pyx_k__54), 0, 0, 0, 0}, - {&__pyx_kp_b__56, __pyx_k__56, sizeof(__pyx_k__56), 0, 0, 0, 0}, - {&__pyx_kp_b__58, __pyx_k__58, sizeof(__pyx_k__58), 0, 0, 0, 0}, - {&__pyx_kp_b__60, __pyx_k__60, sizeof(__pyx_k__60), 0, 0, 0, 0}, - {&__pyx_kp_b__62, __pyx_k__62, sizeof(__pyx_k__62), 0, 0, 0, 0}, - {&__pyx_kp_b__65, __pyx_k__65, sizeof(__pyx_k__65), 0, 0, 0, 0}, - {&__pyx_kp_b__67, __pyx_k__67, sizeof(__pyx_k__67), 0, 0, 0, 0}, - {&__pyx_kp_b__69, __pyx_k__69, sizeof(__pyx_k__69), 0, 0, 0, 0}, - {&__pyx_kp_b__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 0, 0, 0}, - {&__pyx_kp_b__71, __pyx_k__71, sizeof(__pyx_k__71), 0, 0, 0, 0}, - {&__pyx_kp_b__73, __pyx_k__73, sizeof(__pyx_k__73), 0, 0, 0, 0}, - {&__pyx_kp_b__75, __pyx_k__75, sizeof(__pyx_k__75), 0, 0, 0, 0}, - {&__pyx_kp_b__77, __pyx_k__77, sizeof(__pyx_k__77), 0, 0, 0, 0}, - {&__pyx_kp_b__79, __pyx_k__79, sizeof(__pyx_k__79), 0, 0, 0, 0}, - {&__pyx_kp_b__81, __pyx_k__81, sizeof(__pyx_k__81), 0, 0, 0, 0}, - {&__pyx_kp_b__83, __pyx_k__83, sizeof(__pyx_k__83), 0, 0, 0, 0}, - {&__pyx_kp_b__85, __pyx_k__85, sizeof(__pyx_k__85), 0, 0, 0, 0}, - {&__pyx_kp_b__87, __pyx_k__87, sizeof(__pyx_k__87), 0, 0, 0, 0}, - {&__pyx_kp_b__89, __pyx_k__89, sizeof(__pyx_k__89), 0, 0, 0, 0}, - {&__pyx_kp_b__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 0, 0, 0}, - {&__pyx_kp_b__91, __pyx_k__91, sizeof(__pyx_k__91), 0, 0, 0, 0}, - {&__pyx_kp_b__93, __pyx_k__93, sizeof(__pyx_k__93), 0, 0, 0, 0}, - {&__pyx_kp_b__95, __pyx_k__95, sizeof(__pyx_k__95), 0, 0, 0, 0}, - {&__pyx_kp_b__97, __pyx_k__97, sizeof(__pyx_k__97), 0, 0, 0, 0}, - {&__pyx_kp_b__99, __pyx_k__99, sizeof(__pyx_k__99), 0, 0, 0, 0}, - {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_constants, __pyx_k_constants, sizeof(__pyx_k_constants), 0, 0, 1, 1}, - {&__pyx_kp_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 0}, - {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1}, - {&__pyx_n_s_fields, __pyx_k_fields, sizeof(__pyx_k_fields), 0, 0, 1, 1}, - {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, - {&__pyx_kp_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 0}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_integer, __pyx_k_integer, sizeof(__pyx_k_integer), 0, 0, 1, 1}, - {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_neo4j_compat, __pyx_k_neo4j_compat, sizeof(__pyx_k_neo4j_compat), 0, 0, 1, 1}, - {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, - {&__pyx_n_s_pack, __pyx_k_pack, sizeof(__pyx_k_pack), 0, 0, 1, 1}, - {&__pyx_n_s_pack_end_of_stream, __pyx_k_pack_end_of_stream, sizeof(__pyx_k_pack_end_of_stream), 0, 0, 1, 1}, - {&__pyx_n_s_pack_list_stream_header, __pyx_k_pack_list_stream_header, sizeof(__pyx_k_pack_list_stream_header), 0, 0, 1, 1}, - {&__pyx_n_s_pack_map_stream_header, __pyx_k_pack_map_stream_header, sizeof(__pyx_k_pack_map_stream_header), 0, 0, 1, 1}, - {&__pyx_n_s_pack_struct, __pyx_k_pack_struct, sizeof(__pyx_k_pack_struct), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, - {&__pyx_kp_s_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 1, 0}, - {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, - {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, - {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, - {&__pyx_n_s_signature, __pyx_k_signature, sizeof(__pyx_k_signature), 0, 0, 1, 1}, - {&__pyx_n_s_stream, __pyx_k_stream, sizeof(__pyx_k_stream), 0, 0, 1, 1}, - {&__pyx_n_s_string, __pyx_k_string, sizeof(__pyx_k_string), 0, 0, 1, 1}, - {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, - {&__pyx_n_s_struct_pack, __pyx_k_struct_pack, sizeof(__pyx_k_struct_pack), 0, 0, 1, 1}, - {&__pyx_n_s_structure, __pyx_k_structure, sizeof(__pyx_k_structure), 0, 0, 1, 1}, - {&__pyx_n_s_tag, __pyx_k_tag, sizeof(__pyx_k_tag), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_kp_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 0}, - {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1}, - {0, 0, 0, 0, 0, 0, 0} -}; -static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_OverflowError = __Pyx_GetBuiltinName(__pyx_n_s_OverflowError); if (!__pyx_builtin_OverflowError) __PYX_ERR(0, 87, __pyx_L1_error) - __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) __PYX_ERR(0, 126, __pyx_L1_error) - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(0, 130, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "neo4j/packstream/_packer.pyx":57 - * # None - * if value is None: - * write(b"\xC0") # NULL # <<<<<<<<<<<<<< - * - * # Boolean - */ - __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_b_); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 57, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); - - /* "neo4j/packstream/_packer.pyx":61 - * # Boolean - * elif value is True: - * write(b"\xC3") # <<<<<<<<<<<<<< - * elif value is False: - * write(b"\xC2") - */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_b__3); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - - /* "neo4j/packstream/_packer.pyx":63 - * write(b"\xC3") - * elif value is False: - * write(b"\xC2") # <<<<<<<<<<<<<< - * - * # Float (only double precision is supported) - */ - __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_b__5); if (unlikely(!__pyx_tuple__6)) __PYX_ERR(0, 63, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__6); - __Pyx_GIVEREF(__pyx_tuple__6); - - /* "neo4j/packstream/_packer.pyx":67 - * # Float (only double precision is supported) - * elif isinstance(value, float): - * write(b"\xC1") # <<<<<<<<<<<<<< - * write(struct_pack(">d", value)) - * - */ - __pyx_tuple__8 = PyTuple_Pack(1, __pyx_kp_b__7); if (unlikely(!__pyx_tuple__8)) __PYX_ERR(0, 67, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__8); - __Pyx_GIVEREF(__pyx_tuple__8); - - /* "neo4j/packstream/_packer.pyx":75 - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x80 <= value < -0x10: - * write(b"\xC8") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x8000 <= value < 0x8000: - */ - __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_b__9); if (unlikely(!__pyx_tuple__10)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__10); - __Pyx_GIVEREF(__pyx_tuple__10); - - /* "neo4j/packstream/_packer.pyx":78 - * write(PACKED_UINT_8[value % 0x100]) - * elif -0x8000 <= value < 0x8000: - * write(b"\xC9") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[value % 0x10000]) - * elif -0x80000000 <= value < 0x80000000: - */ - __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_b__11); if (unlikely(!__pyx_tuple__12)) __PYX_ERR(0, 78, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__12); - __Pyx_GIVEREF(__pyx_tuple__12); - - /* "neo4j/packstream/_packer.pyx":81 - * write(PACKED_UINT_16[value % 0x10000]) - * elif -0x80000000 <= value < 0x80000000: - * write(b"\xCA") # <<<<<<<<<<<<<< - * write(struct_pack(">i", value)) - * elif INT64_LO <= value < INT64_HI: - */ - __pyx_tuple__14 = PyTuple_Pack(1, __pyx_kp_b__13); if (unlikely(!__pyx_tuple__14)) __PYX_ERR(0, 81, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__14); - __Pyx_GIVEREF(__pyx_tuple__14); - - /* "neo4j/packstream/_packer.pyx":84 - * write(struct_pack(">i", value)) - * elif INT64_LO <= value < INT64_HI: - * write(b"\xCB") # <<<<<<<<<<<<<< - * write(struct_pack(">q", value)) - * else: - */ - __pyx_tuple__16 = PyTuple_Pack(1, __pyx_kp_b__15); if (unlikely(!__pyx_tuple__16)) __PYX_ERR(0, 84, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__16); - __Pyx_GIVEREF(__pyx_tuple__16); - - /* "neo4j/packstream/_packer.pyx":94 - * value_bytes = value - * else: - * value_bytes = value.encode("utf-8") # <<<<<<<<<<<<<< - * self.pack_string_header(len(value_bytes)) - * self.pack_raw(value_bytes) - */ - __pyx_tuple__17 = PyTuple_Pack(1, __pyx_kp_s_utf_8); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 94, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__17); - __Pyx_GIVEREF(__pyx_tuple__17); - - /* "neo4j/packstream/_packer.pyx":130 - * cdef pack_bytes_header(self, int size): - * if not self.supports_bytes: - * raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") # <<<<<<<<<<<<<< - * write = self._write - * if size < 0x100: - */ - __pyx_tuple__18 = PyTuple_Pack(1, __pyx_kp_s_This_PackSteam_channel_does_not); if (unlikely(!__pyx_tuple__18)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__18); - __Pyx_GIVEREF(__pyx_tuple__18); - - /* "neo4j/packstream/_packer.pyx":133 - * write = self._write - * if size < 0x100: - * write(b"\xCC") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_tuple__20 = PyTuple_Pack(1, __pyx_kp_b__19); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__20); - __Pyx_GIVEREF(__pyx_tuple__20); - - /* "neo4j/packstream/_packer.pyx":136 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xCD") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - */ - __pyx_tuple__22 = PyTuple_Pack(1, __pyx_kp_b__21); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 136, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__22); - __Pyx_GIVEREF(__pyx_tuple__22); - - /* "neo4j/packstream/_packer.pyx":139 - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - * write(b"\xCE") # <<<<<<<<<<<<<< - * write(struct_pack(">I", size)) - * else: - */ - __pyx_tuple__24 = PyTuple_Pack(1, __pyx_kp_b__23); if (unlikely(!__pyx_tuple__24)) __PYX_ERR(0, 139, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__24); - __Pyx_GIVEREF(__pyx_tuple__24); - - /* "neo4j/packstream/_packer.pyx":142 - * write(struct_pack(">I", size)) - * else: - * raise OverflowError("Bytes header size out of range") # <<<<<<<<<<<<<< - * - * cdef pack_string_header(self, int size): - */ - __pyx_tuple__25 = PyTuple_Pack(1, __pyx_kp_s_Bytes_header_size_out_of_range); if (unlikely(!__pyx_tuple__25)) __PYX_ERR(0, 142, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__25); - __Pyx_GIVEREF(__pyx_tuple__25); - - /* "neo4j/packstream/_packer.pyx":147 - * write = self._write - * if size == 0x00: - * write(b"\x80") # <<<<<<<<<<<<<< - * elif size == 0x01: - * write(b"\x81") - */ - __pyx_tuple__27 = PyTuple_Pack(1, __pyx_kp_b__26); if (unlikely(!__pyx_tuple__27)) __PYX_ERR(0, 147, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__27); - __Pyx_GIVEREF(__pyx_tuple__27); - - /* "neo4j/packstream/_packer.pyx":149 - * write(b"\x80") - * elif size == 0x01: - * write(b"\x81") # <<<<<<<<<<<<<< - * elif size == 0x02: - * write(b"\x82") - */ - __pyx_tuple__29 = PyTuple_Pack(1, __pyx_kp_b__28); if (unlikely(!__pyx_tuple__29)) __PYX_ERR(0, 149, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__29); - __Pyx_GIVEREF(__pyx_tuple__29); - - /* "neo4j/packstream/_packer.pyx":151 - * write(b"\x81") - * elif size == 0x02: - * write(b"\x82") # <<<<<<<<<<<<<< - * elif size == 0x03: - * write(b"\x83") - */ - __pyx_tuple__31 = PyTuple_Pack(1, __pyx_kp_b__30); if (unlikely(!__pyx_tuple__31)) __PYX_ERR(0, 151, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__31); - __Pyx_GIVEREF(__pyx_tuple__31); - - /* "neo4j/packstream/_packer.pyx":153 - * write(b"\x82") - * elif size == 0x03: - * write(b"\x83") # <<<<<<<<<<<<<< - * elif size == 0x04: - * write(b"\x84") - */ - __pyx_tuple__33 = PyTuple_Pack(1, __pyx_kp_b__32); if (unlikely(!__pyx_tuple__33)) __PYX_ERR(0, 153, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__33); - __Pyx_GIVEREF(__pyx_tuple__33); - - /* "neo4j/packstream/_packer.pyx":155 - * write(b"\x83") - * elif size == 0x04: - * write(b"\x84") # <<<<<<<<<<<<<< - * elif size == 0x05: - * write(b"\x85") - */ - __pyx_tuple__35 = PyTuple_Pack(1, __pyx_kp_b__34); if (unlikely(!__pyx_tuple__35)) __PYX_ERR(0, 155, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__35); - __Pyx_GIVEREF(__pyx_tuple__35); - - /* "neo4j/packstream/_packer.pyx":157 - * write(b"\x84") - * elif size == 0x05: - * write(b"\x85") # <<<<<<<<<<<<<< - * elif size == 0x06: - * write(b"\x86") - */ - __pyx_tuple__37 = PyTuple_Pack(1, __pyx_kp_b__36); if (unlikely(!__pyx_tuple__37)) __PYX_ERR(0, 157, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__37); - __Pyx_GIVEREF(__pyx_tuple__37); - - /* "neo4j/packstream/_packer.pyx":159 - * write(b"\x85") - * elif size == 0x06: - * write(b"\x86") # <<<<<<<<<<<<<< - * elif size == 0x07: - * write(b"\x87") - */ - __pyx_tuple__39 = PyTuple_Pack(1, __pyx_kp_b__38); if (unlikely(!__pyx_tuple__39)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__39); - __Pyx_GIVEREF(__pyx_tuple__39); - - /* "neo4j/packstream/_packer.pyx":161 - * write(b"\x86") - * elif size == 0x07: - * write(b"\x87") # <<<<<<<<<<<<<< - * elif size == 0x08: - * write(b"\x88") - */ - __pyx_tuple__41 = PyTuple_Pack(1, __pyx_kp_b__40); if (unlikely(!__pyx_tuple__41)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__41); - __Pyx_GIVEREF(__pyx_tuple__41); - - /* "neo4j/packstream/_packer.pyx":163 - * write(b"\x87") - * elif size == 0x08: - * write(b"\x88") # <<<<<<<<<<<<<< - * elif size == 0x09: - * write(b"\x89") - */ - __pyx_tuple__43 = PyTuple_Pack(1, __pyx_kp_b__42); if (unlikely(!__pyx_tuple__43)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__43); - __Pyx_GIVEREF(__pyx_tuple__43); - - /* "neo4j/packstream/_packer.pyx":165 - * write(b"\x88") - * elif size == 0x09: - * write(b"\x89") # <<<<<<<<<<<<<< - * elif size == 0x0A: - * write(b"\x8A") - */ - __pyx_tuple__45 = PyTuple_Pack(1, __pyx_kp_b__44); if (unlikely(!__pyx_tuple__45)) __PYX_ERR(0, 165, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__45); - __Pyx_GIVEREF(__pyx_tuple__45); - - /* "neo4j/packstream/_packer.pyx":167 - * write(b"\x89") - * elif size == 0x0A: - * write(b"\x8A") # <<<<<<<<<<<<<< - * elif size == 0x0B: - * write(b"\x8B") - */ - __pyx_tuple__47 = PyTuple_Pack(1, __pyx_kp_b__46); if (unlikely(!__pyx_tuple__47)) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__47); - __Pyx_GIVEREF(__pyx_tuple__47); - - /* "neo4j/packstream/_packer.pyx":169 - * write(b"\x8A") - * elif size == 0x0B: - * write(b"\x8B") # <<<<<<<<<<<<<< - * elif size == 0x0C: - * write(b"\x8C") - */ - __pyx_tuple__49 = PyTuple_Pack(1, __pyx_kp_b__48); if (unlikely(!__pyx_tuple__49)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__49); - __Pyx_GIVEREF(__pyx_tuple__49); - - /* "neo4j/packstream/_packer.pyx":171 - * write(b"\x8B") - * elif size == 0x0C: - * write(b"\x8C") # <<<<<<<<<<<<<< - * elif size == 0x0D: - * write(b"\x8D") - */ - __pyx_tuple__51 = PyTuple_Pack(1, __pyx_kp_b__50); if (unlikely(!__pyx_tuple__51)) __PYX_ERR(0, 171, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__51); - __Pyx_GIVEREF(__pyx_tuple__51); - - /* "neo4j/packstream/_packer.pyx":173 - * write(b"\x8C") - * elif size == 0x0D: - * write(b"\x8D") # <<<<<<<<<<<<<< - * elif size == 0x0E: - * write(b"\x8E") - */ - __pyx_tuple__53 = PyTuple_Pack(1, __pyx_kp_b__52); if (unlikely(!__pyx_tuple__53)) __PYX_ERR(0, 173, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__53); - __Pyx_GIVEREF(__pyx_tuple__53); - - /* "neo4j/packstream/_packer.pyx":175 - * write(b"\x8D") - * elif size == 0x0E: - * write(b"\x8E") # <<<<<<<<<<<<<< - * elif size == 0x0F: - * write(b"\x8F") - */ - __pyx_tuple__55 = PyTuple_Pack(1, __pyx_kp_b__54); if (unlikely(!__pyx_tuple__55)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__55); - __Pyx_GIVEREF(__pyx_tuple__55); - - /* "neo4j/packstream/_packer.pyx":177 - * write(b"\x8E") - * elif size == 0x0F: - * write(b"\x8F") # <<<<<<<<<<<<<< - * elif size < 0x100: - * write(b"\xD0") - */ - __pyx_tuple__57 = PyTuple_Pack(1, __pyx_kp_b__56); if (unlikely(!__pyx_tuple__57)) __PYX_ERR(0, 177, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__57); - __Pyx_GIVEREF(__pyx_tuple__57); - - /* "neo4j/packstream/_packer.pyx":179 - * write(b"\x8F") - * elif size < 0x100: - * write(b"\xD0") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_tuple__59 = PyTuple_Pack(1, __pyx_kp_b__58); if (unlikely(!__pyx_tuple__59)) __PYX_ERR(0, 179, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__59); - __Pyx_GIVEREF(__pyx_tuple__59); - - /* "neo4j/packstream/_packer.pyx":182 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xD1") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - */ - __pyx_tuple__61 = PyTuple_Pack(1, __pyx_kp_b__60); if (unlikely(!__pyx_tuple__61)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__61); - __Pyx_GIVEREF(__pyx_tuple__61); - - /* "neo4j/packstream/_packer.pyx":185 - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - * write(b"\xD2") # <<<<<<<<<<<<<< - * write(struct_pack(">I", size)) - * else: - */ - __pyx_tuple__63 = PyTuple_Pack(1, __pyx_kp_b__62); if (unlikely(!__pyx_tuple__63)) __PYX_ERR(0, 185, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__63); - __Pyx_GIVEREF(__pyx_tuple__63); - - /* "neo4j/packstream/_packer.pyx":188 - * write(struct_pack(">I", size)) - * else: - * raise OverflowError("String header size out of range") # <<<<<<<<<<<<<< - * - * cdef pack_list_header(self, int size): - */ - __pyx_tuple__64 = PyTuple_Pack(1, __pyx_kp_s_String_header_size_out_of_range); if (unlikely(!__pyx_tuple__64)) __PYX_ERR(0, 188, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__64); - __Pyx_GIVEREF(__pyx_tuple__64); - - /* "neo4j/packstream/_packer.pyx":193 - * write = self._write - * if size == 0x00: - * write(b"\x90") # <<<<<<<<<<<<<< - * elif size == 0x01: - * write(b"\x91") - */ - __pyx_tuple__66 = PyTuple_Pack(1, __pyx_kp_b__65); if (unlikely(!__pyx_tuple__66)) __PYX_ERR(0, 193, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__66); - __Pyx_GIVEREF(__pyx_tuple__66); - - /* "neo4j/packstream/_packer.pyx":195 - * write(b"\x90") - * elif size == 0x01: - * write(b"\x91") # <<<<<<<<<<<<<< - * elif size == 0x02: - * write(b"\x92") - */ - __pyx_tuple__68 = PyTuple_Pack(1, __pyx_kp_b__67); if (unlikely(!__pyx_tuple__68)) __PYX_ERR(0, 195, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__68); - __Pyx_GIVEREF(__pyx_tuple__68); - - /* "neo4j/packstream/_packer.pyx":197 - * write(b"\x91") - * elif size == 0x02: - * write(b"\x92") # <<<<<<<<<<<<<< - * elif size == 0x03: - * write(b"\x93") - */ - __pyx_tuple__70 = PyTuple_Pack(1, __pyx_kp_b__69); if (unlikely(!__pyx_tuple__70)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__70); - __Pyx_GIVEREF(__pyx_tuple__70); - - /* "neo4j/packstream/_packer.pyx":199 - * write(b"\x92") - * elif size == 0x03: - * write(b"\x93") # <<<<<<<<<<<<<< - * elif size == 0x04: - * write(b"\x94") - */ - __pyx_tuple__72 = PyTuple_Pack(1, __pyx_kp_b__71); if (unlikely(!__pyx_tuple__72)) __PYX_ERR(0, 199, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__72); - __Pyx_GIVEREF(__pyx_tuple__72); - - /* "neo4j/packstream/_packer.pyx":201 - * write(b"\x93") - * elif size == 0x04: - * write(b"\x94") # <<<<<<<<<<<<<< - * elif size == 0x05: - * write(b"\x95") - */ - __pyx_tuple__74 = PyTuple_Pack(1, __pyx_kp_b__73); if (unlikely(!__pyx_tuple__74)) __PYX_ERR(0, 201, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__74); - __Pyx_GIVEREF(__pyx_tuple__74); - - /* "neo4j/packstream/_packer.pyx":203 - * write(b"\x94") - * elif size == 0x05: - * write(b"\x95") # <<<<<<<<<<<<<< - * elif size == 0x06: - * write(b"\x96") - */ - __pyx_tuple__76 = PyTuple_Pack(1, __pyx_kp_b__75); if (unlikely(!__pyx_tuple__76)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__76); - __Pyx_GIVEREF(__pyx_tuple__76); - - /* "neo4j/packstream/_packer.pyx":205 - * write(b"\x95") - * elif size == 0x06: - * write(b"\x96") # <<<<<<<<<<<<<< - * elif size == 0x07: - * write(b"\x97") - */ - __pyx_tuple__78 = PyTuple_Pack(1, __pyx_kp_b__77); if (unlikely(!__pyx_tuple__78)) __PYX_ERR(0, 205, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__78); - __Pyx_GIVEREF(__pyx_tuple__78); - - /* "neo4j/packstream/_packer.pyx":207 - * write(b"\x96") - * elif size == 0x07: - * write(b"\x97") # <<<<<<<<<<<<<< - * elif size == 0x08: - * write(b"\x98") - */ - __pyx_tuple__80 = PyTuple_Pack(1, __pyx_kp_b__79); if (unlikely(!__pyx_tuple__80)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__80); - __Pyx_GIVEREF(__pyx_tuple__80); - - /* "neo4j/packstream/_packer.pyx":209 - * write(b"\x97") - * elif size == 0x08: - * write(b"\x98") # <<<<<<<<<<<<<< - * elif size == 0x09: - * write(b"\x99") - */ - __pyx_tuple__82 = PyTuple_Pack(1, __pyx_kp_b__81); if (unlikely(!__pyx_tuple__82)) __PYX_ERR(0, 209, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__82); - __Pyx_GIVEREF(__pyx_tuple__82); - - /* "neo4j/packstream/_packer.pyx":211 - * write(b"\x98") - * elif size == 0x09: - * write(b"\x99") # <<<<<<<<<<<<<< - * elif size == 0x0A: - * write(b"\x9A") - */ - __pyx_tuple__84 = PyTuple_Pack(1, __pyx_kp_b__83); if (unlikely(!__pyx_tuple__84)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__84); - __Pyx_GIVEREF(__pyx_tuple__84); - - /* "neo4j/packstream/_packer.pyx":213 - * write(b"\x99") - * elif size == 0x0A: - * write(b"\x9A") # <<<<<<<<<<<<<< - * elif size == 0x0B: - * write(b"\x9B") - */ - __pyx_tuple__86 = PyTuple_Pack(1, __pyx_kp_b__85); if (unlikely(!__pyx_tuple__86)) __PYX_ERR(0, 213, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__86); - __Pyx_GIVEREF(__pyx_tuple__86); - - /* "neo4j/packstream/_packer.pyx":215 - * write(b"\x9A") - * elif size == 0x0B: - * write(b"\x9B") # <<<<<<<<<<<<<< - * elif size == 0x0C: - * write(b"\x9C") - */ - __pyx_tuple__88 = PyTuple_Pack(1, __pyx_kp_b__87); if (unlikely(!__pyx_tuple__88)) __PYX_ERR(0, 215, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__88); - __Pyx_GIVEREF(__pyx_tuple__88); - - /* "neo4j/packstream/_packer.pyx":217 - * write(b"\x9B") - * elif size == 0x0C: - * write(b"\x9C") # <<<<<<<<<<<<<< - * elif size == 0x0D: - * write(b"\x9D") - */ - __pyx_tuple__90 = PyTuple_Pack(1, __pyx_kp_b__89); if (unlikely(!__pyx_tuple__90)) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__90); - __Pyx_GIVEREF(__pyx_tuple__90); - - /* "neo4j/packstream/_packer.pyx":219 - * write(b"\x9C") - * elif size == 0x0D: - * write(b"\x9D") # <<<<<<<<<<<<<< - * elif size == 0x0E: - * write(b"\x9E") - */ - __pyx_tuple__92 = PyTuple_Pack(1, __pyx_kp_b__91); if (unlikely(!__pyx_tuple__92)) __PYX_ERR(0, 219, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__92); - __Pyx_GIVEREF(__pyx_tuple__92); - - /* "neo4j/packstream/_packer.pyx":221 - * write(b"\x9D") - * elif size == 0x0E: - * write(b"\x9E") # <<<<<<<<<<<<<< - * elif size == 0x0F: - * write(b"\x9F") - */ - __pyx_tuple__94 = PyTuple_Pack(1, __pyx_kp_b__93); if (unlikely(!__pyx_tuple__94)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__94); - __Pyx_GIVEREF(__pyx_tuple__94); - - /* "neo4j/packstream/_packer.pyx":223 - * write(b"\x9E") - * elif size == 0x0F: - * write(b"\x9F") # <<<<<<<<<<<<<< - * elif size < 0x100: - * write(b"\xD4") - */ - __pyx_tuple__96 = PyTuple_Pack(1, __pyx_kp_b__95); if (unlikely(!__pyx_tuple__96)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__96); - __Pyx_GIVEREF(__pyx_tuple__96); - - /* "neo4j/packstream/_packer.pyx":225 - * write(b"\x9F") - * elif size < 0x100: - * write(b"\xD4") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_tuple__98 = PyTuple_Pack(1, __pyx_kp_b__97); if (unlikely(!__pyx_tuple__98)) __PYX_ERR(0, 225, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__98); - __Pyx_GIVEREF(__pyx_tuple__98); - - /* "neo4j/packstream/_packer.pyx":228 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xD5") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - */ - __pyx_tuple__100 = PyTuple_Pack(1, __pyx_kp_b__99); if (unlikely(!__pyx_tuple__100)) __PYX_ERR(0, 228, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__100); - __Pyx_GIVEREF(__pyx_tuple__100); - - /* "neo4j/packstream/_packer.pyx":231 - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - * write(b"\xD6") # <<<<<<<<<<<<<< - * write(struct_pack(">I", size)) - * else: - */ - __pyx_tuple__102 = PyTuple_Pack(1, __pyx_kp_b__101); if (unlikely(!__pyx_tuple__102)) __PYX_ERR(0, 231, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__102); - __Pyx_GIVEREF(__pyx_tuple__102); - - /* "neo4j/packstream/_packer.pyx":234 - * write(struct_pack(">I", size)) - * else: - * raise OverflowError("List header size out of range") # <<<<<<<<<<<<<< - * - * cpdef pack_list_stream_header(self): - */ - __pyx_tuple__103 = PyTuple_Pack(1, __pyx_kp_s_List_header_size_out_of_range); if (unlikely(!__pyx_tuple__103)) __PYX_ERR(0, 234, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__103); - __Pyx_GIVEREF(__pyx_tuple__103); - - /* "neo4j/packstream/_packer.pyx":237 - * - * cpdef pack_list_stream_header(self): - * self._write(b"\xD7") # <<<<<<<<<<<<<< - * - * cdef pack_map_header(self, int size): - */ - __pyx_tuple__105 = PyTuple_Pack(1, __pyx_kp_b__104); if (unlikely(!__pyx_tuple__105)) __PYX_ERR(0, 237, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__105); - __Pyx_GIVEREF(__pyx_tuple__105); - - /* "neo4j/packstream/_packer.pyx":242 - * write = self._write - * if size == 0x00: - * write(b"\xA0") # <<<<<<<<<<<<<< - * elif size == 0x01: - * write(b"\xA1") - */ - __pyx_tuple__107 = PyTuple_Pack(1, __pyx_kp_b__106); if (unlikely(!__pyx_tuple__107)) __PYX_ERR(0, 242, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__107); - __Pyx_GIVEREF(__pyx_tuple__107); - - /* "neo4j/packstream/_packer.pyx":244 - * write(b"\xA0") - * elif size == 0x01: - * write(b"\xA1") # <<<<<<<<<<<<<< - * elif size == 0x02: - * write(b"\xA2") - */ - __pyx_tuple__109 = PyTuple_Pack(1, __pyx_kp_b__108); if (unlikely(!__pyx_tuple__109)) __PYX_ERR(0, 244, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__109); - __Pyx_GIVEREF(__pyx_tuple__109); - - /* "neo4j/packstream/_packer.pyx":246 - * write(b"\xA1") - * elif size == 0x02: - * write(b"\xA2") # <<<<<<<<<<<<<< - * elif size == 0x03: - * write(b"\xA3") - */ - __pyx_tuple__111 = PyTuple_Pack(1, __pyx_kp_b__110); if (unlikely(!__pyx_tuple__111)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__111); - __Pyx_GIVEREF(__pyx_tuple__111); - - /* "neo4j/packstream/_packer.pyx":248 - * write(b"\xA2") - * elif size == 0x03: - * write(b"\xA3") # <<<<<<<<<<<<<< - * elif size == 0x04: - * write(b"\xA4") - */ - __pyx_tuple__113 = PyTuple_Pack(1, __pyx_kp_b__112); if (unlikely(!__pyx_tuple__113)) __PYX_ERR(0, 248, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__113); - __Pyx_GIVEREF(__pyx_tuple__113); - - /* "neo4j/packstream/_packer.pyx":250 - * write(b"\xA3") - * elif size == 0x04: - * write(b"\xA4") # <<<<<<<<<<<<<< - * elif size == 0x05: - * write(b"\xA5") - */ - __pyx_tuple__115 = PyTuple_Pack(1, __pyx_kp_b__114); if (unlikely(!__pyx_tuple__115)) __PYX_ERR(0, 250, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__115); - __Pyx_GIVEREF(__pyx_tuple__115); - - /* "neo4j/packstream/_packer.pyx":252 - * write(b"\xA4") - * elif size == 0x05: - * write(b"\xA5") # <<<<<<<<<<<<<< - * elif size == 0x06: - * write(b"\xA6") - */ - __pyx_tuple__117 = PyTuple_Pack(1, __pyx_kp_b__116); if (unlikely(!__pyx_tuple__117)) __PYX_ERR(0, 252, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__117); - __Pyx_GIVEREF(__pyx_tuple__117); - - /* "neo4j/packstream/_packer.pyx":254 - * write(b"\xA5") - * elif size == 0x06: - * write(b"\xA6") # <<<<<<<<<<<<<< - * elif size == 0x07: - * write(b"\xA7") - */ - __pyx_tuple__119 = PyTuple_Pack(1, __pyx_kp_b__118); if (unlikely(!__pyx_tuple__119)) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__119); - __Pyx_GIVEREF(__pyx_tuple__119); - - /* "neo4j/packstream/_packer.pyx":256 - * write(b"\xA6") - * elif size == 0x07: - * write(b"\xA7") # <<<<<<<<<<<<<< - * elif size == 0x08: - * write(b"\xA8") - */ - __pyx_tuple__121 = PyTuple_Pack(1, __pyx_kp_b__120); if (unlikely(!__pyx_tuple__121)) __PYX_ERR(0, 256, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__121); - __Pyx_GIVEREF(__pyx_tuple__121); - - /* "neo4j/packstream/_packer.pyx":258 - * write(b"\xA7") - * elif size == 0x08: - * write(b"\xA8") # <<<<<<<<<<<<<< - * elif size == 0x09: - * write(b"\xA9") - */ - __pyx_tuple__123 = PyTuple_Pack(1, __pyx_kp_b__122); if (unlikely(!__pyx_tuple__123)) __PYX_ERR(0, 258, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__123); - __Pyx_GIVEREF(__pyx_tuple__123); - - /* "neo4j/packstream/_packer.pyx":260 - * write(b"\xA8") - * elif size == 0x09: - * write(b"\xA9") # <<<<<<<<<<<<<< - * elif size == 0x0A: - * write(b"\xAA") - */ - __pyx_tuple__125 = PyTuple_Pack(1, __pyx_kp_b__124); if (unlikely(!__pyx_tuple__125)) __PYX_ERR(0, 260, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__125); - __Pyx_GIVEREF(__pyx_tuple__125); - - /* "neo4j/packstream/_packer.pyx":262 - * write(b"\xA9") - * elif size == 0x0A: - * write(b"\xAA") # <<<<<<<<<<<<<< - * elif size == 0x0B: - * write(b"\xAB") - */ - __pyx_tuple__127 = PyTuple_Pack(1, __pyx_kp_b__126); if (unlikely(!__pyx_tuple__127)) __PYX_ERR(0, 262, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__127); - __Pyx_GIVEREF(__pyx_tuple__127); - - /* "neo4j/packstream/_packer.pyx":264 - * write(b"\xAA") - * elif size == 0x0B: - * write(b"\xAB") # <<<<<<<<<<<<<< - * elif size == 0x0C: - * write(b"\xAC") - */ - __pyx_tuple__129 = PyTuple_Pack(1, __pyx_kp_b__128); if (unlikely(!__pyx_tuple__129)) __PYX_ERR(0, 264, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__129); - __Pyx_GIVEREF(__pyx_tuple__129); - - /* "neo4j/packstream/_packer.pyx":266 - * write(b"\xAB") - * elif size == 0x0C: - * write(b"\xAC") # <<<<<<<<<<<<<< - * elif size == 0x0D: - * write(b"\xAD") - */ - __pyx_tuple__131 = PyTuple_Pack(1, __pyx_kp_b__130); if (unlikely(!__pyx_tuple__131)) __PYX_ERR(0, 266, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__131); - __Pyx_GIVEREF(__pyx_tuple__131); - - /* "neo4j/packstream/_packer.pyx":268 - * write(b"\xAC") - * elif size == 0x0D: - * write(b"\xAD") # <<<<<<<<<<<<<< - * elif size == 0x0E: - * write(b"\xAE") - */ - __pyx_tuple__133 = PyTuple_Pack(1, __pyx_kp_b__132); if (unlikely(!__pyx_tuple__133)) __PYX_ERR(0, 268, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__133); - __Pyx_GIVEREF(__pyx_tuple__133); - - /* "neo4j/packstream/_packer.pyx":270 - * write(b"\xAD") - * elif size == 0x0E: - * write(b"\xAE") # <<<<<<<<<<<<<< - * elif size == 0x0F: - * write(b"\xAF") - */ - __pyx_tuple__135 = PyTuple_Pack(1, __pyx_kp_b__134); if (unlikely(!__pyx_tuple__135)) __PYX_ERR(0, 270, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__135); - __Pyx_GIVEREF(__pyx_tuple__135); - - /* "neo4j/packstream/_packer.pyx":272 - * write(b"\xAE") - * elif size == 0x0F: - * write(b"\xAF") # <<<<<<<<<<<<<< - * elif size < 0x100: - * write(b"\xD8") - */ - __pyx_tuple__137 = PyTuple_Pack(1, __pyx_kp_b__136); if (unlikely(!__pyx_tuple__137)) __PYX_ERR(0, 272, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__137); - __Pyx_GIVEREF(__pyx_tuple__137); - - /* "neo4j/packstream/_packer.pyx":274 - * write(b"\xAF") - * elif size < 0x100: - * write(b"\xD8") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_tuple__139 = PyTuple_Pack(1, __pyx_kp_b__138); if (unlikely(!__pyx_tuple__139)) __PYX_ERR(0, 274, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__139); - __Pyx_GIVEREF(__pyx_tuple__139); - - /* "neo4j/packstream/_packer.pyx":277 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xD9") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - */ - __pyx_tuple__141 = PyTuple_Pack(1, __pyx_kp_b__140); if (unlikely(!__pyx_tuple__141)) __PYX_ERR(0, 277, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__141); - __Pyx_GIVEREF(__pyx_tuple__141); - - /* "neo4j/packstream/_packer.pyx":280 - * write(PACKED_UINT_16[size]) - * elif size < 0x100000000: - * write(b"\xDA") # <<<<<<<<<<<<<< - * write(struct_pack(">I", size)) - * else: - */ - __pyx_tuple__143 = PyTuple_Pack(1, __pyx_kp_b__142); if (unlikely(!__pyx_tuple__143)) __PYX_ERR(0, 280, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__143); - __Pyx_GIVEREF(__pyx_tuple__143); - - /* "neo4j/packstream/_packer.pyx":283 - * write(struct_pack(">I", size)) - * else: - * raise OverflowError("Map header size out of range") # <<<<<<<<<<<<<< - * - * cpdef pack_map_stream_header(self): - */ - __pyx_tuple__144 = PyTuple_Pack(1, __pyx_kp_s_Map_header_size_out_of_range); if (unlikely(!__pyx_tuple__144)) __PYX_ERR(0, 283, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__144); - __Pyx_GIVEREF(__pyx_tuple__144); - - /* "neo4j/packstream/_packer.pyx":286 - * - * cpdef pack_map_stream_header(self): - * self._write(b"\xDB") # <<<<<<<<<<<<<< - * - * cpdef pack_struct(self, bytes signature, fields): - */ - __pyx_tuple__146 = PyTuple_Pack(1, __pyx_kp_b__145); if (unlikely(!__pyx_tuple__146)) __PYX_ERR(0, 286, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__146); - __Pyx_GIVEREF(__pyx_tuple__146); - - /* "neo4j/packstream/_packer.pyx":290 - * cpdef pack_struct(self, bytes signature, fields): - * if len(signature) != 1: - * raise ValueError("Structure signature must be a single byte value") # <<<<<<<<<<<<<< - * write = self._write - * size = len(fields) - */ - __pyx_tuple__147 = PyTuple_Pack(1, __pyx_kp_s_Structure_signature_must_be_a_si); if (unlikely(!__pyx_tuple__147)) __PYX_ERR(0, 290, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__147); - __Pyx_GIVEREF(__pyx_tuple__147); - - /* "neo4j/packstream/_packer.pyx":294 - * size = len(fields) - * if size == 0x00: - * write(b"\xB0") # <<<<<<<<<<<<<< - * elif size == 0x01: - * write(b"\xB1") - */ - __pyx_tuple__149 = PyTuple_Pack(1, __pyx_kp_b__148); if (unlikely(!__pyx_tuple__149)) __PYX_ERR(0, 294, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__149); - __Pyx_GIVEREF(__pyx_tuple__149); - - /* "neo4j/packstream/_packer.pyx":296 - * write(b"\xB0") - * elif size == 0x01: - * write(b"\xB1") # <<<<<<<<<<<<<< - * elif size == 0x02: - * write(b"\xB2") - */ - __pyx_tuple__151 = PyTuple_Pack(1, __pyx_kp_b__150); if (unlikely(!__pyx_tuple__151)) __PYX_ERR(0, 296, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__151); - __Pyx_GIVEREF(__pyx_tuple__151); - - /* "neo4j/packstream/_packer.pyx":298 - * write(b"\xB1") - * elif size == 0x02: - * write(b"\xB2") # <<<<<<<<<<<<<< - * elif size == 0x03: - * write(b"\xB3") - */ - __pyx_tuple__153 = PyTuple_Pack(1, __pyx_kp_b__152); if (unlikely(!__pyx_tuple__153)) __PYX_ERR(0, 298, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__153); - __Pyx_GIVEREF(__pyx_tuple__153); - - /* "neo4j/packstream/_packer.pyx":300 - * write(b"\xB2") - * elif size == 0x03: - * write(b"\xB3") # <<<<<<<<<<<<<< - * elif size == 0x04: - * write(b"\xB4") - */ - __pyx_tuple__155 = PyTuple_Pack(1, __pyx_kp_b__154); if (unlikely(!__pyx_tuple__155)) __PYX_ERR(0, 300, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__155); - __Pyx_GIVEREF(__pyx_tuple__155); - - /* "neo4j/packstream/_packer.pyx":302 - * write(b"\xB3") - * elif size == 0x04: - * write(b"\xB4") # <<<<<<<<<<<<<< - * elif size == 0x05: - * write(b"\xB5") - */ - __pyx_tuple__157 = PyTuple_Pack(1, __pyx_kp_b__156); if (unlikely(!__pyx_tuple__157)) __PYX_ERR(0, 302, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__157); - __Pyx_GIVEREF(__pyx_tuple__157); - - /* "neo4j/packstream/_packer.pyx":304 - * write(b"\xB4") - * elif size == 0x05: - * write(b"\xB5") # <<<<<<<<<<<<<< - * elif size == 0x06: - * write(b"\xB6") - */ - __pyx_tuple__159 = PyTuple_Pack(1, __pyx_kp_b__158); if (unlikely(!__pyx_tuple__159)) __PYX_ERR(0, 304, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__159); - __Pyx_GIVEREF(__pyx_tuple__159); - - /* "neo4j/packstream/_packer.pyx":306 - * write(b"\xB5") - * elif size == 0x06: - * write(b"\xB6") # <<<<<<<<<<<<<< - * elif size == 0x07: - * write(b"\xB7") - */ - __pyx_tuple__161 = PyTuple_Pack(1, __pyx_kp_b__160); if (unlikely(!__pyx_tuple__161)) __PYX_ERR(0, 306, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__161); - __Pyx_GIVEREF(__pyx_tuple__161); - - /* "neo4j/packstream/_packer.pyx":308 - * write(b"\xB6") - * elif size == 0x07: - * write(b"\xB7") # <<<<<<<<<<<<<< - * elif size == 0x08: - * write(b"\xB8") - */ - __pyx_tuple__163 = PyTuple_Pack(1, __pyx_kp_b__162); if (unlikely(!__pyx_tuple__163)) __PYX_ERR(0, 308, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__163); - __Pyx_GIVEREF(__pyx_tuple__163); - - /* "neo4j/packstream/_packer.pyx":310 - * write(b"\xB7") - * elif size == 0x08: - * write(b"\xB8") # <<<<<<<<<<<<<< - * elif size == 0x09: - * write(b"\xB9") - */ - __pyx_tuple__165 = PyTuple_Pack(1, __pyx_kp_b__164); if (unlikely(!__pyx_tuple__165)) __PYX_ERR(0, 310, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__165); - __Pyx_GIVEREF(__pyx_tuple__165); - - /* "neo4j/packstream/_packer.pyx":312 - * write(b"\xB8") - * elif size == 0x09: - * write(b"\xB9") # <<<<<<<<<<<<<< - * elif size == 0x0A: - * write(b"\xBA") - */ - __pyx_tuple__167 = PyTuple_Pack(1, __pyx_kp_b__166); if (unlikely(!__pyx_tuple__167)) __PYX_ERR(0, 312, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__167); - __Pyx_GIVEREF(__pyx_tuple__167); - - /* "neo4j/packstream/_packer.pyx":314 - * write(b"\xB9") - * elif size == 0x0A: - * write(b"\xBA") # <<<<<<<<<<<<<< - * elif size == 0x0B: - * write(b"\xBB") - */ - __pyx_tuple__169 = PyTuple_Pack(1, __pyx_kp_b__168); if (unlikely(!__pyx_tuple__169)) __PYX_ERR(0, 314, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__169); - __Pyx_GIVEREF(__pyx_tuple__169); - - /* "neo4j/packstream/_packer.pyx":316 - * write(b"\xBA") - * elif size == 0x0B: - * write(b"\xBB") # <<<<<<<<<<<<<< - * elif size == 0x0C: - * write(b"\xBC") - */ - __pyx_tuple__171 = PyTuple_Pack(1, __pyx_kp_b__170); if (unlikely(!__pyx_tuple__171)) __PYX_ERR(0, 316, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__171); - __Pyx_GIVEREF(__pyx_tuple__171); - - /* "neo4j/packstream/_packer.pyx":318 - * write(b"\xBB") - * elif size == 0x0C: - * write(b"\xBC") # <<<<<<<<<<<<<< - * elif size == 0x0D: - * write(b"\xBD") - */ - __pyx_tuple__173 = PyTuple_Pack(1, __pyx_kp_b__172); if (unlikely(!__pyx_tuple__173)) __PYX_ERR(0, 318, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__173); - __Pyx_GIVEREF(__pyx_tuple__173); - - /* "neo4j/packstream/_packer.pyx":320 - * write(b"\xBC") - * elif size == 0x0D: - * write(b"\xBD") # <<<<<<<<<<<<<< - * elif size == 0x0E: - * write(b"\xBE") - */ - __pyx_tuple__175 = PyTuple_Pack(1, __pyx_kp_b__174); if (unlikely(!__pyx_tuple__175)) __PYX_ERR(0, 320, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__175); - __Pyx_GIVEREF(__pyx_tuple__175); - - /* "neo4j/packstream/_packer.pyx":322 - * write(b"\xBD") - * elif size == 0x0E: - * write(b"\xBE") # <<<<<<<<<<<<<< - * elif size == 0x0F: - * write(b"\xBF") - */ - __pyx_tuple__177 = PyTuple_Pack(1, __pyx_kp_b__176); if (unlikely(!__pyx_tuple__177)) __PYX_ERR(0, 322, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__177); - __Pyx_GIVEREF(__pyx_tuple__177); - - /* "neo4j/packstream/_packer.pyx":324 - * write(b"\xBE") - * elif size == 0x0F: - * write(b"\xBF") # <<<<<<<<<<<<<< - * elif size < 0x100: - * write(b"\xDC") - */ - __pyx_tuple__179 = PyTuple_Pack(1, __pyx_kp_b__178); if (unlikely(!__pyx_tuple__179)) __PYX_ERR(0, 324, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__179); - __Pyx_GIVEREF(__pyx_tuple__179); - - /* "neo4j/packstream/_packer.pyx":326 - * write(b"\xBF") - * elif size < 0x100: - * write(b"\xDC") # <<<<<<<<<<<<<< - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - */ - __pyx_tuple__181 = PyTuple_Pack(1, __pyx_kp_b__180); if (unlikely(!__pyx_tuple__181)) __PYX_ERR(0, 326, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__181); - __Pyx_GIVEREF(__pyx_tuple__181); - - /* "neo4j/packstream/_packer.pyx":329 - * write(PACKED_UINT_8[size]) - * elif size < 0x10000: - * write(b"\xDD") # <<<<<<<<<<<<<< - * write(PACKED_UINT_16[size]) - * else: - */ - __pyx_tuple__183 = PyTuple_Pack(1, __pyx_kp_b__182); if (unlikely(!__pyx_tuple__183)) __PYX_ERR(0, 329, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__183); - __Pyx_GIVEREF(__pyx_tuple__183); - - /* "neo4j/packstream/_packer.pyx":332 - * write(PACKED_UINT_16[size]) - * else: - * raise OverflowError("Structure size out of range") # <<<<<<<<<<<<<< - * write(signature) - * for field in fields: - */ - __pyx_tuple__184 = PyTuple_Pack(1, __pyx_kp_s_Structure_size_out_of_range); if (unlikely(!__pyx_tuple__184)) __PYX_ERR(0, 332, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__184); - __Pyx_GIVEREF(__pyx_tuple__184); - - /* "neo4j/packstream/_packer.pyx":338 - * - * cpdef pack_end_of_stream(self): - * self._write(b"\xDF") # <<<<<<<<<<<<<< - */ - __pyx_tuple__186 = PyTuple_Pack(1, __pyx_kp_b__185); if (unlikely(!__pyx_tuple__186)) __PYX_ERR(0, 338, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__186); - __Pyx_GIVEREF(__pyx_tuple__186); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple__187 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__187)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__187); - __Pyx_GIVEREF(__pyx_tuple__187); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__188 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__188)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__188); - __Pyx_GIVEREF(__pyx_tuple__188); - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - __pyx_int_128 = PyInt_FromLong(128); if (unlikely(!__pyx_int_128)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_32768 = PyInt_FromLong(32768L); if (unlikely(!__pyx_int_32768)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_65536 = PyInt_FromLong(65536L); if (unlikely(!__pyx_int_65536)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_2147483648 = PyInt_FromString((char *)"2147483648", 0, 0); if (unlikely(!__pyx_int_2147483648)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_4294967296 = PyInt_FromString((char *)"4294967296", 0, 0); if (unlikely(!__pyx_int_4294967296)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_9223372036854775808 = PyInt_FromString((char *)"9223372036854775808", 0, 0); if (unlikely(!__pyx_int_9223372036854775808)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_neg_16 = PyInt_FromLong(-16); if (unlikely(!__pyx_int_neg_16)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_neg_128 = PyInt_FromLong(-128); if (unlikely(!__pyx_int_neg_128)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_neg_32768 = PyInt_FromLong(-32768L); if (unlikely(!__pyx_int_neg_32768)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_neg_2147483648 = PyInt_FromLong(-2147483648L); if (unlikely(!__pyx_int_neg_2147483648)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_int_neg_9223372036854775808 = PyInt_FromString((char *)"-9223372036854775808", 0, 0); if (unlikely(!__pyx_int_neg_9223372036854775808)) __PYX_ERR(0, 1, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC init_packer(void); /*proto*/ -PyMODINIT_FUNC init_packer(void) -#else -PyMODINIT_FUNC PyInit__packer(void); /*proto*/ -PyMODINIT_FUNC PyInit__packer(void) -#if CYTHON_PEP489_MULTI_PHASE_INIT -{ - return PyModuleDef_Init(&__pyx_moduledef); -} -static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { - PyObject *value = PyObject_GetAttrString(spec, from_name); - int result = 0; - if (likely(value)) { - result = PyDict_SetItemString(moddict, to_name, value); - Py_DECREF(value); - } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - result = -1; - } - return result; -} -static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { - PyObject *module = NULL, *moddict, *modname; - 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__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; - return module; -bad: - Py_XDECREF(module); - return NULL; -} - - -static int __pyx_pymod_exec__packer(PyObject *__pyx_pyinit_module) -#endif -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannyDeclarations - #if CYTHON_PEP489_MULTI_PHASE_INIT - if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; - #endif - #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("PyMODINIT_FUNC PyInit__packer(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_AsyncGen_USED - if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ - PyEval_InitThreads(); - #endif - #endif - /*--- Module creation code ---*/ - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_m = __pyx_pyinit_module; - Py_INCREF(__pyx_m); - #else - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("_packer", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - #if CYTHON_COMPILING_IN_PYPY - Py_INCREF(__pyx_b); - #endif - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_neo4j__packstream___packer) { - if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "neo4j.packstream._packer")) { - if (unlikely(PyDict_SetItemString(modules, "neo4j.packstream._packer", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global init code ---*/ - __pyx_v_5neo4j_10packstream_7_packer_INT64_HI = Py_None; Py_INCREF(Py_None); - __pyx_v_5neo4j_10packstream_7_packer_INT64_LO = Py_None; Py_INCREF(Py_None); - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - __pyx_vtabptr_5neo4j_10packstream_7_packer_Packer = &__pyx_vtable_5neo4j_10packstream_7_packer_Packer; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack_raw = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, PyObject *))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_raw; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, PyObject *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer._pack = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, PyObject *))__pyx_f_5neo4j_10packstream_7_packer_6Packer__pack; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack_bytes_header = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_bytes_header; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack_string_header = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_string_header; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack_list_header = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_list_header; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack_list_stream_header = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_list_stream_header; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack_map_header = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_map_header; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack_map_stream_header = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_map_stream_header; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack_struct = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, PyObject *, PyObject *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_struct; - __pyx_vtable_5neo4j_10packstream_7_packer_Packer.pack_end_of_stream = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_7_packer_Packer *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_7_packer_6Packer_pack_end_of_stream; - if (PyType_Ready(&__pyx_type_5neo4j_10packstream_7_packer_Packer) < 0) __PYX_ERR(0, 34, __pyx_L1_error) - __pyx_type_5neo4j_10packstream_7_packer_Packer.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_5neo4j_10packstream_7_packer_Packer.tp_dict, __pyx_vtabptr_5neo4j_10packstream_7_packer_Packer) < 0) __PYX_ERR(0, 34, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "Packer", (PyObject *)&__pyx_type_5neo4j_10packstream_7_packer_Packer) < 0) __PYX_ERR(0, 34, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5neo4j_10packstream_7_packer_Packer) < 0) __PYX_ERR(0, 34, __pyx_L1_error) - __pyx_ptype_5neo4j_10packstream_7_packer_Packer = &__pyx_type_5neo4j_10packstream_7_packer_Packer; - /*--- Type import code ---*/ - /*--- Variable import code ---*/ - /*--- Function import code ---*/ - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "neo4j/packstream/_packer.pyx":22 - * - * - * from struct import pack as struct_pack # <<<<<<<<<<<<<< - * - * from neo4j.compat import integer, string - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_pack); - __Pyx_GIVEREF(__pyx_n_s_pack); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_pack); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_struct, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_pack); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_struct_pack, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_packer.pyx":24 - * from struct import pack as struct_pack - * - * from neo4j.compat import integer, string # <<<<<<<<<<<<<< - * - * from .constants import * - */ - __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_integer); - __Pyx_GIVEREF(__pyx_n_s_integer); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_integer); - __Pyx_INCREF(__pyx_n_s_string); - __Pyx_GIVEREF(__pyx_n_s_string); - PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_string); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_neo4j_compat, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_integer); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_integer, __pyx_t_2) < 0) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_string); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_string, __pyx_t_2) < 0) __PYX_ERR(0, 24, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":26 - * from neo4j.compat import integer, string - * - * from .constants import * # <<<<<<<<<<<<<< - * from .structure import Structure - * - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 26, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s__189); - __Pyx_GIVEREF(__pyx_n_s__189); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s__189); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_constants, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 26, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - if (__pyx_import_star(__pyx_t_2) < 0) __PYX_ERR(0, 26, __pyx_L1_error); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_packer.pyx":27 - * - * from .constants import * - * from .structure import Structure # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_Structure); - __Pyx_GIVEREF(__pyx_n_s_Structure); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Structure); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_structure, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Structure); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_Structure, __pyx_t_2) < 0) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_packer.pyx":30 - * - * - * cdef INT64_HI = 2 ** 63 # <<<<<<<<<<<<<< - * cdef INT64_LO = -(2 ** 63) - * - */ - __Pyx_INCREF(__pyx_int_9223372036854775808); - __Pyx_XGOTREF(__pyx_v_5neo4j_10packstream_7_packer_INT64_HI); - __Pyx_DECREF_SET(__pyx_v_5neo4j_10packstream_7_packer_INT64_HI, __pyx_int_9223372036854775808); - __Pyx_GIVEREF(__pyx_int_9223372036854775808); - - /* "neo4j/packstream/_packer.pyx":31 - * - * cdef INT64_HI = 2 ** 63 - * cdef INT64_LO = -(2 ** 63) # <<<<<<<<<<<<<< - * - * - */ - __Pyx_INCREF(__pyx_int_neg_9223372036854775808); - __Pyx_XGOTREF(__pyx_v_5neo4j_10packstream_7_packer_INT64_LO); - __Pyx_DECREF_SET(__pyx_v_5neo4j_10packstream_7_packer_INT64_LO, __pyx_int_neg_9223372036854775808); - __Pyx_GIVEREF(__pyx_int_neg_9223372036854775808); - - /* "neo4j/packstream/_packer.pyx":1 - * #!/usr/bin/env python # <<<<<<<<<<<<<< - * # -*- encoding: utf-8 -*- - * - */ - __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init neo4j.packstream._packer", 0, __pyx_lineno, __pyx_filename); - } - Py_DECREF(__pyx_m); __pyx_m = 0; - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init neo4j.packstream._packer"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if CYTHON_PEP489_MULTI_PHASE_INIT - return (__pyx_m != NULL) ? 0 : -1; - #elif PY_MAJOR_VERSION >= 3 - return __pyx_m; - #else - return; - #endif -} - -/* --- 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((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* RaiseDoubleKeywords */ -static void __Pyx_RaiseDoubleKeywordsError( - const char* func_name, - PyObject* kw_name) -{ - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION >= 3 - "%s() got multiple values for keyword argument '%U'", func_name, kw_name); - #else - "%s() got multiple values for keyword argument '%s'", func_name, - PyString_AsString(kw_name)); - #endif -} - -/* ParseKeywords */ -static int __Pyx_ParseOptionalKeywords( - PyObject *kwds, - PyObject **argnames[], - PyObject *kwds2, - PyObject *values[], - Py_ssize_t num_pos_args, - const char* function_name) -{ - PyObject *key = 0, *value = 0; - Py_ssize_t pos = 0; - PyObject*** name; - PyObject*** first_kw_arg = argnames + num_pos_args; - while (PyDict_Next(kwds, &pos, &key, &value)) { - name = first_kw_arg; - while (*name && (**name != key)) name++; - if (*name) { - values[name-argnames] = value; - continue; - } - name = first_kw_arg; - #if PY_MAJOR_VERSION < 3 - if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) { - while (*name) { - if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key)) - && _PyString_Eq(**name, key)) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - if ((**argname == key) || ( - (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key)) - && _PyString_Eq(**argname, key))) { - goto arg_passed_twice; - } - argname++; - } - } - } else - #endif - if (likely(PyUnicode_Check(key))) { - while (*name) { - int cmp = (**name == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**name, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) { - values[name-argnames] = value; - break; - } - name++; - } - if (*name) continue; - else { - PyObject*** argname = argnames; - while (argname != first_kw_arg) { - int cmp = (**argname == key) ? 0 : - #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3 - (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 : - #endif - PyUnicode_Compare(**argname, key); - if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad; - if (cmp == 0) goto arg_passed_twice; - argname++; - } - } - } else - goto invalid_keyword_type; - if (kwds2) { - if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad; - } else { - goto invalid_keyword; - } - } - 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; -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif -bad: - return -1; -} - -/* 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); -} - -/* PyCFunctionFastCall */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); - } -} -#endif - -/* PyFunctionFastCall */ -#if CYTHON_FAST_PYCALL -#include "frameobject.h" -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = f->f_localsplus; - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCall */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = func->ob_type->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" 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 = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" 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 - -/* PyObjectCallOneArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* GetModuleGlobalName */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS - result = PyDict_GetItem(__pyx_d, name); - if (likely(result)) { - Py_INCREF(result); - } else { -#else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); - } - return result; -} - -/* PyIntBinop */ - #if !CYTHON_COMPILING_IN_PYPY -static PyObject* __Pyx_PyInt_RemainderObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED int inplace) { - #if PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(op1))) { - const long b = intval; - long x; - long a = PyInt_AS_LONG(op1); - x = a % b; - x += ((x != 0) & ((x ^ b) < 0)) * b; - return PyInt_FromLong(x); - } - #endif - #if CYTHON_USE_PYLONG_INTERNALS - if (likely(PyLong_CheckExact(op1))) { - const long b = intval; - long a, x; -#ifdef HAVE_LONG_LONG - const PY_LONG_LONG llb = intval; - PY_LONG_LONG lla, llx; -#endif - const digit* digits = ((PyLongObject*)op1)->ob_digit; - const Py_ssize_t size = Py_SIZE(op1); - if (likely(__Pyx_sst_abs(size) <= 1)) { - a = likely(size) ? digits[0] : 0; - if (size == -1) a = -a; - } 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])); - break; -#ifdef HAVE_LONG_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])); - goto long_long; -#endif - } - case 2: - if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) { - a = (long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])); - break; -#ifdef HAVE_LONG_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])); - goto long_long; -#endif - } - 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])); - break; -#ifdef HAVE_LONG_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])); - goto long_long; -#endif - } - 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])); - break; -#ifdef HAVE_LONG_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])); - goto long_long; -#endif - } - 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])); - break; -#ifdef HAVE_LONG_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])); - goto long_long; -#endif - } - 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])); - break; -#ifdef HAVE_LONG_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])); - goto long_long; -#endif - } - default: return PyLong_Type.tp_as_number->nb_remainder(op1, op2); - } - } - x = a % b; - x += ((x != 0) & ((x ^ b) < 0)) * b; - return PyLong_FromLong(x); -#ifdef HAVE_LONG_LONG - long_long: - llx = lla % llb; - llx += ((llx != 0) & ((llx ^ llb) < 0)) * llb; - return PyLong_FromLongLong(llx); -#endif - - - } - #endif - return (inplace ? PyNumber_InPlaceRemainder : PyNumber_Remainder)(op1, op2); -} -#endif - -/* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - 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); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *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 - -/* RaiseException */ - #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -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 CYTHON_COMPILING_IN_PYPY - 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); -#else - 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); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* PyObjectCallNoArg */ - #if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, NULL, 0); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); - } - } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); -} - -/* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { - PyErr_Format(PyExc_ValueError, - "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", - index, (index == 1) ? "" : "s"); -} - -/* IterFinish */ - static CYTHON_INLINE int __Pyx_IterFinish(void) { -#if CYTHON_FAST_THREAD_STATE - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* exc_type = tstate->curexc_type; - if (unlikely(exc_type)) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { - PyObject *exc_value, *exc_tb; - exc_value = tstate->curexc_value; - exc_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; - Py_DECREF(exc_type); - Py_XDECREF(exc_value); - Py_XDECREF(exc_tb); - return 0; - } else { - return -1; - } - } - return 0; -#else - if (unlikely(PyErr_Occurred())) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { - PyErr_Clear(); - return 0; - } else { - return -1; - } - } - return 0; -#endif -} - -/* UnpackItemEndCheck */ - static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { - if (unlikely(retval)) { - Py_DECREF(retval); - __Pyx_RaiseTooManyValuesError(expected); - return -1; - } else { - return __Pyx_IterFinish(); - } - return 0; -} - -/* GetItemInt */ - static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!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, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if 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((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* ArgTypeTest */ - static int __Pyx__ArgTypeTest(PyObject *obj, PyTypeObject *type, const char *name, int exact) -{ - if (unlikely(!type)) { - PyErr_SetString(PyExc_SystemError, "Missing type object"); - return 0; - } - else if (exact) { - #if PY_MAJOR_VERSION == 2 - if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1; - #endif - } - else { - if (likely(__Pyx_TypeCheck(obj, type))) return 1; - } - PyErr_Format(PyExc_TypeError, - "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)", - name, type->tp_name, Py_TYPE(obj)->tp_name); - return 0; -} - -/* SetVTable */ - static int __Pyx_SetVtable(PyObject *dict, void *vtable) { -#if PY_VERSION_HEX >= 0x02070000 - PyObject *ob = PyCapsule_New(vtable, 0, 0); -#else - PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); -#endif - if (!ob) - goto bad; - if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) - goto bad; - Py_DECREF(ob); - return 0; -bad: - Py_XDECREF(ob); - return -1; -} - -/* SetupReduce */ - static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { - int ret; - PyObject *name_attr; - name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_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_reduce_ex = NULL; - PyObject *reduce = NULL; - PyObject *reduce_ex = NULL; - PyObject *reduce_cython = NULL; - PyObject *setstate = NULL; - PyObject *setstate_cython = NULL; -#if CYTHON_USE_PYTYPE_LOOKUP - if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; -#else - if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; -#endif -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; -#else - object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; -#endif - reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; - if (reduce_ex == object_reduce_ex) { -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; -#else - object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; -#endif - reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; - if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; - setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); - if (!setstate) PyErr_Clear(); - if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; - } - PyType_Modified((PyTypeObject*)type_obj); - } - } - goto GOOD; -BAD: - if (!PyErr_Occurred()) - PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); - ret = -1; -GOOD: -#if !CYTHON_USE_PYTYPE_LOOKUP - Py_XDECREF(object_reduce); - Py_XDECREF(object_reduce_ex); -#endif - Py_XDECREF(reduce); - Py_XDECREF(reduce_ex); - Py_XDECREF(reduce_cython); - Py_XDECREF(setstate); - Py_XDECREF(setstate_cython); - return ret; -} - -/* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_MAJOR_VERSION < 3 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if (strchr(__Pyx_MODULE_NAME, '.')) { - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_MAJOR_VERSION < 3 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_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)) { - PyErr_Format(PyExc_ImportError, - #if PY_MAJOR_VERSION < 3 - "cannot import name %.230s", PyString_AS_STRING(name)); - #else - "cannot import name %S", name); - #endif - } - return value; -} - -/* CLineInTraceback */ - #ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { - PyObject *use_cline; - PyObject *ptype, *pvalue, *ptraceback; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict; -#endif - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); -#if CYTHON_COMPILING_IN_CPYTHON - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (likely(cython_runtime_dict)) { - use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); - } else -#endif - { - PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); - if (use_cline_obj) { - use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; - Py_DECREF(use_cline_obj); - } else { - PyErr_Clear(); - use_cline = NULL; - } - } - if (!use_cline) { - c_line = 0; - PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); - } - else if (PyObject_Not(use_cline) != 0) { - c_line = 0; - } - __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 PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_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(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - 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; - 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) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); - } - py_frame = PyFrame_New( - tstate, /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __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); -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } 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 PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* 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 long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - 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 - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - 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_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - 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 - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - 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 = a->tp_base; - 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); -} -#if PY_MAJOR_VERSION == 2 -static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { - PyObject *exception, *value, *tb; - int res; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&exception, &value, &tb); - res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - if (!res) { - res = PyObject_IsSubclass(err, exc_type2); - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - } - __Pyx_ErrRestore(exception, value, tb); - return res; -} -#else -static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { - int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; - if (!res) { - res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); - } - return res; -} -#endif -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { - if (likely(err == exc_type)) return 1; - if (likely(PyExceptionClass_Check(err))) { - return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); - } - return PyErr_GivenExceptionMatches(err, exc_type); -} -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { - if (likely(err == exc_type1 || err == exc_type2)) return 1; - if (likely(PyExceptionClass_Check(err))) { - return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); - } - return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); -} -#endif - -/* CStringEquals */ - static CYTHON_INLINE int __Pyx_StrEq(const char *s1, const char *s2) { - while (*s1 != '\0' && *s1 == *s2) { s1++; s2++; } - return *s1 == *s2; -} - -/* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { - char ctversion[4], rtversion[4]; - PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); - if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { - char message[200]; - PyOS_snprintf(message, sizeof(message), - "compiletime version %s of module '%.100s' " - "does not match runtime version %s", - ctversion, __Pyx_MODULE_NAME, rtversion); - return PyErr_WarnEx(NULL, message, 1); - } - return 0; -} - -/* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - if (PyObject_Hash(*t->p) == -1) - PyErr_Clear(); - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -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_DEFAULT -#if !CYTHON_PEP393_ENABLED -static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -} -#else -static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; -#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_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { - return __Pyx_PyUnicode_AsStringAndSize(o, length); - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - 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 PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { -#if PY_MAJOR_VERSION >= 3 - if (PyLong_Check(result)) { - if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, - "__int__ returned non-int (type %.200s). " - "The ability to return an instance of a strict subclass of int " - "is deprecated, and may be removed in a future version of Python.", - Py_TYPE(result)->tp_name)) { - Py_DECREF(result); - return NULL; - } - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - type_name, type_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x) || PyLong_Check(x))) -#else - if (likely(PyLong_Check(x))) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = m->nb_int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = m->nb_long(x); - } - #else - if (likely(m && m->nb_int)) { - name = "int"; - res = m->nb_int(x); - } - #endif -#else - if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { - res = PyNumber_Int(x); - } -#endif - if (likely(res)) { -#if PY_MAJOR_VERSION < 3 - if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { -#else - if (unlikely(!PyLong_CheckExact(res))) { -#endif - return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); - } - } - 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 PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(x); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - 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 = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/neo4j/packstream/_packer.pyx b/neo4j/packstream/_packer.pyx deleted file mode 100644 index f8dce501a..000000000 --- a/neo4j/packstream/_packer.pyx +++ /dev/null @@ -1,338 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from struct import pack as struct_pack - -from neo4j.compat import integer, string - -from .constants import * -from .structure import Structure - - -cdef INT64_HI = 2 ** 63 -cdef INT64_LO = -(2 ** 63) - - -cdef class Packer(object): - - cdef public bint supports_bytes - - cdef stream - cdef _write - - def __cinit__(self, stream): - self.supports_bytes = False - self.stream = stream - self._write = self.stream.write - - cdef pack_raw(self, data): - self._write(data) - - cpdef pack(self, value): - return self._pack(value) - - cdef _pack(self, value): - write = self._write - - # None - if value is None: - write(b"\xC0") # NULL - - # Boolean - elif value is True: - write(b"\xC3") - elif value is False: - write(b"\xC2") - - # Float (only double precision is supported) - elif isinstance(value, float): - write(b"\xC1") - write(struct_pack(">d", value)) - - # Integer - elif isinstance(value, integer): - if -0x10 <= value < 0x80: - write(PACKED_UINT_8[value % 0x100]) - elif -0x80 <= value < -0x10: - write(b"\xC8") - write(PACKED_UINT_8[value % 0x100]) - elif -0x8000 <= value < 0x8000: - write(b"\xC9") - write(PACKED_UINT_16[value % 0x10000]) - elif -0x80000000 <= value < 0x80000000: - write(b"\xCA") - write(struct_pack(">i", value)) - elif INT64_LO <= value < INT64_HI: - write(b"\xCB") - write(struct_pack(">q", value)) - else: - raise OverflowError("Integer %s out of range" % value) - - # String - elif isinstance(value, string): - if isinstance(value, bytes): - value_bytes = value - else: - value_bytes = value.encode("utf-8") - self.pack_string_header(len(value_bytes)) - self.pack_raw(value_bytes) - - # Bytes (deliberately listed after String since in - # Python 2, bytes should be treated as a String) - elif isinstance(value, bytes): - self.pack_bytes_header(len(value)) - self.pack_raw(value) - elif isinstance(value, bytearray): - self.pack_bytes_header(len(value)) - self.pack_raw(bytes(value)) - - # List - elif isinstance(value, list): - self.pack_list_header(len(value)) - for item in value: - self._pack(item) - - # Map - elif isinstance(value, dict): - self.pack_map_header(len(value)) - for key, item in value.items(): - self._pack(key) - self._pack(item) - - # Structure - elif isinstance(value, Structure): - self.pack_struct(value.tag, value.fields) - - # Other - else: - raise ValueError("Values of type %s are not supported" % type(value)) - - cdef pack_bytes_header(self, int size): - if not self.supports_bytes: - raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") - write = self._write - if size < 0x100: - write(b"\xCC") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xCD") - write(PACKED_UINT_16[size]) - elif size < 0x100000000: - write(b"\xCE") - write(struct_pack(">I", size)) - else: - raise OverflowError("Bytes header size out of range") - - cdef pack_string_header(self, int size): - write = self._write - if size == 0x00: - write(b"\x80") - elif size == 0x01: - write(b"\x81") - elif size == 0x02: - write(b"\x82") - elif size == 0x03: - write(b"\x83") - elif size == 0x04: - write(b"\x84") - elif size == 0x05: - write(b"\x85") - elif size == 0x06: - write(b"\x86") - elif size == 0x07: - write(b"\x87") - elif size == 0x08: - write(b"\x88") - elif size == 0x09: - write(b"\x89") - elif size == 0x0A: - write(b"\x8A") - elif size == 0x0B: - write(b"\x8B") - elif size == 0x0C: - write(b"\x8C") - elif size == 0x0D: - write(b"\x8D") - elif size == 0x0E: - write(b"\x8E") - elif size == 0x0F: - write(b"\x8F") - elif size < 0x100: - write(b"\xD0") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xD1") - write(PACKED_UINT_16[size]) - elif size < 0x100000000: - write(b"\xD2") - write(struct_pack(">I", size)) - else: - raise OverflowError("String header size out of range") - - cdef pack_list_header(self, int size): - write = self._write - if size == 0x00: - write(b"\x90") - elif size == 0x01: - write(b"\x91") - elif size == 0x02: - write(b"\x92") - elif size == 0x03: - write(b"\x93") - elif size == 0x04: - write(b"\x94") - elif size == 0x05: - write(b"\x95") - elif size == 0x06: - write(b"\x96") - elif size == 0x07: - write(b"\x97") - elif size == 0x08: - write(b"\x98") - elif size == 0x09: - write(b"\x99") - elif size == 0x0A: - write(b"\x9A") - elif size == 0x0B: - write(b"\x9B") - elif size == 0x0C: - write(b"\x9C") - elif size == 0x0D: - write(b"\x9D") - elif size == 0x0E: - write(b"\x9E") - elif size == 0x0F: - write(b"\x9F") - elif size < 0x100: - write(b"\xD4") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xD5") - write(PACKED_UINT_16[size]) - elif size < 0x100000000: - write(b"\xD6") - write(struct_pack(">I", size)) - else: - raise OverflowError("List header size out of range") - - cpdef pack_list_stream_header(self): - self._write(b"\xD7") - - cdef pack_map_header(self, int size): - write = self._write - if size == 0x00: - write(b"\xA0") - elif size == 0x01: - write(b"\xA1") - elif size == 0x02: - write(b"\xA2") - elif size == 0x03: - write(b"\xA3") - elif size == 0x04: - write(b"\xA4") - elif size == 0x05: - write(b"\xA5") - elif size == 0x06: - write(b"\xA6") - elif size == 0x07: - write(b"\xA7") - elif size == 0x08: - write(b"\xA8") - elif size == 0x09: - write(b"\xA9") - elif size == 0x0A: - write(b"\xAA") - elif size == 0x0B: - write(b"\xAB") - elif size == 0x0C: - write(b"\xAC") - elif size == 0x0D: - write(b"\xAD") - elif size == 0x0E: - write(b"\xAE") - elif size == 0x0F: - write(b"\xAF") - elif size < 0x100: - write(b"\xD8") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xD9") - write(PACKED_UINT_16[size]) - elif size < 0x100000000: - write(b"\xDA") - write(struct_pack(">I", size)) - else: - raise OverflowError("Map header size out of range") - - cpdef pack_map_stream_header(self): - self._write(b"\xDB") - - cpdef pack_struct(self, bytes signature, fields): - if len(signature) != 1: - raise ValueError("Structure signature must be a single byte value") - write = self._write - size = len(fields) - if size == 0x00: - write(b"\xB0") - elif size == 0x01: - write(b"\xB1") - elif size == 0x02: - write(b"\xB2") - elif size == 0x03: - write(b"\xB3") - elif size == 0x04: - write(b"\xB4") - elif size == 0x05: - write(b"\xB5") - elif size == 0x06: - write(b"\xB6") - elif size == 0x07: - write(b"\xB7") - elif size == 0x08: - write(b"\xB8") - elif size == 0x09: - write(b"\xB9") - elif size == 0x0A: - write(b"\xBA") - elif size == 0x0B: - write(b"\xBB") - elif size == 0x0C: - write(b"\xBC") - elif size == 0x0D: - write(b"\xBD") - elif size == 0x0E: - write(b"\xBE") - elif size == 0x0F: - write(b"\xBF") - elif size < 0x100: - write(b"\xDC") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xDD") - write(PACKED_UINT_16[size]) - else: - raise OverflowError("Structure size out of range") - write(signature) - for field in fields: - self._pack(field) - - cpdef pack_end_of_stream(self): - self._write(b"\xDF") diff --git a/neo4j/packstream/_unpacker.c b/neo4j/packstream/_unpacker.c deleted file mode 100644 index 81c52a0da..000000000 --- a/neo4j/packstream/_unpacker.c +++ /dev/null @@ -1,9170 +0,0 @@ -/* Generated by Cython 0.27.3 */ - -/* BEGIN: Cython Metadata -{ - "distutils": { - "name": "neo4j.packstream._unpacker", - "sources": [ - "/home/technige/work/neo4j-python-driver/neo4j/packstream/_unpacker.pyx" - ] - }, - "module_name": "neo4j.packstream._unpacker" -} -END: Cython Metadata */ - -#define PY_SSIZE_T_CLEAN -#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 < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000) - #error Cython requires Python 2.6+ or Python 3.3+. -#else -#define CYTHON_ABI "0_27_3" -#define CYTHON_FUTURE_DIVISION 0 -#include -#ifndef offsetof - #define offsetof(type, member) ( (size_t) & ((type*)0) -> member ) -#endif -#if !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 HAVE_LONG_LONG - #if PY_VERSION_HEX >= 0x02070000 - #define HAVE_LONG_LONG - #endif -#endif -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#ifndef Py_HUGE_VAL - #define Py_HUGE_VAL HUGE_VAL -#endif -#ifdef PYPY_VERSION - #define CYTHON_COMPILING_IN_PYPY 1 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #undef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 0 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #if PY_VERSION_HEX < 0x03050000 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #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_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 0 - #undef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 0 - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 -#elif defined(PYSTON_VERSION) - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 1 - #define CYTHON_COMPILING_IN_CPYTHON 0 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #undef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 0 - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #undef CYTHON_USE_UNICODE_WRITER - #define CYTHON_USE_UNICODE_WRITER 0 - #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_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #undef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 0 - #undef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 0 - #undef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT 0 - #undef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE 0 -#else - #define CYTHON_COMPILING_IN_PYPY 0 - #define CYTHON_COMPILING_IN_PYSTON 0 - #define CYTHON_COMPILING_IN_CPYTHON 1 - #ifndef CYTHON_USE_TYPE_SLOTS - #define CYTHON_USE_TYPE_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYTYPE_LOOKUP - #define CYTHON_USE_PYTYPE_LOOKUP 0 - #elif !defined(CYTHON_USE_PYTYPE_LOOKUP) - #define CYTHON_USE_PYTYPE_LOOKUP 1 - #endif - #if PY_MAJOR_VERSION < 3 - #undef CYTHON_USE_ASYNC_SLOTS - #define CYTHON_USE_ASYNC_SLOTS 0 - #elif !defined(CYTHON_USE_ASYNC_SLOTS) - #define CYTHON_USE_ASYNC_SLOTS 1 - #endif - #if PY_VERSION_HEX < 0x02070000 - #undef CYTHON_USE_PYLONG_INTERNALS - #define CYTHON_USE_PYLONG_INTERNALS 0 - #elif !defined(CYTHON_USE_PYLONG_INTERNALS) - #define CYTHON_USE_PYLONG_INTERNALS 1 - #endif - #ifndef CYTHON_USE_PYLIST_INTERNALS - #define CYTHON_USE_PYLIST_INTERNALS 1 - #endif - #ifndef CYTHON_USE_UNICODE_INTERNALS - #define CYTHON_USE_UNICODE_INTERNALS 1 - #endif - #if PY_VERSION_HEX < 0x030300F0 - #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 - #ifndef CYTHON_ASSUME_SAFE_MACROS - #define CYTHON_ASSUME_SAFE_MACROS 1 - #endif - #ifndef CYTHON_UNPACK_METHODS - #define CYTHON_UNPACK_METHODS 1 - #endif - #ifndef CYTHON_FAST_THREAD_STATE - #define CYTHON_FAST_THREAD_STATE 1 - #endif - #ifndef CYTHON_FAST_PYCALL - #define CYTHON_FAST_PYCALL 1 - #endif - #ifndef CYTHON_PEP489_MULTI_PHASE_INIT - #define CYTHON_PEP489_MULTI_PHASE_INIT (0 && PY_VERSION_HEX >= 0x03050000) - #endif - #ifndef CYTHON_USE_TP_FINALIZE - #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1) - #endif -#endif -#if !defined(CYTHON_FAST_PYCCALL) -#define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1) -#endif -#if CYTHON_USE_PYLONG_INTERNALS - #include "longintrepr.h" - #undef SHIFT - #undef BASE - #undef MASK -#endif -#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag) - #define Py_OptimizeFlag 0 -#endif -#define __PYX_BUILD_PY_SSIZE_T "n" -#define CYTHON_FORMAT_SSIZE_T "z" -#if PY_MAJOR_VERSION < 3 - #define __Pyx_BUILTIN_MODULE_NAME "__builtin__" - #define __Pyx_PyCode_New(a, 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) - #define __Pyx_DefaultClassType PyClass_Type -#else - #define __Pyx_BUILTIN_MODULE_NAME "builtins" - #define __Pyx_PyCode_New(a, 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) - #define __Pyx_DefaultClassType PyType_Type -#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 -#if PY_VERSION_HEX < 0x030700A0 || !defined(METH_FASTCALL) - #ifndef METH_FASTCALL - #define METH_FASTCALL 0x80 - #endif - typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject **args, Py_ssize_t nargs); - typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject **args, - Py_ssize_t nargs, PyObject *kwnames); -#else - #define __Pyx_PyCFunctionFast _PyCFunctionFast - #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords -#endif -#if CYTHON_FAST_PYCCALL -#define __Pyx_PyFastCFunction_Check(func)\ - ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))))) -#else -#define __Pyx_PyFastCFunction_Check(func) 0 -#endif -#if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#elif PY_VERSION_HEX >= 0x03060000 - #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet() -#elif PY_VERSION_HEX >= 0x03000000 - #define __Pyx_PyThreadState_Current PyThreadState_GET() -#else - #define __Pyx_PyThreadState_Current _PyThreadState_Current -#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 -#if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION - #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y) -#else - #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y) - #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y) -#endif -#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND) - #define CYTHON_PEP393_ENABLED 1 - #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\ - 0 : _PyUnicode_Ready((PyObject *)(op))) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u) - #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) 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, ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u))) -#else - #define CYTHON_PEP393_ENABLED 0 - #define PyUnicode_1BYTE_KIND 1 - #define PyUnicode_2BYTE_KIND 2 - #define PyUnicode_4BYTE_KIND 4 - #define __Pyx_PyUnicode_READY(op) (0) - #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u) - #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i])) - #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111) - #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE)) - #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u)) - #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i])) - #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch) - #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u)) -#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 && !defined(PyUnicode_Contains) - #define PyUnicode_Contains(u, s) PySequence_Contains(u, s) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check) - #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type) -#endif -#if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format) - #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt) -#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_PYSTON - #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co) - #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 -#define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b)) -#define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b)) -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b) -#else - #define __Pyx_PyString_Format(a, b) PyString_Format(a, b) -#endif -#if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII) - #define PyObject_ASCII(o) PyObject_Repr(o) -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBaseString_Type PyUnicode_Type - #define PyStringObject PyUnicodeObject - #define PyString_Type PyUnicode_Type - #define PyString_Check PyUnicode_Check - #define PyString_CheckExact PyUnicode_CheckExact -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj) - #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj) -#else - #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj)) - #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj)) -#endif -#ifndef PySet_CheckExact - #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type) -#endif -#define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception) -#if PY_MAJOR_VERSION >= 3 - #define PyIntObject PyLongObject - #define PyInt_Type PyLong_Type - #define PyInt_Check(op) PyLong_Check(op) - #define PyInt_CheckExact(op) PyLong_CheckExact(op) - #define PyInt_FromString PyLong_FromString - #define PyInt_FromUnicode PyLong_FromUnicode - #define PyInt_FromLong PyLong_FromLong - #define PyInt_FromSize_t PyLong_FromSize_t - #define PyInt_FromSsize_t PyLong_FromSsize_t - #define PyInt_AsLong PyLong_AsLong - #define PyInt_AS_LONG PyLong_AS_LONG - #define PyInt_AsSsize_t PyLong_AsSsize_t - #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask - #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask - #define PyNumber_Int PyNumber_Long -#endif -#if PY_MAJOR_VERSION >= 3 - #define PyBoolObject PyLongObject -#endif -#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY - #ifndef PyUnicode_InternFromString - #define PyUnicode_InternFromString(s) PyUnicode_FromString(s) - #endif -#endif -#if PY_VERSION_HEX < 0x030200A4 - typedef long Py_hash_t; - #define __Pyx_PyInt_FromHash_t PyInt_FromLong - #define __Pyx_PyInt_AsHash_t PyInt_AsLong -#else - #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t - #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t -#endif -#if PY_MAJOR_VERSION >= 3 - #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func)) -#else - #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass) -#endif -#ifndef __has_attribute - #define __has_attribute(x) 0 -#endif -#ifndef __has_cpp_attribute - #define __has_cpp_attribute(x) 0 -#endif -#if CYTHON_USE_ASYNC_SLOTS - #if PY_VERSION_HEX >= 0x030500B1 - #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods - #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async) - #else - #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved)) - #endif -#else - #define __Pyx_PyType_AsAsync(obj) NULL -#endif -#ifndef __Pyx_PyAsyncMethodsStruct - typedef struct { - unaryfunc am_await; - unaryfunc am_aiter; - unaryfunc am_anext; - } __Pyx_PyAsyncMethodsStruct; -#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(__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_MAYBE_UNUSED_VAR -# if defined(__cplusplus) - template void CYTHON_MAYBE_UNUSED_VAR( const T& ) { } -# else -# define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x) -# endif -#endif -#ifndef CYTHON_NCP_UNUSED -# if CYTHON_COMPILING_IN_CPYTHON -# define CYTHON_NCP_UNUSED -# else -# define CYTHON_NCP_UNUSED CYTHON_UNUSED -# endif -#endif -#define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None) -#ifdef _MSC_VER - #ifndef _MSC_STDINT_H_ - #if _MSC_VER < 1300 - typedef unsigned char uint8_t; - typedef unsigned int uint32_t; - #else - typedef unsigned __int8 uint8_t; - typedef unsigned __int32 uint32_t; - #endif - #endif -#else - #include -#endif -#ifndef CYTHON_FALLTHROUGH - #if defined(__cplusplus) && __cplusplus >= 201103L - #if __has_cpp_attribute(fallthrough) - #define CYTHON_FALLTHROUGH [[fallthrough]] - #elif __has_cpp_attribute(clang::fallthrough) - #define CYTHON_FALLTHROUGH [[clang::fallthrough]] - #elif __has_cpp_attribute(gnu::fallthrough) - #define CYTHON_FALLTHROUGH [[gnu::fallthrough]] - #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 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 - -#if defined(WIN32) || defined(MS_WINDOWS) - #define _USE_MATH_DEFINES -#endif -#include -#ifdef NAN -#define __PYX_NAN() ((float) NAN) -#else -static CYTHON_INLINE float __PYX_NAN() { - float value; - memset(&value, 0xFF, sizeof(value)); - return value; -} -#endif -#if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL) -#define __Pyx_truncl trunc -#else -#define __Pyx_truncl truncl -#endif - - -#define __PYX_ERR(f_index, lineno, Ln_error) \ -{ \ - __pyx_filename = __pyx_f[f_index]; __pyx_lineno = lineno; __pyx_clineno = __LINE__; goto Ln_error; \ -} - -#ifndef __PYX_EXTERN_C - #ifdef __cplusplus - #define __PYX_EXTERN_C extern "C" - #else - #define __PYX_EXTERN_C extern - #endif -#endif - -#define __PYX_HAVE__neo4j__packstream___unpacker -#define __PYX_HAVE_API__neo4j__packstream___unpacker -#ifdef _OPENMP -#include -#endif /* _OPENMP */ - -#if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS) -#define CYTHON_WITHOUT_ASSERTIONS -#endif - -typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding; - const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; - -#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0 -#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 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))) ) -#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 const char* __Pyx_PyObject_AsString(PyObject*); -static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length); -#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s)) -#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 PY_MAJOR_VERSION < 3 - #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize -#else - #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString - #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize -#endif -#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_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s)) -#define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __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_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s) -#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s) -static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) { - const Py_UNICODE *u_end = u; - while (*u_end++) ; - return (size_t)(u_end - u - 1); -} -#define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u)) -#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode -#define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode -#define __Pyx_NewRef(obj) (Py_INCREF(obj), obj) -#define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None) -#define __Pyx_PyBool_FromLong(b) ((b) ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False)) -static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*); -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(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_PyInt_FromSize_t(size_t); -#if CYTHON_ASSUME_SAFE_MACROS -#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x)) -#else -#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x) -#endif -#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x)) -#if PY_MAJOR_VERSION >= 3 -#define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x)) -#else -#define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x)) -#endif -#define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x)) -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII -static int __Pyx_sys_getdefaultencoding_not_ascii; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - PyObject* ascii_chars_u = NULL; - PyObject* ascii_chars_b = NULL; - const char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - if (strcmp(default_encoding_c, "ascii") == 0) { - __Pyx_sys_getdefaultencoding_not_ascii = 0; - } else { - char ascii_chars[128]; - int c; - for (c = 0; c < 128; c++) { - ascii_chars[c] = c; - } - __Pyx_sys_getdefaultencoding_not_ascii = 1; - ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL); - if (!ascii_chars_u) goto bad; - ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL); - if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) { - PyErr_Format( - PyExc_ValueError, - "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.", - default_encoding_c); - goto bad; - } - Py_DECREF(ascii_chars_u); - Py_DECREF(ascii_chars_b); - } - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - Py_XDECREF(ascii_chars_u); - Py_XDECREF(ascii_chars_b); - return -1; -} -#endif -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3 -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL) -#else -#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL) -#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT -static char* __PYX_DEFAULT_STRING_ENCODING; -static int __Pyx_init_sys_getdefaultencoding_params(void) { - PyObject* sys; - PyObject* default_encoding = NULL; - char* default_encoding_c; - sys = PyImport_ImportModule("sys"); - if (!sys) goto bad; - default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL); - Py_DECREF(sys); - if (!default_encoding) goto bad; - default_encoding_c = PyBytes_AsString(default_encoding); - if (!default_encoding_c) goto bad; - __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c)); - if (!__PYX_DEFAULT_STRING_ENCODING) goto bad; - strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c); - Py_DECREF(default_encoding); - return 0; -bad: - Py_XDECREF(default_encoding); - return -1; -} -#endif -#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__ */ -static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; } - -static PyObject *__pyx_m = NULL; -static PyObject *__pyx_d; -static PyObject *__pyx_b; -static PyObject *__pyx_cython_runtime; -static PyObject *__pyx_empty_tuple; -static PyObject *__pyx_empty_bytes; -static PyObject *__pyx_empty_unicode; -static int __pyx_lineno; -static int __pyx_clineno = 0; -static const char * __pyx_cfilenm= __FILE__; -static const char *__pyx_filename; - - -static const char *__pyx_f[] = { - "_unpacker.pyx", - "stringsource", -}; - -/*--- Type declarations ---*/ -struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker; -struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read; - -/* "neo4j/packstream/_unpacker.pyx":43 - * self.source = source - * - * cdef read(self, int n=1): # <<<<<<<<<<<<<< - * return self.source.read(n) - * - */ -struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read { - int __pyx_n; - int n; -}; - -/* "neo4j/packstream/_unpacker.pyx":33 - * - * - * cdef class Unpacker(object): # <<<<<<<<<<<<<< - * - * cdef source - */ -struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker { - PyObject_HEAD - struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_vtab; - PyObject *source; -}; - - - -struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker { - PyObject *(*attach)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, PyObject *, int __pyx_skip_dispatch); - PyObject *(*read)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read *__pyx_optional_args); - int (*read_int)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *); - PyObject *(*unpack)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int __pyx_skip_dispatch); - PyObject *(*_unpack)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *); - PyObject *(*unpack_list)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int __pyx_skip_dispatch); - PyObject *(*_unpack_list)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int); - PyObject *(*unpack_map)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int __pyx_skip_dispatch); - PyObject *(*_unpack_map)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int); - PyObject *(*unpack_structure_header)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int __pyx_skip_dispatch); - PyObject *(*_unpack_structure_header)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int); -}; -static struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_vtabptr_5neo4j_10packstream_9_unpacker_Unpacker; - -/* --- Runtime support code (head) --- */ -/* Refnanny.proto */ -#ifndef CYTHON_REFNANNY - #define CYTHON_REFNANNY 0 -#endif -#if CYTHON_REFNANNY - typedef struct { - void (*INCREF)(void*, PyObject*, int); - void (*DECREF)(void*, PyObject*, int); - void (*GOTREF)(void*, PyObject*, int); - void (*GIVEREF)(void*, PyObject*, int); - void* (*SetupContext)(const char*, int, 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; -#ifdef WITH_THREAD - #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__);\ - } -#else - #define __Pyx_RefNannySetupContext(name, acquire_gil)\ - __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__) -#endif - #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) {__Pyx_INCREF(r); }} while(0) - #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0) - #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0) - #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0) -#else - #define __Pyx_RefNannyDeclarations - #define __Pyx_RefNannySetupContext(name, acquire_gil) - #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_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) - -/* PyObjectGetAttrStr.proto */ -#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); -#if PY_MAJOR_VERSION < 3 - if (likely(tp->tp_getattr)) - return tp->tp_getattr(obj, PyString_AS_STRING(attr_name)); -#endif - return PyObject_GetAttr(obj, attr_name); -} -#else -#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n) -#endif - -/* GetBuiltinName.proto */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name); - -/* 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); - -/* KeywordStringCheck.proto */ -static int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed); - -/* PyCFunctionFastCall.proto */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs); -#else -#define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL) -#endif - -/* PyFunctionFastCall.proto */ -#if CYTHON_FAST_PYCALL -#define __Pyx_PyFunction_FastCall(func, args, nargs)\ - __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL) -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs); -#else -#define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs) -#endif -#endif - -/* 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 - -/* PyObjectCallOneArg.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg); - -/* PyObjectCallNoArg.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func); -#else -#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL) -#endif - -/* PyThreadStateGet.proto */ -#if CYTHON_FAST_THREAD_STATE -#define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate; -#define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current; -#define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type -#else -#define __Pyx_PyThreadState_declare -#define __Pyx_PyThreadState_assign -#define __Pyx_PyErr_Occurred() 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 -#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 - -/* WriteUnraisableException.proto */ -static void __Pyx_WriteUnraisable(const char *name, int clineno, - int lineno, const char *filename, - int full_traceback, int nogil); - -/* RaiseException.proto */ -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause); - -/* GetModuleGlobalName.proto */ -static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name); - -/* RaiseTooManyValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected); - -/* RaiseNeedMoreValuesToUnpack.proto */ -static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index); - -/* IterFinish.proto */ -static CYTHON_INLINE int __Pyx_IterFinish(void); - -/* UnpackItemEndCheck.proto */ -static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected); - -/* GetItemInt.proto */ -#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\ - (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)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (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); -#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\ - (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); -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); - -/* SetItemInt.proto */ -#define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\ - (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\ - __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\ - (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\ - __Pyx_SetItemInt_Generic(o, to_py_func(i), v))) -static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v); -static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, - int is_list, int wraparound, int boundscheck); - -/* ListCompAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_ListComp_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len)) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - Py_SIZE(list) = len+1; - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_ListComp_Append(L,x) PyList_Append(L,x) -#endif - -/* ListAppend.proto */ -#if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS -static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) { - PyListObject* L = (PyListObject*) list; - Py_ssize_t len = Py_SIZE(list); - if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) { - Py_INCREF(x); - PyList_SET_ITEM(list, len, x); - Py_SIZE(list) = len+1; - return 0; - } - return PyList_Append(list, x); -} -#else -#define __Pyx_PyList_Append(L,x) PyList_Append(L,x) -#endif - -/* SetVTable.proto */ -static int __Pyx_SetVtable(PyObject *dict, void *vtable); - -/* SetupReduce.proto */ -static int __Pyx_setup_reduce(PyObject* type_obj); - -/* Import.proto */ -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level); - -/* ImportFrom.proto */ -static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name); - -/* CLineInTraceback.proto */ -#ifdef CYTHON_CLINE_IN_TRACEBACK -#define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0) -#else -static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line); -#endif - -/* CodeObjectCache.proto */ -typedef struct { - PyCodeObject* code_object; - int code_line; -} __Pyx_CodeObjectCacheEntry; -struct __Pyx_CodeObjectCache { - int count; - int max_count; - __Pyx_CodeObjectCacheEntry* entries; -}; -static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL}; -static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line); -static PyCodeObject *__pyx_find_code_object(int code_line); -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object); - -/* AddTraceback.proto */ -static void __Pyx_AddTraceback(const char *funcname, int c_line, - int py_line, const char *filename); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value); - -/* CIntToPy.proto */ -static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value); - -/* CIntFromPy.proto */ -static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *); - -/* CIntFromPy.proto */ -static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *); - -/* FastTypeChecks.proto */ -#if CYTHON_COMPILING_IN_CPYTHON -#define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type) -static CYTHON_INLINE int __Pyx_IsSubtype(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_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type) -#define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2)) -#endif - -/* CheckBinaryVersion.proto */ -static int __Pyx_check_binary_version(void); - -/* InitStrings.proto */ -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); - -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_attach(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, PyObject *__pyx_v_source, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_read(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read *__pyx_optional_args); /* proto*/ -static int __pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_read_int(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_list(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack_list(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_v_marker); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_map(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack_map(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_v_marker); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_structure_header(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_skip_dispatch); /* proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack_structure_header(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_v_marker); /* proto*/ - -/* Module declarations from 'neo4j.packstream._unpacker' */ -static PyTypeObject *__pyx_ptype_5neo4j_10packstream_9_unpacker_Unpacker = 0; -#define __Pyx_MODULE_NAME "neo4j.packstream._unpacker" -extern int __pyx_module_is_main_neo4j__packstream___unpacker; -int __pyx_module_is_main_neo4j__packstream___unpacker = 0; - -/* Implementation of 'neo4j.packstream._unpacker' */ -static PyObject *__pyx_builtin_object; -static PyObject *__pyx_builtin_RuntimeError; -static PyObject *__pyx_builtin_range; -static PyObject *__pyx_builtin_TypeError; -static const char __pyx_k_B[] = ">B"; -static const char __pyx_k_H[] = ">H"; -static const char __pyx_k_I[] = ">I"; -static const char __pyx_k_b[] = ">b"; -static const char __pyx_k_d[] = ">d"; -static const char __pyx_k_h[] = ">h"; -static const char __pyx_k_i[] = ">i"; -static const char __pyx_k_q[] = ">q"; -static const char __pyx_k_main[] = "__main__"; -static const char __pyx_k_name[] = "__name__"; -static const char __pyx_k_read[] = "read"; -static const char __pyx_k_test[] = "__test__"; -static const char __pyx_k_range[] = "range"; -static const char __pyx_k_utf_8[] = "utf-8"; -static const char __pyx_k_attach[] = "attach"; -static const char __pyx_k_codecs[] = "codecs"; -static const char __pyx_k_decode[] = "decode"; -static const char __pyx_k_import[] = "__import__"; -static const char __pyx_k_object[] = "object"; -static const char __pyx_k_reduce[] = "__reduce__"; -static const char __pyx_k_struct[] = "struct"; -static const char __pyx_k_unpack[] = "unpack"; -static const char __pyx_k_tobytes[] = "tobytes"; -static const char __pyx_k_getstate[] = "__getstate__"; -static const char __pyx_k_read_int[] = "read_int"; -static const char __pyx_k_setstate[] = "__setstate__"; -static const char __pyx_k_Structure[] = "Structure"; -static const char __pyx_k_TypeError[] = "TypeError"; -static const char __pyx_k_reduce_ex[] = "__reduce_ex__"; -static const char __pyx_k_structure[] = "structure"; -static const char __pyx_k_pyx_vtable[] = "__pyx_vtable__"; -static const char __pyx_k_unpack_map[] = "unpack_map"; -static const char __pyx_k_EndOfStream[] = "EndOfStream"; -static const char __pyx_k_unpack_list[] = "unpack_list"; -static const char __pyx_k_RuntimeError[] = "RuntimeError"; -static const char __pyx_k_neo4j_compat[] = "neo4j.compat"; -static const char __pyx_k_memoryview_at[] = "memoryview_at"; -static const char __pyx_k_reduce_cython[] = "__reduce_cython__"; -static const char __pyx_k_struct_unpack[] = "struct_unpack"; -static const char __pyx_k_setstate_cython[] = "__setstate_cython__"; -static const char __pyx_k_Nothing_to_unpack[] = "Nothing to unpack"; -static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback"; -static const char __pyx_k_unpack_structure_header[] = "unpack_structure_header"; -static const char __pyx_k_Unknown_PackStream_marker_02X[] = "Unknown PackStream marker %02X"; -static const char __pyx_k_Expected_structure_found_marker[] = "Expected structure, found marker %02X"; -static const char __pyx_k_no_default___reduce___due_to_non[] = "no default __reduce__ due to non-trivial __cinit__"; -static PyObject *__pyx_kp_s_B; -static PyObject *__pyx_n_s_EndOfStream; -static PyObject *__pyx_kp_s_Expected_structure_found_marker; -static PyObject *__pyx_kp_s_H; -static PyObject *__pyx_kp_s_I; -static PyObject *__pyx_kp_s_Nothing_to_unpack; -static PyObject *__pyx_n_s_RuntimeError; -static PyObject *__pyx_n_s_Structure; -static PyObject *__pyx_n_s_TypeError; -static PyObject *__pyx_kp_s_Unknown_PackStream_marker_02X; -static PyObject *__pyx_n_s_attach; -static PyObject *__pyx_kp_s_b; -static PyObject *__pyx_n_s_cline_in_traceback; -static PyObject *__pyx_n_s_codecs; -static PyObject *__pyx_kp_s_d; -static PyObject *__pyx_n_s_decode; -static PyObject *__pyx_n_s_getstate; -static PyObject *__pyx_kp_s_h; -static PyObject *__pyx_kp_s_i; -static PyObject *__pyx_n_s_import; -static PyObject *__pyx_n_s_main; -static PyObject *__pyx_n_s_memoryview_at; -static PyObject *__pyx_n_s_name; -static PyObject *__pyx_n_s_neo4j_compat; -static PyObject *__pyx_kp_s_no_default___reduce___due_to_non; -static PyObject *__pyx_n_s_object; -static PyObject *__pyx_n_s_pyx_vtable; -static PyObject *__pyx_kp_s_q; -static PyObject *__pyx_n_s_range; -static PyObject *__pyx_n_s_read; -static PyObject *__pyx_n_s_read_int; -static PyObject *__pyx_n_s_reduce; -static PyObject *__pyx_n_s_reduce_cython; -static PyObject *__pyx_n_s_reduce_ex; -static PyObject *__pyx_n_s_setstate; -static PyObject *__pyx_n_s_setstate_cython; -static PyObject *__pyx_n_s_struct; -static PyObject *__pyx_n_s_struct_unpack; -static PyObject *__pyx_n_s_structure; -static PyObject *__pyx_n_s_test; -static PyObject *__pyx_n_s_tobytes; -static PyObject *__pyx_n_s_unpack; -static PyObject *__pyx_n_s_unpack_list; -static PyObject *__pyx_n_s_unpack_map; -static PyObject *__pyx_n_s_unpack_structure_header; -static PyObject *__pyx_kp_s_utf_8; -static int __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker___cinit__(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_2attach(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, PyObject *__pyx_v_source); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_4unpack(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_6unpack_list(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_8unpack_map(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_10unpack_structure_header(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self); /* proto */ -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state); /* proto */ -static PyObject *__pyx_tp_new_5neo4j_10packstream_9_unpacker_Unpacker(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/ -static PyObject *__pyx_tuple_; -static PyObject *__pyx_tuple__2; -static PyObject *__pyx_tuple__3; -static PyObject *__pyx_tuple__4; - -/* "neo4j/packstream/_unpacker.pyx":37 - * cdef source - * - * def __cinit__(self): # <<<<<<<<<<<<<< - * self.source = None - * - */ - -/* Python wrapper */ -static int __pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0); - if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) { - __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;} - if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1; - __pyx_r = __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker___cinit__(((struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static int __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker___cinit__(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__cinit__", 0); - - /* "neo4j/packstream/_unpacker.pyx":38 - * - * def __cinit__(self): - * self.source = None # <<<<<<<<<<<<<< - * - * cpdef attach(self, source): - */ - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - __Pyx_GOTREF(__pyx_v_self->source); - __Pyx_DECREF(__pyx_v_self->source); - __pyx_v_self->source = Py_None; - - /* "neo4j/packstream/_unpacker.pyx":37 - * cdef source - * - * def __cinit__(self): # <<<<<<<<<<<<<< - * self.source = None - * - */ - - /* function exit code */ - __pyx_r = 0; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":40 - * self.source = None - * - * cpdef attach(self, source): # <<<<<<<<<<<<<< - * self.source = source - * - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_3attach(PyObject *__pyx_v_self, PyObject *__pyx_v_source); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_attach(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, PyObject *__pyx_v_source, 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; - PyObject *__pyx_t_5 = NULL; - __Pyx_RefNannySetupContext("attach", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_attach); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_3attach)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (!__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_source); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_source}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_v_source}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_INCREF(__pyx_v_source); - __Pyx_GIVEREF(__pyx_v_source); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_source); - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 40, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":41 - * - * cpdef attach(self, source): - * self.source = source # <<<<<<<<<<<<<< - * - * cdef read(self, int n=1): - */ - __Pyx_INCREF(__pyx_v_source); - __Pyx_GIVEREF(__pyx_v_source); - __Pyx_GOTREF(__pyx_v_self->source); - __Pyx_DECREF(__pyx_v_self->source); - __pyx_v_self->source = __pyx_v_source; - - /* "neo4j/packstream/_unpacker.pyx":40 - * self.source = None - * - * cpdef attach(self, source): # <<<<<<<<<<<<<< - * self.source = source - * - */ - - /* 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("neo4j.packstream._unpacker.Unpacker.attach", __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_5neo4j_10packstream_9_unpacker_8Unpacker_3attach(PyObject *__pyx_v_self, PyObject *__pyx_v_source); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_3attach(PyObject *__pyx_v_self, PyObject *__pyx_v_source) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("attach (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_2attach(((struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self), ((PyObject *)__pyx_v_source)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_2attach(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, PyObject *__pyx_v_source) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("attach", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_attach(__pyx_v_self, __pyx_v_source, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 40, __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("neo4j.packstream._unpacker.Unpacker.attach", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":43 - * self.source = source - * - * cdef read(self, int n=1): # <<<<<<<<<<<<<< - * return self.source.read(n) - * - */ - -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_read(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read *__pyx_optional_args) { - int __pyx_v_n = ((int)1); - 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; - __Pyx_RefNannySetupContext("read", 0); - if (__pyx_optional_args) { - if (__pyx_optional_args->__pyx_n > 0) { - __pyx_v_n = __pyx_optional_args->n; - } - } - - /* "neo4j/packstream/_unpacker.pyx":44 - * - * cdef read(self, int n=1): - * return self.source.read(n) # <<<<<<<<<<<<<< - * - * cdef int read_int(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->source, __pyx_n_s_read); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_n); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (!__pyx_t_4) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_1); - } else { - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[2] = {__pyx_t_4, __pyx_t_3}; - __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-1, 1+1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL; - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 44, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":43 - * self.source = source - * - * cdef read(self, int n=1): # <<<<<<<<<<<<<< - * return self.source.read(n) - * - */ - - /* 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_XDECREF(__pyx_t_5); - __Pyx_AddTraceback("neo4j.packstream._unpacker.Unpacker.read", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":46 - * return self.source.read(n) - * - * cdef int read_int(self): # <<<<<<<<<<<<<< - * return self.source.read_int() - * - */ - -static int __pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_read_int(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self) { - int __pyx_r; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - __Pyx_RefNannySetupContext("read_int", 0); - - /* "neo4j/packstream/_unpacker.pyx":47 - * - * cdef int read_int(self): - * return self.source.read_int() # <<<<<<<<<<<<<< - * - * cpdef unpack(self): - */ - __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->source, __pyx_n_s_read_int); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - } - } - if (__pyx_t_3) { - __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 47, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_1); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 47, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_r = __pyx_t_4; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":46 - * return self.source.read(n) - * - * cdef int read_int(self): # <<<<<<<<<<<<<< - * return self.source.read_int() - * - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_WriteUnraisable("neo4j.packstream._unpacker.Unpacker.read_int", __pyx_clineno, __pyx_lineno, __pyx_filename, 1, 0); - __pyx_r = 0; - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":49 - * return self.source.read_int() - * - * cpdef unpack(self): # <<<<<<<<<<<<<< - * return self._unpack() - * - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_5unpack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__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; - __Pyx_RefNannySetupContext("unpack", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unpack); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_5unpack)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 49, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":50 - * - * cpdef unpack(self): - * return self._unpack() # <<<<<<<<<<<<<< - * - * cdef _unpack(self): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 50, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":49 - * return self.source.read_int() - * - * cpdef unpack(self): # <<<<<<<<<<<<<< - * return self._unpack() - * - */ - - /* 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("neo4j.packstream._unpacker.Unpacker.unpack", __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_5neo4j_10packstream_9_unpacker_8Unpacker_5unpack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_5unpack(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("unpack (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_4unpack(((struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_4unpack(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("unpack", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 49, __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("neo4j.packstream._unpacker.Unpacker.unpack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":52 - * return self._unpack() - * - * cdef _unpack(self): # <<<<<<<<<<<<<< - * cdef int size - * cdef int i - */ - -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self) { - int __pyx_v_size; - int __pyx_v_i; - int __pyx_v_marker; - int __pyx_v_marker_high; - PyObject *__pyx_v_value = NULL; - PyObject *__pyx_v_tag = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - PyObject *__pyx_t_4 = NULL; - PyObject *__pyx_t_5 = NULL; - struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read __pyx_t_6; - PyObject *__pyx_t_7 = NULL; - int __pyx_t_8; - PyObject *__pyx_t_9 = NULL; - PyObject *(*__pyx_t_10)(PyObject *); - int __pyx_t_11; - Py_ssize_t __pyx_t_12; - __Pyx_RefNannySetupContext("_unpack", 0); - - /* "neo4j/packstream/_unpacker.pyx":58 - * cdef int marker_high - * - * marker = self.read_int() # <<<<<<<<<<<<<< - * - * if marker == -1: - */ - __pyx_v_marker = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read_int(__pyx_v_self); - - /* "neo4j/packstream/_unpacker.pyx":60 - * marker = self.read_int() - * - * if marker == -1: # <<<<<<<<<<<<<< - * raise RuntimeError("Nothing to unpack") - * - */ - __pyx_t_1 = ((__pyx_v_marker == -1L) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":61 - * - * if marker == -1: - * raise RuntimeError("Nothing to unpack") # <<<<<<<<<<<<<< - * - * # Tiny Integer - */ - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_Raise(__pyx_t_2, 0, 0, 0); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __PYX_ERR(0, 61, __pyx_L1_error) - - /* "neo4j/packstream/_unpacker.pyx":60 - * marker = self.read_int() - * - * if marker == -1: # <<<<<<<<<<<<<< - * raise RuntimeError("Nothing to unpack") - * - */ - } - - /* "neo4j/packstream/_unpacker.pyx":64 - * - * # Tiny Integer - * if 0x00 <= marker <= 0x7F: # <<<<<<<<<<<<<< - * return marker - * elif 0xF0 <= marker <= 0xFF: - */ - __pyx_t_1 = (0x00 <= __pyx_v_marker); - if (__pyx_t_1) { - __pyx_t_1 = (__pyx_v_marker <= 0x7F); - } - __pyx_t_3 = (__pyx_t_1 != 0); - if (__pyx_t_3) { - - /* "neo4j/packstream/_unpacker.pyx":65 - * # Tiny Integer - * if 0x00 <= marker <= 0x7F: - * return marker # <<<<<<<<<<<<<< - * elif 0xF0 <= marker <= 0xFF: - * return marker - 0x100 - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_marker); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":64 - * - * # Tiny Integer - * if 0x00 <= marker <= 0x7F: # <<<<<<<<<<<<<< - * return marker - * elif 0xF0 <= marker <= 0xFF: - */ - } - - /* "neo4j/packstream/_unpacker.pyx":66 - * if 0x00 <= marker <= 0x7F: - * return marker - * elif 0xF0 <= marker <= 0xFF: # <<<<<<<<<<<<<< - * return marker - 0x100 - * - */ - __pyx_t_3 = (0xF0 <= __pyx_v_marker); - if (__pyx_t_3) { - __pyx_t_3 = (__pyx_v_marker <= 0xFF); - } - __pyx_t_1 = (__pyx_t_3 != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":67 - * return marker - * elif 0xF0 <= marker <= 0xFF: - * return marker - 0x100 # <<<<<<<<<<<<<< - * - * # Null - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_marker - 0x100)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 67, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":66 - * if 0x00 <= marker <= 0x7F: - * return marker - * elif 0xF0 <= marker <= 0xFF: # <<<<<<<<<<<<<< - * return marker - 0x100 - * - */ - } - - /* "neo4j/packstream/_unpacker.pyx":70 - * - * # Null - * elif marker == 0xC0: # <<<<<<<<<<<<<< - * return None - * - */ - __pyx_t_1 = ((__pyx_v_marker == 0xC0) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":71 - * # Null - * elif marker == 0xC0: - * return None # <<<<<<<<<<<<<< - * - * # Float - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = Py_None; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":70 - * - * # Null - * elif marker == 0xC0: # <<<<<<<<<<<<<< - * return None - * - */ - } - - /* "neo4j/packstream/_unpacker.pyx":74 - * - * # Float - * elif marker == 0xC1: # <<<<<<<<<<<<<< - * value, = struct_unpack(">d", self.read(8)) - * return value - */ - __pyx_t_1 = ((__pyx_v_marker == 0xC1) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":75 - * # Float - * elif marker == 0xC1: - * value, = struct_unpack(">d", self.read(8)) # <<<<<<<<<<<<<< - * return value - * - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 8; - __pyx_t_5 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_d, __pyx_t_5}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_d, __pyx_t_5}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_d); - __Pyx_GIVEREF(__pyx_kp_s_d); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_d); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 75, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_4 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 75, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; - index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L5_unpacking_failed; - __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 1) < 0) __PYX_ERR(0, 75, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L6_unpacking_done; - __pyx_L5_unpacking_failed:; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 75, __pyx_L1_error) - __pyx_L6_unpacking_done:; - } - __pyx_v_value = __pyx_t_4; - __pyx_t_4 = 0; - - /* "neo4j/packstream/_unpacker.pyx":76 - * elif marker == 0xC1: - * value, = struct_unpack(">d", self.read(8)) - * return value # <<<<<<<<<<<<<< - * - * # Boolean - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_value); - __pyx_r = __pyx_v_value; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":74 - * - * # Float - * elif marker == 0xC1: # <<<<<<<<<<<<<< - * value, = struct_unpack(">d", self.read(8)) - * return value - */ - } - - /* "neo4j/packstream/_unpacker.pyx":79 - * - * # Boolean - * elif marker == 0xC2: # <<<<<<<<<<<<<< - * return False - * elif marker == 0xC3: - */ - __pyx_t_1 = ((__pyx_v_marker == 0xC2) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":80 - * # Boolean - * elif marker == 0xC2: - * return False # <<<<<<<<<<<<<< - * elif marker == 0xC3: - * return True - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_False); - __pyx_r = Py_False; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":79 - * - * # Boolean - * elif marker == 0xC2: # <<<<<<<<<<<<<< - * return False - * elif marker == 0xC3: - */ - } - - /* "neo4j/packstream/_unpacker.pyx":81 - * elif marker == 0xC2: - * return False - * elif marker == 0xC3: # <<<<<<<<<<<<<< - * return True - * - */ - __pyx_t_1 = ((__pyx_v_marker == 0xC3) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":82 - * return False - * elif marker == 0xC3: - * return True # <<<<<<<<<<<<<< - * - * # Integer - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_True); - __pyx_r = Py_True; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":81 - * elif marker == 0xC2: - * return False - * elif marker == 0xC3: # <<<<<<<<<<<<<< - * return True - * - */ - } - - /* "neo4j/packstream/_unpacker.pyx":85 - * - * # Integer - * elif marker == 0xC8: # <<<<<<<<<<<<<< - * return struct_unpack(">b", self.read(1))[0] - * elif marker == 0xC9: - */ - __pyx_t_1 = ((__pyx_v_marker == 0xC8) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":86 - * # Integer - * elif marker == 0xC8: - * return struct_unpack(">b", self.read(1))[0] # <<<<<<<<<<<<<< - * elif marker == 0xC9: - * return struct_unpack(">h", self.read(2))[0] - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 1; - __pyx_t_9 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 86, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_b, __pyx_t_9}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_b, __pyx_t_9}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 86, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_b); - __Pyx_GIVEREF(__pyx_kp_s_b); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_kp_s_b); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 86, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 86, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":85 - * - * # Integer - * elif marker == 0xC8: # <<<<<<<<<<<<<< - * return struct_unpack(">b", self.read(1))[0] - * elif marker == 0xC9: - */ - } - - /* "neo4j/packstream/_unpacker.pyx":87 - * elif marker == 0xC8: - * return struct_unpack(">b", self.read(1))[0] - * elif marker == 0xC9: # <<<<<<<<<<<<<< - * return struct_unpack(">h", self.read(2))[0] - * elif marker == 0xCA: - */ - __pyx_t_1 = ((__pyx_v_marker == 0xC9) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":88 - * return struct_unpack(">b", self.read(1))[0] - * elif marker == 0xC9: - * return struct_unpack(">h", self.read(2))[0] # <<<<<<<<<<<<<< - * elif marker == 0xCA: - * return struct_unpack(">i", self.read(4))[0] - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 2; - __pyx_t_7 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_9 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_h, __pyx_t_7}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_h, __pyx_t_7}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_9) { - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); __pyx_t_9 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_h); - __Pyx_GIVEREF(__pyx_kp_s_h); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_kp_s_h); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_t_7); - __pyx_t_7 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 88, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":87 - * elif marker == 0xC8: - * return struct_unpack(">b", self.read(1))[0] - * elif marker == 0xC9: # <<<<<<<<<<<<<< - * return struct_unpack(">h", self.read(2))[0] - * elif marker == 0xCA: - */ - } - - /* "neo4j/packstream/_unpacker.pyx":89 - * elif marker == 0xC9: - * return struct_unpack(">h", self.read(2))[0] - * elif marker == 0xCA: # <<<<<<<<<<<<<< - * return struct_unpack(">i", self.read(4))[0] - * elif marker == 0xCB: - */ - __pyx_t_1 = ((__pyx_v_marker == 0xCA) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":90 - * return struct_unpack(">h", self.read(2))[0] - * elif marker == 0xCA: - * return struct_unpack(">i", self.read(4))[0] # <<<<<<<<<<<<<< - * elif marker == 0xCB: - * return struct_unpack(">q", self.read(8))[0] - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 4; - __pyx_t_5 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_i, __pyx_t_5}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_i, __pyx_t_5}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_i); - __Pyx_GIVEREF(__pyx_kp_s_i); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_i); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 90, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_r = __pyx_t_4; - __pyx_t_4 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":89 - * elif marker == 0xC9: - * return struct_unpack(">h", self.read(2))[0] - * elif marker == 0xCA: # <<<<<<<<<<<<<< - * return struct_unpack(">i", self.read(4))[0] - * elif marker == 0xCB: - */ - } - - /* "neo4j/packstream/_unpacker.pyx":91 - * elif marker == 0xCA: - * return struct_unpack(">i", self.read(4))[0] - * elif marker == 0xCB: # <<<<<<<<<<<<<< - * return struct_unpack(">q", self.read(8))[0] - * - */ - __pyx_t_1 = ((__pyx_v_marker == 0xCB) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":92 - * return struct_unpack(">i", self.read(4))[0] - * elif marker == 0xCB: - * return struct_unpack(">q", self.read(8))[0] # <<<<<<<<<<<<<< - * - * # Bytes - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 8; - __pyx_t_9 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_q, __pyx_t_9}; - __pyx_t_4 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_q, __pyx_t_9}; - __pyx_t_4 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_q); - __Pyx_GIVEREF(__pyx_kp_s_q); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_kp_s_q); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_GetItemInt(__pyx_t_4, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 92, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":91 - * elif marker == 0xCA: - * return struct_unpack(">i", self.read(4))[0] - * elif marker == 0xCB: # <<<<<<<<<<<<<< - * return struct_unpack(">q", self.read(8))[0] - * - */ - } - - /* "neo4j/packstream/_unpacker.pyx":95 - * - * # Bytes - * elif marker == 0xCC: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * return self.read(size).tobytes() - */ - __pyx_t_1 = ((__pyx_v_marker == 0xCC) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":96 - * # Bytes - * elif marker == 0xCC: - * size, = struct_unpack(">B", self.read(1)) # <<<<<<<<<<<<<< - * return self.read(size).tobytes() - * elif marker == 0xCD: - */ - __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 1; - __pyx_t_7 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_9 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_4); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_4, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_B, __pyx_t_7}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_B, __pyx_t_7}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_9) { - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); __pyx_t_9 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_kp_s_B); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_t_7); - __pyx_t_7 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 96, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_4 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_4 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_5)->tp_iternext; - index = 0; __pyx_t_4 = __pyx_t_10(__pyx_t_5); if (unlikely(!__pyx_t_4)) goto __pyx_L7_unpacking_failed; - __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_5), 1) < 0) __PYX_ERR(0, 96, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L8_unpacking_done; - __pyx_L7_unpacking_failed:; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 96, __pyx_L1_error) - __pyx_L8_unpacking_done:; - } - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_4); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 96, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_v_size = __pyx_t_8; - - /* "neo4j/packstream/_unpacker.pyx":97 - * elif marker == 0xCC: - * size, = struct_unpack(">B", self.read(1)) - * return self.read(size).tobytes() # <<<<<<<<<<<<<< - * elif marker == 0xCD: - * size, = struct_unpack(">H", self.read(2)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = __pyx_v_size; - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 97, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":95 - * - * # Bytes - * elif marker == 0xCC: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * return self.read(size).tobytes() - */ - } - - /* "neo4j/packstream/_unpacker.pyx":98 - * size, = struct_unpack(">B", self.read(1)) - * return self.read(size).tobytes() - * elif marker == 0xCD: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * return self.read(size).tobytes() - */ - __pyx_t_1 = ((__pyx_v_marker == 0xCD) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":99 - * return self.read(size).tobytes() - * elif marker == 0xCD: - * size, = struct_unpack(">H", self.read(2)) # <<<<<<<<<<<<<< - * return self.read(size).tobytes() - * elif marker == 0xCE: - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 2; - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_7 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_7)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_H, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_7, __pyx_kp_s_H, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_7) { - __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_kp_s_H); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 99, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_5 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_5); - #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; - index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_5)) goto __pyx_L9_unpacking_failed; - __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 1) < 0) __PYX_ERR(0, 99, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L10_unpacking_done; - __pyx_L9_unpacking_failed:; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 99, __pyx_L1_error) - __pyx_L10_unpacking_done:; - } - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 99, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_size = __pyx_t_8; - - /* "neo4j/packstream/_unpacker.pyx":100 - * elif marker == 0xCD: - * size, = struct_unpack(">H", self.read(2)) - * return self.read(size).tobytes() # <<<<<<<<<<<<<< - * elif marker == 0xCE: - * size, = struct_unpack(">I", self.read(4)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = __pyx_v_size; - __pyx_t_5 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 100, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_9 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 100, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_9))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); - } - } - if (__pyx_t_5) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":98 - * size, = struct_unpack(">B", self.read(1)) - * return self.read(size).tobytes() - * elif marker == 0xCD: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * return self.read(size).tobytes() - */ - } - - /* "neo4j/packstream/_unpacker.pyx":101 - * size, = struct_unpack(">H", self.read(2)) - * return self.read(size).tobytes() - * elif marker == 0xCE: # <<<<<<<<<<<<<< - * size, = struct_unpack(">I", self.read(4)) - * return self.read(size).tobytes() - */ - __pyx_t_1 = ((__pyx_v_marker == 0xCE) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":102 - * return self.read(size).tobytes() - * elif marker == 0xCE: - * size, = struct_unpack(">I", self.read(4)) # <<<<<<<<<<<<<< - * return self.read(size).tobytes() - * - */ - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 4; - __pyx_t_5 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_9))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_9); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_9, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_9)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_5}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_9)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_5}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_9, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_7 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_7, 0+__pyx_t_8, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_7, 1+__pyx_t_8, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_7, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - } - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 102, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_9 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_9 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_9); - #else - __pyx_t_9 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_7)->tp_iternext; - index = 0; __pyx_t_9 = __pyx_t_10(__pyx_t_7); if (unlikely(!__pyx_t_9)) goto __pyx_L11_unpacking_failed; - __Pyx_GOTREF(__pyx_t_9); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_7), 1) < 0) __PYX_ERR(0, 102, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - goto __pyx_L12_unpacking_done; - __pyx_L11_unpacking_failed:; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 102, __pyx_L1_error) - __pyx_L12_unpacking_done:; - } - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_9); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 102, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_v_size = __pyx_t_8; - - /* "neo4j/packstream/_unpacker.pyx":103 - * elif marker == 0xCE: - * size, = struct_unpack(">I", self.read(4)) - * return self.read(size).tobytes() # <<<<<<<<<<<<<< - * - * else: - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = __pyx_v_size; - __pyx_t_9 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 103, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_t_9, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 103, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - } - } - if (__pyx_t_9) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 103, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":101 - * size, = struct_unpack(">H", self.read(2)) - * return self.read(size).tobytes() - * elif marker == 0xCE: # <<<<<<<<<<<<<< - * size, = struct_unpack(">I", self.read(4)) - * return self.read(size).tobytes() - */ - } - - /* "neo4j/packstream/_unpacker.pyx":106 - * - * else: - * marker_high = marker & 0xF0 # <<<<<<<<<<<<<< - * # String - * if marker_high == 0x80: # TINY_STRING - */ - /*else*/ { - __pyx_v_marker_high = (__pyx_v_marker & 0xF0); - - /* "neo4j/packstream/_unpacker.pyx":108 - * marker_high = marker & 0xF0 - * # String - * if marker_high == 0x80: # TINY_STRING # <<<<<<<<<<<<<< - * return decode(self.read(marker & 0x0F), "utf-8") - * elif marker == 0xD0: # STRING_8: - */ - __pyx_t_1 = ((__pyx_v_marker_high == 0x80) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":109 - * # String - * if marker_high == 0x80: # TINY_STRING - * return decode(self.read(marker & 0x0F), "utf-8") # <<<<<<<<<<<<<< - * elif marker == 0xD0: # STRING_8: - * size, = struct_unpack(">B", self.read(1)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_decode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = (__pyx_v_marker & 0x0F); - __pyx_t_9 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_9, __pyx_kp_s_utf_8}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_9, __pyx_kp_s_utf_8}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_4 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_t_9); - __Pyx_INCREF(__pyx_kp_s_utf_8); - __Pyx_GIVEREF(__pyx_kp_s_utf_8); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_kp_s_utf_8); - __pyx_t_9 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 109, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":108 - * marker_high = marker & 0xF0 - * # String - * if marker_high == 0x80: # TINY_STRING # <<<<<<<<<<<<<< - * return decode(self.read(marker & 0x0F), "utf-8") - * elif marker == 0xD0: # STRING_8: - */ - } - - /* "neo4j/packstream/_unpacker.pyx":110 - * if marker_high == 0x80: # TINY_STRING - * return decode(self.read(marker & 0x0F), "utf-8") - * elif marker == 0xD0: # STRING_8: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * return decode(self.read(size), "utf-8") - */ - __pyx_t_1 = ((__pyx_v_marker == 0xD0) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":111 - * return decode(self.read(marker & 0x0F), "utf-8") - * elif marker == 0xD0: # STRING_8: - * size, = struct_unpack(">B", self.read(1)) # <<<<<<<<<<<<<< - * return decode(self.read(size), "utf-8") - * elif marker == 0xD1: # STRING_16: - */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 1; - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_9 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_B, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_B, __pyx_t_4}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_9) { - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); __pyx_t_9 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_kp_s_B); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_t_4); - __pyx_t_4 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 111, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_7 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_7); - #else - __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_5 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_5)->tp_iternext; - index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_5); if (unlikely(!__pyx_t_7)) goto __pyx_L14_unpacking_failed; - __Pyx_GOTREF(__pyx_t_7); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_5), 1) < 0) __PYX_ERR(0, 111, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - goto __pyx_L15_unpacking_done; - __pyx_L14_unpacking_failed:; - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 111, __pyx_L1_error) - __pyx_L15_unpacking_done:; - } - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 111, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_v_size = __pyx_t_8; - - /* "neo4j/packstream/_unpacker.pyx":112 - * elif marker == 0xD0: # STRING_8: - * size, = struct_unpack(">B", self.read(1)) - * return decode(self.read(size), "utf-8") # <<<<<<<<<<<<<< - * elif marker == 0xD1: # STRING_16: - * size, = struct_unpack(">H", self.read(2)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_decode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = __pyx_v_size; - __pyx_t_5 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_5, __pyx_kp_s_utf_8}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_5, __pyx_kp_s_utf_8}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_t_5); - __Pyx_INCREF(__pyx_kp_s_utf_8); - __Pyx_GIVEREF(__pyx_kp_s_utf_8); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_kp_s_utf_8); - __pyx_t_5 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 112, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":110 - * if marker_high == 0x80: # TINY_STRING - * return decode(self.read(marker & 0x0F), "utf-8") - * elif marker == 0xD0: # STRING_8: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * return decode(self.read(size), "utf-8") - */ - } - - /* "neo4j/packstream/_unpacker.pyx":113 - * size, = struct_unpack(">B", self.read(1)) - * return decode(self.read(size), "utf-8") - * elif marker == 0xD1: # STRING_16: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * return decode(self.read(size), "utf-8") - */ - __pyx_t_1 = ((__pyx_v_marker == 0xD1) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":114 - * return decode(self.read(size), "utf-8") - * elif marker == 0xD1: # STRING_16: - * size, = struct_unpack(">H", self.read(2)) # <<<<<<<<<<<<<< - * return decode(self.read(size), "utf-8") - * elif marker == 0xD2: # STRING_32: - */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 114, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 2; - __pyx_t_9 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 114, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_H, __pyx_t_9}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_s_H, __pyx_t_9}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_4 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 114, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_kp_s_H); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 114, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 114, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_7 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_7); - #else - __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 114, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_4 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 114, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_4)->tp_iternext; - index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_4); if (unlikely(!__pyx_t_7)) goto __pyx_L16_unpacking_failed; - __Pyx_GOTREF(__pyx_t_7); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_4), 1) < 0) __PYX_ERR(0, 114, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - goto __pyx_L17_unpacking_done; - __pyx_L16_unpacking_failed:; - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 114, __pyx_L1_error) - __pyx_L17_unpacking_done:; - } - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 114, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_v_size = __pyx_t_8; - - /* "neo4j/packstream/_unpacker.pyx":115 - * elif marker == 0xD1: # STRING_16: - * size, = struct_unpack(">H", self.read(2)) - * return decode(self.read(size), "utf-8") # <<<<<<<<<<<<<< - * elif marker == 0xD2: # STRING_32: - * size, = struct_unpack(">I", self.read(4)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_decode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = __pyx_v_size; - __pyx_t_4 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __pyx_t_9 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_4, __pyx_kp_s_utf_8}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_t_4, __pyx_kp_s_utf_8}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else - #endif - { - __pyx_t_5 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - if (__pyx_t_9) { - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_9); __pyx_t_9 = NULL; - } - __Pyx_GIVEREF(__pyx_t_4); - PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_8, __pyx_t_4); - __Pyx_INCREF(__pyx_kp_s_utf_8); - __Pyx_GIVEREF(__pyx_kp_s_utf_8); - PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_8, __pyx_kp_s_utf_8); - __pyx_t_4 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":113 - * size, = struct_unpack(">B", self.read(1)) - * return decode(self.read(size), "utf-8") - * elif marker == 0xD1: # STRING_16: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * return decode(self.read(size), "utf-8") - */ - } - - /* "neo4j/packstream/_unpacker.pyx":116 - * size, = struct_unpack(">H", self.read(2)) - * return decode(self.read(size), "utf-8") - * elif marker == 0xD2: # STRING_32: # <<<<<<<<<<<<<< - * size, = struct_unpack(">I", self.read(4)) - * return decode(self.read(size), "utf-8") - */ - __pyx_t_1 = ((__pyx_v_marker == 0xD2) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":117 - * return decode(self.read(size), "utf-8") - * elif marker == 0xD2: # STRING_32: - * size, = struct_unpack(">I", self.read(4)) # <<<<<<<<<<<<<< - * return decode(self.read(size), "utf-8") - * - */ - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = 4; - __pyx_t_5 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_5}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_kp_s_I, __pyx_t_5}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_4) { - __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_4); __pyx_t_4 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_5); - __pyx_t_5 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 117, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_7 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_7); - #else - __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; - index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L18_unpacking_failed; - __Pyx_GOTREF(__pyx_t_7); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 1) < 0) __PYX_ERR(0, 117, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L19_unpacking_done; - __pyx_L18_unpacking_failed:; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 117, __pyx_L1_error) - __pyx_L19_unpacking_done:; - } - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 117, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_v_size = __pyx_t_8; - - /* "neo4j/packstream/_unpacker.pyx":118 - * elif marker == 0xD2: # STRING_32: - * size, = struct_unpack(">I", self.read(4)) - * return decode(self.read(size), "utf-8") # <<<<<<<<<<<<<< - * - * # List - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_decode); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_6.__pyx_n = 1; - __pyx_t_6.n = __pyx_v_size; - __pyx_t_9 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_6); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_5 = NULL; - __pyx_t_8 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_7))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_7); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_7, function); - __pyx_t_8 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_9, __pyx_kp_s_utf_8}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_7)) { - PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_t_9, __pyx_kp_s_utf_8}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_7, __pyx_temp+1-__pyx_t_8, 2+__pyx_t_8); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_4 = PyTuple_New(2+__pyx_t_8); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - if (__pyx_t_5) { - __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL; - } - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_8, __pyx_t_9); - __Pyx_INCREF(__pyx_kp_s_utf_8); - __Pyx_GIVEREF(__pyx_kp_s_utf_8); - PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_8, __pyx_kp_s_utf_8); - __pyx_t_9 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 118, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":116 - * size, = struct_unpack(">H", self.read(2)) - * return decode(self.read(size), "utf-8") - * elif marker == 0xD2: # STRING_32: # <<<<<<<<<<<<<< - * size, = struct_unpack(">I", self.read(4)) - * return decode(self.read(size), "utf-8") - */ - } - - /* "neo4j/packstream/_unpacker.pyx":121 - * - * # List - * elif 0x90 <= marker <= 0x9F or 0xD4 <= marker <= 0xD7: # <<<<<<<<<<<<<< - * return self._unpack_list(marker) - * - */ - __pyx_t_3 = (0x90 <= __pyx_v_marker); - if (__pyx_t_3) { - __pyx_t_3 = (__pyx_v_marker <= 0x9F); - } - __pyx_t_11 = (__pyx_t_3 != 0); - if (!__pyx_t_11) { - } else { - __pyx_t_1 = __pyx_t_11; - goto __pyx_L20_bool_binop_done; - } - __pyx_t_11 = (0xD4 <= __pyx_v_marker); - if (__pyx_t_11) { - __pyx_t_11 = (__pyx_v_marker <= 0xD7); - } - __pyx_t_3 = (__pyx_t_11 != 0); - __pyx_t_1 = __pyx_t_3; - __pyx_L20_bool_binop_done:; - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":122 - * # List - * elif 0x90 <= marker <= 0x9F or 0xD4 <= marker <= 0xD7: - * return self._unpack_list(marker) # <<<<<<<<<<<<<< - * - * # Map - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack_list(__pyx_v_self, __pyx_v_marker); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 122, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":121 - * - * # List - * elif 0x90 <= marker <= 0x9F or 0xD4 <= marker <= 0xD7: # <<<<<<<<<<<<<< - * return self._unpack_list(marker) - * - */ - } - - /* "neo4j/packstream/_unpacker.pyx":125 - * - * # Map - * elif 0xA0 <= marker <= 0xAF or 0xD8 <= marker <= 0xDB: # <<<<<<<<<<<<<< - * return self._unpack_map(marker) - * - */ - __pyx_t_3 = (0xA0 <= __pyx_v_marker); - if (__pyx_t_3) { - __pyx_t_3 = (__pyx_v_marker <= 0xAF); - } - __pyx_t_11 = (__pyx_t_3 != 0); - if (!__pyx_t_11) { - } else { - __pyx_t_1 = __pyx_t_11; - goto __pyx_L22_bool_binop_done; - } - __pyx_t_11 = (0xD8 <= __pyx_v_marker); - if (__pyx_t_11) { - __pyx_t_11 = (__pyx_v_marker <= 0xDB); - } - __pyx_t_3 = (__pyx_t_11 != 0); - __pyx_t_1 = __pyx_t_3; - __pyx_L22_bool_binop_done:; - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":126 - * # Map - * elif 0xA0 <= marker <= 0xAF or 0xD8 <= marker <= 0xDB: - * return self._unpack_map(marker) # <<<<<<<<<<<<<< - * - * # Structure - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack_map(__pyx_v_self, __pyx_v_marker); 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; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":125 - * - * # Map - * elif 0xA0 <= marker <= 0xAF or 0xD8 <= marker <= 0xDB: # <<<<<<<<<<<<<< - * return self._unpack_map(marker) - * - */ - } - - /* "neo4j/packstream/_unpacker.pyx":129 - * - * # Structure - * elif 0xB0 <= marker <= 0xBF or 0xDC <= marker <= 0xDD: # <<<<<<<<<<<<<< - * size, tag = self._unpack_structure_header(marker) - * value = Structure(tag, *([None] * size)) - */ - __pyx_t_3 = (0xB0 <= __pyx_v_marker); - if (__pyx_t_3) { - __pyx_t_3 = (__pyx_v_marker <= 0xBF); - } - __pyx_t_11 = (__pyx_t_3 != 0); - if (!__pyx_t_11) { - } else { - __pyx_t_1 = __pyx_t_11; - goto __pyx_L24_bool_binop_done; - } - __pyx_t_11 = (0xDC <= __pyx_v_marker); - if (__pyx_t_11) { - __pyx_t_11 = (__pyx_v_marker <= 0xDD); - } - __pyx_t_3 = (__pyx_t_11 != 0); - __pyx_t_1 = __pyx_t_3; - __pyx_L24_bool_binop_done:; - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":130 - * # Structure - * elif 0xB0 <= marker <= 0xBF or 0xDC <= marker <= 0xDD: - * size, tag = self._unpack_structure_header(marker) # <<<<<<<<<<<<<< - * value = Structure(tag, *([None] * size)) - * for i in range(len(value)): - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack_structure_header(__pyx_v_self, __pyx_v_marker); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 2)) { - if (size > 2) __Pyx_RaiseTooManyValuesError(2); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 130, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_7 = PyTuple_GET_ITEM(sequence, 0); - __pyx_t_4 = PyTuple_GET_ITEM(sequence, 1); - } else { - __pyx_t_7 = PyList_GET_ITEM(sequence, 0); - __pyx_t_4 = PyList_GET_ITEM(sequence, 1); - } - __Pyx_INCREF(__pyx_t_7); - __Pyx_INCREF(__pyx_t_4); - #else - __pyx_t_7 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __pyx_t_4 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; - index = 0; __pyx_t_7 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_7)) goto __pyx_L26_unpacking_failed; - __Pyx_GOTREF(__pyx_t_7); - index = 1; __pyx_t_4 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_4)) goto __pyx_L26_unpacking_failed; - __Pyx_GOTREF(__pyx_t_4); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 2) < 0) __PYX_ERR(0, 130, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L27_unpacking_done; - __pyx_L26_unpacking_failed:; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 130, __pyx_L1_error) - __pyx_L27_unpacking_done:; - } - __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 130, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_v_size = __pyx_t_8; - __pyx_v_tag = __pyx_t_4; - __pyx_t_4 = 0; - - /* "neo4j/packstream/_unpacker.pyx":131 - * elif 0xB0 <= marker <= 0xBF or 0xDC <= marker <= 0xDD: - * size, tag = self._unpack_structure_header(marker) - * value = Structure(tag, *([None] * size)) # <<<<<<<<<<<<<< - * for i in range(len(value)): - * value[i] = self._unpack() - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_Structure); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_4); - __Pyx_INCREF(__pyx_v_tag); - __Pyx_GIVEREF(__pyx_v_tag); - PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_v_tag); - __pyx_t_7 = PyList_New(1 * ((__pyx_v_size<0) ? 0:__pyx_v_size)); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - { Py_ssize_t __pyx_temp; - for (__pyx_temp=0; __pyx_temp < __pyx_v_size; __pyx_temp++) { - __Pyx_INCREF(Py_None); - __Pyx_GIVEREF(Py_None); - PyList_SET_ITEM(__pyx_t_7, __pyx_temp, Py_None); - } - } - __pyx_t_9 = PySequence_Tuple(__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_t_7 = PyNumber_Add(__pyx_t_4, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 131, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __pyx_v_value = __pyx_t_9; - __pyx_t_9 = 0; - - /* "neo4j/packstream/_unpacker.pyx":132 - * size, tag = self._unpack_structure_header(marker) - * value = Structure(tag, *([None] * size)) - * for i in range(len(value)): # <<<<<<<<<<<<<< - * value[i] = self._unpack() - * return value - */ - __pyx_t_12 = PyObject_Length(__pyx_v_value); if (unlikely(__pyx_t_12 == ((Py_ssize_t)-1))) __PYX_ERR(0, 132, __pyx_L1_error) - for (__pyx_t_8 = 0; __pyx_t_8 < __pyx_t_12; __pyx_t_8+=1) { - __pyx_v_i = __pyx_t_8; - - /* "neo4j/packstream/_unpacker.pyx":133 - * value = Structure(tag, *([None] * size)) - * for i in range(len(value)): - * value[i] = self._unpack() # <<<<<<<<<<<<<< - * return value - * - */ - __pyx_t_9 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (unlikely(__Pyx_SetItemInt(__pyx_v_value, __pyx_v_i, __pyx_t_9, int, 1, __Pyx_PyInt_From_int, 0, 1, 1) < 0)) __PYX_ERR(0, 133, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":134 - * for i in range(len(value)): - * value[i] = self._unpack() - * return value # <<<<<<<<<<<<<< - * - * elif marker == 0xDF: # END_OF_STREAM: - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_value); - __pyx_r = __pyx_v_value; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":129 - * - * # Structure - * elif 0xB0 <= marker <= 0xBF or 0xDC <= marker <= 0xDD: # <<<<<<<<<<<<<< - * size, tag = self._unpack_structure_header(marker) - * value = Structure(tag, *([None] * size)) - */ - } - - /* "neo4j/packstream/_unpacker.pyx":136 - * return value - * - * elif marker == 0xDF: # END_OF_STREAM: # <<<<<<<<<<<<<< - * return EndOfStream - * - */ - __pyx_t_1 = ((__pyx_v_marker == 0xDF) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":137 - * - * elif marker == 0xDF: # END_OF_STREAM: - * return EndOfStream # <<<<<<<<<<<<<< - * - * else: - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_EndOfStream); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 137, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_r = __pyx_t_9; - __pyx_t_9 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":136 - * return value - * - * elif marker == 0xDF: # END_OF_STREAM: # <<<<<<<<<<<<<< - * return EndOfStream - * - */ - } - - /* "neo4j/packstream/_unpacker.pyx":140 - * - * else: - * raise RuntimeError("Unknown PackStream marker %02X" % marker) # <<<<<<<<<<<<<< - * - * cpdef list unpack_list(self): - */ - /*else*/ { - __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_marker); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_7 = __Pyx_PyString_Format(__pyx_kp_s_Unknown_PackStream_marker_02X, __pyx_t_9); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_9 = PyTuple_New(1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_GIVEREF(__pyx_t_7); - PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); - __pyx_t_7 = 0; - __pyx_t_7 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_9, NULL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 140, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_7); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_Raise(__pyx_t_7, 0, 0, 0); - __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0; - __PYX_ERR(0, 140, __pyx_L1_error) - } - } - - /* "neo4j/packstream/_unpacker.pyx":52 - * return self._unpack() - * - * cdef _unpack(self): # <<<<<<<<<<<<<< - * cdef int size - * cdef int i - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_4); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_7); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("neo4j.packstream._unpacker.Unpacker._unpack", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_value); - __Pyx_XDECREF(__pyx_v_tag); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":142 - * raise RuntimeError("Unknown PackStream marker %02X" % marker) - * - * cpdef list unpack_list(self): # <<<<<<<<<<<<<< - * cdef int marker - * - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_7unpack_list(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_list(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_skip_dispatch) { - int __pyx_v_marker; - 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; - __Pyx_RefNannySetupContext("unpack_list", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unpack_list); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_7unpack_list)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!(likely(PyList_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "list", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 142, __pyx_L1_error) - __pyx_r = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":145 - * cdef int marker - * - * marker = self.read_int() # <<<<<<<<<<<<<< - * return self._unpack_list(marker) - * - */ - __pyx_v_marker = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read_int(__pyx_v_self); - - /* "neo4j/packstream/_unpacker.pyx":146 - * - * marker = self.read_int() - * return self._unpack_list(marker) # <<<<<<<<<<<<<< - * - * cdef list _unpack_list(self, int marker): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack_list(__pyx_v_self, __pyx_v_marker); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":142 - * raise RuntimeError("Unknown PackStream marker %02X" % marker) - * - * cpdef list unpack_list(self): # <<<<<<<<<<<<<< - * cdef int marker - * - */ - - /* 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("neo4j.packstream._unpacker.Unpacker.unpack_list", __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_5neo4j_10packstream_9_unpacker_8Unpacker_7unpack_list(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_7unpack_list(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("unpack_list (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_6unpack_list(((struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_6unpack_list(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("unpack_list", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_list(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __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("neo4j.packstream._unpacker.Unpacker.unpack_list", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":148 - * return self._unpack_list(marker) - * - * cdef list _unpack_list(self, int marker): # <<<<<<<<<<<<<< - * cdef int marker_high - * cdef int size - */ - -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack_list(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_v_marker) { - int __pyx_v_marker_high; - int __pyx_v_size; - PyObject *__pyx_v_value = 0; - PyObject *__pyx_v_item = NULL; - CYTHON_UNUSED int __pyx_v__; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - int __pyx_t_4; - int __pyx_t_5; - PyObject *__pyx_t_6 = NULL; - struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - PyObject *(*__pyx_t_10)(PyObject *); - int __pyx_t_11; - int __pyx_t_12; - __Pyx_RefNannySetupContext("_unpack_list", 0); - - /* "neo4j/packstream/_unpacker.pyx":153 - * cdef list value - * - * marker_high = marker & 0xF0 # <<<<<<<<<<<<<< - * if marker_high == 0x90: - * size = marker & 0x0F - */ - __pyx_v_marker_high = (__pyx_v_marker & 0xF0); - - /* "neo4j/packstream/_unpacker.pyx":154 - * - * marker_high = marker & 0xF0 - * if marker_high == 0x90: # <<<<<<<<<<<<<< - * size = marker & 0x0F - * if size == 0: - */ - __pyx_t_1 = ((__pyx_v_marker_high == 0x90) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":155 - * marker_high = marker & 0xF0 - * if marker_high == 0x90: - * size = marker & 0x0F # <<<<<<<<<<<<<< - * if size == 0: - * return [] - */ - __pyx_v_size = (__pyx_v_marker & 0x0F); - - /* "neo4j/packstream/_unpacker.pyx":156 - * if marker_high == 0x90: - * size = marker & 0x0F - * if size == 0: # <<<<<<<<<<<<<< - * return [] - * elif size == 1: - */ - switch (__pyx_v_size) { - case 0: - - /* "neo4j/packstream/_unpacker.pyx":157 - * size = marker & 0x0F - * if size == 0: - * return [] # <<<<<<<<<<<<<< - * elif size == 1: - * return [self._unpack()] - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = PyList_New(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 157, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_r = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":156 - * if marker_high == 0x90: - * size = marker & 0x0F - * if size == 0: # <<<<<<<<<<<<<< - * return [] - * elif size == 1: - */ - break; - - /* "neo4j/packstream/_unpacker.pyx":158 - * if size == 0: - * return [] - * elif size == 1: # <<<<<<<<<<<<<< - * return [self._unpack()] - * else: - */ - case 1: - - /* "neo4j/packstream/_unpacker.pyx":159 - * return [] - * elif size == 1: - * return [self._unpack()] # <<<<<<<<<<<<<< - * else: - * return [self._unpack() for _ in range(size)] - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 159, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_GIVEREF(__pyx_t_2); - PyList_SET_ITEM(__pyx_t_3, 0, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_r = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":158 - * if size == 0: - * return [] - * elif size == 1: # <<<<<<<<<<<<<< - * return [self._unpack()] - * else: - */ - break; - default: - - /* "neo4j/packstream/_unpacker.pyx":161 - * return [self._unpack()] - * else: - * return [self._unpack() for _ in range(size)] # <<<<<<<<<<<<<< - * elif marker == 0xD4: # LIST_8: - * size, = struct_unpack(">B", self.read(1)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __pyx_v_size; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v__ = __pyx_t_5; - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 161, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_r = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; - break; - } - - /* "neo4j/packstream/_unpacker.pyx":154 - * - * marker_high = marker & 0xF0 - * if marker_high == 0x90: # <<<<<<<<<<<<<< - * size = marker & 0x0F - * if size == 0: - */ - } - - /* "neo4j/packstream/_unpacker.pyx":162 - * else: - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD4: # LIST_8: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * return [self._unpack() for _ in range(size)] - */ - __pyx_t_1 = ((__pyx_v_marker == 0xD4) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":163 - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD4: # LIST_8: - * size, = struct_unpack(">B", self.read(1)) # <<<<<<<<<<<<<< - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD5: # LIST_16: - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7.__pyx_n = 1; - __pyx_t_7.n = 1; - __pyx_t_6 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = NULL; - __pyx_t_4 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_4 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_B, __pyx_t_6}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_B, __pyx_t_6}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_8) { - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_kp_s_B); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_4, __pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_4, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { - PyObject* sequence = __pyx_t_3; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 163, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_2 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_2); - #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_9 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; - index = 0; __pyx_t_2 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_2)) goto __pyx_L6_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 1) < 0) __PYX_ERR(0, 163, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L7_unpacking_done; - __pyx_L6_unpacking_failed:; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 163, __pyx_L1_error) - __pyx_L7_unpacking_done:; - } - __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 163, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_size = __pyx_t_4; - - /* "neo4j/packstream/_unpacker.pyx":164 - * elif marker == 0xD4: # LIST_8: - * size, = struct_unpack(">B", self.read(1)) - * return [self._unpack() for _ in range(size)] # <<<<<<<<<<<<<< - * elif marker == 0xD5: # LIST_16: - * size, = struct_unpack(">H", self.read(2)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 164, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __pyx_v_size; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v__ = __pyx_t_5; - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 164, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 164, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_r = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":162 - * else: - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD4: # LIST_8: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * return [self._unpack() for _ in range(size)] - */ - } - - /* "neo4j/packstream/_unpacker.pyx":165 - * size, = struct_unpack(">B", self.read(1)) - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD5: # LIST_16: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * return [self._unpack() for _ in range(size)] - */ - __pyx_t_1 = ((__pyx_v_marker == 0xD5) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":166 - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD5: # LIST_16: - * size, = struct_unpack(">H", self.read(2)) # <<<<<<<<<<<<<< - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD6: # LIST_32: - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7.__pyx_n = 1; - __pyx_t_7.n = 2; - __pyx_t_9 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_6 = NULL; - __pyx_t_4 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_4 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_H, __pyx_t_9}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_H, __pyx_t_9}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_kp_s_H); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_4, __pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_4, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { - PyObject* sequence = __pyx_t_3; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 166, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_2 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_2); - #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext; - index = 0; __pyx_t_2 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L10_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_8), 1) < 0) __PYX_ERR(0, 166, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - goto __pyx_L11_unpacking_done; - __pyx_L10_unpacking_failed:; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 166, __pyx_L1_error) - __pyx_L11_unpacking_done:; - } - __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 166, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_size = __pyx_t_4; - - /* "neo4j/packstream/_unpacker.pyx":167 - * elif marker == 0xD5: # LIST_16: - * size, = struct_unpack(">H", self.read(2)) - * return [self._unpack() for _ in range(size)] # <<<<<<<<<<<<<< - * elif marker == 0xD6: # LIST_32: - * size, = struct_unpack(">I", self.read(4)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __pyx_v_size; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v__ = __pyx_t_5; - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 167, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_r = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":165 - * size, = struct_unpack(">B", self.read(1)) - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD5: # LIST_16: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * return [self._unpack() for _ in range(size)] - */ - } - - /* "neo4j/packstream/_unpacker.pyx":168 - * size, = struct_unpack(">H", self.read(2)) - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD6: # LIST_32: # <<<<<<<<<<<<<< - * size, = struct_unpack(">I", self.read(4)) - * return [self._unpack() for _ in range(size)] - */ - __pyx_t_1 = ((__pyx_v_marker == 0xD6) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":169 - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD6: # LIST_32: - * size, = struct_unpack(">I", self.read(4)) # <<<<<<<<<<<<<< - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD7: # LIST_STREAM: - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_7.__pyx_n = 1; - __pyx_t_7.n = 4; - __pyx_t_8 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = NULL; - __pyx_t_4 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_4 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_I, __pyx_t_8}; - __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_I, __pyx_t_8}; - __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_9) { - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_4, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_4, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) { - PyObject* sequence = __pyx_t_3; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 169, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_2 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_2); - #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - #endif - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_6 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext; - index = 0; __pyx_t_2 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_2)) goto __pyx_L14_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_6), 1) < 0) __PYX_ERR(0, 169, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - goto __pyx_L15_unpacking_done; - __pyx_L14_unpacking_failed:; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 169, __pyx_L1_error) - __pyx_L15_unpacking_done:; - } - __pyx_t_4 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_4 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 169, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_size = __pyx_t_4; - - /* "neo4j/packstream/_unpacker.pyx":170 - * elif marker == 0xD6: # LIST_32: - * size, = struct_unpack(">I", self.read(4)) - * return [self._unpack() for _ in range(size)] # <<<<<<<<<<<<<< - * elif marker == 0xD7: # LIST_STREAM: - * value = [] - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 170, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_4 = __pyx_v_size; - for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) { - __pyx_v__ = __pyx_t_5; - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 170, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(__Pyx_ListComp_Append(__pyx_t_3, (PyObject*)__pyx_t_2))) __PYX_ERR(0, 170, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - __pyx_r = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":168 - * size, = struct_unpack(">H", self.read(2)) - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD6: # LIST_32: # <<<<<<<<<<<<<< - * size, = struct_unpack(">I", self.read(4)) - * return [self._unpack() for _ in range(size)] - */ - } - - /* "neo4j/packstream/_unpacker.pyx":171 - * size, = struct_unpack(">I", self.read(4)) - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD7: # LIST_STREAM: # <<<<<<<<<<<<<< - * value = [] - * item = None - */ - __pyx_t_1 = ((__pyx_v_marker == 0xD7) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":172 - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD7: # LIST_STREAM: - * value = [] # <<<<<<<<<<<<<< - * item = None - * while item is not EndOfStream: - */ - __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 172, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_v_value = ((PyObject*)__pyx_t_3); - __pyx_t_3 = 0; - - /* "neo4j/packstream/_unpacker.pyx":173 - * elif marker == 0xD7: # LIST_STREAM: - * value = [] - * item = None # <<<<<<<<<<<<<< - * while item is not EndOfStream: - * item = self._unpack() - */ - __Pyx_INCREF(Py_None); - __pyx_v_item = Py_None; - - /* "neo4j/packstream/_unpacker.pyx":174 - * value = [] - * item = None - * while item is not EndOfStream: # <<<<<<<<<<<<<< - * item = self._unpack() - * if item is not EndOfStream: - */ - while (1) { - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_EndOfStream); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 174, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_1 = (__pyx_v_item != __pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_11 = (__pyx_t_1 != 0); - if (!__pyx_t_11) break; - - /* "neo4j/packstream/_unpacker.pyx":175 - * item = None - * while item is not EndOfStream: - * item = self._unpack() # <<<<<<<<<<<<<< - * if item is not EndOfStream: - * value.append(item) - */ - __pyx_t_3 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 175, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __Pyx_DECREF_SET(__pyx_v_item, __pyx_t_3); - __pyx_t_3 = 0; - - /* "neo4j/packstream/_unpacker.pyx":176 - * while item is not EndOfStream: - * item = self._unpack() - * if item is not EndOfStream: # <<<<<<<<<<<<<< - * value.append(item) - * return value - */ - __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_EndOfStream); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_11 = (__pyx_v_item != __pyx_t_3); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_1 = (__pyx_t_11 != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":177 - * item = self._unpack() - * if item is not EndOfStream: - * value.append(item) # <<<<<<<<<<<<<< - * return value - * else: - */ - __pyx_t_12 = __Pyx_PyList_Append(__pyx_v_value, __pyx_v_item); if (unlikely(__pyx_t_12 == ((int)-1))) __PYX_ERR(0, 177, __pyx_L1_error) - - /* "neo4j/packstream/_unpacker.pyx":176 - * while item is not EndOfStream: - * item = self._unpack() - * if item is not EndOfStream: # <<<<<<<<<<<<<< - * value.append(item) - * return value - */ - } - } - - /* "neo4j/packstream/_unpacker.pyx":178 - * if item is not EndOfStream: - * value.append(item) - * return value # <<<<<<<<<<<<<< - * else: - * return None - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_value); - __pyx_r = __pyx_v_value; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":171 - * size, = struct_unpack(">I", self.read(4)) - * return [self._unpack() for _ in range(size)] - * elif marker == 0xD7: # LIST_STREAM: # <<<<<<<<<<<<<< - * value = [] - * item = None - */ - } - - /* "neo4j/packstream/_unpacker.pyx":180 - * return value - * else: - * return None # <<<<<<<<<<<<<< - * - * cpdef dict unpack_map(self): - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = ((PyObject*)Py_None); - goto __pyx_L0; - } - - /* "neo4j/packstream/_unpacker.pyx":148 - * return self._unpack_list(marker) - * - * cdef list _unpack_list(self, int marker): # <<<<<<<<<<<<<< - * cdef int marker_high - * cdef int size - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_XDECREF(__pyx_t_9); - __Pyx_AddTraceback("neo4j.packstream._unpacker.Unpacker._unpack_list", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_value); - __Pyx_XDECREF(__pyx_v_item); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":182 - * return None - * - * cpdef dict unpack_map(self): # <<<<<<<<<<<<<< - * marker = self.read_int() - * return self._unpack_map(marker) - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_9unpack_map(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_map(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_skip_dispatch) { - int __pyx_v_marker; - 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; - __Pyx_RefNannySetupContext("unpack_map", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unpack_map); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_9unpack_map)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 182, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - if (!(likely(PyDict_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "dict", Py_TYPE(__pyx_t_2)->tp_name), 0))) __PYX_ERR(0, 182, __pyx_L1_error) - __pyx_r = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":183 - * - * cpdef dict unpack_map(self): - * marker = self.read_int() # <<<<<<<<<<<<<< - * return self._unpack_map(marker) - * - */ - __pyx_v_marker = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read_int(__pyx_v_self); - - /* "neo4j/packstream/_unpacker.pyx":184 - * cpdef dict unpack_map(self): - * marker = self.read_int() - * return self._unpack_map(marker) # <<<<<<<<<<<<<< - * - * cdef dict _unpack_map(self, int marker): - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack_map(__pyx_v_self, __pyx_v_marker); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 184, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = ((PyObject*)__pyx_t_1); - __pyx_t_1 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":182 - * return None - * - * cpdef dict unpack_map(self): # <<<<<<<<<<<<<< - * marker = self.read_int() - * return self._unpack_map(marker) - */ - - /* 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("neo4j.packstream._unpacker.Unpacker.unpack_map", __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_5neo4j_10packstream_9_unpacker_8Unpacker_9unpack_map(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_9unpack_map(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("unpack_map (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_8unpack_map(((struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_8unpack_map(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("unpack_map", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_map(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 182, __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("neo4j.packstream._unpacker.Unpacker.unpack_map", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":186 - * return self._unpack_map(marker) - * - * cdef dict _unpack_map(self, int marker): # <<<<<<<<<<<<<< - * cdef int size - * cdef int marker_high - */ - -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack_map(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_v_marker) { - int __pyx_v_size; - int __pyx_v_marker_high; - PyObject *__pyx_v_value = 0; - CYTHON_UNUSED int __pyx_v__; - PyObject *__pyx_v_key = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - int __pyx_t_3; - int __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *__pyx_t_9 = NULL; - PyObject *(*__pyx_t_10)(PyObject *); - int __pyx_t_11; - __Pyx_RefNannySetupContext("_unpack_map", 0); - - /* "neo4j/packstream/_unpacker.pyx":191 - * cdef dict value - * - * marker_high = marker & 0xF0 # <<<<<<<<<<<<<< - * if marker_high == 0xA0: - * size = marker & 0x0F - */ - __pyx_v_marker_high = (__pyx_v_marker & 0xF0); - - /* "neo4j/packstream/_unpacker.pyx":192 - * - * marker_high = marker & 0xF0 - * if marker_high == 0xA0: # <<<<<<<<<<<<<< - * size = marker & 0x0F - * value = {} - */ - __pyx_t_1 = ((__pyx_v_marker_high == 0xA0) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":193 - * marker_high = marker & 0xF0 - * if marker_high == 0xA0: - * size = marker & 0x0F # <<<<<<<<<<<<<< - * value = {} - * for _ in range(size): - */ - __pyx_v_size = (__pyx_v_marker & 0x0F); - - /* "neo4j/packstream/_unpacker.pyx":194 - * if marker_high == 0xA0: - * size = marker & 0x0F - * value = {} # <<<<<<<<<<<<<< - * for _ in range(size): - * key = self._unpack() - */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 194, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_value = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":195 - * size = marker & 0x0F - * value = {} - * for _ in range(size): # <<<<<<<<<<<<<< - * key = self._unpack() - * value[key] = self._unpack() - */ - __pyx_t_3 = __pyx_v_size; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v__ = __pyx_t_4; - - /* "neo4j/packstream/_unpacker.pyx":196 - * value = {} - * for _ in range(size): - * key = self._unpack() # <<<<<<<<<<<<<< - * value[key] = self._unpack() - * return value - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 196, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":197 - * for _ in range(size): - * key = self._unpack() - * value[key] = self._unpack() # <<<<<<<<<<<<<< - * return value - * elif marker == 0xD8: # MAP_8: - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyDict_SetItem(__pyx_v_value, __pyx_v_key, __pyx_t_2) < 0)) __PYX_ERR(0, 197, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":198 - * key = self._unpack() - * value[key] = self._unpack() - * return value # <<<<<<<<<<<<<< - * elif marker == 0xD8: # MAP_8: - * size, = struct_unpack(">B", self.read(1)) - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_value); - __pyx_r = __pyx_v_value; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":192 - * - * marker_high = marker & 0xF0 - * if marker_high == 0xA0: # <<<<<<<<<<<<<< - * size = marker & 0x0F - * value = {} - */ - } - - /* "neo4j/packstream/_unpacker.pyx":199 - * value[key] = self._unpack() - * return value - * elif marker == 0xD8: # MAP_8: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * value = {} - */ - __pyx_t_1 = ((__pyx_v_marker == 0xD8) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":200 - * return value - * elif marker == 0xD8: # MAP_8: - * size, = struct_unpack(">B", self.read(1)) # <<<<<<<<<<<<<< - * value = {} - * for _ in range(size): - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7.__pyx_n = 1; - __pyx_t_7.n = 1; - __pyx_t_6 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = NULL; - __pyx_t_3 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_8)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_8); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_3 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_B, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_8, __pyx_kp_s_B, __pyx_t_6}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } else - #endif - { - __pyx_t_9 = PyTuple_New(2+__pyx_t_3); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - if (__pyx_t_8) { - __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_kp_s_B); - PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_3, __pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_t_6); - PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_3, __pyx_t_6); - __pyx_t_6 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 200, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_5 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_5); - #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_9 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_9)->tp_iternext; - index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_9); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed; - __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_9), 1) < 0) __PYX_ERR(0, 200, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - goto __pyx_L7_unpacking_done; - __pyx_L6_unpacking_failed:; - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 200, __pyx_L1_error) - __pyx_L7_unpacking_done:; - } - __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 200, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_size = __pyx_t_3; - - /* "neo4j/packstream/_unpacker.pyx":201 - * elif marker == 0xD8: # MAP_8: - * size, = struct_unpack(">B", self.read(1)) - * value = {} # <<<<<<<<<<<<<< - * for _ in range(size): - * key = self._unpack() - */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 201, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_value = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":202 - * size, = struct_unpack(">B", self.read(1)) - * value = {} - * for _ in range(size): # <<<<<<<<<<<<<< - * key = self._unpack() - * value[key] = self._unpack() - */ - __pyx_t_3 = __pyx_v_size; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v__ = __pyx_t_4; - - /* "neo4j/packstream/_unpacker.pyx":203 - * value = {} - * for _ in range(size): - * key = self._unpack() # <<<<<<<<<<<<<< - * value[key] = self._unpack() - * return value - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 203, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":204 - * for _ in range(size): - * key = self._unpack() - * value[key] = self._unpack() # <<<<<<<<<<<<<< - * return value - * elif marker == 0xD9: # MAP_16: - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyDict_SetItem(__pyx_v_value, __pyx_v_key, __pyx_t_2) < 0)) __PYX_ERR(0, 204, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":205 - * key = self._unpack() - * value[key] = self._unpack() - * return value # <<<<<<<<<<<<<< - * elif marker == 0xD9: # MAP_16: - * size, = struct_unpack(">H", self.read(2)) - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_value); - __pyx_r = __pyx_v_value; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":199 - * value[key] = self._unpack() - * return value - * elif marker == 0xD8: # MAP_8: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * value = {} - */ - } - - /* "neo4j/packstream/_unpacker.pyx":206 - * value[key] = self._unpack() - * return value - * elif marker == 0xD9: # MAP_16: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * value = {} - */ - __pyx_t_1 = ((__pyx_v_marker == 0xD9) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":207 - * return value - * elif marker == 0xD9: # MAP_16: - * size, = struct_unpack(">H", self.read(2)) # <<<<<<<<<<<<<< - * value = {} - * for _ in range(size): - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7.__pyx_n = 1; - __pyx_t_7.n = 2; - __pyx_t_9 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_7); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_9); - __pyx_t_6 = NULL; - __pyx_t_3 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_3 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_H, __pyx_t_9}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_H, __pyx_t_9}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_kp_s_H); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_3, __pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_t_9); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_3, __pyx_t_9); - __pyx_t_9 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 207, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_5 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_5); - #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_8 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_8)->tp_iternext; - index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_8); if (unlikely(!__pyx_t_5)) goto __pyx_L10_unpacking_failed; - __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_8), 1) < 0) __PYX_ERR(0, 207, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - goto __pyx_L11_unpacking_done; - __pyx_L10_unpacking_failed:; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 207, __pyx_L1_error) - __pyx_L11_unpacking_done:; - } - __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 207, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_size = __pyx_t_3; - - /* "neo4j/packstream/_unpacker.pyx":208 - * elif marker == 0xD9: # MAP_16: - * size, = struct_unpack(">H", self.read(2)) - * value = {} # <<<<<<<<<<<<<< - * for _ in range(size): - * key = self._unpack() - */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 208, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_value = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":209 - * size, = struct_unpack(">H", self.read(2)) - * value = {} - * for _ in range(size): # <<<<<<<<<<<<<< - * key = self._unpack() - * value[key] = self._unpack() - */ - __pyx_t_3 = __pyx_v_size; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v__ = __pyx_t_4; - - /* "neo4j/packstream/_unpacker.pyx":210 - * value = {} - * for _ in range(size): - * key = self._unpack() # <<<<<<<<<<<<<< - * value[key] = self._unpack() - * return value - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 210, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":211 - * for _ in range(size): - * key = self._unpack() - * value[key] = self._unpack() # <<<<<<<<<<<<<< - * return value - * elif marker == 0xDA: # MAP_32: - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyDict_SetItem(__pyx_v_value, __pyx_v_key, __pyx_t_2) < 0)) __PYX_ERR(0, 211, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":212 - * key = self._unpack() - * value[key] = self._unpack() - * return value # <<<<<<<<<<<<<< - * elif marker == 0xDA: # MAP_32: - * size, = struct_unpack(">I", self.read(4)) - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_value); - __pyx_r = __pyx_v_value; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":206 - * value[key] = self._unpack() - * return value - * elif marker == 0xD9: # MAP_16: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * value = {} - */ - } - - /* "neo4j/packstream/_unpacker.pyx":213 - * value[key] = self._unpack() - * return value - * elif marker == 0xDA: # MAP_32: # <<<<<<<<<<<<<< - * size, = struct_unpack(">I", self.read(4)) - * value = {} - */ - __pyx_t_1 = ((__pyx_v_marker == 0xDA) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":214 - * return value - * elif marker == 0xDA: # MAP_32: - * size, = struct_unpack(">I", self.read(4)) # <<<<<<<<<<<<<< - * value = {} - * for _ in range(size): - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_7.__pyx_n = 1; - __pyx_t_7.n = 4; - __pyx_t_8 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_9 = NULL; - __pyx_t_3 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_9)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_9); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_3 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_I, __pyx_t_8}; - __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_9, __pyx_kp_s_I, __pyx_t_8}; - __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_3, 2+__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0; - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(2+__pyx_t_3); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_9) { - __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_9); __pyx_t_9 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_kp_s_I); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_3, __pyx_kp_s_I); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_3, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) { - PyObject* sequence = __pyx_t_2; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 214, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_5 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_5); - #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_6 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_10 = Py_TYPE(__pyx_t_6)->tp_iternext; - index = 0; __pyx_t_5 = __pyx_t_10(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L14_unpacking_failed; - __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_10(__pyx_t_6), 1) < 0) __PYX_ERR(0, 214, __pyx_L1_error) - __pyx_t_10 = NULL; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - goto __pyx_L15_unpacking_done; - __pyx_L14_unpacking_failed:; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_10 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 214, __pyx_L1_error) - __pyx_L15_unpacking_done:; - } - __pyx_t_3 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_3 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 214, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_size = __pyx_t_3; - - /* "neo4j/packstream/_unpacker.pyx":215 - * elif marker == 0xDA: # MAP_32: - * size, = struct_unpack(">I", self.read(4)) - * value = {} # <<<<<<<<<<<<<< - * for _ in range(size): - * key = self._unpack() - */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 215, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_value = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":216 - * size, = struct_unpack(">I", self.read(4)) - * value = {} - * for _ in range(size): # <<<<<<<<<<<<<< - * key = self._unpack() - * value[key] = self._unpack() - */ - __pyx_t_3 = __pyx_v_size; - for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_3; __pyx_t_4+=1) { - __pyx_v__ = __pyx_t_4; - - /* "neo4j/packstream/_unpacker.pyx":217 - * value = {} - * for _ in range(size): - * key = self._unpack() # <<<<<<<<<<<<<< - * value[key] = self._unpack() - * return value - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 217, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_XDECREF_SET(__pyx_v_key, __pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":218 - * for _ in range(size): - * key = self._unpack() - * value[key] = self._unpack() # <<<<<<<<<<<<<< - * return value - * elif marker == 0xDB: # MAP_STREAM: - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 218, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyDict_SetItem(__pyx_v_value, __pyx_v_key, __pyx_t_2) < 0)) __PYX_ERR(0, 218, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":219 - * key = self._unpack() - * value[key] = self._unpack() - * return value # <<<<<<<<<<<<<< - * elif marker == 0xDB: # MAP_STREAM: - * value = {} - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_value); - __pyx_r = __pyx_v_value; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":213 - * value[key] = self._unpack() - * return value - * elif marker == 0xDA: # MAP_32: # <<<<<<<<<<<<<< - * size, = struct_unpack(">I", self.read(4)) - * value = {} - */ - } - - /* "neo4j/packstream/_unpacker.pyx":220 - * value[key] = self._unpack() - * return value - * elif marker == 0xDB: # MAP_STREAM: # <<<<<<<<<<<<<< - * value = {} - * key = None - */ - __pyx_t_1 = ((__pyx_v_marker == 0xDB) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":221 - * return value - * elif marker == 0xDB: # MAP_STREAM: - * value = {} # <<<<<<<<<<<<<< - * key = None - * while key is not EndOfStream: - */ - __pyx_t_2 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 221, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_v_value = ((PyObject*)__pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":222 - * elif marker == 0xDB: # MAP_STREAM: - * value = {} - * key = None # <<<<<<<<<<<<<< - * while key is not EndOfStream: - * key = self._unpack() - */ - __Pyx_INCREF(Py_None); - __pyx_v_key = Py_None; - - /* "neo4j/packstream/_unpacker.pyx":223 - * value = {} - * key = None - * while key is not EndOfStream: # <<<<<<<<<<<<<< - * key = self._unpack() - * if key is not EndOfStream: - */ - while (1) { - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_EndOfStream); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 223, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_1 = (__pyx_v_key != __pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_11 = (__pyx_t_1 != 0); - if (!__pyx_t_11) break; - - /* "neo4j/packstream/_unpacker.pyx":224 - * key = None - * while key is not EndOfStream: - * key = self._unpack() # <<<<<<<<<<<<<< - * if key is not EndOfStream: - * value[key] = self._unpack() - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 224, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF_SET(__pyx_v_key, __pyx_t_2); - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":225 - * while key is not EndOfStream: - * key = self._unpack() - * if key is not EndOfStream: # <<<<<<<<<<<<<< - * value[key] = self._unpack() - * return value - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_EndOfStream); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 225, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_11 = (__pyx_v_key != __pyx_t_2); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_1 = (__pyx_t_11 != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":226 - * key = self._unpack() - * if key is not EndOfStream: - * value[key] = self._unpack() # <<<<<<<<<<<<<< - * return value - * else: - */ - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack(__pyx_v_self); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (unlikely(PyDict_SetItem(__pyx_v_value, __pyx_v_key, __pyx_t_2) < 0)) __PYX_ERR(0, 226, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":225 - * while key is not EndOfStream: - * key = self._unpack() - * if key is not EndOfStream: # <<<<<<<<<<<<<< - * value[key] = self._unpack() - * return value - */ - } - } - - /* "neo4j/packstream/_unpacker.pyx":227 - * if key is not EndOfStream: - * value[key] = self._unpack() - * return value # <<<<<<<<<<<<<< - * else: - * return None - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_v_value); - __pyx_r = __pyx_v_value; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":220 - * value[key] = self._unpack() - * return value - * elif marker == 0xDB: # MAP_STREAM: # <<<<<<<<<<<<<< - * value = {} - * key = None - */ - } - - /* "neo4j/packstream/_unpacker.pyx":229 - * return value - * else: - * return None # <<<<<<<<<<<<<< - * - * cpdef unpack_structure_header(self): - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(Py_None); - __pyx_r = ((PyObject*)Py_None); - goto __pyx_L0; - } - - /* "neo4j/packstream/_unpacker.pyx":186 - * return self._unpack_map(marker) - * - * cdef dict _unpack_map(self, int marker): # <<<<<<<<<<<<<< - * cdef int size - * cdef int marker_high - */ - - /* function exit code */ - __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("neo4j.packstream._unpacker.Unpacker._unpack_map", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_value); - __Pyx_XDECREF(__pyx_v_key); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":231 - * return None - * - * cpdef unpack_structure_header(self): # <<<<<<<<<<<<<< - * cdef int marker - * - */ - -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_11unpack_structure_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_structure_header(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_skip_dispatch) { - int __pyx_v_marker; - 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; - __Pyx_RefNannySetupContext("unpack_structure_header", 0); - /* Check if called by wrapper */ - if (unlikely(__pyx_skip_dispatch)) ; - /* Check if overridden in Python */ - else if (unlikely(Py_TYPE(((PyObject *)__pyx_v_self))->tp_dictoffset != 0)) { - __pyx_t_1 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_unpack_structure_header); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (!PyCFunction_Check(__pyx_t_1) || (PyCFunction_GET_FUNCTION(__pyx_t_1) != (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_11unpack_structure_header)) { - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_t_1); - __pyx_t_3 = __pyx_t_1; __pyx_t_4 = NULL; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) { - __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3); - if (likely(__pyx_t_4)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3); - __Pyx_INCREF(__pyx_t_4); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_3, function); - } - } - if (__pyx_t_4) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 231, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_r = __pyx_t_2; - __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - goto __pyx_L0; - } - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - } - - /* "neo4j/packstream/_unpacker.pyx":234 - * cdef int marker - * - * marker = self.read_int() # <<<<<<<<<<<<<< - * if marker == -1: - * return None, None - */ - __pyx_v_marker = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read_int(__pyx_v_self); - - /* "neo4j/packstream/_unpacker.pyx":235 - * - * marker = self.read_int() - * if marker == -1: # <<<<<<<<<<<<<< - * return None, None - * else: - */ - __pyx_t_5 = ((__pyx_v_marker == -1L) != 0); - if (__pyx_t_5) { - - /* "neo4j/packstream/_unpacker.pyx":236 - * marker = self.read_int() - * if marker == -1: - * return None, None # <<<<<<<<<<<<<< - * else: - * return self._unpack_structure_header(marker) - */ - __Pyx_XDECREF(__pyx_r); - __Pyx_INCREF(__pyx_tuple__2); - __pyx_r = __pyx_tuple__2; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":235 - * - * marker = self.read_int() - * if marker == -1: # <<<<<<<<<<<<<< - * return None, None - * else: - */ - } - - /* "neo4j/packstream/_unpacker.pyx":238 - * return None, None - * else: - * return self._unpack_structure_header(marker) # <<<<<<<<<<<<<< - * - * cdef _unpack_structure_header(self, int marker): - */ - /*else*/ { - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->_unpack_structure_header(__pyx_v_self, __pyx_v_marker); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 238, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __pyx_r = __pyx_t_1; - __pyx_t_1 = 0; - goto __pyx_L0; - } - - /* "neo4j/packstream/_unpacker.pyx":231 - * return None - * - * cpdef unpack_structure_header(self): # <<<<<<<<<<<<<< - * cdef int marker - * - */ - - /* 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("neo4j.packstream._unpacker.Unpacker.unpack_structure_header", __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_5neo4j_10packstream_9_unpacker_8Unpacker_11unpack_structure_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_11unpack_structure_header(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("unpack_structure_header (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_10unpack_structure_header(((struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_10unpack_structure_header(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("unpack_structure_header", 0); - __Pyx_XDECREF(__pyx_r); - __pyx_t_1 = __pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_structure_header(__pyx_v_self, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 231, __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("neo4j.packstream._unpacker.Unpacker.unpack_structure_header", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __pyx_L0:; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "neo4j/packstream/_unpacker.pyx":240 - * return self._unpack_structure_header(marker) - * - * cdef _unpack_structure_header(self, int marker): # <<<<<<<<<<<<<< - * cdef int size - * cdef int marker_high - */ - -static PyObject *__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack_structure_header(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, int __pyx_v_marker) { - int __pyx_v_size; - int __pyx_v_marker_high; - PyObject *__pyx_v_signature = NULL; - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - int __pyx_t_1; - PyObject *__pyx_t_2 = NULL; - PyObject *__pyx_t_3 = NULL; - struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read __pyx_t_4; - PyObject *__pyx_t_5 = NULL; - PyObject *__pyx_t_6 = NULL; - int __pyx_t_7; - PyObject *__pyx_t_8 = NULL; - PyObject *(*__pyx_t_9)(PyObject *); - __Pyx_RefNannySetupContext("_unpack_structure_header", 0); - - /* "neo4j/packstream/_unpacker.pyx":244 - * cdef int marker_high - * - * marker_high = marker & 0xF0 # <<<<<<<<<<<<<< - * if marker_high == 0xB0: # TINY_STRUCT - * signature = self.read(1).tobytes() - */ - __pyx_v_marker_high = (__pyx_v_marker & 0xF0); - - /* "neo4j/packstream/_unpacker.pyx":245 - * - * marker_high = marker & 0xF0 - * if marker_high == 0xB0: # TINY_STRUCT # <<<<<<<<<<<<<< - * signature = self.read(1).tobytes() - * return marker & 0x0F, signature - */ - __pyx_t_1 = ((__pyx_v_marker_high == 0xB0) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":246 - * marker_high = marker & 0xF0 - * if marker_high == 0xB0: # TINY_STRUCT - * signature = self.read(1).tobytes() # <<<<<<<<<<<<<< - * return marker & 0x0F, signature - * elif marker == 0xDC: # STRUCT_8: - */ - __pyx_t_4.__pyx_n = 1; - __pyx_t_4.n = 1; - __pyx_t_3 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - __pyx_t_3 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - } - } - if (__pyx_t_3) { - __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 246, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else { - __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_5); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 246, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_signature = __pyx_t_2; - __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":247 - * if marker_high == 0xB0: # TINY_STRUCT - * signature = self.read(1).tobytes() - * return marker & 0x0F, signature # <<<<<<<<<<<<<< - * elif marker == 0xDC: # STRUCT_8: - * size, = struct_unpack(">B", self.read(1)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_marker & 0x0F)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 247, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); - __Pyx_INCREF(__pyx_v_signature); - __Pyx_GIVEREF(__pyx_v_signature); - PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_v_signature); - __pyx_t_2 = 0; - __pyx_r = __pyx_t_5; - __pyx_t_5 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":245 - * - * marker_high = marker & 0xF0 - * if marker_high == 0xB0: # TINY_STRUCT # <<<<<<<<<<<<<< - * signature = self.read(1).tobytes() - * return marker & 0x0F, signature - */ - } - - /* "neo4j/packstream/_unpacker.pyx":248 - * signature = self.read(1).tobytes() - * return marker & 0x0F, signature - * elif marker == 0xDC: # STRUCT_8: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * signature = self.read(1).tobytes() - */ - __pyx_t_1 = ((__pyx_v_marker == 0xDC) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":249 - * return marker & 0x0F, signature - * elif marker == 0xDC: # STRUCT_8: - * size, = struct_unpack(">B", self.read(1)) # <<<<<<<<<<<<<< - * signature = self.read(1).tobytes() - * return size, signature - */ - __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_4.__pyx_n = 1; - __pyx_t_4.n = 1; - __pyx_t_3 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_3); - __pyx_t_6 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) { - __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2); - if (likely(__pyx_t_6)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2); - __Pyx_INCREF(__pyx_t_6); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_2, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_B, __pyx_t_3}; - __pyx_t_5 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) { - PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_kp_s_B, __pyx_t_3}; - __pyx_t_5 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0; - } else - #endif - { - __pyx_t_8 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - if (__pyx_t_6) { - __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_kp_s_B); - PyTuple_SET_ITEM(__pyx_t_8, 0+__pyx_t_7, __pyx_kp_s_B); - __Pyx_GIVEREF(__pyx_t_3); - PyTuple_SET_ITEM(__pyx_t_8, 1+__pyx_t_7, __pyx_t_3); - __pyx_t_3 = 0; - __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_5))) || (PyList_CheckExact(__pyx_t_5))) { - PyObject* sequence = __pyx_t_5; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 249, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_2 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_2); - #else - __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - #endif - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_8 = PyObject_GetIter(__pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext; - index = 0; __pyx_t_2 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_2)) goto __pyx_L4_unpacking_failed; - __Pyx_GOTREF(__pyx_t_2); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 1) < 0) __PYX_ERR(0, 249, __pyx_L1_error) - __pyx_t_9 = NULL; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - goto __pyx_L5_unpacking_done; - __pyx_L4_unpacking_failed:; - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_9 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 249, __pyx_L1_error) - __pyx_L5_unpacking_done:; - } - __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_2); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 249, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_v_size = __pyx_t_7; - - /* "neo4j/packstream/_unpacker.pyx":250 - * elif marker == 0xDC: # STRUCT_8: - * size, = struct_unpack(">B", self.read(1)) - * signature = self.read(1).tobytes() # <<<<<<<<<<<<<< - * return size, signature - * elif marker == 0xDD: # STRUCT_16: - */ - __pyx_t_4.__pyx_n = 1; - __pyx_t_4.n = 1; - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 250, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 250, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_8))) { - __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_8); - if (likely(__pyx_t_2)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8); - __Pyx_INCREF(__pyx_t_2); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_8, function); - } - } - if (__pyx_t_2) { - __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_8, __pyx_t_2); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 250, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else { - __pyx_t_5 = __Pyx_PyObject_CallNoArg(__pyx_t_8); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 250, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_5); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_v_signature = __pyx_t_5; - __pyx_t_5 = 0; - - /* "neo4j/packstream/_unpacker.pyx":251 - * size, = struct_unpack(">B", self.read(1)) - * signature = self.read(1).tobytes() - * return size, signature # <<<<<<<<<<<<<< - * elif marker == 0xDD: # STRUCT_16: - * size, = struct_unpack(">H", self.read(2)) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_8 = PyTuple_New(2); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 251, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_GIVEREF(__pyx_t_5); - PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); - __Pyx_INCREF(__pyx_v_signature); - __Pyx_GIVEREF(__pyx_v_signature); - PyTuple_SET_ITEM(__pyx_t_8, 1, __pyx_v_signature); - __pyx_t_5 = 0; - __pyx_r = __pyx_t_8; - __pyx_t_8 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":248 - * signature = self.read(1).tobytes() - * return marker & 0x0F, signature - * elif marker == 0xDC: # STRUCT_8: # <<<<<<<<<<<<<< - * size, = struct_unpack(">B", self.read(1)) - * signature = self.read(1).tobytes() - */ - } - - /* "neo4j/packstream/_unpacker.pyx":252 - * signature = self.read(1).tobytes() - * return size, signature - * elif marker == 0xDD: # STRUCT_16: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * signature = self.read(1).tobytes() - */ - __pyx_t_1 = ((__pyx_v_marker == 0xDD) != 0); - if (__pyx_t_1) { - - /* "neo4j/packstream/_unpacker.pyx":253 - * return size, signature - * elif marker == 0xDD: # STRUCT_16: - * size, = struct_unpack(">H", self.read(2)) # <<<<<<<<<<<<<< - * signature = self.read(1).tobytes() - * return size, signature - */ - __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_struct_unpack); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_4.__pyx_n = 1; - __pyx_t_4.n = 2; - __pyx_t_2 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __pyx_t_3 = NULL; - __pyx_t_7 = 0; - if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) { - __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5); - if (likely(__pyx_t_3)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5); - __Pyx_INCREF(__pyx_t_3); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_5, function); - __pyx_t_7 = 1; - } - } - #if CYTHON_FAST_PYCALL - if (PyFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_s_H, __pyx_t_2}; - __pyx_t_8 = __Pyx_PyFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - #if CYTHON_FAST_PYCCALL - if (__Pyx_PyFastCFunction_Check(__pyx_t_5)) { - PyObject *__pyx_temp[3] = {__pyx_t_3, __pyx_kp_s_H, __pyx_t_2}; - __pyx_t_8 = __Pyx_PyCFunction_FastCall(__pyx_t_5, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0; - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - } else - #endif - { - __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - if (__pyx_t_3) { - __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __pyx_t_3 = NULL; - } - __Pyx_INCREF(__pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_kp_s_H); - PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_s_H); - __Pyx_GIVEREF(__pyx_t_2); - PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_2); - __pyx_t_2 = 0; - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - } - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - if ((likely(PyTuple_CheckExact(__pyx_t_8))) || (PyList_CheckExact(__pyx_t_8))) { - PyObject* sequence = __pyx_t_8; - #if !CYTHON_COMPILING_IN_PYPY - Py_ssize_t size = Py_SIZE(sequence); - #else - Py_ssize_t size = PySequence_Size(sequence); - #endif - if (unlikely(size != 1)) { - if (size > 1) __Pyx_RaiseTooManyValuesError(1); - else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size); - __PYX_ERR(0, 253, __pyx_L1_error) - } - #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - if (likely(PyTuple_CheckExact(sequence))) { - __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); - } else { - __pyx_t_5 = PyList_GET_ITEM(sequence, 0); - } - __Pyx_INCREF(__pyx_t_5); - #else - __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - #endif - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - } else { - Py_ssize_t index = -1; - __pyx_t_6 = PyObject_GetIter(__pyx_t_8); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __pyx_t_9 = Py_TYPE(__pyx_t_6)->tp_iternext; - index = 0; __pyx_t_5 = __pyx_t_9(__pyx_t_6); if (unlikely(!__pyx_t_5)) goto __pyx_L6_unpacking_failed; - __Pyx_GOTREF(__pyx_t_5); - if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_6), 1) < 0) __PYX_ERR(0, 253, __pyx_L1_error) - __pyx_t_9 = NULL; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - goto __pyx_L7_unpacking_done; - __pyx_L6_unpacking_failed:; - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_9 = NULL; - if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index); - __PYX_ERR(0, 253, __pyx_L1_error) - __pyx_L7_unpacking_done:; - } - __pyx_t_7 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_7 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 253, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_v_size = __pyx_t_7; - - /* "neo4j/packstream/_unpacker.pyx":254 - * elif marker == 0xDD: # STRUCT_16: - * size, = struct_unpack(">H", self.read(2)) - * signature = self.read(1).tobytes() # <<<<<<<<<<<<<< - * return size, signature - * else: - */ - __pyx_t_4.__pyx_n = 1; - __pyx_t_4.n = 1; - __pyx_t_5 = ((struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self->__pyx_vtab)->read(__pyx_v_self, &__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_5); - __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_tobytes); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - __pyx_t_5 = NULL; - if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_6))) { - __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6); - if (likely(__pyx_t_5)) { - PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6); - __Pyx_INCREF(__pyx_t_5); - __Pyx_INCREF(function); - __Pyx_DECREF_SET(__pyx_t_6, function); - } - } - if (__pyx_t_5) { - __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 254, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0; - } else { - __pyx_t_8 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 254, __pyx_L1_error) - } - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_v_signature = __pyx_t_8; - __pyx_t_8 = 0; - - /* "neo4j/packstream/_unpacker.pyx":255 - * size, = struct_unpack(">H", self.read(2)) - * signature = self.read(1).tobytes() - * return size, signature # <<<<<<<<<<<<<< - * else: - * raise RuntimeError("Expected structure, found marker %02X" % marker) - */ - __Pyx_XDECREF(__pyx_r); - __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_size); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 255, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); - __Pyx_INCREF(__pyx_v_signature); - __Pyx_GIVEREF(__pyx_v_signature); - PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_v_signature); - __pyx_t_8 = 0; - __pyx_r = __pyx_t_6; - __pyx_t_6 = 0; - goto __pyx_L0; - - /* "neo4j/packstream/_unpacker.pyx":252 - * signature = self.read(1).tobytes() - * return size, signature - * elif marker == 0xDD: # STRUCT_16: # <<<<<<<<<<<<<< - * size, = struct_unpack(">H", self.read(2)) - * signature = self.read(1).tobytes() - */ - } - - /* "neo4j/packstream/_unpacker.pyx":257 - * return size, signature - * else: - * raise RuntimeError("Expected structure, found marker %02X" % marker) # <<<<<<<<<<<<<< - */ - /*else*/ { - __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_marker); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __pyx_t_8 = __Pyx_PyString_Format(__pyx_kp_s_Expected_structure_found_marker, __pyx_t_6); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_6); - __Pyx_GIVEREF(__pyx_t_8); - PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_8); - __pyx_t_8 = 0; - __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_RuntimeError, __pyx_t_6, NULL); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 257, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_8); - __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0; - __Pyx_Raise(__pyx_t_8, 0, 0, 0); - __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0; - __PYX_ERR(0, 257, __pyx_L1_error) - } - - /* "neo4j/packstream/_unpacker.pyx":240 - * return self._unpack_structure_header(marker) - * - * cdef _unpack_structure_header(self, int marker): # <<<<<<<<<<<<<< - * cdef int size - * cdef int marker_high - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_2); - __Pyx_XDECREF(__pyx_t_3); - __Pyx_XDECREF(__pyx_t_5); - __Pyx_XDECREF(__pyx_t_6); - __Pyx_XDECREF(__pyx_t_8); - __Pyx_AddTraceback("neo4j.packstream._unpacker.Unpacker._unpack_structure_header", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = 0; - __pyx_L0:; - __Pyx_XDECREF(__pyx_v_signature); - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_13__reduce_cython__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__reduce_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_12__reduce_cython__(((struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_12__reduce_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__reduce_cython__", 0); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 2, __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(1, 2, __pyx_L1_error) - - /* "(tree fragment)":1 - * def __reduce_cython__(self): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.packstream._unpacker.Unpacker.__reduce_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -/* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - -/* Python wrapper */ -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state); /*proto*/ -static PyObject *__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_15__setstate_cython__(PyObject *__pyx_v_self, PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = 0; - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__setstate_cython__ (wrapper)", 0); - __pyx_r = __pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_14__setstate_cython__(((struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)__pyx_v_self), ((PyObject *)__pyx_v___pyx_state)); - - /* function exit code */ - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} - -static PyObject *__pyx_pf_5neo4j_10packstream_9_unpacker_8Unpacker_14__setstate_cython__(CYTHON_UNUSED struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v___pyx_state) { - PyObject *__pyx_r = NULL; - __Pyx_RefNannyDeclarations - PyObject *__pyx_t_1 = NULL; - __Pyx_RefNannySetupContext("__setstate_cython__", 0); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(1, 4, __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(1, 4, __pyx_L1_error) - - /* "(tree fragment)":3 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): # <<<<<<<<<<<<<< - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - - /* function exit code */ - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_AddTraceback("neo4j.packstream._unpacker.Unpacker.__setstate_cython__", __pyx_clineno, __pyx_lineno, __pyx_filename); - __pyx_r = NULL; - __Pyx_XGIVEREF(__pyx_r); - __Pyx_RefNannyFinishContext(); - return __pyx_r; -} -static struct __pyx_vtabstruct_5neo4j_10packstream_9_unpacker_Unpacker __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker; - -static PyObject *__pyx_tp_new_5neo4j_10packstream_9_unpacker_Unpacker(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) { - struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *p; - PyObject *o; - if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) { - o = (*t->tp_alloc)(t, 0); - } else { - o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0); - } - if (unlikely(!o)) return 0; - p = ((struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)o); - p->__pyx_vtab = __pyx_vtabptr_5neo4j_10packstream_9_unpacker_Unpacker; - p->source = Py_None; Py_INCREF(Py_None); - if (unlikely(__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) goto bad; - return o; - bad: - Py_DECREF(o); o = 0; - return NULL; -} - -static void __pyx_tp_dealloc_5neo4j_10packstream_9_unpacker_Unpacker(PyObject *o) { - struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *p = (struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)o; - #if CYTHON_USE_TP_FINALIZE - if (unlikely(PyType_HasFeature(Py_TYPE(o), Py_TPFLAGS_HAVE_FINALIZE) && Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) { - if (PyObject_CallFinalizerFromDealloc(o)) return; - } - #endif - PyObject_GC_UnTrack(o); - Py_CLEAR(p->source); - (*Py_TYPE(o)->tp_free)(o); -} - -static int __pyx_tp_traverse_5neo4j_10packstream_9_unpacker_Unpacker(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *p = (struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)o; - if (p->source) { - e = (*v)(p->source, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_5neo4j_10packstream_9_unpacker_Unpacker(PyObject *o) { - PyObject* tmp; - struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *p = (struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *)o; - tmp = ((PyObject*)p->source); - p->source = Py_None; Py_INCREF(Py_None); - Py_XDECREF(tmp); - return 0; -} - -static PyMethodDef __pyx_methods_5neo4j_10packstream_9_unpacker_Unpacker[] = { - {"attach", (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_3attach, METH_O, 0}, - {"unpack", (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_5unpack, METH_NOARGS, 0}, - {"unpack_list", (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_7unpack_list, METH_NOARGS, 0}, - {"unpack_map", (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_9unpack_map, METH_NOARGS, 0}, - {"unpack_structure_header", (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_11unpack_structure_header, METH_NOARGS, 0}, - {"__reduce_cython__", (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_13__reduce_cython__, METH_NOARGS, 0}, - {"__setstate_cython__", (PyCFunction)__pyx_pw_5neo4j_10packstream_9_unpacker_8Unpacker_15__setstate_cython__, METH_O, 0}, - {0, 0, 0, 0} -}; - -static PyTypeObject __pyx_type_5neo4j_10packstream_9_unpacker_Unpacker = { - PyVarObject_HEAD_INIT(0, 0) - "neo4j.packstream._unpacker.Unpacker", /*tp_name*/ - sizeof(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_5neo4j_10packstream_9_unpacker_Unpacker, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - #if PY_MAJOR_VERSION < 3 - 0, /*tp_compare*/ - #endif - #if PY_MAJOR_VERSION >= 3 - 0, /*tp_as_async*/ - #endif - 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_5neo4j_10packstream_9_unpacker_Unpacker, /*tp_traverse*/ - __pyx_tp_clear_5neo4j_10packstream_9_unpacker_Unpacker, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_5neo4j_10packstream_9_unpacker_Unpacker, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_5neo4j_10packstream_9_unpacker_Unpacker, /*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 PY_VERSION_HEX >= 0x030400a1 - 0, /*tp_finalize*/ - #endif -}; - -static PyMethodDef __pyx_methods[] = { - {0, 0, 0, 0} -}; - -#if PY_MAJOR_VERSION >= 3 -#if CYTHON_PEP489_MULTI_PHASE_INIT -static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/ -static int __pyx_pymod_exec__unpacker(PyObject* module); /*proto*/ -static PyModuleDef_Slot __pyx_moduledef_slots[] = { - {Py_mod_create, (void*)__pyx_pymod_create}, - {Py_mod_exec, (void*)__pyx_pymod_exec__unpacker}, - {0, NULL} -}; -#endif - -static struct PyModuleDef __pyx_moduledef = { - PyModuleDef_HEAD_INIT, - "_unpacker", - 0, /* m_doc */ - #if CYTHON_PEP489_MULTI_PHASE_INIT - 0, /* m_size */ - #else - -1, /* m_size */ - #endif - __pyx_methods /* m_methods */, - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_moduledef_slots, /* m_slots */ - #else - NULL, /* m_reload */ - #endif - NULL, /* m_traverse */ - NULL, /* m_clear */ - NULL /* m_free */ -}; -#endif - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_kp_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 0}, - {&__pyx_n_s_EndOfStream, __pyx_k_EndOfStream, sizeof(__pyx_k_EndOfStream), 0, 0, 1, 1}, - {&__pyx_kp_s_Expected_structure_found_marker, __pyx_k_Expected_structure_found_marker, sizeof(__pyx_k_Expected_structure_found_marker), 0, 0, 1, 0}, - {&__pyx_kp_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 0}, - {&__pyx_kp_s_I, __pyx_k_I, sizeof(__pyx_k_I), 0, 0, 1, 0}, - {&__pyx_kp_s_Nothing_to_unpack, __pyx_k_Nothing_to_unpack, sizeof(__pyx_k_Nothing_to_unpack), 0, 0, 1, 0}, - {&__pyx_n_s_RuntimeError, __pyx_k_RuntimeError, sizeof(__pyx_k_RuntimeError), 0, 0, 1, 1}, - {&__pyx_n_s_Structure, __pyx_k_Structure, sizeof(__pyx_k_Structure), 0, 0, 1, 1}, - {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1}, - {&__pyx_kp_s_Unknown_PackStream_marker_02X, __pyx_k_Unknown_PackStream_marker_02X, sizeof(__pyx_k_Unknown_PackStream_marker_02X), 0, 0, 1, 0}, - {&__pyx_n_s_attach, __pyx_k_attach, sizeof(__pyx_k_attach), 0, 0, 1, 1}, - {&__pyx_kp_s_b, __pyx_k_b, sizeof(__pyx_k_b), 0, 0, 1, 0}, - {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1}, - {&__pyx_n_s_codecs, __pyx_k_codecs, sizeof(__pyx_k_codecs), 0, 0, 1, 1}, - {&__pyx_kp_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 0}, - {&__pyx_n_s_decode, __pyx_k_decode, sizeof(__pyx_k_decode), 0, 0, 1, 1}, - {&__pyx_n_s_getstate, __pyx_k_getstate, sizeof(__pyx_k_getstate), 0, 0, 1, 1}, - {&__pyx_kp_s_h, __pyx_k_h, sizeof(__pyx_k_h), 0, 0, 1, 0}, - {&__pyx_kp_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 0}, - {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1}, - {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1}, - {&__pyx_n_s_memoryview_at, __pyx_k_memoryview_at, sizeof(__pyx_k_memoryview_at), 0, 0, 1, 1}, - {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1}, - {&__pyx_n_s_neo4j_compat, __pyx_k_neo4j_compat, sizeof(__pyx_k_neo4j_compat), 0, 0, 1, 1}, - {&__pyx_kp_s_no_default___reduce___due_to_non, __pyx_k_no_default___reduce___due_to_non, sizeof(__pyx_k_no_default___reduce___due_to_non), 0, 0, 1, 0}, - {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1}, - {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1}, - {&__pyx_kp_s_q, __pyx_k_q, sizeof(__pyx_k_q), 0, 0, 1, 0}, - {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1}, - {&__pyx_n_s_read, __pyx_k_read, sizeof(__pyx_k_read), 0, 0, 1, 1}, - {&__pyx_n_s_read_int, __pyx_k_read_int, sizeof(__pyx_k_read_int), 0, 0, 1, 1}, - {&__pyx_n_s_reduce, __pyx_k_reduce, sizeof(__pyx_k_reduce), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_cython, __pyx_k_reduce_cython, sizeof(__pyx_k_reduce_cython), 0, 0, 1, 1}, - {&__pyx_n_s_reduce_ex, __pyx_k_reduce_ex, sizeof(__pyx_k_reduce_ex), 0, 0, 1, 1}, - {&__pyx_n_s_setstate, __pyx_k_setstate, sizeof(__pyx_k_setstate), 0, 0, 1, 1}, - {&__pyx_n_s_setstate_cython, __pyx_k_setstate_cython, sizeof(__pyx_k_setstate_cython), 0, 0, 1, 1}, - {&__pyx_n_s_struct, __pyx_k_struct, sizeof(__pyx_k_struct), 0, 0, 1, 1}, - {&__pyx_n_s_struct_unpack, __pyx_k_struct_unpack, sizeof(__pyx_k_struct_unpack), 0, 0, 1, 1}, - {&__pyx_n_s_structure, __pyx_k_structure, sizeof(__pyx_k_structure), 0, 0, 1, 1}, - {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1}, - {&__pyx_n_s_tobytes, __pyx_k_tobytes, sizeof(__pyx_k_tobytes), 0, 0, 1, 1}, - {&__pyx_n_s_unpack, __pyx_k_unpack, sizeof(__pyx_k_unpack), 0, 0, 1, 1}, - {&__pyx_n_s_unpack_list, __pyx_k_unpack_list, sizeof(__pyx_k_unpack_list), 0, 0, 1, 1}, - {&__pyx_n_s_unpack_map, __pyx_k_unpack_map, sizeof(__pyx_k_unpack_map), 0, 0, 1, 1}, - {&__pyx_n_s_unpack_structure_header, __pyx_k_unpack_structure_header, sizeof(__pyx_k_unpack_structure_header), 0, 0, 1, 1}, - {&__pyx_kp_s_utf_8, __pyx_k_utf_8, sizeof(__pyx_k_utf_8), 0, 0, 1, 0}, - {0, 0, 0, 0, 0, 0, 0} -}; -static int __Pyx_InitCachedBuiltins(void) { - __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) __PYX_ERR(0, 30, __pyx_L1_error) - __pyx_builtin_RuntimeError = __Pyx_GetBuiltinName(__pyx_n_s_RuntimeError); if (!__pyx_builtin_RuntimeError) __PYX_ERR(0, 61, __pyx_L1_error) - __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) __PYX_ERR(0, 132, __pyx_L1_error) - __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) __PYX_ERR(1, 2, __pyx_L1_error) - return 0; - __pyx_L1_error:; - return -1; -} - -static int __Pyx_InitCachedConstants(void) { - __Pyx_RefNannyDeclarations - __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0); - - /* "neo4j/packstream/_unpacker.pyx":61 - * - * if marker == -1: - * raise RuntimeError("Nothing to unpack") # <<<<<<<<<<<<<< - * - * # Tiny Integer - */ - __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Nothing_to_unpack); if (unlikely(!__pyx_tuple_)) __PYX_ERR(0, 61, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple_); - __Pyx_GIVEREF(__pyx_tuple_); - - /* "neo4j/packstream/_unpacker.pyx":236 - * marker = self.read_int() - * if marker == -1: - * return None, None # <<<<<<<<<<<<<< - * else: - * return self._unpack_structure_header(marker) - */ - __pyx_tuple__2 = PyTuple_Pack(2, Py_None, Py_None); if (unlikely(!__pyx_tuple__2)) __PYX_ERR(0, 236, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__2); - __Pyx_GIVEREF(__pyx_tuple__2); - - /* "(tree fragment)":2 - * def __reduce_cython__(self): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - */ - __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__3)) __PYX_ERR(1, 2, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__3); - __Pyx_GIVEREF(__pyx_tuple__3); - - /* "(tree fragment)":4 - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") - * def __setstate_cython__(self, __pyx_state): - * raise TypeError("no default __reduce__ due to non-trivial __cinit__") # <<<<<<<<<<<<<< - */ - __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_no_default___reduce___due_to_non); if (unlikely(!__pyx_tuple__4)) __PYX_ERR(1, 4, __pyx_L1_error) - __Pyx_GOTREF(__pyx_tuple__4); - __Pyx_GIVEREF(__pyx_tuple__4); - __Pyx_RefNannyFinishContext(); - return 0; - __pyx_L1_error:; - __Pyx_RefNannyFinishContext(); - return -1; -} - -static int __Pyx_InitGlobals(void) { - if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - return 0; - __pyx_L1_error:; - return -1; -} - -#if PY_MAJOR_VERSION < 3 -PyMODINIT_FUNC init_unpacker(void); /*proto*/ -PyMODINIT_FUNC init_unpacker(void) -#else -PyMODINIT_FUNC PyInit__unpacker(void); /*proto*/ -PyMODINIT_FUNC PyInit__unpacker(void) -#if CYTHON_PEP489_MULTI_PHASE_INIT -{ - return PyModuleDef_Init(&__pyx_moduledef); -} -static int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name) { - PyObject *value = PyObject_GetAttrString(spec, from_name); - int result = 0; - if (likely(value)) { - result = PyDict_SetItemString(moddict, to_name, value); - Py_DECREF(value); - } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) { - PyErr_Clear(); - } else { - result = -1; - } - return result; -} -static PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) { - PyObject *module = NULL, *moddict, *modname; - 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__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__") < 0)) goto bad; - if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__") < 0)) goto bad; - return module; -bad: - Py_XDECREF(module); - return NULL; -} - - -static int __pyx_pymod_exec__unpacker(PyObject *__pyx_pyinit_module) -#endif -#endif -{ - PyObject *__pyx_t_1 = NULL; - PyObject *__pyx_t_2 = NULL; - __Pyx_RefNannyDeclarations - #if CYTHON_PEP489_MULTI_PHASE_INIT - if (__pyx_m && __pyx_m == __pyx_pyinit_module) return 0; - #endif - #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("PyMODINIT_FUNC PyInit__unpacker(void)", 0); - if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error) - #ifdef __Pyx_CyFunction_USED - if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_FusedFunction_USED - if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Coroutine_USED - if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_Generator_USED - if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_AsyncGen_USED - if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - #ifdef __Pyx_StopAsyncIteration_USED - if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - /*--- Library function declarations ---*/ - /*--- Threads initialization code ---*/ - #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS - #ifdef WITH_THREAD /* Python build with threading support? */ - PyEval_InitThreads(); - #endif - #endif - /*--- Module creation code ---*/ - #if CYTHON_PEP489_MULTI_PHASE_INIT - __pyx_m = __pyx_pyinit_module; - Py_INCREF(__pyx_m); - #else - #if PY_MAJOR_VERSION < 3 - __pyx_m = Py_InitModule4("_unpacker", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m); - #else - __pyx_m = PyModule_Create(&__pyx_moduledef); - #endif - if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error) - Py_INCREF(__pyx_d); - __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error) - __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error) - #if CYTHON_COMPILING_IN_PYPY - Py_INCREF(__pyx_b); - #endif - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error); - /*--- Initialize various global constants etc. ---*/ - if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT) - if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - if (__pyx_module_is_main_neo4j__packstream___unpacker) { - if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - } - #if PY_MAJOR_VERSION >= 3 - { - PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error) - if (!PyDict_GetItemString(modules, "neo4j.packstream._unpacker")) { - if (unlikely(PyDict_SetItemString(modules, "neo4j.packstream._unpacker", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error) - } - } - #endif - /*--- Builtin init code ---*/ - if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Constants init code ---*/ - if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - /*--- Global init code ---*/ - /*--- Variable export code ---*/ - /*--- Function export code ---*/ - /*--- Type init code ---*/ - __pyx_vtabptr_5neo4j_10packstream_9_unpacker_Unpacker = &__pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker.attach = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, PyObject *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_attach; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker.read = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, struct __pyx_opt_args_5neo4j_10packstream_9_unpacker_8Unpacker_read *__pyx_optional_args))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_read; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker.read_int = (int (*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_read_int; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker.unpack = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker._unpack = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker.unpack_list = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_list; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker._unpack_list = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack_list; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker.unpack_map = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_map; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker._unpack_map = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack_map; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker.unpack_structure_header = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int __pyx_skip_dispatch))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker_unpack_structure_header; - __pyx_vtable_5neo4j_10packstream_9_unpacker_Unpacker._unpack_structure_header = (PyObject *(*)(struct __pyx_obj_5neo4j_10packstream_9_unpacker_Unpacker *, int))__pyx_f_5neo4j_10packstream_9_unpacker_8Unpacker__unpack_structure_header; - if (PyType_Ready(&__pyx_type_5neo4j_10packstream_9_unpacker_Unpacker) < 0) __PYX_ERR(0, 33, __pyx_L1_error) - __pyx_type_5neo4j_10packstream_9_unpacker_Unpacker.tp_print = 0; - if (__Pyx_SetVtable(__pyx_type_5neo4j_10packstream_9_unpacker_Unpacker.tp_dict, __pyx_vtabptr_5neo4j_10packstream_9_unpacker_Unpacker) < 0) __PYX_ERR(0, 33, __pyx_L1_error) - if (PyObject_SetAttrString(__pyx_m, "Unpacker", (PyObject *)&__pyx_type_5neo4j_10packstream_9_unpacker_Unpacker) < 0) __PYX_ERR(0, 33, __pyx_L1_error) - if (__Pyx_setup_reduce((PyObject*)&__pyx_type_5neo4j_10packstream_9_unpacker_Unpacker) < 0) __PYX_ERR(0, 33, __pyx_L1_error) - __pyx_ptype_5neo4j_10packstream_9_unpacker_Unpacker = &__pyx_type_5neo4j_10packstream_9_unpacker_Unpacker; - /*--- Type import code ---*/ - /*--- Variable import code ---*/ - /*--- Function import code ---*/ - /*--- Execution code ---*/ - #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED) - if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error) - #endif - - /* "neo4j/packstream/_unpacker.pyx":22 - * - * - * from codecs import decode # <<<<<<<<<<<<<< - * from struct import unpack as struct_unpack - * - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_decode); - __Pyx_GIVEREF(__pyx_n_s_decode); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_decode); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_codecs, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_decode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_decode, __pyx_t_1) < 0) __PYX_ERR(0, 22, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":23 - * - * from codecs import decode - * from struct import unpack as struct_unpack # <<<<<<<<<<<<<< - * - * from neo4j.compat import memoryview_at - */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_unpack); - __Pyx_GIVEREF(__pyx_n_s_unpack); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_unpack); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_struct, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_unpack); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_struct_unpack, __pyx_t_2) < 0) __PYX_ERR(0, 23, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_unpacker.pyx":25 - * from struct import unpack as struct_unpack - * - * from neo4j.compat import memoryview_at # <<<<<<<<<<<<<< - * - * from .structure import Structure - */ - __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_INCREF(__pyx_n_s_memoryview_at); - __Pyx_GIVEREF(__pyx_n_s_memoryview_at); - PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_memoryview_at); - __pyx_t_2 = __Pyx_Import(__pyx_n_s_neo4j_compat, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 25, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_memoryview_at); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 25, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_memoryview_at, __pyx_t_1) < 0) __PYX_ERR(0, 25, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - - /* "neo4j/packstream/_unpacker.pyx":27 - * from neo4j.compat import memoryview_at - * - * from .structure import Structure # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - __Pyx_INCREF(__pyx_n_s_Structure); - __Pyx_GIVEREF(__pyx_n_s_Structure); - PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_Structure); - __pyx_t_1 = __Pyx_Import(__pyx_n_s_structure, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_Structure); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_2); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_Structure, __pyx_t_2) < 0) __PYX_ERR(0, 27, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0; - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_unpacker.pyx":30 - * - * - * EndOfStream = object() # <<<<<<<<<<<<<< - * - * - */ - __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_builtin_object); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 30, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_EndOfStream, __pyx_t_1) < 0) __PYX_ERR(0, 30, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /* "neo4j/packstream/_unpacker.pyx":1 - * #!/usr/bin/env python # <<<<<<<<<<<<<< - * # -*- encoding: utf-8 -*- - * - */ - __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_GOTREF(__pyx_t_1); - if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error) - __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0; - - /*--- Wrapped vars code ---*/ - - goto __pyx_L0; - __pyx_L1_error:; - __Pyx_XDECREF(__pyx_t_1); - __Pyx_XDECREF(__pyx_t_2); - if (__pyx_m) { - if (__pyx_d) { - __Pyx_AddTraceback("init neo4j.packstream._unpacker", 0, __pyx_lineno, __pyx_filename); - } - Py_DECREF(__pyx_m); __pyx_m = 0; - } else if (!PyErr_Occurred()) { - PyErr_SetString(PyExc_ImportError, "init neo4j.packstream._unpacker"); - } - __pyx_L0:; - __Pyx_RefNannyFinishContext(); - #if CYTHON_PEP489_MULTI_PHASE_INIT - return (__pyx_m != NULL) ? 0 : -1; - #elif PY_MAJOR_VERSION >= 3 - return __pyx_m; - #else - return; - #endif -} - -/* --- 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((char *)modname); - if (!m) goto end; - p = PyObject_GetAttrString(m, (char *)"RefNannyAPI"); - if (!p) goto end; - r = PyLong_AsVoidPtr(p); -end: - Py_XDECREF(p); - Py_XDECREF(m); - return (__Pyx_RefNannyAPIStruct *)r; -} -#endif - -/* GetBuiltinName */ -static PyObject *__Pyx_GetBuiltinName(PyObject *name) { - PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name); - if (unlikely(!result)) { - PyErr_Format(PyExc_NameError, -#if PY_MAJOR_VERSION >= 3 - "name '%U' is not defined", name); -#else - "name '%.200s' is not defined", PyString_AS_STRING(name)); -#endif - } - return result; -} - -/* 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); -} - -/* KeywordStringCheck */ -static int __Pyx_CheckKeywordStrings( - PyObject *kwdict, - const char* function_name, - int kw_allowed) -{ - PyObject* key = 0; - Py_ssize_t pos = 0; -#if CYTHON_COMPILING_IN_PYPY - if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0)) - goto invalid_keyword; - return 1; -#else - while (PyDict_Next(kwdict, &pos, &key, 0)) { - #if PY_MAJOR_VERSION < 3 - if (unlikely(!PyString_Check(key))) - #endif - if (unlikely(!PyUnicode_Check(key))) - goto invalid_keyword_type; - } - if ((!kw_allowed) && unlikely(key)) - goto invalid_keyword; - return 1; -invalid_keyword_type: - PyErr_Format(PyExc_TypeError, - "%.200s() keywords must be strings", function_name); - return 0; -#endif -invalid_keyword: - PyErr_Format(PyExc_TypeError, - #if PY_MAJOR_VERSION < 3 - "%.200s() got an unexpected keyword argument '%.200s'", - function_name, PyString_AsString(key)); - #else - "%s() got an unexpected keyword argument '%U'", - function_name, key); - #endif - return 0; -} - -/* PyCFunctionFastCall */ -#if CYTHON_FAST_PYCCALL -static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) { - PyCFunctionObject *func = (PyCFunctionObject*)func_obj; - PyCFunction meth = PyCFunction_GET_FUNCTION(func); - PyObject *self = PyCFunction_GET_SELF(func); - int flags = PyCFunction_GET_FLAGS(func); - assert(PyCFunction_Check(func)); - assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS))); - assert(nargs >= 0); - assert(nargs == 0 || args != NULL); - /* _PyCFunction_FastCallDict() must not be called with an exception set, - because it may clear it (directly or indirectly) and so the - caller loses its exception */ - assert(!PyErr_Occurred()); - if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) { - return (*((__Pyx_PyCFunctionFastWithKeywords)meth)) (self, args, nargs, NULL); - } else { - return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs); - } -} -#endif - -/* PyFunctionFastCall */ -#if CYTHON_FAST_PYCALL -#include "frameobject.h" -static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na, - PyObject *globals) { - PyFrameObject *f; - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject **fastlocals; - Py_ssize_t i; - PyObject *result; - assert(globals != NULL); - /* XXX Perhaps we should create a specialized - PyFrame_New() that doesn't take locals, but does - take builtins without sanity checking them. - */ - assert(tstate != NULL); - f = PyFrame_New(tstate, co, globals, NULL); - if (f == NULL) { - return NULL; - } - fastlocals = f->f_localsplus; - for (i = 0; i < na; i++) { - Py_INCREF(*args); - fastlocals[i] = *args++; - } - result = PyEval_EvalFrameEx(f,0); - ++tstate->recursion_depth; - Py_DECREF(f); - --tstate->recursion_depth; - return result; -} -#if 1 || PY_VERSION_HEX < 0x030600B1 -static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, int nargs, PyObject *kwargs) { - PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func); - PyObject *globals = PyFunction_GET_GLOBALS(func); - PyObject *argdefs = PyFunction_GET_DEFAULTS(func); - PyObject *closure; -#if PY_MAJOR_VERSION >= 3 - PyObject *kwdefs; -#endif - PyObject *kwtuple, **k; - PyObject **d; - Py_ssize_t nd; - Py_ssize_t nk; - PyObject *result; - assert(kwargs == NULL || PyDict_Check(kwargs)); - nk = kwargs ? PyDict_Size(kwargs) : 0; - if (Py_EnterRecursiveCall((char*)" while calling a Python object")) { - return NULL; - } - if ( -#if PY_MAJOR_VERSION >= 3 - co->co_kwonlyargcount == 0 && -#endif - likely(kwargs == NULL || nk == 0) && - co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) { - if (argdefs == NULL && co->co_argcount == nargs) { - result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals); - goto done; - } - else if (nargs == 0 && argdefs != NULL - && co->co_argcount == Py_SIZE(argdefs)) { - /* function called with no arguments, but all parameters have - a default value: use default values as arguments .*/ - args = &PyTuple_GET_ITEM(argdefs, 0); - result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals); - goto done; - } - } - if (kwargs != NULL) { - Py_ssize_t pos, i; - kwtuple = PyTuple_New(2 * nk); - if (kwtuple == NULL) { - result = NULL; - goto done; - } - k = &PyTuple_GET_ITEM(kwtuple, 0); - pos = i = 0; - while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) { - Py_INCREF(k[i]); - Py_INCREF(k[i+1]); - i += 2; - } - nk = i / 2; - } - else { - kwtuple = NULL; - k = NULL; - } - closure = PyFunction_GET_CLOSURE(func); -#if PY_MAJOR_VERSION >= 3 - kwdefs = PyFunction_GET_KW_DEFAULTS(func); -#endif - if (argdefs != NULL) { - d = &PyTuple_GET_ITEM(argdefs, 0); - nd = Py_SIZE(argdefs); - } - else { - d = NULL; - nd = 0; - } -#if PY_MAJOR_VERSION >= 3 - result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, kwdefs, closure); -#else - result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL, - args, nargs, - k, (int)nk, - d, (int)nd, closure); -#endif - Py_XDECREF(kwtuple); -done: - Py_LeaveRecursiveCall(); - return result; -} -#endif -#endif - -/* PyObjectCall */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) { - PyObject *result; - ternaryfunc call = func->ob_type->tp_call; - if (unlikely(!call)) - return PyObject_Call(func, arg, kw); - if (unlikely(Py_EnterRecursiveCall((char*)" 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 = PyCFunction_GET_FUNCTION(func); - self = PyCFunction_GET_SELF(func); - if (unlikely(Py_EnterRecursiveCall((char*)" 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 - -/* PyObjectCallOneArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_New(1); - if (unlikely(!args)) return NULL; - Py_INCREF(arg); - PyTuple_SET_ITEM(args, 0, arg); - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, &arg, 1); - } -#endif - if (likely(PyCFunction_Check(func))) { - if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) { - return __Pyx_PyObject_CallMethO(func, arg); -#if CYTHON_FAST_PYCCALL - } else if (PyCFunction_GET_FLAGS(func) & METH_FASTCALL) { - return __Pyx_PyCFunction_FastCall(func, &arg, 1); -#endif - } - } - return __Pyx__PyObject_CallOneArg(func, arg); -} -#else -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) { - PyObject *result; - PyObject *args = PyTuple_Pack(1, arg); - if (unlikely(!args)) return NULL; - result = __Pyx_PyObject_Call(func, args, NULL); - Py_DECREF(args); - return result; -} -#endif - -/* PyObjectCallNoArg */ -#if CYTHON_COMPILING_IN_CPYTHON -static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) { -#if CYTHON_FAST_PYCALL - if (PyFunction_Check(func)) { - return __Pyx_PyFunction_FastCall(func, NULL, 0); - } -#endif -#ifdef __Pyx_CyFunction_USED - if (likely(PyCFunction_Check(func) || __Pyx_TypeCheck(func, __pyx_CyFunctionType))) { -#else - if (likely(PyCFunction_Check(func))) { -#endif - if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) { - return __Pyx_PyObject_CallMethO(func, NULL); - } - } - return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL); -} -#endif - -/* PyErrFetchRestore */ - #if CYTHON_FAST_THREAD_STATE -static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) { - 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); -} -static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) { - *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 - -/* WriteUnraisableException */ - static void __Pyx_WriteUnraisable(const char *name, CYTHON_UNUSED int clineno, - CYTHON_UNUSED int lineno, CYTHON_UNUSED const char *filename, - int full_traceback, CYTHON_UNUSED int nogil) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - __Pyx_PyThreadState_declare -#ifdef WITH_THREAD - PyGILState_STATE state; - if (nogil) - state = PyGILState_Ensure(); -#ifdef _MSC_VER - else state = (PyGILState_STATE)-1; -#endif -#endif - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&old_exc, &old_val, &old_tb); - if (full_traceback) { - Py_XINCREF(old_exc); - Py_XINCREF(old_val); - Py_XINCREF(old_tb); - __Pyx_ErrRestore(old_exc, old_val, old_tb); - PyErr_PrintEx(1); - } - #if PY_MAJOR_VERSION < 3 - ctx = PyString_FromString(name); - #else - ctx = PyUnicode_FromString(name); - #endif - __Pyx_ErrRestore(old_exc, old_val, old_tb); - if (!ctx) { - PyErr_WriteUnraisable(Py_None); - } else { - PyErr_WriteUnraisable(ctx); - Py_DECREF(ctx); - } -#ifdef WITH_THREAD - if (nogil) - PyGILState_Release(state); -#endif -} - -/* RaiseException */ - #if PY_MAJOR_VERSION < 3 -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, - CYTHON_UNUSED PyObject *cause) { - __Pyx_PyThreadState_declare - Py_XINCREF(type); - if (!value || value == Py_None) - value = NULL; - else - Py_INCREF(value); - if (!tb || tb == Py_None) - tb = NULL; - else { - Py_INCREF(tb); - if (!PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - } - if (PyType_Check(type)) { -#if CYTHON_COMPILING_IN_PYPY - if (!value) { - Py_INCREF(Py_None); - value = Py_None; - } -#endif - PyErr_NormalizeException(&type, &value, &tb); - } else { - if (value) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - value = type; - type = (PyObject*) Py_TYPE(type); - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - } - __Pyx_PyThreadState_assign - __Pyx_ErrRestore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} -#else -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 CYTHON_COMPILING_IN_PYPY - 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); -#else - 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); - } -#endif - } -bad: - Py_XDECREF(owned_instance); - return; -} -#endif - -/* GetModuleGlobalName */ - static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) { - PyObject *result; -#if !CYTHON_AVOID_BORROWED_REFS - result = PyDict_GetItem(__pyx_d, name); - if (likely(result)) { - Py_INCREF(result); - } else { -#else - result = PyObject_GetItem(__pyx_d, name); - if (!result) { - PyErr_Clear(); -#endif - result = __Pyx_GetBuiltinName(name); - } - return result; -} - -/* RaiseTooManyValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) { - PyErr_Format(PyExc_ValueError, - "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected); -} - -/* RaiseNeedMoreValuesToUnpack */ - static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) { - PyErr_Format(PyExc_ValueError, - "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack", - index, (index == 1) ? "" : "s"); -} - -/* IterFinish */ - static CYTHON_INLINE int __Pyx_IterFinish(void) { -#if CYTHON_FAST_THREAD_STATE - PyThreadState *tstate = __Pyx_PyThreadState_Current; - PyObject* exc_type = tstate->curexc_type; - if (unlikely(exc_type)) { - if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) { - PyObject *exc_value, *exc_tb; - exc_value = tstate->curexc_value; - exc_tb = tstate->curexc_traceback; - tstate->curexc_type = 0; - tstate->curexc_value = 0; - tstate->curexc_traceback = 0; - Py_DECREF(exc_type); - Py_XDECREF(exc_value); - Py_XDECREF(exc_tb); - return 0; - } else { - return -1; - } - } - return 0; -#else - if (unlikely(PyErr_Occurred())) { - if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) { - PyErr_Clear(); - return 0; - } else { - return -1; - } - } - return 0; -#endif -} - -/* UnpackItemEndCheck */ - static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) { - if (unlikely(retval)) { - Py_DECREF(retval); - __Pyx_RaiseTooManyValuesError(expected); - return -1; - } else { - return __Pyx_IterFinish(); - } - return 0; -} - -/* GetItemInt */ - static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) { - PyObject *r; - if (!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, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS - Py_ssize_t wrapped_i = i; - if (wraparound & unlikely(i < 0)) { - wrapped_i += PyList_GET_SIZE(o); - } - if ((!boundscheck) || likely((0 <= wrapped_i) & (wrapped_i < PyList_GET_SIZE(o)))) { - PyObject *r = PyList_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if 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((0 <= wrapped_i) & (wrapped_i < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, wrapped_i); - Py_INCREF(r); - return r; - } - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -#else - return PySequence_GetItem(o, i); -#endif -} -static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list, - CYTHON_NCP_UNUSED int wraparound, - CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o); - if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) { - PyObject *r = PyList_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } - else if (PyTuple_CheckExact(o)) { - Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o); - if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) { - PyObject *r = PyTuple_GET_ITEM(o, n); - Py_INCREF(r); - return r; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return NULL; - PyErr_Clear(); - } - } - return m->sq_item(o, i); - } - } -#else - if (is_list || PySequence_Check(o)) { - return PySequence_GetItem(o, i); - } -#endif - return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i)); -} - -/* SetItemInt */ - static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) { - int r; - if (!j) return -1; - r = PyObject_SetItem(o, j, v); - Py_DECREF(j); - return r; -} -static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list, - CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) { -#if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS - if (is_list || PyList_CheckExact(o)) { - Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o)); - if ((!boundscheck) || likely((n >= 0) & (n < PyList_GET_SIZE(o)))) { - PyObject* old = PyList_GET_ITEM(o, n); - Py_INCREF(v); - PyList_SET_ITEM(o, n, v); - Py_DECREF(old); - return 1; - } - } else { - PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence; - if (likely(m && m->sq_ass_item)) { - if (wraparound && unlikely(i < 0) && likely(m->sq_length)) { - Py_ssize_t l = m->sq_length(o); - if (likely(l >= 0)) { - i += l; - } else { - if (!PyErr_ExceptionMatches(PyExc_OverflowError)) - return -1; - PyErr_Clear(); - } - } - return m->sq_ass_item(o, i, v); - } - } -#else -#if CYTHON_COMPILING_IN_PYPY - if (is_list || (PySequence_Check(o) && !PyDict_Check(o))) { -#else - if (is_list || PySequence_Check(o)) { -#endif - return PySequence_SetItem(o, i, v); - } -#endif - return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v); -} - -/* SetVTable */ - static int __Pyx_SetVtable(PyObject *dict, void *vtable) { -#if PY_VERSION_HEX >= 0x02070000 - PyObject *ob = PyCapsule_New(vtable, 0, 0); -#else - PyObject *ob = PyCObject_FromVoidPtr(vtable, 0); -#endif - if (!ob) - goto bad; - if (PyDict_SetItem(dict, __pyx_n_s_pyx_vtable, ob) < 0) - goto bad; - Py_DECREF(ob); - return 0; -bad: - Py_XDECREF(ob); - return -1; -} - -/* SetupReduce */ - static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) { - int ret; - PyObject *name_attr; - name_attr = __Pyx_PyObject_GetAttrStr(meth, __pyx_n_s_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_reduce_ex = NULL; - PyObject *reduce = NULL; - PyObject *reduce_ex = NULL; - PyObject *reduce_cython = NULL; - PyObject *setstate = NULL; - PyObject *setstate_cython = NULL; -#if CYTHON_USE_PYTYPE_LOOKUP - if (_PyType_Lookup((PyTypeObject*)type_obj, __pyx_n_s_getstate)) goto GOOD; -#else - if (PyObject_HasAttr(type_obj, __pyx_n_s_getstate)) goto GOOD; -#endif -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce_ex = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; -#else - object_reduce_ex = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce_ex); if (!object_reduce_ex) goto BAD; -#endif - reduce_ex = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_ex); if (unlikely(!reduce_ex)) goto BAD; - if (reduce_ex == object_reduce_ex) { -#if CYTHON_USE_PYTYPE_LOOKUP - object_reduce = _PyType_Lookup(&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; -#else - object_reduce = __Pyx_PyObject_GetAttrStr((PyObject*)&PyBaseObject_Type, __pyx_n_s_reduce); if (!object_reduce) goto BAD; -#endif - reduce = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce); if (unlikely(!reduce)) goto BAD; - if (reduce == object_reduce || __Pyx_setup_reduce_is_named(reduce, __pyx_n_s_reduce_cython)) { - reduce_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_reduce_cython); if (unlikely(!reduce_cython)) goto BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce, reduce_cython); if (unlikely(ret < 0)) goto BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_reduce_cython); if (unlikely(ret < 0)) goto BAD; - setstate = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate); - if (!setstate) PyErr_Clear(); - if (!setstate || __Pyx_setup_reduce_is_named(setstate, __pyx_n_s_setstate_cython)) { - setstate_cython = __Pyx_PyObject_GetAttrStr(type_obj, __pyx_n_s_setstate_cython); if (unlikely(!setstate_cython)) goto BAD; - ret = PyDict_SetItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate, setstate_cython); if (unlikely(ret < 0)) goto BAD; - ret = PyDict_DelItem(((PyTypeObject*)type_obj)->tp_dict, __pyx_n_s_setstate_cython); if (unlikely(ret < 0)) goto BAD; - } - PyType_Modified((PyTypeObject*)type_obj); - } - } - goto GOOD; -BAD: - if (!PyErr_Occurred()) - PyErr_Format(PyExc_RuntimeError, "Unable to initialize pickling for %s", ((PyTypeObject*)type_obj)->tp_name); - ret = -1; -GOOD: -#if !CYTHON_USE_PYTYPE_LOOKUP - Py_XDECREF(object_reduce); - Py_XDECREF(object_reduce_ex); -#endif - Py_XDECREF(reduce); - Py_XDECREF(reduce_ex); - Py_XDECREF(reduce_cython); - Py_XDECREF(setstate); - Py_XDECREF(setstate_cython); - return ret; -} - -/* Import */ - static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) { - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - #if PY_MAJOR_VERSION < 3 - PyObject *py_import; - py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import); - if (!py_import) - goto bad; - #endif - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - { - #if PY_MAJOR_VERSION >= 3 - if (level == -1) { - if (strchr(__Pyx_MODULE_NAME, '.')) { - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, 1); - if (!module) { - if (!PyErr_ExceptionMatches(PyExc_ImportError)) - goto bad; - PyErr_Clear(); - } - } - level = 0; - } - #endif - if (!module) { - #if PY_MAJOR_VERSION < 3 - PyObject *py_level = PyInt_FromLong(level); - if (!py_level) - goto bad; - module = PyObject_CallFunctionObjArgs(py_import, - name, global_dict, empty_dict, list, py_level, NULL); - Py_DECREF(py_level); - #else - module = PyImport_ImportModuleLevelObject( - name, global_dict, empty_dict, list, level); - #endif - } - } -bad: - #if PY_MAJOR_VERSION < 3 - Py_XDECREF(py_import); - #endif - Py_XDECREF(empty_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)) { - PyErr_Format(PyExc_ImportError, - #if PY_MAJOR_VERSION < 3 - "cannot import name %.230s", PyString_AS_STRING(name)); - #else - "cannot import name %S", name); - #endif - } - return value; -} - -/* CLineInTraceback */ - #ifndef CYTHON_CLINE_IN_TRACEBACK -static int __Pyx_CLineForTraceback(CYTHON_UNUSED PyThreadState *tstate, int c_line) { - PyObject *use_cline; - PyObject *ptype, *pvalue, *ptraceback; -#if CYTHON_COMPILING_IN_CPYTHON - PyObject **cython_runtime_dict; -#endif - __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback); -#if CYTHON_COMPILING_IN_CPYTHON - cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime); - if (likely(cython_runtime_dict)) { - use_cline = PyDict_GetItem(*cython_runtime_dict, __pyx_n_s_cline_in_traceback); - } else -#endif - { - PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback); - if (use_cline_obj) { - use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True; - Py_DECREF(use_cline_obj); - } else { - PyErr_Clear(); - use_cline = NULL; - } - } - if (!use_cline) { - c_line = 0; - PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False); - } - else if (PyObject_Not(use_cline) != 0) { - c_line = 0; - } - __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 PyCodeObject *__pyx_find_code_object(int code_line) { - PyCodeObject* code_object; - int pos; - if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) { - return NULL; - } - pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) { - return NULL; - } - code_object = __pyx_code_cache.entries[pos].code_object; - Py_INCREF(code_object); - return code_object; -} -static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) { - int pos, i; - __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries; - if (unlikely(!code_line)) { - return; - } - if (unlikely(!entries)) { - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry)); - if (likely(entries)) { - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = 64; - __pyx_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(__pyx_code_cache.entries, __pyx_code_cache.count, code_line); - if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) { - PyCodeObject* tmp = entries[pos].code_object; - entries[pos].code_object = code_object; - Py_DECREF(tmp); - return; - } - if (__pyx_code_cache.count == __pyx_code_cache.max_count) { - int new_max = __pyx_code_cache.max_count + 64; - entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc( - __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry)); - if (unlikely(!entries)) { - return; - } - __pyx_code_cache.entries = entries; - __pyx_code_cache.max_count = new_max; - } - for (i=__pyx_code_cache.count; i>pos; i--) { - entries[i] = entries[i-1]; - } - entries[pos].code_line = code_line; - entries[pos].code_object = code_object; - __pyx_code_cache.count++; - Py_INCREF(code_object); -} - -/* AddTraceback */ - #include "compile.h" -#include "frameobject.h" -#include "traceback.h" -static PyCodeObject* __Pyx_CreateCodeObjectForTraceback( - const char *funcname, int c_line, - int py_line, const char *filename) { - PyCodeObject *py_code = 0; - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - #if PY_MAJOR_VERSION < 3 - py_srcfile = PyString_FromString(filename); - #else - py_srcfile = PyUnicode_FromString(filename); - #endif - if (!py_srcfile) goto bad; - if (c_line) { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #else - py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line); - #endif - } - else { - #if PY_MAJOR_VERSION < 3 - py_funcname = PyString_FromString(funcname); - #else - py_funcname = PyUnicode_FromString(funcname); - #endif - } - if (!py_funcname) goto bad; - py_code = __Pyx_PyCode_New( - 0, - 0, - 0, - 0, - 0, - __pyx_empty_bytes, /*PyObject *code,*/ - __pyx_empty_tuple, /*PyObject *consts,*/ - __pyx_empty_tuple, /*PyObject *names,*/ - __pyx_empty_tuple, /*PyObject *varnames,*/ - __pyx_empty_tuple, /*PyObject *freevars,*/ - __pyx_empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - py_line, - __pyx_empty_bytes /*PyObject *lnotab*/ - ); - Py_DECREF(py_srcfile); - Py_DECREF(py_funcname); - return py_code; -bad: - Py_XDECREF(py_srcfile); - 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; - 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) { - py_code = __Pyx_CreateCodeObjectForTraceback( - funcname, c_line, py_line, filename); - if (!py_code) goto bad; - __pyx_insert_code_object(c_line ? -c_line : py_line, py_code); - } - py_frame = PyFrame_New( - tstate, /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - __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); -} - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(int) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(int) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value); -#endif - } - } else { - if (sizeof(int) <= sizeof(long)) { - return PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(int), - little, !is_unsigned); - } -} - -/* 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;\ - } - -/* CIntToPy */ - static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; - if (is_unsigned) { - if (sizeof(long) < sizeof(long)) { - return PyInt_FromLong((long) value); - } else if (sizeof(long) <= sizeof(unsigned long)) { - return PyLong_FromUnsignedLong((unsigned long) value); -#ifdef HAVE_LONG_LONG - } 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 PyInt_FromLong((long) value); -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - return PyLong_FromLongLong((PY_LONG_LONG) value); -#endif - } - } - { - int one = 1; int little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&value; - return _PyLong_FromByteArray(bytes, sizeof(long), - little, !is_unsigned); - } -} - -/* CIntFromPy */ - static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) { - const int neg_one = (int) -1, const_zero = (int) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(int) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (int) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0]) - 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 - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (int) 0; - case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0]) - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - int val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (int) -1; - } - } else { - int val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (int) -1; - val = __Pyx_PyInt_As_int(tmp); - Py_DECREF(tmp); - 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; -} - -/* CIntFromPy */ - static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) { - const long neg_one = (long) -1, const_zero = (long) 0; - const int is_unsigned = neg_one > const_zero; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x))) { - if (sizeof(long) < sizeof(long)) { - __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x)) - } else { - long val = PyInt_AS_LONG(x); - if (is_unsigned && unlikely(val < 0)) { - goto raise_neg_overflow; - } - return (long) val; - } - } else -#endif - if (likely(PyLong_Check(x))) { - if (is_unsigned) { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0]) - 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 - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x)) -#endif - } - } else { -#if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)x)->ob_digit; - switch (Py_SIZE(x)) { - case 0: return (long) 0; - case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0])) - case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0]) - 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)) -#ifdef HAVE_LONG_LONG - } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) { - __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x)) -#endif - } - } - { -#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray) - PyErr_SetString(PyExc_RuntimeError, - "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers"); -#else - long val; - PyObject *v = __Pyx_PyNumber_IntOrLong(x); - #if PY_MAJOR_VERSION < 3 - if (likely(v) && !PyLong_Check(v)) { - PyObject *tmp = v; - v = PyNumber_Long(tmp); - Py_DECREF(tmp); - } - #endif - if (likely(v)) { - int one = 1; int is_little = (int)*(unsigned char *)&one; - unsigned char *bytes = (unsigned char *)&val; - int ret = _PyLong_AsByteArray((PyLongObject *)v, - bytes, sizeof(val), - is_little, !is_unsigned); - Py_DECREF(v); - if (likely(!ret)) - return val; - } -#endif - return (long) -1; - } - } else { - long val; - PyObject *tmp = __Pyx_PyNumber_IntOrLong(x); - if (!tmp) return (long) -1; - val = __Pyx_PyInt_As_long(tmp); - Py_DECREF(tmp); - 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; -} - -/* FastTypeChecks */ - #if CYTHON_COMPILING_IN_CPYTHON -static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) { - while (a) { - a = a->tp_base; - 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); -} -#if PY_MAJOR_VERSION == 2 -static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) { - PyObject *exception, *value, *tb; - int res; - __Pyx_PyThreadState_declare - __Pyx_PyThreadState_assign - __Pyx_ErrFetch(&exception, &value, &tb); - res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0; - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - if (!res) { - res = PyObject_IsSubclass(err, exc_type2); - if (unlikely(res == -1)) { - PyErr_WriteUnraisable(err); - res = 0; - } - } - __Pyx_ErrRestore(exception, value, tb); - return res; -} -#else -static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) { - int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0; - if (!res) { - res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2); - } - return res; -} -#endif -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) { - if (likely(err == exc_type)) return 1; - if (likely(PyExceptionClass_Check(err))) { - return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type); - } - return PyErr_GivenExceptionMatches(err, exc_type); -} -static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) { - if (likely(err == exc_type1 || err == exc_type2)) return 1; - if (likely(PyExceptionClass_Check(err))) { - return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2); - } - return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2)); -} -#endif - -/* CheckBinaryVersion */ - static int __Pyx_check_binary_version(void) { - char ctversion[4], rtversion[4]; - PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION); - PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion()); - if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) { - char message[200]; - PyOS_snprintf(message, sizeof(message), - "compiletime version %s of module '%.100s' " - "does not match runtime version %s", - ctversion, __Pyx_MODULE_NAME, rtversion); - return PyErr_WarnEx(NULL, message, 1); - } - return 0; -} - -/* InitStrings */ - static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - #if PY_MAJOR_VERSION < 3 - if (t->is_unicode) { - *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL); - } else if (t->intern) { - *t->p = PyString_InternFromString(t->s); - } else { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - } - #else - if (t->is_unicode | t->is_str) { - if (t->intern) { - *t->p = PyUnicode_InternFromString(t->s); - } else if (t->encoding) { - *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL); - } else { - *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1); - } - } else { - *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1); - } - #endif - if (!*t->p) - return -1; - if (PyObject_Hash(*t->p) == -1) - PyErr_Clear(); - ++t; - } - return 0; -} - -static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) { - return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str)); -} -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_DEFAULT -#if !CYTHON_PEP393_ENABLED -static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - char* defenc_c; - PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL); - if (!defenc) return NULL; - defenc_c = PyBytes_AS_STRING(defenc); -#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - { - char* end = defenc_c + PyBytes_GET_SIZE(defenc); - char* c; - for (c = defenc_c; c < end; c++) { - if ((unsigned char) (*c) >= 128) { - PyUnicode_AsASCIIString(o); - return NULL; - } - } - } -#endif - *length = PyBytes_GET_SIZE(defenc); - return defenc_c; -} -#else -static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) { - if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL; -#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_DEFAULT - if ( -#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII - __Pyx_sys_getdefaultencoding_not_ascii && -#endif - PyUnicode_Check(o)) { - return __Pyx_PyUnicode_AsStringAndSize(o, length); - } else -#endif -#if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE)) - if (PyByteArray_Check(o)) { - *length = PyByteArray_GET_SIZE(o); - return PyByteArray_AS_STRING(o); - } else -#endif - { - 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 PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) { -#if PY_MAJOR_VERSION >= 3 - if (PyLong_Check(result)) { - if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1, - "__int__ returned non-int (type %.200s). " - "The ability to return an instance of a strict subclass of int " - "is deprecated, and may be removed in a future version of Python.", - Py_TYPE(result)->tp_name)) { - Py_DECREF(result); - return NULL; - } - return result; - } -#endif - PyErr_Format(PyExc_TypeError, - "__%.4s__ returned non-%.4s (type %.200s)", - type_name, type_name, Py_TYPE(result)->tp_name); - Py_DECREF(result); - return NULL; -} -static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) { -#if CYTHON_USE_TYPE_SLOTS - PyNumberMethods *m; -#endif - const char *name = NULL; - PyObject *res = NULL; -#if PY_MAJOR_VERSION < 3 - if (likely(PyInt_Check(x) || PyLong_Check(x))) -#else - if (likely(PyLong_Check(x))) -#endif - return __Pyx_NewRef(x); -#if CYTHON_USE_TYPE_SLOTS - m = Py_TYPE(x)->tp_as_number; - #if PY_MAJOR_VERSION < 3 - if (m && m->nb_int) { - name = "int"; - res = m->nb_int(x); - } - else if (m && m->nb_long) { - name = "long"; - res = m->nb_long(x); - } - #else - if (likely(m && m->nb_int)) { - name = "int"; - res = m->nb_int(x); - } - #endif -#else - if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) { - res = PyNumber_Int(x); - } -#endif - if (likely(res)) { -#if PY_MAJOR_VERSION < 3 - if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) { -#else - if (unlikely(!PyLong_CheckExact(res))) { -#endif - return __Pyx_PyNumber_IntOrLongWrongResultType(res, name); - } - } - 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 PY_MAJOR_VERSION < 3 - if (likely(PyInt_CheckExact(b))) { - if (sizeof(Py_ssize_t) >= sizeof(long)) - return PyInt_AS_LONG(b); - else - return PyInt_AsSsize_t(x); - } -#endif - if (likely(PyLong_CheckExact(b))) { - #if CYTHON_USE_PYLONG_INTERNALS - const digit* digits = ((PyLongObject*)b)->ob_digit; - const Py_ssize_t size = Py_SIZE(b); - if (likely(__Pyx_sst_abs(size) <= 1)) { - ival = likely(size) ? digits[0] : 0; - if (size == -1) ival = -ival; - return ival; - } else { - 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 = PyInt_AsSsize_t(x); - Py_DECREF(x); - return ival; -} -static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) { - return PyInt_FromSize_t(ival); -} - - -#endif /* Py_PYTHON_H */ diff --git a/neo4j/packstream/_unpacker.pyx b/neo4j/packstream/_unpacker.pyx deleted file mode 100644 index 2042586d6..000000000 --- a/neo4j/packstream/_unpacker.pyx +++ /dev/null @@ -1,257 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from codecs import decode -from struct import unpack as struct_unpack - -from neo4j.compat import memoryview_at - -from .structure import Structure - - -EndOfStream = object() - - -cdef class Unpacker(object): - - cdef source - - def __cinit__(self): - self.source = None - - cpdef attach(self, source): - self.source = source - - cdef read(self, int n=1): - return self.source.read(n) - - cdef int read_int(self): - return self.source.read_int() - - cpdef unpack(self): - return self._unpack() - - cdef _unpack(self): - cdef int size - cdef int i - cdef int marker - cdef int marker_high - - marker = self.read_int() - - if marker == -1: - raise RuntimeError("Nothing to unpack") - - # Tiny Integer - if 0x00 <= marker <= 0x7F: - return marker - elif 0xF0 <= marker <= 0xFF: - return marker - 0x100 - - # Null - elif marker == 0xC0: - return None - - # Float - elif marker == 0xC1: - value, = struct_unpack(">d", self.read(8)) - return value - - # Boolean - elif marker == 0xC2: - return False - elif marker == 0xC3: - return True - - # Integer - elif marker == 0xC8: - return struct_unpack(">b", self.read(1))[0] - elif marker == 0xC9: - return struct_unpack(">h", self.read(2))[0] - elif marker == 0xCA: - return struct_unpack(">i", self.read(4))[0] - elif marker == 0xCB: - return struct_unpack(">q", self.read(8))[0] - - # Bytes - elif marker == 0xCC: - size, = struct_unpack(">B", self.read(1)) - return self.read(size).tobytes() - elif marker == 0xCD: - size, = struct_unpack(">H", self.read(2)) - return self.read(size).tobytes() - elif marker == 0xCE: - size, = struct_unpack(">I", self.read(4)) - return self.read(size).tobytes() - - else: - marker_high = marker & 0xF0 - # String - if marker_high == 0x80: # TINY_STRING - return decode(self.read(marker & 0x0F), "utf-8") - elif marker == 0xD0: # STRING_8: - size, = struct_unpack(">B", self.read(1)) - return decode(self.read(size), "utf-8") - elif marker == 0xD1: # STRING_16: - size, = struct_unpack(">H", self.read(2)) - return decode(self.read(size), "utf-8") - elif marker == 0xD2: # STRING_32: - size, = struct_unpack(">I", self.read(4)) - return decode(self.read(size), "utf-8") - - # List - elif 0x90 <= marker <= 0x9F or 0xD4 <= marker <= 0xD7: - return self._unpack_list(marker) - - # Map - elif 0xA0 <= marker <= 0xAF or 0xD8 <= marker <= 0xDB: - return self._unpack_map(marker) - - # Structure - elif 0xB0 <= marker <= 0xBF or 0xDC <= marker <= 0xDD: - size, tag = self._unpack_structure_header(marker) - value = Structure(tag, *([None] * size)) - for i in range(len(value)): - value[i] = self._unpack() - return value - - elif marker == 0xDF: # END_OF_STREAM: - return EndOfStream - - else: - raise RuntimeError("Unknown PackStream marker %02X" % marker) - - cpdef list unpack_list(self): - cdef int marker - - marker = self.read_int() - return self._unpack_list(marker) - - cdef list _unpack_list(self, int marker): - cdef int marker_high - cdef int size - cdef list value - - marker_high = marker & 0xF0 - if marker_high == 0x90: - size = marker & 0x0F - if size == 0: - return [] - elif size == 1: - return [self._unpack()] - else: - return [self._unpack() for _ in range(size)] - elif marker == 0xD4: # LIST_8: - size, = struct_unpack(">B", self.read(1)) - return [self._unpack() for _ in range(size)] - elif marker == 0xD5: # LIST_16: - size, = struct_unpack(">H", self.read(2)) - return [self._unpack() for _ in range(size)] - elif marker == 0xD6: # LIST_32: - size, = struct_unpack(">I", self.read(4)) - return [self._unpack() for _ in range(size)] - elif marker == 0xD7: # LIST_STREAM: - value = [] - item = None - while item is not EndOfStream: - item = self._unpack() - if item is not EndOfStream: - value.append(item) - return value - else: - return None - - cpdef dict unpack_map(self): - marker = self.read_int() - return self._unpack_map(marker) - - cdef dict _unpack_map(self, int marker): - cdef int size - cdef int marker_high - cdef dict value - - marker_high = marker & 0xF0 - if marker_high == 0xA0: - size = marker & 0x0F - value = {} - for _ in range(size): - key = self._unpack() - value[key] = self._unpack() - return value - elif marker == 0xD8: # MAP_8: - size, = struct_unpack(">B", self.read(1)) - value = {} - for _ in range(size): - key = self._unpack() - value[key] = self._unpack() - return value - elif marker == 0xD9: # MAP_16: - size, = struct_unpack(">H", self.read(2)) - value = {} - for _ in range(size): - key = self._unpack() - value[key] = self._unpack() - return value - elif marker == 0xDA: # MAP_32: - size, = struct_unpack(">I", self.read(4)) - value = {} - for _ in range(size): - key = self._unpack() - value[key] = self._unpack() - return value - elif marker == 0xDB: # MAP_STREAM: - value = {} - key = None - while key is not EndOfStream: - key = self._unpack() - if key is not EndOfStream: - value[key] = self._unpack() - return value - else: - return None - - cpdef unpack_structure_header(self): - cdef int marker - - marker = self.read_int() - if marker == -1: - return None, None - else: - return self._unpack_structure_header(marker) - - cdef _unpack_structure_header(self, int marker): - cdef int size - cdef int marker_high - - marker_high = marker & 0xF0 - if marker_high == 0xB0: # TINY_STRUCT - signature = self.read(1).tobytes() - return marker & 0x0F, signature - elif marker == 0xDC: # STRUCT_8: - size, = struct_unpack(">B", self.read(1)) - signature = self.read(1).tobytes() - return size, signature - elif marker == 0xDD: # STRUCT_16: - size, = struct_unpack(">H", self.read(2)) - signature = self.read(1).tobytes() - return size, signature - else: - raise RuntimeError("Expected structure, found marker %02X" % marker) diff --git a/neo4j/packstream/constants.py b/neo4j/packstream/constants.py deleted file mode 100644 index 6d28fcce6..000000000 --- a/neo4j/packstream/constants.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from struct import pack as _struct_pack - - -NULL_ = b"\xC0" -FALSE = b"\xC2" -TRUE = b"\xC3" - -PACKED_UINT_8 = [_struct_pack(">B", value) for value in range(0x100)] -PACKED_UINT_16 = [_struct_pack(">H", value) for value in range(0x10000)] - -UNPACKED_UINT_8 = {bytes(bytearray([x])): x for x in range(0x100)} -UNPACKED_UINT_16 = {_struct_pack(">H", x): x for x in range(0x10000)} - -UNPACKED_MARKERS = {NULL_: None, TRUE: True, FALSE: False} -UNPACKED_MARKERS.update({bytes(bytearray([z])): z for z in range(0x00, 0x80)}) -UNPACKED_MARKERS.update({bytes(bytearray([z + 256])): z for z in range(-0x10, 0x00)}) diff --git a/neo4j/packstream/packer.py b/neo4j/packstream/packer.py deleted file mode 100644 index 893f868dd..000000000 --- a/neo4j/packstream/packer.py +++ /dev/null @@ -1,334 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from struct import pack as struct_pack - -from neo4j.compat import integer, string - -from .constants import * -from .structure import Structure - - -INT64_HI = 2 ** 63 -INT64_LO = -(2 ** 63) - - -class Packer(object): - - supports_bytes = False - - def __init__(self, stream): - self.stream = stream - self._write = self.stream.write - - def pack_raw(self, data): - self._write(data) - - def pack(self, value): - return self._pack(value) - - def _pack(self, value): - write = self._write - - # None - if value is None: - write(b"\xC0") # NULL - - # Boolean - elif value is True: - write(b"\xC3") - elif value is False: - write(b"\xC2") - - # Float (only double precision is supported) - elif isinstance(value, float): - write(b"\xC1") - write(struct_pack(">d", value)) - - # Integer - elif isinstance(value, integer): - if -0x10 <= value < 0x80: - write(PACKED_UINT_8[value % 0x100]) - elif -0x80 <= value < -0x10: - write(b"\xC8") - write(PACKED_UINT_8[value % 0x100]) - elif -0x8000 <= value < 0x8000: - write(b"\xC9") - write(PACKED_UINT_16[value % 0x10000]) - elif -0x80000000 <= value < 0x80000000: - write(b"\xCA") - write(struct_pack(">i", value)) - elif INT64_LO <= value < INT64_HI: - write(b"\xCB") - write(struct_pack(">q", value)) - else: - raise OverflowError("Integer %s out of range" % value) - - # String - elif isinstance(value, string): - if isinstance(value, bytes): - value_bytes = value - else: - value_bytes = value.encode("utf-8") - self.pack_string_header(len(value_bytes)) - self.pack_raw(value_bytes) - - # Bytes (deliberately listed after String since in - # Python 2, bytes should be treated as a String) - elif isinstance(value, bytes): - self.pack_bytes_header(len(value)) - self.pack_raw(value) - elif isinstance(value, bytearray): - self.pack_bytes_header(len(value)) - self.pack_raw(bytes(value)) - - # List - elif isinstance(value, list): - self.pack_list_header(len(value)) - for item in value: - self._pack(item) - - # Map - elif isinstance(value, dict): - self.pack_map_header(len(value)) - for key, item in value.items(): - self._pack(key) - self._pack(item) - - # Structure - elif isinstance(value, Structure): - self.pack_struct(value.tag, value.fields) - - # Other - else: - raise ValueError("Values of type %s are not supported" % type(value)) - - def pack_bytes_header(self, size): - if not self.supports_bytes: - raise TypeError("This PackSteam channel does not support BYTES (consider upgrading to Neo4j 3.2+)") - write = self._write - if size < 0x100: - write(b"\xCC") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xCD") - write(PACKED_UINT_16[size]) - elif size < 0x100000000: - write(b"\xCE") - write(struct_pack(">I", size)) - else: - raise OverflowError("Bytes header size out of range") - - def pack_string_header(self, size): - write = self._write - if size == 0x00: - write(b"\x80") - elif size == 0x01: - write(b"\x81") - elif size == 0x02: - write(b"\x82") - elif size == 0x03: - write(b"\x83") - elif size == 0x04: - write(b"\x84") - elif size == 0x05: - write(b"\x85") - elif size == 0x06: - write(b"\x86") - elif size == 0x07: - write(b"\x87") - elif size == 0x08: - write(b"\x88") - elif size == 0x09: - write(b"\x89") - elif size == 0x0A: - write(b"\x8A") - elif size == 0x0B: - write(b"\x8B") - elif size == 0x0C: - write(b"\x8C") - elif size == 0x0D: - write(b"\x8D") - elif size == 0x0E: - write(b"\x8E") - elif size == 0x0F: - write(b"\x8F") - elif size < 0x100: - write(b"\xD0") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xD1") - write(PACKED_UINT_16[size]) - elif size < 0x100000000: - write(b"\xD2") - write(struct_pack(">I", size)) - else: - raise OverflowError("String header size out of range") - - def pack_list_header(self, size): - write = self._write - if size == 0x00: - write(b"\x90") - elif size == 0x01: - write(b"\x91") - elif size == 0x02: - write(b"\x92") - elif size == 0x03: - write(b"\x93") - elif size == 0x04: - write(b"\x94") - elif size == 0x05: - write(b"\x95") - elif size == 0x06: - write(b"\x96") - elif size == 0x07: - write(b"\x97") - elif size == 0x08: - write(b"\x98") - elif size == 0x09: - write(b"\x99") - elif size == 0x0A: - write(b"\x9A") - elif size == 0x0B: - write(b"\x9B") - elif size == 0x0C: - write(b"\x9C") - elif size == 0x0D: - write(b"\x9D") - elif size == 0x0E: - write(b"\x9E") - elif size == 0x0F: - write(b"\x9F") - elif size < 0x100: - write(b"\xD4") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xD5") - write(PACKED_UINT_16[size]) - elif size < 0x100000000: - write(b"\xD6") - write(struct_pack(">I", size)) - else: - raise OverflowError("List header size out of range") - - def pack_list_stream_header(self): - self._write(b"\xD7") - - def pack_map_header(self, size): - write = self._write - if size == 0x00: - write(b"\xA0") - elif size == 0x01: - write(b"\xA1") - elif size == 0x02: - write(b"\xA2") - elif size == 0x03: - write(b"\xA3") - elif size == 0x04: - write(b"\xA4") - elif size == 0x05: - write(b"\xA5") - elif size == 0x06: - write(b"\xA6") - elif size == 0x07: - write(b"\xA7") - elif size == 0x08: - write(b"\xA8") - elif size == 0x09: - write(b"\xA9") - elif size == 0x0A: - write(b"\xAA") - elif size == 0x0B: - write(b"\xAB") - elif size == 0x0C: - write(b"\xAC") - elif size == 0x0D: - write(b"\xAD") - elif size == 0x0E: - write(b"\xAE") - elif size == 0x0F: - write(b"\xAF") - elif size < 0x100: - write(b"\xD8") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xD9") - write(PACKED_UINT_16[size]) - elif size < 0x100000000: - write(b"\xDA") - write(struct_pack(">I", size)) - else: - raise OverflowError("Map header size out of range") - - def pack_map_stream_header(self): - self._write(b"\xDB") - - def pack_struct(self, signature, fields): - if len(signature) != 1 or not isinstance(signature, bytes): - raise ValueError("Structure signature must be a single byte value") - write = self._write - size = len(fields) - if size == 0x00: - write(b"\xB0") - elif size == 0x01: - write(b"\xB1") - elif size == 0x02: - write(b"\xB2") - elif size == 0x03: - write(b"\xB3") - elif size == 0x04: - write(b"\xB4") - elif size == 0x05: - write(b"\xB5") - elif size == 0x06: - write(b"\xB6") - elif size == 0x07: - write(b"\xB7") - elif size == 0x08: - write(b"\xB8") - elif size == 0x09: - write(b"\xB9") - elif size == 0x0A: - write(b"\xBA") - elif size == 0x0B: - write(b"\xBB") - elif size == 0x0C: - write(b"\xBC") - elif size == 0x0D: - write(b"\xBD") - elif size == 0x0E: - write(b"\xBE") - elif size == 0x0F: - write(b"\xBF") - elif size < 0x100: - write(b"\xDC") - write(PACKED_UINT_8[size]) - elif size < 0x10000: - write(b"\xDD") - write(PACKED_UINT_16[size]) - else: - raise OverflowError("Structure size out of range") - write(signature) - for field in fields: - self._pack(field) - - def pack_end_of_stream(self): - self._write(b"\xDF") diff --git a/neo4j/packstream/structure.py b/neo4j/packstream/structure.py deleted file mode 100644 index 3c4d88699..000000000 --- a/neo4j/packstream/structure.py +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -class Structure(object): - - def __init__(self, tag, *fields): - self.tag = tag - self.fields = list(fields) - - def __repr__(self): - return "Structure<%s>(%s)" % (self.tag, ", ".join(map(repr, self.fields))) - - def __eq__(self, other): - try: - return self.tag == other.tag and self.fields == other.fields - except AttributeError: - return False - - def __ne__(self, other): - return not self.__eq__(other) - - def __len__(self): - return len(self.fields) - - def __getitem__(self, key): - return self.fields[key] - - def __setitem__(self, key, value): - self.fields[key] = value diff --git a/neo4j/packstream/unpacker.py b/neo4j/packstream/unpacker.py deleted file mode 100644 index a693ba743..000000000 --- a/neo4j/packstream/unpacker.py +++ /dev/null @@ -1,235 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from codecs import decode -from struct import unpack as struct_unpack - -from neo4j.compat import memoryview_at - -from .structure import Structure - - -EndOfStream = object() - - -class Unpacker(object): - - def __init__(self): - self.source = None - - def attach(self, source): - self.source = source - - def read(self, n=1): - return self.source.read(n) - - def read_int(self): - return self.source.read_int() - - def unpack(self): - return self._unpack() - - def _unpack(self): - marker = self.read_int() - - if marker == -1: - raise RuntimeError("Nothing to unpack") - - # Tiny Integer - if 0x00 <= marker <= 0x7F: - return marker - elif 0xF0 <= marker <= 0xFF: - return marker - 0x100 - - # Null - elif marker == 0xC0: - return None - - # Float - elif marker == 0xC1: - value, = struct_unpack(">d", self.read(8)) - return value - - # Boolean - elif marker == 0xC2: - return False - elif marker == 0xC3: - return True - - # Integer - elif marker == 0xC8: - return struct_unpack(">b", self.read(1))[0] - elif marker == 0xC9: - return struct_unpack(">h", self.read(2))[0] - elif marker == 0xCA: - return struct_unpack(">i", self.read(4))[0] - elif marker == 0xCB: - return struct_unpack(">q", self.read(8))[0] - - # Bytes - elif marker == 0xCC: - size, = struct_unpack(">B", self.read(1)) - return self.read(size).tobytes() - elif marker == 0xCD: - size, = struct_unpack(">H", self.read(2)) - return self.read(size).tobytes() - elif marker == 0xCE: - size, = struct_unpack(">I", self.read(4)) - return self.read(size).tobytes() - - else: - marker_high = marker & 0xF0 - # String - if marker_high == 0x80: # TINY_STRING - return decode(self.read(marker & 0x0F), "utf-8") - elif marker == 0xD0: # STRING_8: - size, = struct_unpack(">B", self.read(1)) - return decode(self.read(size), "utf-8") - elif marker == 0xD1: # STRING_16: - size, = struct_unpack(">H", self.read(2)) - return decode(self.read(size), "utf-8") - elif marker == 0xD2: # STRING_32: - size, = struct_unpack(">I", self.read(4)) - return decode(self.read(size), "utf-8") - - # List - elif 0x90 <= marker <= 0x9F or 0xD4 <= marker <= 0xD7: - return self._unpack_list(marker) - - # Map - elif 0xA0 <= marker <= 0xAF or 0xD8 <= marker <= 0xDB: - return self._unpack_map(marker) - - # Structure - elif 0xB0 <= marker <= 0xBF or 0xDC <= marker <= 0xDD: - size, tag = self._unpack_structure_header(marker) - value = Structure(tag, *([None] * size)) - for i in range(len(value)): - value[i] = self._unpack() - return value - - elif marker == 0xDF: # END_OF_STREAM: - return EndOfStream - - else: - raise RuntimeError("Unknown PackStream marker %02X" % marker) - - def unpack_list(self): - marker = self.read_int() - return self._unpack_list(marker) - - def _unpack_list(self, marker): - marker_high = marker & 0xF0 - if marker_high == 0x90: - size = marker & 0x0F - if size == 0: - return [] - elif size == 1: - return [self._unpack()] - else: - return [self._unpack() for _ in range(size)] - elif marker == 0xD4: # LIST_8: - size, = struct_unpack(">B", self.read(1)) - return [self._unpack() for _ in range(size)] - elif marker == 0xD5: # LIST_16: - size, = struct_unpack(">H", self.read(2)) - return [self._unpack() for _ in range(size)] - elif marker == 0xD6: # LIST_32: - size, = struct_unpack(">I", self.read(4)) - return [self._unpack() for _ in range(size)] - elif marker == 0xD7: # LIST_STREAM: - value = [] - item = None - while item is not EndOfStream: - item = self._unpack() - if item is not EndOfStream: - value.append(item) - return value - else: - return None - - def unpack_map(self): - marker = self.read_int() - return self._unpack_map(marker) - - def _unpack_map(self, marker): - marker_high = marker & 0xF0 - if marker_high == 0xA0: - size = marker & 0x0F - value = {} - for _ in range(size): - key = self._unpack() - value[key] = self._unpack() - return value - elif marker == 0xD8: # MAP_8: - size, = struct_unpack(">B", self.read(1)) - value = {} - for _ in range(size): - key = self._unpack() - value[key] = self._unpack() - return value - elif marker == 0xD9: # MAP_16: - size, = struct_unpack(">H", self.read(2)) - value = {} - for _ in range(size): - key = self._unpack() - value[key] = self._unpack() - return value - elif marker == 0xDA: # MAP_32: - size, = struct_unpack(">I", self.read(4)) - value = {} - for _ in range(size): - key = self._unpack() - value[key] = self._unpack() - return value - elif marker == 0xDB: # MAP_STREAM: - value = {} - key = None - while key is not EndOfStream: - key = self._unpack() - if key is not EndOfStream: - value[key] = self._unpack() - return value - else: - return None - - def unpack_structure_header(self): - marker = self.read_int() - if marker == -1: - return None, None - else: - return self._unpack_structure_header(marker) - - def _unpack_structure_header(self, marker): - marker_high = marker & 0xF0 - if marker_high == 0xB0: # TINY_STRUCT - signature = self.read(1).tobytes() - return marker & 0x0F, signature - elif marker == 0xDC: # STRUCT_8: - size, = struct_unpack(">B", self.read(1)) - signature = self.read(1).tobytes() - return size, signature - elif marker == 0xDD: # STRUCT_16: - size, = struct_unpack(">H", self.read(2)) - signature = self.read(1).tobytes() - return size, signature - else: - raise RuntimeError("Expected structure, found marker %02X" % marker) diff --git a/neo4j/util.py b/neo4j/util.py deleted file mode 100644 index d705201b3..000000000 --- a/neo4j/util.py +++ /dev/null @@ -1,144 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from importlib import import_module -import logging -from os import getenv as getenv -from sys import stdout -from warnings import warn - - -class ServerVersion(object): - def __init__(self, product, version_tuple, tags_tuple): - self.product = product - self.version_tuple = version_tuple - self.tags_tuple = tags_tuple - - def at_least_version(self, major, minor): - return self.version_tuple >= (major, minor) - - @classmethod - def from_str(cls, full_version): - if full_version is None: - return ServerVersion("Neo4j", (3, 0), ()) - product, _, tagged_version = full_version.partition("/") - tags = tagged_version.split("-") - version = map(int, tags[0].split(".")) - return ServerVersion(product, tuple(version), tuple(tags[1:])) - - -class ColourFormatter(logging.Formatter): - """ Colour formatter for pretty log output. - """ - - def format(self, record): - s = super(ColourFormatter, self).format(record) - if record.levelno == logging.CRITICAL: - return "\x1b[31;1m%s\x1b[0m" % s # bright red - elif record.levelno == logging.ERROR: - return "\x1b[33;1m%s\x1b[0m" % s # bright yellow - elif record.levelno == logging.WARNING: - return "\x1b[33m%s\x1b[0m" % s # yellow - elif record.levelno == logging.INFO: - return "\x1b[36m%s\x1b[0m" % s # cyan - elif record.levelno == logging.DEBUG: - return "\x1b[34m%s\x1b[0m" % s # blue - else: - return s - - -class Watcher(object): - """ Log watcher for monitoring driver and protocol activity. - """ - - handlers = {} - - def __init__(self, logger_name): - super(Watcher, self).__init__() - self.logger_name = logger_name - self.logger = logging.getLogger(self.logger_name) - self.formatter = ColourFormatter("%(asctime)s %(message)s") - - def __enter__(self): - self.watch() - return self - - def __exit__(self, exc_type, exc_val, exc_tb): - self.stop() - - def watch(self, level=logging.DEBUG, out=stdout): - self.stop() - handler = logging.StreamHandler(out) - handler.setFormatter(self.formatter) - self.handlers[self.logger_name] = handler - self.logger.addHandler(handler) - self.logger.setLevel(level) - - def stop(self): - try: - self.logger.removeHandler(self.handlers[self.logger_name]) - except KeyError: - pass - - -def watch(logger_name, level=logging.DEBUG, out=stdout): - """ Quick wrapper for using the Watcher. - - :param logger_name: name of logger to watch - :param level: minimum log level to show (default INFO) - :param out: where to send output (default stdout) - :return: Watcher instance - """ - watcher = Watcher(logger_name) - watcher.watch(level, out) - return watcher - - -def import_best(c_module, py_module): - pure_python = getenv("PURE_PYTHON", "") - if pure_python: - return import_module(py_module) - else: - try: - return import_module(c_module) - except ImportError: - return import_module(py_module) - - -def deprecated(message): - """ Decorator for deprecating functions and methods. - - :: - - @deprecated("'foo' has been deprecated in favour of 'bar'") - def foo(x): - pass - - """ - def f__(f): - def f_(*args, **kwargs): - warn(message, category=DeprecationWarning, stacklevel=2) - return f(*args, **kwargs) - f_.__name__ = f.__name__ - f_.__doc__ = f.__doc__ - f_.__dict__.update(f.__dict__) - return f_ - return f__ diff --git a/neo4j/v1/__init__.py b/neo4j/v1/__init__.py index 3d604c9bf..4d51caf64 100644 --- a/neo4j/v1/__init__.py +++ b/neo4j/v1/__init__.py @@ -18,10 +18,5 @@ # See the License for the specific language governing permissions and # limitations under the License. -from .api import * -from .direct import * -from .exceptions import * -from .result import * -from .routing import * -from .security import * -from .types import * + +from .. import * diff --git a/neo4j/v1/api.py b/neo4j/v1/api.py deleted file mode 100644 index bd9e4251c..000000000 --- a/neo4j/v1/api.py +++ /dev/null @@ -1,808 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from collections import deque -from random import random -from time import sleep -from warnings import warn - -from neo4j.bolt.connection import RUN, PULL_ALL -from neo4j.bolt.response import Response -from neo4j.exceptions import ServiceUnavailable -from neo4j.compat import urlparse, ustr -from neo4j.exceptions import CypherError, TransientError -from neo4j.config import default_config -from neo4j.compat import perf_counter - -from .exceptions import DriverError, SessionError, SessionExpired, TransactionError - -_warned_about_transaction_bookmarks = False - -READ_ACCESS = "READ" -WRITE_ACCESS = "WRITE" - -INITIAL_RETRY_DELAY = 1.0 -RETRY_DELAY_MULTIPLIER = 2.0 -RETRY_DELAY_JITTER_FACTOR = 0.2 - - -def last_bookmark(b0, b1): - """ Return the latest of two bookmarks by looking for the maximum - integer value following the last colon in the bookmark string. - """ - n = [None, None] - _, _, n[0] = b0.rpartition(":") - _, _, n[1] = b1.rpartition(":") - for i in range(2): - try: - n[i] = int(n[i]) - except ValueError: - raise ValueError("Invalid bookmark: {}".format(b0)) - return b0 if n[0] > n[1] else b1 - - -def retry_delay_generator(initial_delay, multiplier, jitter_factor): - delay = initial_delay - while True: - jitter = jitter_factor * delay - yield delay - jitter + (2 * jitter * random()) - delay *= multiplier - - -def is_retriable_transient_error(error): - """ - :type error: TransientError - """ - return not (error.code in ("Neo.TransientError.Transaction.Terminated", - "Neo.TransientError.Transaction.LockClientStopped")) - - -class GraphDatabase(object): - """ Accessor for :class:`.Driver` construction. - """ - - @classmethod - def driver(cls, uri, **config): - """ Create a :class:`.Driver` object. Calling this method provides - identical functionality to constructing a :class:`.Driver` or - :class:`.Driver` subclass instance directly. - """ - return Driver(uri, **config) - - -class Driver(object): - """ Base class for all types of :class:`.Driver`, instances of which are - used as the primary access point to Neo4j. - - :param uri: URI for a graph database service - :param config: configuration and authentication details (valid keys are listed below) - """ - - #: Overridden by subclasses to specify the URI scheme owned by that - #: class. - uri_scheme = None - - #: Connection pool - _pool = None - - #: Indicator of driver closure. - _closed = False - - @classmethod - def _check_uri(cls, uri): - """ Check whether a URI is compatible with a :class:`.Driver` - subclass. When called from a subclass, execution simply passes - through if the URI scheme is valid for that class. If invalid, - a `ValueError` is raised. - - :param uri: URI to check for compatibility - :raise: `ValueError` if URI scheme is incompatible - """ - parsed = urlparse(uri) - if parsed.scheme != cls.uri_scheme: - raise ValueError("%s objects require the %r URI scheme" % (cls.__name__, cls.uri_scheme)) - - def __new__(cls, uri, **config): - parsed = urlparse(uri) - for subclass in Driver.__subclasses__(): - if parsed.scheme == subclass.uri_scheme: - return subclass(uri, **config) - raise ValueError("URI scheme %r not supported" % parsed.scheme) - - def __del__(self): - self.close() - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - self.close() - - def session(self, access_mode=None, **parameters): - """ Create a new :class:`.Session` object based on this - :class:`.Driver`. - - :param access_mode: default access mode (read or write) for - transactions in this session - :param parameters: custom session parameters (see - :class:`.Session` for details) - :returns: new :class:`.Session` object - """ - if self.closed(): - raise DriverError("Driver closed") - - def close(self): - """ Shut down, closing any open connections that were spawned by - this :class:`.Driver`. - """ - if not self._closed: - self._closed = True - if self._pool is not None: - self._pool.close() - self._pool = None - - def closed(self): - return self._closed - - -class Session(object): - """ A :class:`.Session` is a logical context for transactional units - of work. Connections are drawn from the :class:`.Driver` connection - pool as required. - - Session creation is a lightweight operation and sessions are not thread - safe. Therefore a session should generally be short-lived, and not - span multiple threads. - - In general, sessions will be created and destroyed within a `with` - context. For example:: - - with driver.session() as session: - result = session.run("MATCH (a:Person) RETURN a.name") - # do something with the result... - - :param acquirer: callback function for acquiring new connections - with a given access mode - :param access_mode: default access mode (read or write) for - transactions in this session - :param parameters: custom session parameters, including: - - `bookmark` - A single bookmark after which this session should begin. - (Deprecated, use `bookmarks` instead) - - `bookmarks` - A collection of bookmarks after which this session should begin. - - `max_retry_time` - The maximum time after which to stop attempting retries of failed - transactions. - - """ - - # The current connection. - _connection = None - - # The access mode for the current connection. - _connection_access_mode = None - - # The current :class:`.Transaction` instance, if any. - _transaction = None - - # The last result received. - _last_result = None - - # The collection of bookmarks after which the next - # :class:`.Transaction` should be carried out. - _bookmarks = () - - # Default maximum time to keep retrying failed transactions. - _max_retry_time = default_config["max_retry_time"] - - _closed = False - - def __init__(self, acquirer, access_mode, **parameters): - self._acquirer = acquirer - self._default_access_mode = access_mode - for key, value in parameters.items(): - if key == "bookmark": - self._bookmarks = [value] if value else [] - elif key == "bookmarks": - self._bookmarks = value or [] - elif key == "max_retry_time": - self._max_retry_time = value - else: - pass # for compatibility - - def __del__(self): - try: - self.close() - except (SessionError, ServiceUnavailable): - pass - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - self.close() - - def _connect(self, access_mode=None): - if access_mode is None: - access_mode = self._default_access_mode - if self._connection: - if access_mode == self._connection_access_mode: - return - self._disconnect(sync=True) - self._connection = self._acquirer(access_mode) - self._connection_access_mode = access_mode - - def _disconnect(self, sync): - if self._connection: - if sync: - try: - self._connection.sync() - except (SessionError, ServiceUnavailable): - pass - if self._connection: - self._connection.in_use = False - self._connection = None - self._connection_access_mode = None - - def close(self): - """ Close the session. This will release any borrowed resources, - such as connections, and will roll back any outstanding transactions. - """ - try: - if self.has_transaction(): - try: - self.rollback_transaction() - except (CypherError, TransactionError, SessionError, ServiceUnavailable): - pass - finally: - self._closed = True - self._disconnect(sync=True) - - def closed(self): - """ Indicator for whether or not this session has been closed. - - :returns: :const:`True` if closed, :const:`False` otherwise. - """ - return self._closed - - def run(self, statement, parameters=None, **kwparameters): - """ Run a Cypher statement within an auto-commit transaction. - - The statement is sent and the result header received - immediately but the :class:`.StatementResult` content is - fetched lazily as consumed by the client application. - - If a statement is executed before a previous - :class:`.StatementResult` in the same :class:`.Session` has - been fully consumed, the first result will be fully fetched - and buffered. Note therefore that the generally recommended - pattern of usage is to fully consume one result before - executing a subsequent statement. If two results need to be - consumed in parallel, multiple :class:`.Session` objects - can be used as an alternative to result buffering. - - For more usage details, see :meth:`.Transaction.run`. - - :param statement: template Cypher statement - :param parameters: dictionary of parameters - :param kwparameters: additional keyword parameters - :returns: :class:`.StatementResult` object - """ - if self.closed(): - raise SessionError("Session closed") - if not statement: - raise ValueError("Cannot run an empty statement") - - if not self.has_transaction(): - self._connect() - - result = self.__run__(statement, dict(parameters or {}, **kwparameters)) - - if not self.has_transaction(): - self._connection.send() - self._connection.fetch() - - return result - - def send(self): - """ Send all outstanding requests. - """ - if self._connection: - self._connection.send() - - def fetch(self): - """ Attempt to fetch at least one more record. - - :returns: number of records fetched - """ - if self._connection: - detail_count, _ = self._connection.fetch() - return detail_count - return 0 - - def sync(self): - """ Carry out a full send and receive. - - :returns: number of records fetched - """ - if self._connection: - detail_count, _ = self._connection.sync() - return detail_count - return 0 - - def detach(self, result): - """ Detach a result from this session by fetching and buffering any - remaining records. - - :param result: - :returns: number of records fetched - """ - count = 0 - - self.send() - fetch = self.fetch - while result.attached(): - count += fetch() - - if self._last_result is result: - self._last_result = None - if not self.has_transaction(): - self._disconnect(sync=False) - - return count - - def last_bookmark(self): - """ The bookmark returned by the last :class:`.Transaction`. - """ - last = None - for bookmark in self._bookmarks: - if last is None: - last = bookmark - else: - last = last_bookmark(last, bookmark) - return last - - def has_transaction(self): - return bool(self._transaction) - - def _create_transaction(self): - self._transaction = Transaction(self, on_close=self._destroy_transaction) - - def _destroy_transaction(self): - self._transaction = None - - def begin_transaction(self, bookmark=None): - """ Create a new :class:`.Transaction` within this session. - Calling this method with a bookmark is equivalent to - - :param bookmark: a bookmark to which the server should - synchronise before beginning the transaction - :returns: new :class:`.Transaction` instance. - :raise: :class:`.TransactionError` if a transaction is already open - """ - if self.has_transaction(): - raise TransactionError("Explicit transaction already open") - - if bookmark is not None: - global _warned_about_transaction_bookmarks - if not _warned_about_transaction_bookmarks: - from warnings import warn - warn("Passing bookmarks at transaction level is deprecated", category=DeprecationWarning, stacklevel=2) - _warned_about_transaction_bookmarks = True - self._bookmarks = [bookmark] - - self._create_transaction() - self._connect() - self.__begin__() - return self._transaction - - def commit_transaction(self): - """ Commit the current transaction. - - :returns: the bookmark returned from the server, if any - :raise: :class:`.TransactionError` if no transaction is currently open - """ - if not self.has_transaction(): - raise TransactionError("No transaction to commit") - self._transaction = None - result = self.__commit__() - result.consume() - bookmark = self.__bookmark__(result) - self._bookmarks = [bookmark] - return bookmark - - def rollback_transaction(self): - """ Rollback the current transaction. - - :raise: :class:`.TransactionError` if no transaction is currently open - """ - if not self.has_transaction(): - raise TransactionError("No transaction to rollback") - self._destroy_transaction() - rollback_result = self.__rollback__() - try: - rollback_result.consume() - except ServiceUnavailable: - pass - - def reset(self): - """ Reset the session. - """ - self._destroy_transaction() - self._connection.reset() - - def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs): - if not callable(unit_of_work): - raise TypeError("Unit of work is not callable") - retry_delay = retry_delay_generator(INITIAL_RETRY_DELAY, - RETRY_DELAY_MULTIPLIER, - RETRY_DELAY_JITTER_FACTOR) - errors = [] - t0 = perf_counter() - while True: - try: - self._create_transaction() - self._connect(access_mode) - self.__begin__() - tx = self._transaction - try: - result = unit_of_work(tx, *args, **kwargs) - except: - if tx.success is None: - tx.success = False - raise - else: - if tx.success is None: - tx.success = True - finally: - tx.close() - except (ServiceUnavailable, SessionExpired) as error: - errors.append(error) - except TransientError as error: - if is_retriable_transient_error(error): - errors.append(error) - else: - raise - else: - return result - t1 = perf_counter() - if t1 - t0 > self._max_retry_time: - break - sleep(next(retry_delay)) - if errors: - raise errors[-1] - else: - raise ServiceUnavailable("Transaction failed") - - def read_transaction(self, unit_of_work, *args, **kwargs): - return self._run_transaction(READ_ACCESS, unit_of_work, *args, **kwargs) - - def write_transaction(self, unit_of_work, *args, **kwargs): - return self._run_transaction(WRITE_ACCESS, unit_of_work, *args, **kwargs) - - def _run(self, statement, parameters): - from neo4j.v1.result import BoltStatementResult - from neo4j.v1.types import fix_parameters - if self.closed(): - raise SessionError("Session closed") - - run_response = Response(self._connection) - pull_all_response = Response(self._connection) - self._last_result = result = BoltStatementResult(self, run_response, pull_all_response) - result.statement = ustr(statement) - result.parameters = fix_parameters(parameters, self._connection.protocol_version, - supports_bytes=self._connection.server.supports_bytes()) - - self._connection.append(RUN, (result.statement, result.parameters), response=run_response) - self._connection.append(PULL_ALL, response=pull_all_response) - - return result - - def __run__(self, statement, parameters): - return self._run(statement, parameters) - - def __begin__(self): - if self._bookmarks: - parameters = {"bookmark": self.last_bookmark(), "bookmarks": self._bookmarks} - else: - parameters = {} - return self.__run__(u"BEGIN", parameters) - - def __commit__(self): - return self.__run__(u"COMMIT", {}) - - def __rollback__(self): - return self.__run__(u"ROLLBACK", {}) - - def __bookmark__(self, result): - summary = result.summary() - return summary.metadata.get("bookmark") - - -class Transaction(object): - """ Container for multiple Cypher queries to be executed within - a single context. Transactions can be used within a :py:const:`with` - block where the value of :attr:`.success` will determine whether - the transaction is committed or rolled back on :meth:`.Transaction.close`:: - - with session.begin_transaction() as tx: - pass - - """ - - #: When set, the transaction will be committed on close, otherwise it - #: will be rolled back. This attribute can be set in user code - #: multiple times before a transaction completes with only the final - #: value taking effect. - success = None - - _closed = False - - def __init__(self, session, on_close): - self.session = session - self.on_close = on_close - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - if self.success is None: - self.success = not bool(exc_type) - self.close() - - def run(self, statement, parameters=None, **kwparameters): - """ Run a Cypher statement within the context of this transaction. - - The statement is sent to the server lazily, when its result is - consumed. To force the statement to be sent to the server, use - the :meth:`.Transaction.sync` method. - - Cypher is typically expressed as a statement template plus a - set of named parameters. In Python, parameters may be expressed - through a dictionary of parameters, through individual parameter - arguments, or as a mixture of both. For example, the `run` - statements below are all equivalent:: - - >>> statement = "CREATE (a:Person {name:{name}, age:{age}})" - >>> tx.run(statement, {"name": "Alice", "age": 33}) - >>> tx.run(statement, {"name": "Alice"}, age=33) - >>> tx.run(statement, name="Alice", age=33) - - Parameter values can be of any type supported by the Neo4j type - system. In Python, this includes :class:`bool`, :class:`int`, - :class:`str`, :class:`list` and :class:`dict`. Note however that - :class:`list` properties must be homogenous. - - :param statement: template Cypher statement - :param parameters: dictionary of parameters - :param kwparameters: additional keyword parameters - :returns: :class:`.StatementResult` object - """ - if self.closed(): - raise TransactionError("Transaction closed") - return self.session.run(statement, parameters, **kwparameters) - - def sync(self): - """ Force any queued statements to be sent to the server and - all related results to be fetched and buffered. - - :raise TransactionError: if the transaction is closed - """ - if self.closed(): - raise TransactionError("Transaction closed") - self.session.sync() - - def commit(self): - """ Mark this transaction as successful and close in order to - trigger a COMMIT. - - :raise TransactionError: if already closed - """ - if self.closed(): - raise TransactionError("Transaction closed") - self.success = True - self.close() - - def rollback(self): - """ Mark this transaction as unsuccessful and close in order to - trigger a ROLLBACK. - - :raise TransactionError: if already closed - """ - if self.closed(): - raise TransactionError("Transaction closed") - self.success = False - self.close() - - def close(self): - """ Close this transaction, triggering either a COMMIT or a ROLLBACK. - """ - if not self.closed(): - try: - self.sync() - except CypherError: - self.success = False - raise - finally: - if self.session.has_transaction(): - if self.success: - self.session.commit_transaction() - else: - self.session.rollback_transaction() - self._closed = True - self.on_close() - - def closed(self): - """ Indicator to show whether the transaction has been closed. - :returns: :const:`True` if closed, :const:`False` otherwise. - """ - return self._closed - - -class StatementResult(object): - """ A handler for the result of Cypher statement execution. Instances - of this class are typically constructed and returned by - :meth:`.Session.run` and :meth:`.Transaction.run`. - """ - - #: The statement text that was executed to produce this result. - statement = None - - #: Dictionary of parameters passed with the statement. - parameters = None - - zipper = zip - - def __init__(self, session, hydrant): - self._session = session - self._hydrant = hydrant - self._keys = None - self._records = deque() - self._summary = None - - def __iter__(self): - return self.records() - - @property - def session(self): - return self._session - - def attached(self): - """ Indicator for whether or not this result is still attached to - a :class:`.Session`. - - :returns: :const:`True` if still attached, :const:`False` otherwise - """ - return self._session and not self._session.closed() - - def detach(self): - """ Detach this result from its parent session by fetching the - remainder of this result from the network into the buffer. - - :returns: number of records fetched - """ - if self.attached(): - return self._session.detach(self) - else: - return 0 - - def keys(self): - """ The keys for the records in this result. - - :returns: tuple of key names - """ - if self._keys is not None: - return self._keys - if self.attached(): - self._session.send() - while self.attached() and self._keys is None: - self._session.fetch() - return self._keys - - def records(self): - """ Generator for records obtained from this result. - - :yields: iterable of :class:`.Record` objects - """ - records = self._records - next_record = records.popleft - while records: - yield next_record() - attached = self.attached - if attached(): - self._session.send() - while attached(): - self._session.fetch() - while records: - yield next_record() - - def summary(self): - """ Obtain the summary of this result, buffering any remaining records. - - :returns: The :class:`.ResultSummary` for this result - """ - self.detach() - return self._summary - - def consume(self): - """ Consume the remainder of this result and return the summary. - - :returns: The :class:`.ResultSummary` for this result - """ - if self.attached(): - for _ in self: - pass - return self.summary() - - def single(self): - """ Obtain the next and only remaining record from this result. - - A warning is generated if more than one record is available but - the first of these is still returned. - - :returns: the next :class:`.Record` or :const:`None` if none remain - :warns: if more than one record is available - """ - records = list(self) - size = len(records) - if size == 0: - return None - if size != 1: - warn("Expected a result with a single record, but this result contains %d" % size) - return records[0] - - def peek(self): - """ Obtain the next record from this result without consuming it. - This leaves the record in the buffer for further processing. - - :returns: the next :class:`.Record` or :const:`None` if none remain - """ - hydrate = self._hydrant.hydrate - zipper = self.zipper - keys = self.keys() - records = self._records - if records: - values = records[0] - return zipper(keys, hydrate(values)) - if not self.attached(): - return None - if self.attached(): - self._session.send() - while self.attached() and not records: - self._session.fetch() - if records: - values = records[0] - return zipper(keys, hydrate(values)) - return None - - def graph(self): - """ Return a Graph instance containing all the graph objects - in the result. After calling this method, the result becomes - detached, buffering all remaining records. - - :returns: result graph - """ - self.detach() - return self._hydrant.graph diff --git a/neo4j/v1/direct.py b/neo4j/v1/direct.py deleted file mode 100644 index cea740e29..000000000 --- a/neo4j/v1/direct.py +++ /dev/null @@ -1,81 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from neo4j.addressing import SocketAddress -from neo4j.bolt.connection import DEFAULT_PORT, ConnectionPool, connect, ConnectionErrorHandler -from neo4j.config import default_config -from neo4j.v1.api import Driver, Session -from neo4j.v1.security import SecurityPlan - - -class DirectConnectionErrorHandler(ConnectionErrorHandler): - """ Handler for errors in direct driver connections. - """ - - def __init__(self): - super(DirectConnectionErrorHandler, self).__init__({}) # does not need to handle errors - - -class DirectConnectionPool(ConnectionPool): - - def __init__(self, connector, address, **config): - super(DirectConnectionPool, self).__init__(connector, DirectConnectionErrorHandler(), **config) - self.address = address - - def acquire(self, access_mode=None): - return self.acquire_direct(self.address) - - -class DirectDriver(Driver): - """ A :class:`.DirectDriver` is created from a ``bolt`` URI and addresses - a single database instance. This provides basic connectivity to any - database service topology. - """ - - uri_scheme = "bolt" - - def __new__(cls, uri, **config): - cls._check_uri(uri) - if SocketAddress.parse_routing_context(uri): - raise ValueError("Parameters are not supported with scheme 'bolt'. Given URI: '%s'." % uri) - instance = object.__new__(cls) - # We keep the address containing the host name or IP address exactly - # as-is from the original URI. This means that every new connection - # will carry out DNS resolution, leading to the possibility that - # the connection pool may contain multiple IP address keys, one for - # an old address and one for a new address. - instance.address = SocketAddress.from_uri(uri, DEFAULT_PORT) - instance.security_plan = security_plan = SecurityPlan.build(**config) - instance.encrypted = security_plan.encrypted - - def connector(address, error_handler): - return connect(address, security_plan.ssl_context, error_handler, **config) - - pool = DirectConnectionPool(connector, instance.address, **config) - pool.release(pool.acquire()) - instance._pool = pool - instance._max_retry_time = config.get("max_retry_time", default_config["max_retry_time"]) - return instance - - def session(self, access_mode=None, **parameters): - if "max_retry_time" not in parameters: - parameters["max_retry_time"] = self._max_retry_time - return Session(self._pool.acquire, access_mode, **parameters) diff --git a/neo4j/v1/exceptions.py b/neo4j/v1/exceptions.py deleted file mode 100644 index 7d51101d2..000000000 --- a/neo4j/v1/exceptions.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -class DriverError(Exception): - """ Raised when an error occurs while using a driver. - """ - - def __init__(self, driver, *args, **kwargs): - super(DriverError, self).__init__(*args, **kwargs) - self.driver = driver - - -class SessionError(Exception): - """ Raised when an error occurs while using a session. - """ - - def __init__(self, session, *args, **kwargs): - super(SessionError, self).__init__(*args, **kwargs) - self.session = session - - -class SessionExpired(SessionError): - """ Raised when no a session is no longer able to fulfil - the purpose described by its original parameters. - """ - - def __init__(self, session, *args, **kwargs): - super(SessionExpired, self).__init__(session, *args, **kwargs) - - -class TransactionError(Exception): - """ Raised when an error occurs while using a transaction. - """ - - def __init__(self, transaction, *args, **kwargs): - super(TransactionError, self).__init__(*args, **kwargs) - self.transaction = transaction diff --git a/neo4j/v1/result.py b/neo4j/v1/result.py deleted file mode 100644 index a58e4f756..000000000 --- a/neo4j/v1/result.py +++ /dev/null @@ -1,285 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from collections import namedtuple - -from neo4j.exceptions import CypherError -from neo4j.v1.api import StatementResult -from neo4j.v1.types import Record, PackStreamHydrator - - -STATEMENT_TYPE_READ_ONLY = "r" -STATEMENT_TYPE_READ_WRITE = "rw" -STATEMENT_TYPE_WRITE_ONLY = "w" -STATEMENT_TYPE_SCHEMA_WRITE = "s" - - -class BoltStatementResult(StatementResult): - """ A handler for the result of Cypher statement execution. - """ - - @classmethod - def zipper(cls, k, v): - return Record(zip(k, v)) - - def __init__(self, session, run_response, pull_all_response): - super(BoltStatementResult, self).__init__(session, PackStreamHydrator(session._connection.protocol_version)) - - all_metadata = {} - - def on_header(metadata): - # Called on receipt of the result header. - all_metadata.update(metadata) - self._keys = tuple(metadata.get("fields", ())) - - def on_records(records): - # Called on receipt of one or more result records. - self._records.extend(map(lambda record: self.zipper(self.keys(), self._hydrant.hydrate(record)), records)) - - def on_footer(metadata): - # Called on receipt of the result footer. - connection = self.session._connection - all_metadata.update(metadata, statement=self.statement, parameters=self.parameters, - server=connection.server, protocol_version=connection.protocol_version) - self._summary = BoltStatementResultSummary(**all_metadata) - self._session, session_ = None, self._session - session_.detach(self) - - def on_failure(metadata): - # Called on execution failure. - self.session.reset() - on_footer(metadata) - raise CypherError.hydrate(**metadata) - - run_response.on_success = on_header - run_response.on_failure = on_failure - - pull_all_response.on_records = on_records - pull_all_response.on_success = on_footer - pull_all_response.on_failure = on_failure - - def value(self, item=0, default=None): - """ Return the remainder of the result as a list of values. - - :param item: field to return for each remaining record - :param default: default value, used if the index of key is unavailable - :returns: list of individual values - """ - return [record.value(item, default) for record in self.records()] - - def values(self, *items): - """ Return the remainder of the result as a list of tuples. - - :param items: fields to return for each remaining record - :returns: list of value tuples - """ - return [record.values(*items) for record in self.records()] - - def data(self, *items): - """ Return the remainder of the result as a list of dictionaries. - - :param items: fields to return for each remaining record - :returns: list of dictionaries - """ - return [record.data(*items) for record in self.records()] - - -class BoltStatementResultSummary(object): - """ A summary of execution returned with a :class:`.StatementResult` object. - """ - - #: The version of Bolt protocol over which this result was obtained. - protocol_version = None - - #: The server on which this result was generated. - server = None - - #: The statement that was executed to produce this result. - statement = None - - #: Dictionary of parameters passed with the statement. - parameters = None - - #: The type of statement (``'r'`` = read-only, ``'rw'`` = read/write). - statement_type = None - - #: A set of statistical information held in a :class:`.Counters` instance. - counters = None - - #: A :class:`.Plan` instance - plan = None - - #: A :class:`.ProfiledPlan` instance - profile = None - - #: The time it took for the server to have the result available. - result_available_after = None - - #: The time it took for the server to consume the result. - result_consumed_after = None - - #: Notifications provide extra information for a user executing a statement. - #: They can be warnings about problematic queries or other valuable information that can be - #: presented in a client. - #: Unlike failures or errors, notifications do not affect the execution of a statement. - notifications = None - - def __init__(self, **metadata): - self.metadata = metadata - self.protocol_version = metadata.get("protocol_version") - self.server = metadata.get("server") - self.statement = metadata.get("statement") - self.parameters = metadata.get("parameters") - self.statement_type = metadata.get("type") - self.counters = SummaryCounters(metadata.get("stats", {})) - self.result_available_after = metadata.get("result_available_after") - self.result_consumed_after = metadata.get("result_consumed_after") - if "plan" in metadata: - self.plan = make_plan(metadata["plan"]) - if "profile" in metadata: - self.profile = make_plan(metadata["profile"]) - self.plan = self.profile - self.notifications = [] - for notification in metadata.get("notifications", []): - position = notification.get("position") - if position is not None: - position = Position(position["offset"], position["line"], position["column"]) - self.notifications.append(Notification(notification["code"], notification["title"], - notification["description"], notification["severity"], position)) - - -class SummaryCounters(object): - """ Set of statistics from a Cypher statement execution. - """ - - #: - nodes_created = 0 - - #: - nodes_deleted = 0 - - #: - relationships_created = 0 - - #: - relationships_deleted = 0 - - #: - properties_set = 0 - - #: - labels_added = 0 - - #: - labels_removed = 0 - - #: - indexes_added = 0 - - #: - indexes_removed = 0 - - #: - constraints_added = 0 - - #: - constraints_removed = 0 - - def __init__(self, statistics): - for key, value in dict(statistics).items(): - key = key.replace("-", "_") - setattr(self, key, value) - - def __repr__(self): - return repr(vars(self)) - - @property - def contains_updates(self): - return bool(self.nodes_created or self.nodes_deleted or - self.relationships_created or self.relationships_deleted or - self.properties_set or self.labels_added or self.labels_removed or - self.indexes_added or self.indexes_removed or - self.constraints_added or self.constraints_removed) - - -#: A plan describes how the database will execute your statement. -#: -#: operator_type: -#: the name of the operation performed by the plan -#: identifiers: -#: the list of identifiers used by this plan -#: arguments: -#: a dictionary of arguments used in the specific operation performed by the plan -#: children: -#: a list of sub-plans -Plan = namedtuple("Plan", ("operator_type", "identifiers", "arguments", "children")) - -#: A profiled plan describes how the database executed your statement. -#: -#: db_hits: -#: the number of times this part of the plan touched the underlying data stores -#: rows: -#: the number of records this part of the plan produced -ProfiledPlan = namedtuple("ProfiledPlan", Plan._fields + ("db_hits", "rows")) - -#: Representation for notifications found when executing a statement. A -#: notification can be visualized in a client pinpointing problems or -#: other information about the statement. -#: -#: code: -#: a notification code for the discovered issue. -#: title: -#: a short summary of the notification -#: description: -#: a long description of the notification -#: severity: -#: the severity level of the notification -#: position: -#: the position in the statement where this notification points to, if relevant. -Notification = namedtuple("Notification", ("code", "title", "description", "severity", "position")) - -#: A position within a statement, consisting of offset, line and column. -#: -#: offset: -#: the character offset referred to by this position; offset numbers start at 0 -#: line: -#: the line number referred to by the position; line numbers start at 1 -#: column: -#: the column number referred to by the position; column numbers start at 1 -Position = namedtuple("Position", ("offset", "line", "column")) - - -def make_plan(plan_dict): - """ Construct a Plan or ProfiledPlan from a dictionary of metadata values. - - :param plan_dict: - :return: - """ - operator_type = plan_dict["operatorType"] - identifiers = plan_dict.get("identifiers", []) - arguments = plan_dict.get("args", []) - children = [make_plan(child) for child in plan_dict.get("children", [])] - if "dbHits" in plan_dict or "rows" in plan_dict: - db_hits = plan_dict.get("dbHits", 0) - rows = plan_dict.get("rows", 0) - return ProfiledPlan(operator_type, identifiers, arguments, children, db_hits, rows) - else: - return Plan(operator_type, identifiers, arguments, children) diff --git a/neo4j/v1/routing.py b/neo4j/v1/routing.py deleted file mode 100644 index 3fab8b69b..000000000 --- a/neo4j/v1/routing.py +++ /dev/null @@ -1,473 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from abc import abstractmethod -from sys import maxsize -from threading import Lock -from time import clock - -from neo4j.addressing import SocketAddress -from neo4j.bolt import ConnectionPool, ServiceUnavailable, ProtocolError, DEFAULT_PORT, connect, ConnectionErrorHandler -from neo4j.compat.collections import MutableSet, OrderedDict -from neo4j.exceptions import CypherError, DatabaseUnavailableError, NotALeaderError, ForbiddenOnReadOnlyDatabaseError -from neo4j.util import ServerVersion -from neo4j.v1.api import Driver, Session, READ_ACCESS, WRITE_ACCESS -from neo4j.v1.exceptions import SessionExpired -from neo4j.v1.security import SecurityPlan -from neo4j.config import default_config, LOAD_BALANCING_STRATEGY_LEAST_CONNECTED, LOAD_BALANCING_STRATEGY_ROUND_ROBIN - - -class OrderedSet(MutableSet): - - def __init__(self, elements=()): - self._elements = OrderedDict.fromkeys(elements) - self._current = None - - def __repr__(self): - return "{%s}" % ", ".join(map(repr, self._elements)) - - def __contains__(self, element): - return element in self._elements - - def __iter__(self): - return iter(self._elements) - - def __len__(self): - return len(self._elements) - - def __getitem__(self, index): - return list(self._elements.keys())[index] - - def add(self, element): - self._elements[element] = None - - def clear(self): - self._elements.clear() - - def discard(self, element): - try: - del self._elements[element] - except KeyError: - pass - - def remove(self, element): - try: - del self._elements[element] - except KeyError: - raise ValueError(element) - - def update(self, elements=()): - self._elements.update(OrderedDict.fromkeys(elements)) - - def replace(self, elements=()): - e = self._elements - e.clear() - e.update(OrderedDict.fromkeys(elements)) - - -class RoutingTable(object): - - timer = clock - - @classmethod - def parse_routing_info(cls, records): - """ Parse the records returned from a getServers call and - return a new RoutingTable instance. - """ - if len(records) != 1: - raise ProtocolError("Expected exactly one record") - record = records[0] - routers = [] - readers = [] - writers = [] - try: - servers = record["servers"] - for server in servers: - role = server["role"] - addresses = [] - for address in server["addresses"]: - addresses.append(SocketAddress.parse(address, DEFAULT_PORT)) - if role == "ROUTE": - routers.extend(addresses) - elif role == "READ": - readers.extend(addresses) - elif role == "WRITE": - writers.extend(addresses) - ttl = record["ttl"] - except (KeyError, TypeError): - raise ProtocolError("Cannot parse routing info") - else: - return cls(routers, readers, writers, ttl) - - def __init__(self, routers=(), readers=(), writers=(), ttl=0): - self.routers = OrderedSet(routers) - self.readers = OrderedSet(readers) - self.writers = OrderedSet(writers) - self.last_updated_time = self.timer() - self.ttl = ttl - - def is_fresh(self, access_mode): - """ Indicator for whether routing information is still usable. - """ - expired = self.last_updated_time + self.ttl <= self.timer() - has_server_for_mode = (access_mode == READ_ACCESS and self.readers) or (access_mode == WRITE_ACCESS and self.writers) - return not expired and self.routers and has_server_for_mode - - def update(self, new_routing_table): - """ Update the current routing table with new routing information - from a replacement table. - """ - self.routers.replace(new_routing_table.routers) - self.readers.replace(new_routing_table.readers) - self.writers.replace(new_routing_table.writers) - self.last_updated_time = self.timer() - self.ttl = new_routing_table.ttl - - def servers(self): - return set(self.routers) | set(self.writers) | set(self.readers) - - -class LoadBalancingStrategy(object): - - @classmethod - def build(cls, connection_pool, **config): - load_balancing_strategy = config.get("load_balancing_strategy", default_config["load_balancing_strategy"]) - if load_balancing_strategy == LOAD_BALANCING_STRATEGY_LEAST_CONNECTED: - return LeastConnectedLoadBalancingStrategy(connection_pool) - elif load_balancing_strategy == LOAD_BALANCING_STRATEGY_ROUND_ROBIN: - return RoundRobinLoadBalancingStrategy() - else: - raise ValueError("Unknown load balancing strategy '%s'" % load_balancing_strategy) - - @abstractmethod - def select_reader(self, known_readers): - raise NotImplementedError() - - @abstractmethod - def select_writer(self, known_writers): - raise NotImplementedError() - - -class RoundRobinLoadBalancingStrategy(LoadBalancingStrategy): - - _readers_offset = 0 - _writers_offset = 0 - - def select_reader(self, known_readers): - address = self._select(self._readers_offset, known_readers) - self._readers_offset += 1 - return address - - def select_writer(self, known_writers): - address = self._select(self._writers_offset, known_writers) - self._writers_offset += 1 - return address - - @classmethod - def _select(cls, offset, addresses): - if not addresses: - return None - return addresses[offset % len(addresses)] - - -class LeastConnectedLoadBalancingStrategy(LoadBalancingStrategy): - - def __init__(self, connection_pool): - self._readers_offset = 0 - self._writers_offset = 0 - self._connection_pool = connection_pool - - def select_reader(self, known_readers): - address = self._select(self._readers_offset, known_readers) - self._readers_offset += 1 - return address - - def select_writer(self, known_writers): - address = self._select(self._writers_offset, known_writers) - self._writers_offset += 1 - return address - - def _select(self, offset, addresses): - if not addresses: - return None - num_addresses = len(addresses) - start_index = offset % num_addresses - index = start_index - - least_connected_address = None - least_in_use_connections = maxsize - - while True: - address = addresses[index] - index = (index + 1) % num_addresses - - in_use_connections = self._connection_pool.in_use_connection_count(address) - - if in_use_connections < least_in_use_connections: - least_connected_address = address - least_in_use_connections = in_use_connections - - if index == start_index: - return least_connected_address - - -class RoutingConnectionErrorHandler(ConnectionErrorHandler): - """ Handler for errors in routing driver connections. - """ - - def __init__(self, pool): - super(RoutingConnectionErrorHandler, self).__init__({ - SessionExpired: lambda address: pool.deactivate(address), - ServiceUnavailable: lambda address: pool.deactivate(address), - DatabaseUnavailableError: lambda address: pool.deactivate(address), - NotALeaderError: lambda address: pool.remove_writer(address), - ForbiddenOnReadOnlyDatabaseError: lambda address: pool.remove_writer(address) - }) - - -class RoutingConnectionPool(ConnectionPool): - """ Connection pool with routing table. - """ - - def __init__(self, connector, initial_address, routing_context, *routers, **config): - super(RoutingConnectionPool, self).__init__(connector, RoutingConnectionErrorHandler(self), **config) - self.initial_address = initial_address - self.routing_context = routing_context - self.routing_table = RoutingTable(routers) - self.missing_writer = False - self.refresh_lock = Lock() - self.load_balancing_strategy = LoadBalancingStrategy.build(self, **config) - - def fetch_routing_info(self, address): - """ Fetch raw routing info from a given router address. - - :param address: router address - :return: list of routing records or - None if no connection could be established - :raise ServiceUnavailable: if the server does not support routing or - if routing support is broken - """ - - class RoutingInfoUpdateSession(Session): - - def __run__(self, _, routing_context): - if ServerVersion.from_str(self._connection.server.version).at_least_version(3, 2): - statement, parameters = ("CALL dbms.cluster.routing.getRoutingTable({context})", - {"context": routing_context}) - else: - statement, parameters = "CALL dbms.cluster.routing.getServers", {} - return self._run(statement, parameters) - - try: - with RoutingInfoUpdateSession(lambda _: self.acquire_direct(address), access_mode=None) as session: - return list(session.run("ignored", self.routing_context)) - except CypherError as error: - if error.code == "Neo.ClientError.Procedure.ProcedureNotFound": - raise ServiceUnavailable("Server {!r} does not support routing".format(address)) - else: - raise ServiceUnavailable("Routing support broken on server {!r}".format(address)) - except ServiceUnavailable: - self.deactivate(address) - return None - - def fetch_routing_table(self, address): - """ Fetch a routing table from a given router address. - - :param address: router address - :return: a new RoutingTable instance or None if the given router is - currently unable to provide routing information - :raise ServiceUnavailable: if no writers are available - :raise ProtocolError: if the routing information received is unusable - """ - new_routing_info = self.fetch_routing_info(address) - if new_routing_info is None: - return None - - # Parse routing info and count the number of each type of server - new_routing_table = RoutingTable.parse_routing_info(new_routing_info) - num_routers = len(new_routing_table.routers) - num_readers = len(new_routing_table.readers) - num_writers = len(new_routing_table.writers) - - # No writers are available. This likely indicates a temporary state, - # such as leader switching, so we should not signal an error. - # When no writers available, then we flag we are reading in absence of writer - self.missing_writer = (num_writers == 0) - - # No routers - if num_routers == 0: - raise ProtocolError("No routing servers returned from server %r" % (address,)) - - # No readers - if num_readers == 0: - raise ProtocolError("No read servers returned from server %r" % (address,)) - - # At least one of each is fine, so return this table - return new_routing_table - - def update_routing_table_from(self, *routers): - """ Try to update routing tables with the given routers. - - :return: True if the routing table is successfully updated, otherwise False - """ - for router in routers: - new_routing_table = self.fetch_routing_table(router) - if new_routing_table is not None: - self.routing_table.update(new_routing_table) - return True - return False - - def update_routing_table(self): - """ Update the routing table from the first router able to provide - valid routing information. - """ - # copied because it can be modified - existing_routers = list(self.routing_table.routers) - - has_tried_initial_routers = False - if self.missing_writer: - has_tried_initial_routers = True - if self.update_routing_table_from(self.initial_address): - return - - if self.update_routing_table_from(*existing_routers): - return - - if not has_tried_initial_routers and self.initial_address not in existing_routers: - if self.update_routing_table_from(self.initial_address): - return - - # None of the routers have been successful, so just fail - raise ServiceUnavailable("Unable to retrieve routing information") - - def update_connection_pool(self): - servers = self.routing_table.servers() - for address in list(self.connections): - if address not in servers: - super(RoutingConnectionPool, self).deactivate(address) - - def ensure_routing_table_is_fresh(self, access_mode): - """ Update the routing table if stale. - - This method performs two freshness checks, before and after acquiring - the refresh lock. If the routing table is already fresh on entry, the - method exits immediately; otherwise, the refresh lock is acquired and - the second freshness check that follows determines whether an update - is still required. - - This method is thread-safe. - - :return: `True` if an update was required, `False` otherwise. - """ - if self.routing_table.is_fresh(access_mode): - return False - with self.refresh_lock: - if self.routing_table.is_fresh(access_mode): - if access_mode == READ_ACCESS: - # if reader is fresh but writers is not fresh, then we are reading in absence of writer - self.missing_writer = not self.routing_table.is_fresh(WRITE_ACCESS) - return False - self.update_routing_table() - self.update_connection_pool() - return True - - def acquire(self, access_mode=None): - if access_mode is None: - access_mode = WRITE_ACCESS - if access_mode == READ_ACCESS: - server_list = self.routing_table.readers - server_selector = self.load_balancing_strategy.select_reader - elif access_mode == WRITE_ACCESS: - server_list = self.routing_table.writers - server_selector = self.load_balancing_strategy.select_writer - else: - raise ValueError("Unsupported access mode {}".format(access_mode)) - - self.ensure_routing_table_is_fresh(access_mode) - while True: - address = server_selector(server_list) - if address is None: - break - try: - connection = self.acquire_direct(address) # should always be a resolved address - connection.Error = SessionExpired - except ServiceUnavailable: - self.deactivate(address) - else: - return connection - raise SessionExpired("Failed to obtain connection towards '%s' server." % access_mode) - - def deactivate(self, address): - """ Deactivate an address from the connection pool, - if present, remove from the routing table and also closing - all idle connections to that address. - """ - # We use `discard` instead of `remove` here since the former - # will not fail if the address has already been removed. - self.routing_table.routers.discard(address) - self.routing_table.readers.discard(address) - self.routing_table.writers.discard(address) - super(RoutingConnectionPool, self).deactivate(address) - - def remove_writer(self, address): - """ Remove a writer address from the routing table, if present. - """ - self.routing_table.writers.discard(address) - - -class RoutingDriver(Driver): - """ A :class:`.RoutingDriver` is created from a ``bolt+routing`` URI. The - routing behaviour works in tandem with Neo4j's causal clustering feature - by directing read and write behaviour to appropriate cluster members. - """ - - uri_scheme = "bolt+routing" - - def __new__(cls, uri, **config): - cls._check_uri(uri) - instance = object.__new__(cls) - instance.initial_address = initial_address = SocketAddress.from_uri(uri, DEFAULT_PORT) - instance.security_plan = security_plan = SecurityPlan.build(**config) - instance.encrypted = security_plan.encrypted - routing_context = SocketAddress.parse_routing_context(uri) - if not security_plan.routing_compatible: - # this error message is case-specific as there is only one incompatible - # scenario right now - raise ValueError("TRUST_ON_FIRST_USE is not compatible with routing") - - def connector(address, error_handler): - return connect(address, security_plan.ssl_context, error_handler, **config) - - pool = RoutingConnectionPool(connector, initial_address, routing_context, initial_address, **config) - try: - pool.update_routing_table() - except: - pool.close() - raise - else: - instance._pool = pool - instance._max_retry_time = config.get("max_retry_time", default_config["max_retry_time"]) - return instance - - def session(self, access_mode=None, **parameters): - if "max_retry_time" not in parameters: - parameters["max_retry_time"] = self._max_retry_time - return Session(self._pool.acquire, access_mode, **parameters) diff --git a/neo4j/v1/security.py b/neo4j/v1/security.py deleted file mode 100644 index c9c89f614..000000000 --- a/neo4j/v1/security.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -from warnings import warn - -from neo4j.compat.ssl import SSL_AVAILABLE, SSLContext, PROTOCOL_SSLv23, OP_NO_SSLv2, CERT_REQUIRED -from neo4j.config import default_config, TRUST_ALL_CERTIFICATES, TRUST_CUSTOM_CA_SIGNED_CERTIFICATES, TRUST_ON_FIRST_USE, TRUST_SIGNED_CERTIFICATES, TRUST_SYSTEM_CA_SIGNED_CERTIFICATES - -ENCRYPTION_OFF = 0 -ENCRYPTION_ON = 1 -ENCRYPTION_DEFAULT = ENCRYPTION_ON if SSL_AVAILABLE else ENCRYPTION_OFF - - -class AuthToken(object): - """ Container for auth information - """ - - #: By default we should not send any realm - realm = None - - def __init__(self, scheme, principal, credentials, realm=None, **parameters): - self.scheme = scheme - self.principal = principal - self.credentials = credentials - if realm: - self.realm = realm - if parameters: - self.parameters = parameters - - -class SecurityPlan(object): - - @classmethod - def build(cls, **config): - encrypted = config.get("encrypted", default_config["encrypted"]) - if encrypted is None: - encrypted = _encryption_default() - trust = config.get("trust", default_config["trust"]) - if encrypted: - if not SSL_AVAILABLE: - raise RuntimeError("Bolt over TLS is only available in Python 2.7.9+ and " - "Python 3.3+") - ssl_context = SSLContext(PROTOCOL_SSLv23) - ssl_context.options |= OP_NO_SSLv2 - if trust == TRUST_ON_FIRST_USE: - warn("TRUST_ON_FIRST_USE is deprecated, please use " - "TRUST_ALL_CERTIFICATES instead") - elif trust == TRUST_SIGNED_CERTIFICATES: - warn("TRUST_SIGNED_CERTIFICATES is deprecated, please use " - "TRUST_SYSTEM_CA_SIGNED_CERTIFICATES instead") - ssl_context.verify_mode = CERT_REQUIRED - elif trust == TRUST_ALL_CERTIFICATES: - pass - elif trust == TRUST_CUSTOM_CA_SIGNED_CERTIFICATES: - raise NotImplementedError("Custom CA support is not implemented") - elif trust == TRUST_SYSTEM_CA_SIGNED_CERTIFICATES: - ssl_context.verify_mode = CERT_REQUIRED - else: - raise ValueError("Unknown trust mode") - ssl_context.set_default_verify_paths() - else: - ssl_context = None - return cls(encrypted, ssl_context, trust != TRUST_ON_FIRST_USE) - - def __init__(self, requires_encryption, ssl_context, routing_compatible): - self.encrypted = bool(requires_encryption) - self.ssl_context = ssl_context - self.routing_compatible = routing_compatible - - -def basic_auth(user, password, realm=None): - """ Generate a basic auth token for a given user and password. - - :param user: user name - :param password: current password - :param realm: specifies the authentication provider - :return: auth token for use with :meth:`GraphDatabase.driver` - """ - return AuthToken("basic", user, password, realm) - - -def kerberos_auth(base64_encoded_ticket): - """ Generate a kerberos auth token with the base64 encoded ticket - - :param base64_encoded_ticket: a base64 encoded service ticket - :return: an authentication token that can be used to connect to Neo4j - """ - return AuthToken("kerberos", "", base64_encoded_ticket) - - -def custom_auth(principal, credentials, realm, scheme, **parameters): - """ Generate a basic auth token for a given user and password. - - :param principal: specifies who is being authenticated - :param credentials: authenticates the principal - :param realm: specifies the authentication provider - :param scheme: specifies the type of authentication - :param parameters: parameters passed along to the authentication provider - :return: auth token for use with :meth:`GraphDatabase.driver` - """ - return AuthToken(scheme, principal, credentials, realm, **parameters) - - -_warned_about_insecure_default = False - - -def _encryption_default(): - global _warned_about_insecure_default - if not SSL_AVAILABLE and not _warned_about_insecure_default: - warn("Bolt over TLS is only available in Python 2.7.9+ and Python 3.3+ " - "so communications are not secure") - _warned_about_insecure_default = True - return ENCRYPTION_DEFAULT diff --git a/neo4j/v1/types/__init__.py b/neo4j/v1/types/__init__.py index e9a4f9ee1..2b5406c93 100644 --- a/neo4j/v1/types/__init__.py +++ b/neo4j/v1/types/__init__.py @@ -26,20 +26,8 @@ """ -from collections import Mapping -from functools import reduce -from operator import xor as xor_operator - -from neo4j.packstream import Structure from neo4j.compat import map_type, string, integer, ustr -from .graph import Graph, hydration_functions as graph_hydration_functions, \ - dehydration_functions as graph_dehydration_functions -from .spatial import hydration_functions as spatial_hydration_functions, \ - dehydration_functions as spatial_dehydration_functions -from .temporal import hydration_functions as temporal_hydration_functions, \ - dehydration_functions as temporal_dehydration_functions - # These classes are imported in order to retain backward compatibility with 1.5. # They should be removed in 2.0. from .graph import Entity, Node, Relationship, Path @@ -49,207 +37,25 @@ INT64_MAX = (2 ** 63) - 1 -def iter_items(iterable): - """ Iterate through all items (key-value pairs) within an iterable - dictionary-like object. If the object has a `keys` method, this is - used along with `__getitem__` to yield each pair in turn. If no - `keys` method exists, each iterable element is assumed to be a - 2-tuple of key and value. - """ - if hasattr(iterable, "keys"): - for key in iterable.keys(): - yield key, iterable[key] - else: - for key, value in iterable: - yield key, value - - -def fix_parameters(parameters, protocol_version, **kwargs): - if not parameters: - return {} - dehydrator = PackStreamDehydrator(protocol_version, **kwargs) - try: - dehydrated, = dehydrator.dehydrate([parameters]) - except TypeError as error: - value = error.args[0] - raise TypeError("Parameters of type {} are not supported".format(type(value).__name__)) - else: - return dehydrated - - -class Record(tuple, Mapping): - """ A :class:`.Record` is an immutable ordered collection of key-value - pairs. It is generally closer to a :py:class:`namedtuple` than to a - :py:class:`OrderedDict` inasmuch as iteration of the collection will - yield values rather than keys. - """ - - __keys = None - - def __new__(cls, iterable): - keys = [] - values = [] - for key, value in iter_items(iterable): - keys.append(key) - values.append(value) - inst = tuple.__new__(cls, values) - inst.__keys = tuple(keys) - return inst - - def __repr__(self): - return "<%s %s>" % (self.__class__.__name__, - " ".join("%s=%r" % (field, self[i]) for i, field in enumerate(self.__keys))) - - def __eq__(self, other): - return dict(self) == dict(other) - - def __ne__(self, other): - return not self.__eq__(other) - - def __hash__(self): - return reduce(xor_operator, map(hash, self.items())) - - def __getitem__(self, key): - if isinstance(key, slice): - keys = self.__keys[key] - values = super(Record, self).__getitem__(key) - return self.__class__(zip(keys, values)) - index = self.index(key) - if 0 <= index < len(self): - return super(Record, self).__getitem__(index) - else: - return None - - def __getslice__(self, start, stop): - key = slice(start, stop) - keys = self.__keys[key] - values = tuple(self)[key] - return self.__class__(zip(keys, values)) - - def get(self, key, default=None): - try: - index = self.__keys.index(ustr(key)) - except ValueError: - return default - if 0 <= index < len(self): - return super(Record, self).__getitem__(index) - else: - return default - - def index(self, key): - """ Return the index of the given item. - """ - if isinstance(key, integer): - if 0 <= key < len(self.__keys): - return key - raise IndexError(key) - elif isinstance(key, string): - try: - return self.__keys.index(key) - except ValueError: - raise KeyError(key) - else: - raise TypeError(key) - - def value(self, key=0, default=None): - """ Obtain a single value from the record by index or key. If no - index or key is specified, the first value is returned. If the - specified item does not exist, the default value is returned. - - :param key: - :param default: - :return: - """ - try: - index = self.index(key) - except (IndexError, KeyError): - return default - else: - return self[index] - - def keys(self): - """ Return the keys of the record. - - :return: list of key names - """ - return list(self.__keys) - - def values(self, *keys): - """ Return the values of the record, optionally filtering to - include only certain values by index or key. - - :param keys: indexes or keys of the items to include; if none - are provided, all values will be included - :return: list of values - """ - if keys: - d = [] - for key in keys: - try: - i = self.index(key) - except KeyError: - d.append(None) - else: - d.append(self[i]) - return d - return list(self) - - def items(self, *keys): - """ Return the fields of the record as a list of key and value tuples - - :return: - """ - if keys: - d = [] - for key in keys: - try: - i = self.index(key) - except KeyError: - d.append((key, None)) - else: - d.append((self.__keys[i], self[i])) - return d - return list((self.__keys[i], super(Record, self).__getitem__(i)) for i in range(len(self))) - - def data(self, *keys): - """ Return the keys and values of this record as a dictionary, - optionally including only certain values by index or key. Keys - provided in the items that are not in the record will be - inserted with a value of :const:`None`; indexes provided - that are out of bounds will trigger an :exc:`IndexError`. - - :param keys: indexes or keys of the items to include; if none - are provided, all values will be included - :return: dictionary of values, keyed by field name - :raises: :exc:`IndexError` if an out-of-bounds index is specified - """ - if keys: - d = {} - for key in keys: - try: - i = self.index(key) - except KeyError: - d[key] = None - else: - d[self.__keys[i]] = self[i] - return d - return dict(self) - - class PackStreamHydrator(object): def __init__(self, protocol_version): + from .graph import Graph, hydration_functions as graph_hydration_functions + super(PackStreamHydrator, self).__init__() self.graph = Graph() self.hydration_functions = {} self.hydration_functions.update(graph_hydration_functions(self.graph)) if protocol_version >= 2: + from .spatial import hydration_functions as spatial_hydration_functions + from .temporal import hydration_functions as temporal_hydration_functions self.hydration_functions.update(spatial_hydration_functions()) self.hydration_functions.update(temporal_hydration_functions()) def hydrate(self, values): """ Convert PackStream values into native values. """ + from neobolt.packstream import Structure def hydrate_(obj): if isinstance(obj, Structure): @@ -273,10 +79,13 @@ def hydrate_(obj): class PackStreamDehydrator(object): def __init__(self, protocol_version, supports_bytes=False): + from .graph import Graph, dehydration_functions as graph_dehydration_functions self.supports_bytes = supports_bytes self.dehydration_functions = {} self.dehydration_functions.update(graph_dehydration_functions()) if protocol_version >= 2: + from .spatial import dehydration_functions as spatial_dehydration_functions + from .temporal import dehydration_functions as temporal_dehydration_functions self.dehydration_functions.update(spatial_dehydration_functions()) self.dehydration_functions.update(temporal_dehydration_functions()) diff --git a/neo4j/v1/types/graph.py b/neo4j/v1/types/graph.py index 5fec1f83e..315e50dc4 100644 --- a/neo4j/v1/types/graph.py +++ b/neo4j/v1/types/graph.py @@ -26,7 +26,7 @@ from collections import Mapping from neo4j.compat import xstr -from neo4j.util import deprecated +from neo4j.meta import deprecated __all__ = [ diff --git a/neo4j/v1/types/spatial.py b/neo4j/v1/types/spatial.py index fcede8275..7e104cbb4 100644 --- a/neo4j/v1/types/spatial.py +++ b/neo4j/v1/types/spatial.py @@ -24,7 +24,7 @@ """ -from neo4j.packstream.structure import Structure +from neobolt.packstream.structure import Structure __all__ = [ diff --git a/neo4j/v1/types/temporal.py b/neo4j/v1/types/temporal.py index 586e135df..983e6ae19 100644 --- a/neo4j/v1/types/temporal.py +++ b/neo4j/v1/types/temporal.py @@ -31,7 +31,7 @@ from neotime import Duration, Date, Time, DateTime from pytz import FixedOffset, timezone, utc -from neo4j.packstream.structure import Structure +from neobolt.packstream.structure import Structure UNIX_EPOCH_DATE = Date(1970, 1, 1) diff --git a/requirements.txt b/requirements.txt index 9b76949b9..142f24131 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1 +1,2 @@ -neotime==1.0.0 +neobolt==1.7.0a2 +neotime diff --git a/setup.py b/setup.py index f74d116e6..b4ab8c490 100644 --- a/setup.py +++ b/setup.py @@ -29,20 +29,9 @@ from neo4j.meta import version -try: - from Cython.Build import cythonize - from Cython.Distutils import build_ext -except ImportError: - ext_modules = [ - Extension("neo4j.bolt._io", ["neo4j/bolt/_io.c"]), - Extension("neo4j.packstream._packer", ["neo4j/packstream/_packer.c"]), - Extension("neo4j.packstream._unpacker", ["neo4j/packstream/_unpacker.c"]), - ] -else: - ext_modules = cythonize([Extension("*", ["**/*.pyx"])]) - install_requires = [ - "neotime==1.0.0", + "neobolt==1.7.0a2", + "neotime", ] classifiers = [ "Intended Audience :: Developers", @@ -54,19 +43,14 @@ "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", + "Programming Language :: Python :: 3.7", ] packages = [ "neo4j", - "neo4j.bolt", "neo4j.compat", - "neo4j.packstream", "neo4j.v1", "neo4j.v1.types", ] -package_data = { - "neo4j.bolt": ["*.pyx"], - "neo4j.packstream": ["*.pyx"], -} setup_args = { "name": "neo4j-driver", "version": version, @@ -80,12 +64,6 @@ "install_requires": install_requires, "classifiers": classifiers, "packages": packages, - "ext_modules": ext_modules, } -try: - setup(**setup_args) -except SystemExit: - print("Compilation failed, falling back to pure Python.") - del setup_args["ext_modules"] - setup(**setup_args) +setup(**setup_args) diff --git a/test/auth.py b/test/auth.py index 97a58205b..401c98ae8 100644 --- a/test/auth.py +++ b/test/auth.py @@ -21,9 +21,9 @@ from sys import argv -from neo4j.v1 import basic_auth -from neo4j.v1.api import GraphDatabase -from neo4j.util import Watcher +from neobolt.util import Watcher + +from neo4j.v1 import GraphDatabase, basic_auth def update_password(user, password, new_password): diff --git a/test/env.py b/test/env.py index 36c6b3ef5..e0e62c8f7 100644 --- a/test/env.py +++ b/test/env.py @@ -31,4 +31,4 @@ # Password for the currently running server NEO4J_PASSWORD = getenv("NEO4J_PASSWORD") -NEOCTRL_ARGS = getenv("NEOCTRL_ARGS", "3.3.1") \ No newline at end of file +NEOCTRL_ARGS = getenv("NEOCTRL_ARGS", "3.4.1") diff --git a/test/integration/test_driver.py b/test/integration/test_driver.py index 3b3bf983b..efba79311 100644 --- a/test/integration/test_driver.py +++ b/test/integration/test_driver.py @@ -19,7 +19,7 @@ # limitations under the License. -from neo4j.bolt import DEFAULT_PORT +from neobolt.bolt import DEFAULT_PORT from neo4j.v1 import GraphDatabase, Driver, ServiceUnavailable from test.integration.tools import IntegrationTestCase diff --git a/test/integration/test_result.py b/test/integration/test_result.py index 46648189c..541c98430 100644 --- a/test/integration/test_result.py +++ b/test/integration/test_result.py @@ -19,6 +19,8 @@ # limitations under the License. +import pytest + from neo4j.exceptions import CypherError from test.integration.tools import DirectIntegrationTestCase @@ -273,11 +275,9 @@ def test_single_consumes_entire_result_if_one_record(self): assert not result.attached() def test_single_consumes_entire_result_if_multiple_records(self): - import warnings session = self.driver.session() result = session.run("UNWIND range(1, 3) AS n RETURN n") - with warnings.catch_warnings(): - warnings.simplefilter("always") + with pytest.warns(UserWarning): _ = result.single() assert not result.attached() diff --git a/test/integration/tools.py b/test/integration/tools.py index 5c4555e2c..7be0e7312 100644 --- a/test/integration/tools.py +++ b/test/integration/tools.py @@ -34,7 +34,6 @@ from neo4j.v1 import GraphDatabase from neo4j.exceptions import AuthError -from neo4j.util import ServerVersion from test.env import NEO4J_SERVER_PACKAGE, NEO4J_USER, NEO4J_PASSWORD, NEOCTRL_ARGS @@ -65,6 +64,25 @@ def is_listening(address): return True +class ServerVersion(object): + def __init__(self, product, version_tuple, tags_tuple): + self.product = product + self.version_tuple = version_tuple + self.tags_tuple = tags_tuple + + def at_least_version(self, major, minor): + return self.version_tuple >= (major, minor) + + @classmethod + def from_str(cls, full_version): + if full_version is None: + return ServerVersion("Neo4j", (3, 0), ()) + product, _, tagged_version = full_version.partition("/") + tags = tagged_version.split("-") + version = map(int, tags[0].split(".")) + return ServerVersion(product, tuple(version), tuple(tags[1:])) + + class IntegrationTestCase(TestCase): """ Base class for test cases that integrate with a server. """ diff --git a/test/performance/tools.py b/test/performance/tools.py index dfe8bd8fe..7674c6719 100644 --- a/test/performance/tools.py +++ b/test/performance/tools.py @@ -36,9 +36,9 @@ from neo4j.v1 import GraphDatabase from neo4j.exceptions import AuthError -from neo4j.util import ServerVersion from test.env import NEO4J_SERVER_PACKAGE, NEO4J_USER, NEO4J_PASSWORD +from test.integration.tools import ServerVersion def copy_dist(source, target): diff --git a/test/stub/test_directdriver.py b/test/stub/test_directdriver.py index e01654b4f..a5ddf4545 100644 --- a/test/stub/test_directdriver.py +++ b/test/stub/test_directdriver.py @@ -19,8 +19,9 @@ # limitations under the License. +from neobolt.exceptions import ServiceUnavailable + from neo4j.v1 import GraphDatabase, DirectDriver -from neo4j.exceptions import ServiceUnavailable from test.stub.tools import StubTestCase, StubCluster diff --git a/test/stub/test_routing.py b/test/stub/test_routing.py deleted file mode 100644 index ece32c510..000000000 --- a/test/stub/test_routing.py +++ /dev/null @@ -1,574 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from neo4j.bolt import connect, ProtocolError, ServiceUnavailable -from neo4j.v1 import basic_auth, READ_ACCESS, WRITE_ACCESS, RoutingTable, RoutingConnectionPool - -from test.stub.tools import StubCluster, StubTestCase - -VALID_ROUTING_RECORD = { - "ttl": 300, - "servers": [ - {"role": "ROUTE", "addresses": ["127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"]}, - {"role": "READ", "addresses": ["127.0.0.1:9004", "127.0.0.1:9005"]}, - {"role": "WRITE", "addresses": ["127.0.0.1:9006"]}, - ], -} - -VALID_ROUTING_RECORD_WITH_EXTRA_ROLE = { - "ttl": 300, - "servers": [ - {"role": "ROUTE", "addresses": ["127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"]}, - {"role": "READ", "addresses": ["127.0.0.1:9004", "127.0.0.1:9005"]}, - {"role": "WRITE", "addresses": ["127.0.0.1:9006"]}, - {"role": "MAGIC", "addresses": ["127.0.0.1:9007"]}, - ], -} - -INVALID_ROUTING_RECORD = { - "X": 1, -} - -UNREACHABLE_ADDRESS = ("127.0.0.1", 8080) - - -def connector(address, error_handler): - return connect(address, error_handler=error_handler, auth=basic_auth("neotest", "neotest")) - - -def RoutingPool(*routers): - return RoutingConnectionPool(connector, UNREACHABLE_ADDRESS, {}, *routers) - - -class RoutingConnectionPoolFetchRoutingInfoTestCase(StubTestCase): - def test_should_get_info_from_router(self): - with StubCluster({9001: "router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool() as pool: - result = pool.fetch_routing_info(address) - assert len(result) == 1 - record = result[0] - assert record["ttl"] == 300 - assert record["servers"] == [ - {"role": "ROUTE", "addresses": ["127.0.0.1:9001", "127.0.0.1:9002", - "127.0.0.1:9003"]}, - {"role": "READ", "addresses": ["127.0.0.1:9004", "127.0.0.1:9005"]}, - {"role": "WRITE", "addresses": ["127.0.0.1:9006"]}, - ] - - def test_should_remove_router_if_cannot_connect(self): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert address in pool.routing_table.routers - _ = pool.fetch_routing_info(address) - assert address not in pool.routing_table.routers - - def test_should_remove_router_if_connection_drops(self): - with StubCluster({9001: "rude_router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert address in pool.routing_table.routers - _ = pool.fetch_routing_info(address) - assert address not in pool.routing_table.routers - - def test_should_not_fail_if_cannot_connect_but_router_already_removed(self): - address = ("127.0.0.1", 9001) - with RoutingPool() as pool: - assert address not in pool.routing_table.routers - _ = pool.fetch_routing_info(address) - assert address not in pool.routing_table.routers - - def test_should_not_fail_if_connection_drops_but_router_already_removed(self): - with StubCluster({9001: "rude_router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool() as pool: - assert address not in pool.routing_table.routers - _ = pool.fetch_routing_info(address) - assert address not in pool.routing_table.routers - - def test_should_return_none_if_cannot_connect(self): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - result = pool.fetch_routing_info(address) - assert result is None - - def test_should_return_none_if_connection_drops(self): - with StubCluster({9001: "rude_router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - result = pool.fetch_routing_info(address) - assert result is None - - def test_should_fail_for_non_router(self): - with StubCluster({9001: "non_router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - with self.assertRaises(ServiceUnavailable): - _ = pool.fetch_routing_info(address) - - def test_should_fail_if_database_error(self): - with StubCluster({9001: "broken_router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - with self.assertRaises(ServiceUnavailable): - _ = pool.fetch_routing_info(address) - - def test_should_call_get_routing_tables_with_context(self): - with StubCluster({9001: "get_routing_table_with_context.script"}): - address = ("127.0.0.1", 9001) - routing_context = {"name": "molly", "age": "1"} - with RoutingConnectionPool(connector, UNREACHABLE_ADDRESS, routing_context) as pool: - pool.fetch_routing_info(address) - - def test_should_call_get_routing_tables(self): - with StubCluster({9001: "get_routing_table.script"}): - address = ("127.0.0.1", 9001) - with RoutingConnectionPool(connector, UNREACHABLE_ADDRESS, {}) as pool: - pool.fetch_routing_info(address) - - -class RoutingConnectionPoolFetchRoutingTableTestCase(StubTestCase): - def test_should_get_table_from_router(self): - with StubCluster({9001: "router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool() as pool: - table = pool.fetch_routing_table(address) - assert table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002), - ("127.0.0.1", 9003)} - assert table.readers == {("127.0.0.1", 9004), ("127.0.0.1", 9005)} - assert table.writers == {("127.0.0.1", 9006)} - assert table.ttl == 300 - assert not pool.missing_writer - - def test_null_info_should_return_null_table(self): - address = ("127.0.0.1", 9001) - with RoutingPool() as pool: - table = pool.fetch_routing_table(address) - assert table is None - - def test_no_routers_should_raise_protocol_error(self): - with StubCluster({9001: "router_no_routers.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool() as pool: - with self.assertRaises(ProtocolError): - _ = pool.fetch_routing_table(address) - - def test_no_readers_should_raise_protocol_error(self): - with StubCluster({9001: "router_no_readers.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool() as pool: - with self.assertRaises(ProtocolError): - _ = pool.fetch_routing_table(address) - - def test_no_writers_should_return_table_with_no_writer(self): - with StubCluster({9001: "router_no_writers.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool() as pool: - table = pool.fetch_routing_table(address) - assert table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002), - ("127.0.0.1", 9003)} - assert table.readers == {("127.0.0.1", 9004), ("127.0.0.1", 9005)} - assert not table.writers - assert table.ttl == 300 - assert pool.missing_writer - - -class RoutingConnectionPoolUpdateRoutingTableTestCase(StubTestCase): - scenarios = { - (None,): ServiceUnavailable, - (RoutingTable,): RoutingTable, - (ServiceUnavailable,): ServiceUnavailable, - (None, None): ServiceUnavailable, - (None, RoutingTable): RoutingTable, - (None, ServiceUnavailable): ServiceUnavailable, - (None, None, None): ServiceUnavailable, - (None, None, RoutingTable): RoutingTable, - (None, None, ServiceUnavailable): ServiceUnavailable, - } - - def test_roll_back_to_initial_server_if_failed_update_with_existing_routers(self): - with StubCluster({9001: "router.script"}): - initial_address = ("127.0.0.1", 9001) # roll back addresses - routers = [("127.0.0.1", 9002), ("127.0.0.1", 9003)] # not reachable servers - with RoutingConnectionPool(connector, initial_address, {}, *routers) as pool: - pool.update_routing_table() - table = pool.routing_table - assert table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002), - ("127.0.0.1", 9003)} - assert table.readers == {("127.0.0.1", 9004), ("127.0.0.1", 9005)} - assert table.writers == {("127.0.0.1", 9006)} - assert table.ttl == 300 - - def test_try_initial_server_first_if_missing_writer(self): - with StubCluster({9001: "router.script"}): - initial_address = ("127.0.0.1", 9001) - with RoutingConnectionPool(connector, initial_address, {}) as pool: - pool.missing_writer = True - pool.update_routing_table() - table = pool.routing_table - assert table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002), - ("127.0.0.1", 9003)} - assert table.readers == {("127.0.0.1", 9004), ("127.0.0.1", 9005)} - assert table.writers == {("127.0.0.1", 9006)} - assert table.ttl == 300 - assert not pool.missing_writer - - def test_update_with_no_routers_should_signal_service_unavailable(self): - with RoutingPool() as pool: - with self.assertRaises(ServiceUnavailable): - pool.update_routing_table() - - def test_update_scenarios(self): - for server_outcomes, overall_outcome in self.scenarios.items(): - self._test_server_outcome(server_outcomes, overall_outcome) - - def _test_server_outcome(self, server_outcomes, overall_outcome): - print("%r -> %r" % (server_outcomes, overall_outcome)) - servers = {} - routers = [] - for port, outcome in enumerate(server_outcomes, 9001): - if outcome is None: - servers[port] = "rude_router.script" - elif outcome is RoutingTable: - servers[port] = "router.script" - elif outcome is ServiceUnavailable: - servers[port] = "non_router.script" - else: - assert False, "Unexpected server outcome %r" % outcome - routers.append(("127.0.0.1", port)) - with StubCluster(servers): - with RoutingPool(*routers) as pool: - if overall_outcome is RoutingTable: - pool.update_routing_table() - table = pool.routing_table - assert table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002), - ("127.0.0.1", 9003)} - assert table.readers == {("127.0.0.1", 9004), ("127.0.0.1", 9005)} - assert table.writers == {("127.0.0.1", 9006)} - assert table.ttl == 300 - elif overall_outcome is ServiceUnavailable: - with self.assertRaises(ServiceUnavailable): - pool.update_routing_table() - else: - assert False, "Unexpected overall outcome %r" % overall_outcome - - -class RoutingConnectionPoolEnsureRoutingTableTestCase(StubTestCase): - def test_should_update_if_stale(self): - with StubCluster({9001: "router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - first_updated_time = pool.routing_table.last_updated_time - pool.routing_table.ttl = 0 - pool.ensure_routing_table_is_fresh(WRITE_ACCESS) - second_updated_time = pool.routing_table.last_updated_time - assert second_updated_time != first_updated_time - assert not pool.missing_writer - - def test_should_not_update_if_fresh(self): - with StubCluster({9001: "router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - pool.ensure_routing_table_is_fresh(WRITE_ACCESS) - first_updated_time = pool.routing_table.last_updated_time - pool.ensure_routing_table_is_fresh(WRITE_ACCESS) - second_updated_time = pool.routing_table.last_updated_time - assert second_updated_time == first_updated_time - assert not pool.missing_writer - - def test_should_flag_reading_without_writer(self): - with StubCluster({9001: "router_no_writers.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert not pool.routing_table.is_fresh(READ_ACCESS) - assert not pool.routing_table.is_fresh(WRITE_ACCESS) - pool.ensure_routing_table_is_fresh(READ_ACCESS) - assert pool.missing_writer - - def test_should_purge_idle_connections_from_connection_pool(self): - with StubCluster({9006: "router.script", 9001: "router_with_multiple_servers.script"}): - address = ("127.0.0.1", 9006) - with RoutingPool(address) as pool: - # close the acquired connection with init router and then set it to be idle - conn = pool.acquire(WRITE_ACCESS) - conn.close() - conn.in_use = False - - table = pool.routing_table - assert table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002), - ("127.0.0.1", 9003)} - assert table.readers == {("127.0.0.1", 9004), ("127.0.0.1", 9005)} - assert table.writers == {("127.0.0.1", 9006)} - assert set(pool.connections.keys()) == {("127.0.0.1", 9006)} - - # immediately expire the routing table to enforce update a new routing table - pool.routing_table.ttl = 0 - pool.ensure_routing_table_is_fresh(WRITE_ACCESS) - table = pool.routing_table - assert table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002)} - assert table.readers == {("127.0.0.1", 9001), ("127.0.0.1", 9003)} - assert table.writers == {("127.0.0.1", 9004)} - - assert set(pool.connections.keys()) == {("127.0.0.1", 9001)} - - def test_should_not_purge_idle_connections_from_connection_pool(self): - with StubCluster({9006: "router.script", 9001: "router_with_multiple_servers.script"}): - address = ("127.0.0.1", 9006) - with RoutingPool(address) as pool: - # close the acquired connection with init router and then set it to be inUse - conn = pool.acquire(WRITE_ACCESS) - conn.close() - conn.in_use = True - - table = pool.routing_table - assert table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002), - ("127.0.0.1", 9003)} - assert table.readers == {("127.0.0.1", 9004), ("127.0.0.1", 9005)} - assert table.writers == {("127.0.0.1", 9006)} - assert set(pool.connections.keys()) == {("127.0.0.1", 9006)} - - # immediately expire the routing table to enforce update a new routing table - pool.routing_table.ttl = 0 - pool.ensure_routing_table_is_fresh(WRITE_ACCESS) - table = pool.routing_table - assert table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002)} - assert table.readers == {("127.0.0.1", 9001), ("127.0.0.1", 9003)} - assert table.writers == {("127.0.0.1", 9004)} - - assert set(pool.connections.keys()) == {("127.0.0.1", 9001), ("127.0.0.1", 9006)} - - - # TODO: fix flaky test - # def test_concurrent_refreshes_should_not_block_if_fresh(self): - # address = ("127.0.0.1", 9001) - # table = RoutingTable.parse_routing_info([VALID_ROUTING_RECORD]) - # - # with RoutingPool(address) as pool: - # semaphore = Semaphore() - # - # class Refresher(Thread): - # - # refreshed = None - # - # def run(self): - # self.refreshed = pool.refresh_routing_table() - # - # class BlockingRefresher(Refresher): - # - # @classmethod - # def blocking_update(cls): - # pool.routing_table.update(table) - # semaphore.acquire() - # semaphore.release() - # return table - # - # def run(self): - # with patch.object(RoutingConnectionPool, "update_routing_table", - # side_effect=self.blocking_update): - # super(BlockingRefresher, self).run() - # - # first = BlockingRefresher() - # second = Refresher() - # - # assert not pool.routing_table.is_fresh() - # - # semaphore.acquire() - # first.start() - # second.start() - # sleep(1) - # assert not second.is_alive() # second call should return immediately without blocking - # second.join() - # semaphore.release() - # first.join() - # - # assert first.refreshed - # assert not second.refreshed - # assert pool.routing_table.is_fresh() - - # TODO: fix flaky test - # def test_concurrent_refreshes_should_block_if_stale(self): - # address = ("127.0.0.1", 9001) - # table = RoutingTable.parse_routing_info([VALID_ROUTING_RECORD]) - # - # with RoutingPool(address) as pool: - # semaphore = Semaphore() - # - # class Refresher(Thread): - # - # refreshed = None - # - # def run(self): - # self.refreshed = pool.refresh_routing_table() - # - # class BlockingRefresher(Refresher): - # - # @classmethod - # def blocking_update(cls): - # semaphore.acquire() - # semaphore.release() - # pool.routing_table.update(table) - # return table - # - # def run(self): - # with patch.object(RoutingConnectionPool, "update_routing_table", - # side_effect=self.blocking_update): - # super(BlockingRefresher, self).run() - # - # first = BlockingRefresher() - # second = Refresher() - # - # assert not pool.routing_table.is_fresh() - # - # semaphore.acquire() - # first.start() - # second.start() - # sleep(1) - # assert second.is_alive() # second call should block - # semaphore.release() - # second.join() - # first.join() - # - # assert first.refreshed - # assert not second.refreshed - # assert pool.routing_table.is_fresh() - - -class RoutingConnectionPoolAcquireForReadTestCase(StubTestCase): - def test_should_refresh(self): - with StubCluster({9001: "router.script", 9004: "empty.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert not pool.routing_table.is_fresh(READ_ACCESS) - _ = pool.acquire(access_mode=READ_ACCESS) - assert pool.routing_table.is_fresh(READ_ACCESS) - assert not pool.missing_writer - - def test_connected_to_reader(self): - with StubCluster({9001: "router.script", 9004: "empty.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert not pool.routing_table.is_fresh(READ_ACCESS) - connection = pool.acquire(access_mode=READ_ACCESS) - assert connection.server.address in pool.routing_table.readers - assert not pool.missing_writer - - def test_should_retry_if_first_reader_fails(self): - with StubCluster({9001: "router.script", - 9004: "fail_on_init.script", - 9005: "empty.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert not pool.routing_table.is_fresh(READ_ACCESS) - _ = pool.acquire(access_mode=READ_ACCESS) - assert ("127.0.0.1", 9004) not in pool.routing_table.readers - assert ("127.0.0.1", 9005) in pool.routing_table.readers - - def test_should_connect_to_read_in_absent_of_writer(self): - with StubCluster({9001: "router_no_writers.script", 9004: "empty.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert not pool.routing_table.is_fresh(READ_ACCESS) - connection = pool.acquire(access_mode=READ_ACCESS) - assert connection.server.address in pool.routing_table.readers - assert not pool.routing_table.is_fresh(WRITE_ACCESS) - assert pool.missing_writer - - -class RoutingConnectionPoolAcquireForWriteTestCase(StubTestCase): - def test_should_refresh(self): - with StubCluster({9001: "router.script", 9006: "empty.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert not pool.routing_table.is_fresh(WRITE_ACCESS) - _ = pool.acquire(access_mode=WRITE_ACCESS) - assert pool.routing_table.is_fresh(WRITE_ACCESS) - assert not pool.missing_writer - - def test_connected_to_writer(self): - with StubCluster({9001: "router.script", 9006: "empty.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert not pool.routing_table.is_fresh(WRITE_ACCESS) - connection = pool.acquire(access_mode=WRITE_ACCESS) - assert connection.server.address in pool.routing_table.writers - assert not pool.missing_writer - - def test_should_retry_if_first_writer_fails(self): - with StubCluster({9001: "router_with_multiple_writers.script", - 9006: "fail_on_init.script", - 9007: "empty.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert not pool.routing_table.is_fresh(WRITE_ACCESS) - _ = pool.acquire(access_mode=WRITE_ACCESS) - assert ("127.0.0.1", 9006) not in pool.routing_table.writers - assert ("127.0.0.1", 9007) in pool.routing_table.writers - - def test_should_error_to_writer_in_absent_of_reader(self): - with StubCluster({9001: "router_no_readers.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - assert not pool.routing_table.is_fresh(WRITE_ACCESS) - with self.assertRaises(ProtocolError): - _ = pool.acquire(access_mode=WRITE_ACCESS) - assert not pool.routing_table.is_fresh(READ_ACCESS) - assert not pool.routing_table.is_fresh(WRITE_ACCESS) - assert not pool.missing_writer - - -class RoutingConnectionPoolDeactivateTestCase(StubTestCase): - def test_should_remove_router_from_routing_table_if_present(self): - with StubCluster({9001: "router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - pool.ensure_routing_table_is_fresh(WRITE_ACCESS) - target = ("127.0.0.1", 9001) - assert target in pool.routing_table.routers - pool.deactivate(target) - assert target not in pool.routing_table.routers - - def test_should_remove_reader_from_routing_table_if_present(self): - with StubCluster({9001: "router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - pool.ensure_routing_table_is_fresh(WRITE_ACCESS) - target = ("127.0.0.1", 9004) - assert target in pool.routing_table.readers - pool.deactivate(target) - assert target not in pool.routing_table.readers - - def test_should_remove_writer_from_routing_table_if_present(self): - with StubCluster({9001: "router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - pool.ensure_routing_table_is_fresh(WRITE_ACCESS) - target = ("127.0.0.1", 9006) - assert target in pool.routing_table.writers - pool.deactivate(target) - assert target not in pool.routing_table.writers - - def test_should_not_fail_if_absent(self): - with StubCluster({9001: "router.script"}): - address = ("127.0.0.1", 9001) - with RoutingPool(address) as pool: - pool.ensure_routing_table_is_fresh(WRITE_ACCESS) - target = ("127.0.0.1", 9007) - pool.deactivate(target) diff --git a/test/stub/test_routingdriver.py b/test/stub/test_routingdriver.py index f137ac380..9db0e23ff 100644 --- a/test/stub/test_routingdriver.py +++ b/test/stub/test_routingdriver.py @@ -19,11 +19,12 @@ # limitations under the License. -from neo4j.v1 import GraphDatabase, READ_ACCESS, WRITE_ACCESS, SessionExpired, \ - RoutingDriver, RoutingConnectionPool, LeastConnectedLoadBalancingStrategy, LOAD_BALANCING_STRATEGY_ROUND_ROBIN, \ - RoundRobinLoadBalancingStrategy, TransientError +from neobolt.bolt import ProtocolError, ServiceUnavailable +from neobolt.config import LOAD_BALANCING_STRATEGY_ROUND_ROBIN +from neobolt.routing import LeastConnectedLoadBalancingStrategy, RoundRobinLoadBalancingStrategy + from neo4j.exceptions import ClientError -from neo4j.bolt import ProtocolError, ServiceUnavailable +from neo4j.v1 import GraphDatabase, READ_ACCESS, WRITE_ACCESS, SessionExpired, RoutingDriver, TransientError from test.stub.tools import StubTestCase, StubCluster @@ -220,6 +221,7 @@ def test_should_error_when_missing_reader(self): GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False) def test_default_load_balancing_strategy_is_least_connected(self): + from neobolt.routing import RoutingConnectionPool with StubCluster({9001: "router.script"}): uri = "bolt+routing://127.0.0.1:9001" with GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False) as driver: @@ -228,6 +230,7 @@ def test_default_load_balancing_strategy_is_least_connected(self): self.assertIsInstance(driver._pool.load_balancing_strategy, LeastConnectedLoadBalancingStrategy) def test_can_select_round_robin_load_balancing_strategy(self): + from neobolt.routing import RoutingConnectionPool with StubCluster({9001: "router.script"}): uri = "bolt+routing://127.0.0.1:9001" with GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False, diff --git a/test/unit/test_addressing.py b/test/unit/test_addressing.py deleted file mode 100644 index 0f305fc12..000000000 --- a/test/unit/test_addressing.py +++ /dev/null @@ -1,69 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from unittest import TestCase - -from neo4j.addressing import SocketAddress - - -class RoutingTableParseAddressTestCase(TestCase): - - def test_should_parse_ipv4_address_and_port(self): - parsed = SocketAddress.parse("127.0.0.1:7687") - assert parsed == ("127.0.0.1", 7687) - - def test_should_parse_ipv6_address_and_port(self): - parsed = SocketAddress.parse("[::1]:7687") - assert parsed == ("::1", 7687, 0, 0) - - def test_should_parse_host_name_and_port(self): - parsed = SocketAddress.parse("localhost:7687") - assert parsed == ("localhost", 7687) - - def test_should_fail_on_non_numeric_port(self): - with self.assertRaises(ValueError): - _ = SocketAddress.parse("127.0.0.1:X") - - def test_parse_empty_routing_context(self): - verify_routing_context({}, "bolt+routing://127.0.0.1/cat?") - verify_routing_context({}, "bolt+routing://127.0.0.1/cat") - verify_routing_context({}, "bolt+routing://127.0.0.1/?") - verify_routing_context({}, "bolt+routing://127.0.0.1/") - verify_routing_context({}, "bolt+routing://127.0.0.1?") - verify_routing_context({}, "bolt+routing://127.0.0.1") - - def test_parse_routing_context(self): - verify_routing_context({"name": "molly", "color": "white"}, "bolt+routing://127.0.0.1/cat?name=molly&color=white") - verify_routing_context({"name": "molly", "color": "white"}, "bolt+routing://127.0.0.1/?name=molly&color=white") - verify_routing_context({"name": "molly", "color": "white"}, "bolt+routing://127.0.0.1?name=molly&color=white") - - def test_should_error_when_value_missing(self): - with self.assertRaises(ValueError): - SocketAddress.parse_routing_context("bolt+routing://127.0.0.1/?name=&color=white") - - def test_should_error_when_key_duplicate(self): - with self.assertRaises(ValueError): - SocketAddress.parse_routing_context("bolt+routing://127.0.0.1/?name=molly&name=white") - - -def verify_routing_context(expected, uri): - context = SocketAddress.parse_routing_context(uri) - assert context == expected diff --git a/test/unit/test_api.py b/test/unit/test_api.py index 34221af57..2a2f43b36 100644 --- a/test/unit/test_api.py +++ b/test/unit/test_api.py @@ -22,7 +22,7 @@ from unittest import TestCase from uuid import uuid4 -from neo4j.v1.types import fix_parameters +from neo4j import fix_parameters def dehydrated_value(value): diff --git a/test/unit/test_chunkedinputbuffer.py b/test/unit/test_chunkedinputbuffer.py deleted file mode 100644 index 044a3bf85..000000000 --- a/test/unit/test_chunkedinputbuffer.py +++ /dev/null @@ -1,257 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from unittest import TestCase - -from neo4j.bolt.io import ChunkedInputBuffer as PyChunkedInputBuffer - - -class ChunkedInputBufferTestCase(TestCase): - ChunkedInputBuffer = PyChunkedInputBuffer - - def test_should_start_empty(self): - # Given - buffer = self.ChunkedInputBuffer() - - # Then - assert buffer.view().tobytes() == b"" - - def test_should_be_able_to_set_capacity(self): - # Given - buffer = self.ChunkedInputBuffer(capacity=10) - - # Then - assert buffer.capacity() == 10 - - def test_should_be_able_to_load_data(self): - # Given - buffer = self.ChunkedInputBuffer() - - # When - buffer.load(b"\x00\x05hello") - - # Then - assert buffer.view().tobytes() == b"\x00\x05hello" - - def test_should_be_able_to_load_multiple_times(self): - # Given - buffer = self.ChunkedInputBuffer() - - # When - buffer.load(b"\x00\x05hello") - buffer.load(b"\x00\x05world") - - # Then - assert buffer.view().tobytes() == b"\x00\x05hello\x00\x05world" - - def test_should_be_able_to_load_after_discard(self): - # Given - buffer = self.ChunkedInputBuffer() - - # When - buffer.load(b"\x00\x05hello\x00\x00") - buffer.frame_message() - frame = buffer.frame() - - # Then - assert frame.panes() == [(2, 7)] - - # When - buffer.discard_message() - buffer.load(b"\x00\x07bonjour\x00\x00") - buffer.frame_message() - frame = buffer.frame() - - # Then - assert frame.panes() == [(2, 9)] - - def test_should_auto_extend_on_load(self): - # Given - buffer = self.ChunkedInputBuffer(capacity=10) - buffer.load(b"\x00\x05hello") - - # When - buffer.load(b"\x00\x07bonjour") - - # Then - assert buffer.capacity() == 16 - - def test_should_start_with_no_frame(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello\x00\x00") - buffer.load(b"\x00\x07bonjour\x00\x00") - - # Then - assert buffer.frame() is None - - def test_should_be_able_to_frame_message(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello\x00\x00") - buffer.load(b"\x00\x07bonjour\x00\x00") - - # When - framed = buffer.frame_message() - - # Then - assert framed - assert buffer.frame().panes() == [(2, 7)] - - def test_should_be_able_to_frame_empty_message(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x00") - - # When - framed = buffer.frame_message() - - # Then - assert framed - assert buffer.frame().panes() == [] - - def test_should_not_be_able_to_frame_empty_buffer(self): - # Given - buffer = self.ChunkedInputBuffer() - - # When - framed = buffer.frame_message() - - # Then - assert not framed - - def test_should_not_be_able_to_frame_partial_message(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello") - - # When - framed = buffer.frame_message() - - # Then - assert not framed - - def test_should_be_able_to_discard_message(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello\x00\x00") - buffer.load(b"\x00\x07bonjour\x00\x00") - buffer.frame_message() - - # When - buffer.discard_message() - - # Then - assert buffer.frame() is None - - def test_should_be_able_to_discard_empty_message(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x00") - buffer.frame_message() - - # When - buffer.discard_message() - - # Then - assert buffer.frame() is None - - def test_discarding_message_should_move_read_pointer(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello\x00\x00") - buffer.load(b"\x00\x07bonjour\x00\x00") - buffer.frame_message() - buffer.discard_message() - - # When - framed = buffer.frame_message() - - # Then - assert framed - assert buffer.frame().panes() == [(2, 9)] - - def test_should_be_able_to_frame_successive_messages_without_discarding(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello\x00\x00") - buffer.load(b"\x00\x07bonjour\x00\x00") - buffer.frame_message() - - # When - framed = buffer.frame_message() - - # Then - assert framed - assert buffer.frame().panes() == [(2, 9)] - - def test_discarding_message_should_not_recycle_buffer(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello\x00\x00") - buffer.load(b"\x00\x07bonjour\x00\x00") - buffer.frame_message() - - # When - buffer.discard_message() - - # Then - assert buffer.view().tobytes() == b"\x00\x05hello\x00\x00\x00\x07bonjour\x00\x00" - - def test_should_not_be_able_to_frame_message_if_empty(self): - # Given - buffer = self.ChunkedInputBuffer() - - # Then - assert not buffer.frame_message() - - def test_should_not_be_able_to_frame_message_if_incomplete(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello") - - # Then - assert not buffer.frame_message() - - def test_should_be_able_to_frame_message_if_complete(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello\x00\x00") - - # Then - assert buffer.frame_message() - - def test_should_be_able_to_frame_message_if_complete_with_more(self): - # Given - buffer = self.ChunkedInputBuffer() - buffer.load(b"\x00\x05hello\x00\x00\x00\x05world\x00\x00") - - # Then - assert buffer.frame_message() - - -try: - from neo4j.bolt._io import ChunkedInputBuffer as CChunkedInputBuffer -except ImportError: - pass -else: - class CChunkedInputBufferTestCase(ChunkedInputBufferTestCase): - ChunkedInputBuffer = CChunkedInputBuffer diff --git a/test/unit/test_chunkedoutputbuffer.py b/test/unit/test_chunkedoutputbuffer.py deleted file mode 100644 index a5ebfa536..000000000 --- a/test/unit/test_chunkedoutputbuffer.py +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from unittest import TestCase - -from neo4j.bolt.io import ChunkedOutputBuffer as PyChunkedOutputBuffer - - -class ChunkedOutputBufferTestCase(TestCase): - ChunkedOutputBuffer = PyChunkedOutputBuffer - - def test_should_start_empty(self): - # Given - buffer = self.ChunkedOutputBuffer() - - # Then - assert buffer.view().tobytes() == b"" - - def test_should_be_able_to_set_max_chunk_size(self): - # Given - buffer = self.ChunkedOutputBuffer(max_chunk_size=4) - - # Then - assert buffer.max_chunk_size() == 4 - - def test_small_data_should_be_directly_appended(self): - # Given - buffer = self.ChunkedOutputBuffer() - - # When - buffer.write(b"hello") - - # Then - assert buffer.view().tobytes() == b"\x00\x05hello" - - def test_overflow_data_should_use_a_new_chunk(self): - # Given - buffer = self.ChunkedOutputBuffer(max_chunk_size=6) - - # When - buffer.write(b"over") - buffer.write(b"flow") - - # Then - assert buffer.view().tobytes() == b"\x00\x04over\x00\x04flow" - - def test_big_data_should_be_split_across_chunks(self): - # Given - buffer = self.ChunkedOutputBuffer(max_chunk_size=2) - - # When - buffer.write(b"octopus") - - # Then - assert buffer.view().tobytes() == b"\x00\x02oc\x00\x02to\x00\x02pu\x00\x01s" - - def test_clear_should_clear_everything(self): - # Given - buffer = self.ChunkedOutputBuffer() - - # When - buffer.write(b"redacted") - buffer.clear() - - # Then - assert buffer.view().tobytes() == b"" - - def test_cleared_buffer_should_be_reusable(self): - # Given - buffer = self.ChunkedOutputBuffer() - - # When - buffer.write(b"Windows") - buffer.clear() - buffer.write(b"Linux") - - # Then - assert buffer.view().tobytes() == b"\x00\x05Linux" - - def test_should_be_able_to_force_chunks(self): - # Given - buffer = self.ChunkedOutputBuffer() - - # When - buffer.write(b"hello") - buffer.chunk() - buffer.write(b"world") - buffer.chunk() - - # Then - assert buffer.view().tobytes() == b"\x00\x05hello\x00\x05world" - - def test_should_be_able_to_force_empty_chunk(self): - # Given - buffer = self.ChunkedOutputBuffer() - - # When - buffer.write(b"hello") - buffer.chunk() - buffer.chunk() - - # Then - assert buffer.view().tobytes() == b"\x00\x05hello\x00\x00" - - -try: - from neo4j.bolt._io import ChunkedOutputBuffer as CChunkedOutputBuffer -except ImportError: - pass -else: - class CChunkedOutputBufferTestCase(ChunkedOutputBufferTestCase): - ChunkedOutputBuffer = CChunkedOutputBuffer diff --git a/test/unit/test_connection.py b/test/unit/test_connection.py deleted file mode 100644 index baae4ee0e..000000000 --- a/test/unit/test_connection.py +++ /dev/null @@ -1,198 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from __future__ import print_function -from unittest import TestCase -from threading import Thread, Event -from neo4j.v1 import DirectConnectionErrorHandler, ServiceUnavailable -from neo4j.bolt import Connection, ConnectionPool -from neo4j.exceptions import ClientError - -class FakeSocket(object): - def __init__(self, address): - self.address = address - - def getpeername(self): - return self.address - - def sendall(self, data): - return - - def close(self): - return - - -class QuickConnection(object): - - def __init__(self, socket): - self.socket = socket - self.address = socket.getpeername() - - def reset(self): - pass - - def close(self): - self.socket.close() - - def closed(self): - return False - - def defunct(self): - return False - - def timedout(self): - return False - - -def connector(address, _): - return QuickConnection(FakeSocket(address)) - - -class ConnectionTestCase(TestCase): - - def test_conn_timedout(self): - address = ("127.0.0.1", 7687) - connection = Connection(address, FakeSocket(address), 1, DirectConnectionErrorHandler(), max_connection_lifetime=0) - self.assertEqual(connection.timedout(), True) - - def test_conn_not_timedout_if_not_enabled(self): - address = ("127.0.0.1", 7687) - connection = Connection(address, FakeSocket(address), 1, DirectConnectionErrorHandler(), - max_connection_lifetime=-1) - self.assertEqual(connection.timedout(), False) - - def test_conn_not_timedout(self): - address = ("127.0.0.1", 7687) - connection = Connection(address, FakeSocket(address), 1, DirectConnectionErrorHandler(), - max_connection_lifetime=999999999) - self.assertEqual(connection.timedout(), False) - - -class ConnectionPoolTestCase(TestCase): - def setUp(self): - self.pool = ConnectionPool(connector, DirectConnectionErrorHandler()) - - def tearDown(self): - self.pool.close() - - def assert_pool_size(self, address, expected_active, expected_inactive, pool=None): - if pool is None: - pool = self.pool - try: - connections = pool.connections[address] - except KeyError: - assert 0 == expected_active - assert 0 == expected_inactive - else: - assert len([c for c in connections if c.in_use]) == expected_active - assert len([c for c in connections if not c.in_use]) == expected_inactive - - def test_can_acquire(self): - address = ("127.0.0.1", 7687) - connection = self.pool.acquire_direct(address) - assert connection.address == address - self.assert_pool_size(address, 1, 0) - - def test_can_acquire_twice(self): - address = ("127.0.0.1", 7687) - connection_1 = self.pool.acquire_direct(address) - connection_2 = self.pool.acquire_direct(address) - assert connection_1.address == address - assert connection_2.address == address - assert connection_1 is not connection_2 - self.assert_pool_size(address, 2, 0) - - def test_can_acquire_two_addresses(self): - address_1 = ("127.0.0.1", 7687) - address_2 = ("127.0.0.1", 7474) - connection_1 = self.pool.acquire_direct(address_1) - connection_2 = self.pool.acquire_direct(address_2) - assert connection_1.address == address_1 - assert connection_2.address == address_2 - self.assert_pool_size(address_1, 1, 0) - self.assert_pool_size(address_2, 1, 0) - - def test_can_acquire_and_release(self): - address = ("127.0.0.1", 7687) - connection = self.pool.acquire_direct(address) - self.assert_pool_size(address, 1, 0) - self.pool.release(connection) - self.assert_pool_size(address, 0, 1) - - def test_releasing_twice(self): - address = ("127.0.0.1", 7687) - connection = self.pool.acquire_direct(address) - self.pool.release(connection) - self.assert_pool_size(address, 0, 1) - self.pool.release(connection) - self.assert_pool_size(address, 0, 1) - - def test_cannot_acquire_after_close(self): - with ConnectionPool(lambda a: QuickConnection(FakeSocket(a)), DirectConnectionErrorHandler()) as pool: - pool.close() - with self.assertRaises(ServiceUnavailable): - _ = pool.acquire_direct("X") - - def test_in_use_count(self): - address = ("127.0.0.1", 7687) - self.assertEqual(self.pool.in_use_connection_count(address), 0) - connection = self.pool.acquire_direct(address) - self.assertEqual(self.pool.in_use_connection_count(address), 1) - self.pool.release(connection) - self.assertEqual(self.pool.in_use_connection_count(address), 0) - - def test_max_conn_pool_size(self): - with ConnectionPool(connector, DirectConnectionErrorHandler, - max_connection_pool_size=1, connection_acquisition_timeout=0) as pool: - address = ("127.0.0.1", 7687) - pool.acquire_direct(address) - self.assertEqual(pool.in_use_connection_count(address), 1) - with self.assertRaises(ClientError): - pool.acquire_direct(address) - self.assertEqual(pool.in_use_connection_count(address), 1) - - def test_multithread(self): - with ConnectionPool(connector, DirectConnectionErrorHandler, - max_connection_pool_size=5, connection_acquisition_timeout=10) as pool: - address = ("127.0.0.1", 7687) - releasing_event = Event() - - # We start 10 threads to compete connections from pool with size of 5 - threads = [] - for i in range(10): - t = Thread(target=acquire_release_conn, args=(pool, address, releasing_event)) - t.start() - threads.append(t) - - # The pool size should be 5, all are in-use - self.assert_pool_size(address, 5, 0, pool) - # Now we allow thread to release connections they obtained from pool - releasing_event.set() - - # wait for all threads to release connections back to pool - for t in threads: - t.join() - # The pool size is still 5, but all are free - self.assert_pool_size(address, 0, 5, pool) - - -def acquire_release_conn(pool, address, releasing_event): - conn = pool.acquire_direct(address) - releasing_event.wait() - pool.release(conn) \ No newline at end of file diff --git a/test/unit/test_messageframe.py b/test/unit/test_messageframe.py deleted file mode 100644 index ee703ca27..000000000 --- a/test/unit/test_messageframe.py +++ /dev/null @@ -1,123 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -from unittest import TestCase - -from neo4j.util import import_best as _import_best - -MessageFrame = _import_best("neo4j.bolt._io", "neo4j.bolt.io").MessageFrame - - -class MessageFrameTestCase(TestCase): - - def test_should_be_able_to_read_int(self): - # Given - frame = MessageFrame(memoryview(b"\x00\x03ABC\x00\x00"), [(2, 5)]) - - # When - values = [frame.read_int() for _ in range(4)] - - # Then - assert values == [65, 66, 67, -1] - - def test_should_be_able_to_read_int_across_chunks(self): - # Given - frame = MessageFrame(memoryview(b"\x00\x03ABC\x00\x03DEF\x00\x00"), [(2, 5), (7, 10)]) - - # When - values = [frame.read_int() for _ in range(7)] - - # Then - assert values == [65, 66, 67, 68, 69, 70, -1] - - def test_should_be_able_to_read_one(self): - # Given - frame = MessageFrame(memoryview(b"\x00\x03ABC\x00\x00"), [(2, 5)]) - - # When - value = frame.read(1) - - # Then - assert bytearray(value) == bytearray(b"A") - assert isinstance(value, memoryview) - - def test_should_be_able_to_read_some(self): - # Given - frame = MessageFrame(memoryview(b"\x00\x03ABC\x00\x00"), [(2, 5)]) - - # When - value = frame.read(2) - - # Then - assert bytearray(value) == bytearray(b"AB") - assert isinstance(value, memoryview) - - def test_should_be_able_to_read_all(self): - # Given - frame = MessageFrame(memoryview(b"\x00\x03ABC\x00\x00"), [(2, 5)]) - - # When - value = frame.read(3) - - # Then - assert bytearray(value) == bytearray(b"ABC") - assert isinstance(value, memoryview) - - def test_should_read_empty_if_exhausted(self): - # Given - frame = MessageFrame(memoryview(b"\x00\x03ABC\x00\x00"), [(2, 5)]) - frame.read(3) - - # When - value = frame.read(3) - - # Then - assert bytearray(value) == bytearray(b"") - - def test_should_be_able_to_read_beyond(self): - # Given - frame = MessageFrame(memoryview(b"\x00\x03ABC\x00\x00"), [(2, 5)]) - - # When - value = frame.read(4) - - # Then - assert bytearray(value) == bytearray(b"ABC") - - def test_should_be_able_to_read_across_chunks(self): - # Given - frame = MessageFrame(memoryview(b"\x00\x03ABC\x00\x03DEF\x00\x00"), [(2, 5), (7, 10)]) - - # When - value = frame.read(4) - - # Then - assert bytearray(value) == bytearray(b"ABCD") - - def test_should_be_able_to_read_all_across_chunks(self): - # Given - frame = MessageFrame(memoryview(b"\x00\x03ABC\x00\x03DEF\x00\x00"), [(2, 5), (7, 10)]) - - # When - value = frame.read(6) - - # Then - assert bytearray(value) == bytearray(b"ABCDEF") diff --git a/test/unit/test_packstream.py b/test/unit/test_packstream.py deleted file mode 100644 index 401443d3e..000000000 --- a/test/unit/test_packstream.py +++ /dev/null @@ -1,301 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - - -import struct -from collections import OrderedDict -from io import BytesIO -from math import pi -from unittest import TestCase -from uuid import uuid4 - -from neo4j.bolt.io import MessageFrame as PyMessageFrame -from neo4j.packstream.packer import Packer as PyPacker -from neo4j.packstream.unpacker import Unpacker as PyUnpacker -from neo4j.packstream.structure import Structure - - -class PackStreamTestCase(TestCase): - MessageFrame = PyMessageFrame - Packer = PyPacker - Unpacker = PyUnpacker - - @classmethod - def packb(cls, *values): - stream = BytesIO() - packer = cls.Packer(stream) - for value in values: - packer.pack(value) - return stream.getvalue() - - @classmethod - def assert_packable(cls, value, packed_value): - stream_out = BytesIO() - packer = cls.Packer(stream_out) - packer.supports_bytes = True - packer.pack(value) - packed = stream_out.getvalue() - try: - assert packed == packed_value - except AssertionError: - raise AssertionError("Packed value %r is %r instead of expected %r" % - (value, packed, packed_value)) - unpacker = cls.Unpacker() - unpacker.attach(cls.MessageFrame(memoryview(packed), [(0, len(packed))])) - unpacked = unpacker.unpack() - try: - assert unpacked == value - except AssertionError: - raise AssertionError("Unpacked value %r is not equal to original %r" % (unpacked, value)) - - def test_none(self): - self.assert_packable(None, b"\xC0") - - def test_boolean(self): - self.assert_packable(True, b"\xC3") - self.assert_packable(False, b"\xC2") - - def test_negative_tiny_int(self): - for z in range(-16, 0): - self.assert_packable(z, bytes(bytearray([z + 0x100]))) - - def test_positive_tiny_int(self): - for z in range(0, 128): - self.assert_packable(z, bytes(bytearray([z]))) - - def test_negative_int8(self): - for z in range(-128, -16): - self.assert_packable(z, bytes(bytearray([0xC8, z + 0x100]))) - - def test_positive_int16(self): - for z in range(128, 32768): - expected = b"\xC9" + struct.pack(">h", z) - self.assert_packable(z, expected) - - def test_negative_int16(self): - for z in range(-32768, -128): - expected = b"\xC9" + struct.pack(">h", z) - self.assert_packable(z, expected) - - def test_positive_int32(self): - for e in range(15, 31): - z = 2 ** e - expected = b"\xCA" + struct.pack(">i", z) - self.assert_packable(z, expected) - - def test_negative_int32(self): - for e in range(15, 31): - z = -(2 ** e + 1) - expected = b"\xCA" + struct.pack(">i", z) - self.assert_packable(z, expected) - - def test_positive_int64(self): - for e in range(31, 63): - z = 2 ** e - expected = b"\xCB" + struct.pack(">q", z) - self.assert_packable(z, expected) - - def test_negative_int64(self): - for e in range(31, 63): - z = -(2 ** e + 1) - expected = b"\xCB" + struct.pack(">q", z) - self.assert_packable(z, expected) - - def test_zero_float64(self): - zero = 0.0 - expected = b"\xC1" + struct.pack(">d", zero) - self.assert_packable(zero, expected) - - def test_tau_float64(self): - tau = 2 * pi - expected = b"\xC1" + struct.pack(">d", tau) - self.assert_packable(tau, expected) - - def test_positive_float64(self): - for e in range(0, 100): - r = float(2 ** e) + 0.5 - expected = b"\xC1" + struct.pack(">d", r) - self.assert_packable(r, expected) - - def test_negative_float64(self): - for e in range(0, 100): - r = -(float(2 ** e) + 0.5) - expected = b"\xC1" + struct.pack(">d", r) - self.assert_packable(r, expected) - - def test_empty_bytes(self): - self.assert_packable(bytearray(), b"\xCC\x00") - - def test_bytes_8(self): - self.assert_packable(bytearray(b"hello"), b"\xCC\x05hello") - - def test_bytes_16(self): - b = bytearray(40000) - self.assert_packable(b, b"\xCD\x9C\x40" + b) - - def test_bytes_32(self): - b = bytearray(80000) - self.assert_packable(b, b"\xCE\x00\x01\x38\x80" + b) - - def test_empty_string(self): - self.assert_packable(u"", b"\x80") - - def test_tiny_string(self): - self.assert_packable(u"hello", b"\x85hello") - - def test_string_8(self): - t = u"A" * 40 - b = t.encode("utf-8") - self.assert_packable(t, b"\xD0\x28" + b) - - def test_string_16(self): - t = u"A" * 40000 - b = t.encode("utf-8") - self.assert_packable(t, b"\xD1\x9C\x40" + b) - - def test_string_32(self): - t = u"A" * 80000 - b = t.encode("utf-8") - self.assert_packable(t, b"\xD2\x00\x01\x38\x80" + b) - - def test_unicode_string(self): - t = u"héllö" - b = t.encode("utf-8") - self.assert_packable(t, bytes(bytearray([0x80 + len(b)])) + b) - - def test_empty_list(self): - self.assert_packable([], b"\x90") - - def test_tiny_list(self): - self.assert_packable([1, 2, 3], b"\x93\x01\x02\x03") - - def test_list_8(self): - l = [1] * 40 - self.assert_packable(l, b"\xD4\x28" + (b"\x01" * 40)) - - def test_list_16(self): - l = [1] * 40000 - self.assert_packable(l, b"\xD5\x9C\x40" + (b"\x01" * 40000)) - - def test_list_32(self): - l = [1] * 80000 - self.assert_packable(l, b"\xD6\x00\x01\x38\x80" + (b"\x01" * 80000)) - - def test_nested_lists(self): - self.assert_packable([[[]]], b"\x91\x91\x90") - - def test_list_stream(self): - packed_value = b"\xD7\x01\x02\x03\xDF" - unpacked_value = [1, 2, 3] - stream_out = BytesIO() - packer = self.Packer(stream_out) - packer.pack_list_stream_header() - packer.pack(1) - packer.pack(2) - packer.pack(3) - packer.pack_end_of_stream() - packed = stream_out.getvalue() - try: - assert packed == packed_value - except AssertionError: - raise AssertionError("Packed value is %r instead of expected %r" % - (packed, packed_value)) - unpacker = self.Unpacker() - unpacker.attach(self.MessageFrame(memoryview(packed), [(0, len(packed))])) - unpacked = unpacker.unpack() - try: - assert unpacked == unpacked_value - except AssertionError: - raise AssertionError("Unpacked value %r is not equal to expected %r" % - (unpacked, unpacked_value)) - - def test_empty_map(self): - self.assert_packable({}, b"\xA0") - - def test_tiny_map(self): - d = OrderedDict([(u"A", 1), (u"B", 2)]) - self.assert_packable(d, b"\xA2\x81A\x01\x81B\x02") - - def test_map_8(self): - d = OrderedDict([(u"A%s" % i, 1) for i in range(40)]) - b = b"".join(self.packb(u"A%s" % i, 1) for i in range(40)) - self.assert_packable(d, b"\xD8\x28" + b) - - def test_map_16(self): - d = OrderedDict([(u"A%s" % i, 1) for i in range(40000)]) - b = b"".join(self.packb(u"A%s" % i, 1) for i in range(40000)) - self.assert_packable(d, b"\xD9\x9C\x40" + b) - - def test_map_32(self): - d = OrderedDict([(u"A%s" % i, 1) for i in range(80000)]) - b = b"".join(self.packb(u"A%s" % i, 1) for i in range(80000)) - self.assert_packable(d, b"\xDA\x00\x01\x38\x80" + b) - - def test_map_stream(self): - packed_value = b"\xDB\x81A\x01\x81B\x02\xDF" - unpacked_value = {u"A": 1, u"B": 2} - stream_out = BytesIO() - packer = self.Packer(stream_out) - packer.pack_map_stream_header() - packer.pack(u"A") - packer.pack(1) - packer.pack(u"B") - packer.pack(2) - packer.pack_end_of_stream() - packed = stream_out.getvalue() - try: - assert packed == packed_value - except AssertionError: - raise AssertionError("Packed value is %r instead of expected %r" % - (packed, packed_value)) - unpacker = self.Unpacker() - unpacker.attach(self.MessageFrame(memoryview(packed), [(0, len(packed))])) - unpacked = unpacker.unpack() - try: - assert unpacked == unpacked_value - except AssertionError: - raise AssertionError("Unpacked value %r is not equal to expected %r" % - (unpacked, unpacked_value)) - - def test_illegal_signature(self): - with self.assertRaises(ValueError): - self.assert_packable(Structure(b"XXX"), b"\xB0XXX") - - def test_empty_struct(self): - self.assert_packable(Structure(b"X"), b"\xB0X") - - def test_tiny_struct(self): - self.assert_packable(Structure(b"Z", u"A", 1), b"\xB2Z\x81A\x01") - - def test_illegal_uuid(self): - with self.assertRaises(ValueError): - self.assert_packable(uuid4(), b"\xB0XXX") - -try: - from neo4j.bolt._io import MessageFrame as CMessageFrame - from neo4j.packstream._packer import Packer as CPacker - from neo4j.packstream._unpacker import Unpacker as CUnpacker -except ImportError: - pass -else: - class CPackStreamTestCase(PackStreamTestCase): - MessageFrame = CMessageFrame - Packer = CPacker - Unpacker = CUnpacker diff --git a/test/unit/test_routing.py b/test/unit/test_routing.py deleted file mode 100644 index ae9fe1f88..000000000 --- a/test/unit/test_routing.py +++ /dev/null @@ -1,352 +0,0 @@ -#!/usr/bin/env python -# -*- encoding: utf-8 -*- - -# Copyright (c) 2002-2018 "Neo4j," -# Neo4j Sweden AB [http://neo4j.com] -# -# This file is part of Neo4j. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -from collections import OrderedDict -from unittest import TestCase - -from neo4j.bolt import ProtocolError -from neo4j.bolt.connection import connect -from neo4j.v1.routing import OrderedSet, RoutingTable, RoutingConnectionPool, LeastConnectedLoadBalancingStrategy, \ - RoundRobinLoadBalancingStrategy -from neo4j.v1.security import basic_auth -from neo4j.v1.api import READ_ACCESS, WRITE_ACCESS - - -VALID_ROUTING_RECORD = { - "ttl": 300, - "servers": [ - {"role": "ROUTE", "addresses": ["127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"]}, - {"role": "READ", "addresses": ["127.0.0.1:9004", "127.0.0.1:9005"]}, - {"role": "WRITE", "addresses": ["127.0.0.1:9006"]}, - ], -} - -VALID_ROUTING_RECORD_WITH_EXTRA_ROLE = { - "ttl": 300, - "servers": [ - {"role": "ROUTE", "addresses": ["127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"]}, - {"role": "READ", "addresses": ["127.0.0.1:9004", "127.0.0.1:9005"]}, - {"role": "WRITE", "addresses": ["127.0.0.1:9006"]}, - {"role": "MAGIC", "addresses": ["127.0.0.1:9007"]}, - ], -} - -INVALID_ROUTING_RECORD = { - "X": 1, -} - - -def connector(address, error_handler): - return connect(address, error_handler=error_handler, auth=basic_auth("neotest", "neotest")) - - -class OrderedSetTestCase(TestCase): - def test_should_repr_as_set(self): - s = OrderedSet([1, 2, 3]) - assert repr(s) == "{1, 2, 3}" - - def test_should_contain_element(self): - s = OrderedSet([1, 2, 3]) - assert 2 in s - - def test_should_not_contain_non_element(self): - s = OrderedSet([1, 2, 3]) - assert 4 not in s - - def test_should_be_able_to_get_item_if_empty(self): - s = OrderedSet([]) - with self.assertRaises(IndexError): - _ = s[0] - - def test_should_be_able_to_get_items_by_index(self): - s = OrderedSet([1, 2, 3]) - self.assertEqual(s[0], 1) - self.assertEqual(s[1], 2) - self.assertEqual(s[2], 3) - - def test_should_be_iterable(self): - s = OrderedSet([1, 2, 3]) - assert list(iter(s)) == [1, 2, 3] - - def test_should_have_length(self): - s = OrderedSet([1, 2, 3]) - assert len(s) == 3 - - def test_should_be_able_to_add_new(self): - s = OrderedSet([1, 2, 3]) - s.add(4) - assert list(s) == [1, 2, 3, 4] - - def test_should_be_able_to_add_existing(self): - s = OrderedSet([1, 2, 3]) - s.add(2) - assert list(s) == [1, 2, 3] - - def test_should_be_able_to_clear(self): - s = OrderedSet([1, 2, 3]) - s.clear() - assert list(s) == [] - - def test_should_be_able_to_discard_existing(self): - s = OrderedSet([1, 2, 3]) - s.discard(2) - assert list(s) == [1, 3] - - def test_should_be_able_to_discard_non_existing(self): - s = OrderedSet([1, 2, 3]) - s.discard(4) - assert list(s) == [1, 2, 3] - - def test_should_be_able_to_remove_existing(self): - s = OrderedSet([1, 2, 3]) - s.remove(2) - assert list(s) == [1, 3] - - def test_should_not_be_able_to_remove_non_existing(self): - s = OrderedSet([1, 2, 3]) - with self.assertRaises(ValueError): - s.remove(4) - - def test_should_be_able_to_update(self): - s = OrderedSet([1, 2, 3]) - s.update([3, 4, 5]) - assert list(s) == [1, 2, 3, 4, 5] - - def test_should_be_able_to_replace(self): - s = OrderedSet([1, 2, 3]) - s.replace([3, 4, 5]) - assert list(s) == [3, 4, 5] - - -class RoutingTableConstructionTestCase(TestCase): - def test_should_be_initially_stale(self): - table = RoutingTable() - assert not table.is_fresh(READ_ACCESS) - assert not table.is_fresh(WRITE_ACCESS) - - -class RoutingTableParseRoutingInfoTestCase(TestCase): - def test_should_return_routing_table_on_valid_record(self): - table = RoutingTable.parse_routing_info([VALID_ROUTING_RECORD]) - assert table.routers == {('127.0.0.1', 9001), ('127.0.0.1', 9002), ('127.0.0.1', 9003)} - assert table.readers == {('127.0.0.1', 9004), ('127.0.0.1', 9005)} - assert table.writers == {('127.0.0.1', 9006)} - assert table.ttl == 300 - - def test_should_return_routing_table_on_valid_record_with_extra_role(self): - table = RoutingTable.parse_routing_info([VALID_ROUTING_RECORD_WITH_EXTRA_ROLE]) - assert table.routers == {('127.0.0.1', 9001), ('127.0.0.1', 9002), ('127.0.0.1', 9003)} - assert table.readers == {('127.0.0.1', 9004), ('127.0.0.1', 9005)} - assert table.writers == {('127.0.0.1', 9006)} - assert table.ttl == 300 - - def test_should_fail_on_invalid_record(self): - with self.assertRaises(ProtocolError): - _ = RoutingTable.parse_routing_info([INVALID_ROUTING_RECORD]) - - def test_should_fail_on_zero_records(self): - with self.assertRaises(ProtocolError): - _ = RoutingTable.parse_routing_info([]) - - def test_should_fail_on_multiple_records(self): - with self.assertRaises(ProtocolError): - _ = RoutingTable.parse_routing_info([VALID_ROUTING_RECORD, VALID_ROUTING_RECORD]) - - -class RoutingTableServersTestCase(TestCase): - def test_should_return_all_distinct_servers_in_routing_table(self): - routing_table = { - "ttl": 300, - "servers": [ - {"role": "ROUTE", "addresses": ["127.0.0.1:9001", "127.0.0.1:9002", "127.0.0.1:9003"]}, - {"role": "READ", "addresses": ["127.0.0.1:9001", "127.0.0.1:9005"]}, - {"role": "WRITE", "addresses": ["127.0.0.1:9002"]}, - ], - } - table = RoutingTable.parse_routing_info([routing_table]) - assert table.servers() == {('127.0.0.1', 9001), ('127.0.0.1', 9002), ('127.0.0.1', 9003), ('127.0.0.1', 9005)} - - -class RoutingTableFreshnessTestCase(TestCase): - def test_should_be_fresh_after_update(self): - table = RoutingTable.parse_routing_info([VALID_ROUTING_RECORD]) - assert table.is_fresh(READ_ACCESS) - assert table.is_fresh(WRITE_ACCESS) - - def test_should_become_stale_on_expiry(self): - table = RoutingTable.parse_routing_info([VALID_ROUTING_RECORD]) - table.ttl = 0 - assert not table.is_fresh(READ_ACCESS) - assert not table.is_fresh(WRITE_ACCESS) - - def test_should_become_stale_if_no_readers(self): - table = RoutingTable.parse_routing_info([VALID_ROUTING_RECORD]) - table.readers.clear() - assert not table.is_fresh(READ_ACCESS) - assert table.is_fresh(WRITE_ACCESS) - - def test_should_become_stale_if_no_writers(self): - table = RoutingTable.parse_routing_info([VALID_ROUTING_RECORD]) - table.writers.clear() - assert table.is_fresh(READ_ACCESS) - assert not table.is_fresh(WRITE_ACCESS) - - -class RoutingTableUpdateTestCase(TestCase): - def setUp(self): - self.table = RoutingTable( - [("192.168.1.1", 7687), ("192.168.1.2", 7687)], [("192.168.1.3", 7687)], [], 0) - self.new_table = RoutingTable( - [("127.0.0.1", 9001), ("127.0.0.1", 9002), ("127.0.0.1", 9003)], - [("127.0.0.1", 9004), ("127.0.0.1", 9005)], [("127.0.0.1", 9006)], 300) - - def test_update_should_replace_routers(self): - self.table.update(self.new_table) - assert self.table.routers == {("127.0.0.1", 9001), ("127.0.0.1", 9002), ("127.0.0.1", 9003)} - - def test_update_should_replace_readers(self): - self.table.update(self.new_table) - assert self.table.readers == {("127.0.0.1", 9004), ("127.0.0.1", 9005)} - - def test_update_should_replace_writers(self): - self.table.update(self.new_table) - assert self.table.writers == {("127.0.0.1", 9006)} - - def test_update_should_replace_ttl(self): - self.table.update(self.new_table) - assert self.table.ttl == 300 - - -class RoutingConnectionPoolConstructionTestCase(TestCase): - def test_should_populate_initial_router(self): - initial_router = ("127.0.0.1", 9001) - router = ("127.0.0.1", 9002) - with RoutingConnectionPool(connector, initial_router, {}, router) as pool: - assert pool.routing_table.routers == {("127.0.0.1", 9002)} - - -class FakeConnectionPool(object): - - def __init__(self, addresses): - self._addresses = addresses - - def in_use_connection_count(self, address): - return self._addresses.get(address, 0) - - -class RoundRobinLoadBalancingStrategyTestCase(TestCase): - - def test_simple_reader_selection(self): - strategy = RoundRobinLoadBalancingStrategy() - self.assertEqual(strategy.select_reader(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "0.0.0.0") - self.assertEqual(strategy.select_reader(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "1.1.1.1") - self.assertEqual(strategy.select_reader(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "2.2.2.2") - self.assertEqual(strategy.select_reader(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "0.0.0.0") - - def test_empty_reader_selection(self): - strategy = RoundRobinLoadBalancingStrategy() - self.assertIsNone(strategy.select_reader([])) - - def test_simple_writer_selection(self): - strategy = RoundRobinLoadBalancingStrategy() - self.assertEqual(strategy.select_writer(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "0.0.0.0") - self.assertEqual(strategy.select_writer(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "1.1.1.1") - self.assertEqual(strategy.select_writer(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "2.2.2.2") - self.assertEqual(strategy.select_writer(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "0.0.0.0") - - def test_empty_writer_selection(self): - strategy = RoundRobinLoadBalancingStrategy() - self.assertIsNone(strategy.select_writer([])) - - -class LeastConnectedLoadBalancingStrategyTestCase(TestCase): - - def test_simple_reader_selection(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ("0.0.0.0", 2), - ("1.1.1.1", 1), - ("2.2.2.2", 0), - ]))) - self.assertEqual(strategy.select_reader(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "2.2.2.2") - - def test_reader_selection_with_clash(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ("0.0.0.0", 0), - ("0.0.0.1", 0), - ("1.1.1.1", 1), - ]))) - self.assertEqual(strategy.select_reader(["0.0.0.0", "0.0.0.1", "1.1.1.1"]), "0.0.0.0") - self.assertEqual(strategy.select_reader(["0.0.0.0", "0.0.0.1", "1.1.1.1"]), "0.0.0.1") - - def test_empty_reader_selection(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ]))) - self.assertIsNone(strategy.select_reader([])) - - def test_not_in_pool_reader_selection(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ("1.1.1.1", 1), - ("2.2.2.2", 2), - ]))) - self.assertEqual(strategy.select_reader(["2.2.2.2", "3.3.3.3"]), "3.3.3.3") - - def test_partially_in_pool_reader_selection(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ("1.1.1.1", 1), - ("2.2.2.2", 0), - ]))) - self.assertEqual(strategy.select_reader(["2.2.2.2", "3.3.3.3"]), "2.2.2.2") - self.assertEqual(strategy.select_reader(["2.2.2.2", "3.3.3.3"]), "3.3.3.3") - - def test_simple_writer_selection(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ("0.0.0.0", 2), - ("1.1.1.1", 1), - ("2.2.2.2", 0), - ]))) - self.assertEqual(strategy.select_writer(["0.0.0.0", "1.1.1.1", "2.2.2.2"]), "2.2.2.2") - - def test_writer_selection_with_clash(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ("0.0.0.0", 0), - ("0.0.0.1", 0), - ("1.1.1.1", 1), - ]))) - self.assertEqual(strategy.select_writer(["0.0.0.0", "0.0.0.1", "1.1.1.1"]), "0.0.0.0") - self.assertEqual(strategy.select_writer(["0.0.0.0", "0.0.0.1", "1.1.1.1"]), "0.0.0.1") - - def test_empty_writer_selection(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ]))) - self.assertIsNone(strategy.select_writer([])) - - def test_not_in_pool_writer_selection(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ("1.1.1.1", 1), - ("2.2.2.2", 2), - ]))) - self.assertEqual(strategy.select_writer(["2.2.2.2", "3.3.3.3"]), "3.3.3.3") - - def test_partially_in_pool_writer_selection(self): - strategy = LeastConnectedLoadBalancingStrategy(FakeConnectionPool(OrderedDict([ - ("1.1.1.1", 1), - ("2.2.2.2", 0), - ]))) - self.assertEqual(strategy.select_writer(["2.2.2.2", "3.3.3.3"]), "2.2.2.2") - self.assertEqual(strategy.select_writer(["2.2.2.2", "3.3.3.3"]), "3.3.3.3") diff --git a/test/unit/test_security.py b/test/unit/test_security.py index 9af716c6b..c6ff94bd2 100644 --- a/test/unit/test_security.py +++ b/test/unit/test_security.py @@ -18,8 +18,10 @@ # See the License for the specific language governing permissions and # limitations under the License. + from unittest import TestCase -from neo4j.v1.security import kerberos_auth, basic_auth, custom_auth +from neo4j.v1 import kerberos_auth, basic_auth, custom_auth + class AuthTokenTestCase(TestCase): diff --git a/test/unit/test_types.py b/test/unit/test_types.py index f245f92af..a674a63a5 100644 --- a/test/unit/test_types.py +++ b/test/unit/test_types.py @@ -21,7 +21,7 @@ from unittest import TestCase -from neo4j.packstream import Structure +from neobolt.packstream import Structure from neo4j.v1.types import PackStreamHydrator from neo4j.v1.types.graph import Node, Path, Graph diff --git a/tox.ini b/tox.ini index 4814a905c..70bc52a01 100644 --- a/tox.ini +++ b/tox.ini @@ -7,8 +7,8 @@ envlist = [testenv] deps = - -rrequirements.txt - -rtest/requirements.txt + -r{toxinidir}/requirements.txt + -r{toxinidir}/test/requirements.txt passenv = NEO4J_SERVER_PACKAGE NEO4J_USER From b3c2b74c21cdd09149d41df3a5db08120169f5be Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Tue, 31 Jul 2018 22:33:28 +0100 Subject: [PATCH 2/8] Internal responses --- neo4j/__init__.py | 197 +++++++++++++++------------------- neo4j/compat/__init__.py | 22 ++++ neo4j/meta.py | 22 ---- neo4j/v1/types/__init__.py | 5 + neo4j/v1/types/graph.py | 3 +- requirements.txt | 2 +- setup.py | 2 +- test/stub/test_accesslevel.py | 2 + 8 files changed, 116 insertions(+), 139 deletions(-) diff --git a/neo4j/__init__.py b/neo4j/__init__.py index 062143963..bfd3f17b4 100644 --- a/neo4j/__init__.py +++ b/neo4j/__init__.py @@ -89,6 +89,7 @@ STATEMENT_TYPE_SCHEMA_WRITE = "s" +# TODO: remove in 2.0 _warned_about_transaction_bookmarks = False @@ -426,7 +427,10 @@ def run(self, statement, parameters=None, **kwparameters): if not self.has_transaction(): self._connect() - result = self.__run__(statement, dict(parameters or {}, **kwparameters)) + statement = ustr(statement) + parameters = fix_parameters(dict(parameters or {}, **kwparameters), self._connection.protocol_version, + supports_bytes=self._connection.server.supports_bytes()) + result = self._run(statement, parameters) if not self.has_transaction(): try: @@ -477,25 +481,28 @@ def sync(self): return detail_count return 0 - def detach(self, result): + def detach(self, result, sync=True): """ Detach a result from this session by fetching and buffering any remaining records. :param result: + :param sync: :returns: number of records fetched """ count = 0 - self.send() - fetch = self.fetch - while result.attached(): - count += fetch() + if sync and result.attached(): + self.send() + fetch = self.fetch + while result.attached(): + count += fetch() if self._last_result is result: self._last_result = None if not self.has_transaction(): self._disconnect(sync=False) + result._session = None return count def last_bookmark(self): @@ -530,6 +537,7 @@ def begin_transaction(self, bookmark=None): if self.has_transaction(): raise TransactionError("Explicit transaction already open") + # TODO: remove in 2.0 if bookmark is not None: global _warned_about_transaction_bookmarks if not _warned_about_transaction_bookmarks: @@ -540,7 +548,7 @@ def begin_transaction(self, bookmark=None): self._create_transaction() self._connect() - self.__begin__() + self._begin() return self._transaction def commit_transaction(self): @@ -552,9 +560,7 @@ def commit_transaction(self): if not self.has_transaction(): raise TransactionError("No transaction to commit") self._transaction = None - result = self.__commit__() - result.consume() - bookmark = self.__bookmark__(result) + bookmark = self._commit() self._bookmarks = [bookmark] return bookmark @@ -567,11 +573,7 @@ def rollback_transaction(self): if not self.has_transaction(): raise TransactionError("No transaction to rollback") self._destroy_transaction() - rollback_result = self.__rollback__() - try: - rollback_result.consume() - except ServiceUnavailable: - pass + self._rollback() def reset(self): """ Reset the session. @@ -593,7 +595,7 @@ def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs): try: self._create_transaction() self._connect(access_mode) - self.__begin__() + self._begin() tx = self._transaction try: result = unit_of_work(tx, *args, **kwargs) @@ -630,43 +632,61 @@ def read_transaction(self, unit_of_work, *args, **kwargs): def write_transaction(self, unit_of_work, *args, **kwargs): return self._run_transaction(WRITE_ACCESS, unit_of_work, *args, **kwargs) - def _run(self, statement, parameters): - from neobolt.bolt.connection import RUN, PULL_ALL - from neobolt.bolt.response import Response + def _assert_open(self): if self.closed(): raise SessionError("Session closed") - run_response = Response(self._connection) - pull_all_response = Response(self._connection) - self._last_result = result = BoltStatementResult(self, run_response, pull_all_response) - result.statement = ustr(statement) - result.parameters = fix_parameters(parameters, self._connection.protocol_version, - supports_bytes=self._connection.server.supports_bytes()) - - self._connection.append(RUN, (result.statement, result.parameters), response=run_response) - self._connection.append(PULL_ALL, response=pull_all_response) - + def _run(self, statement, parameters): + self._assert_open() + cx = self._connection + hydrant = PackStreamHydrator(cx.protocol_version) + metadata = { + "statement": statement, + "parameters": parameters, + "server": cx.server, + "protocol_version": cx.protocol_version, + } + self._last_result = result = BoltStatementResult(self, hydrant, metadata) + cx.run(statement, parameters, metadata) + cx.pull_all( + metadata, + on_records=lambda records: result._records.extend( + hydrant.hydrate_records(result.keys(), records)), + on_summary=lambda: result.detach(sync=False), + ) return result - def __run__(self, statement, parameters): - return self._run(statement, parameters) - - def __begin__(self): + def _begin(self): + self._assert_open() + metadata = {} + parameters = {} if self._bookmarks: - parameters = {"bookmark": self.last_bookmark(), "bookmarks": self._bookmarks} - else: - parameters = {} - return self.__run__(u"BEGIN", parameters) - - def __commit__(self): - return self.__run__(u"COMMIT", {}) - - def __rollback__(self): - return self.__run__(u"ROLLBACK", {}) + parameters["bookmark"] = self.last_bookmark() # TODO: remove in 2.0 + parameters["bookmarks"] = self._bookmarks + cx = self._connection + cx.run(u"BEGIN", parameters, metadata) + cx.pull_all(metadata) + + def _commit(self): + self._assert_open() + metadata = {} + try: + cx = self._connection + cx.run(u"COMMIT", {}, metadata) + cx.pull_all(metadata) + finally: + self._disconnect(sync=True) + return metadata.get("bookmark") - def __bookmark__(self, result): - summary = result.summary() - return summary.metadata.get("bookmark") + def _rollback(self): + self._assert_open() + metadata = {} + try: + cx = self._connection + cx.run(u"ROLLBACK", {}, metadata) + cx.pull_all(metadata) + finally: + self._disconnect(sync=True) class Transaction(object): @@ -796,18 +816,10 @@ class StatementResult(object): :meth:`.Session.run` and :meth:`.Transaction.run`. """ - #: The statement text that was executed to produce this result. - statement = None - - #: Dictionary of parameters passed with the statement. - parameters = None - - zipper = zip - - def __init__(self, session, hydrant): + def __init__(self, session, hydrant, metadata): self._session = session self._hydrant = hydrant - self._keys = None + self._metadata = metadata self._records = deque() self._summary = None @@ -826,14 +838,14 @@ def attached(self): """ return self._session and not self._session.closed() - def detach(self): + def detach(self, sync=True): """ Detach this result from its parent session by fetching the remainder of this result from the network into the buffer. :returns: number of records fetched """ if self.attached(): - return self._session.detach(self) + return self._session.detach(self, sync=sync) else: return 0 @@ -842,13 +854,14 @@ def keys(self): :returns: tuple of key names """ - if self._keys is not None: - return self._keys - if self.attached(): - self._session.send() - while self.attached() and self._keys is None: - self._session.fetch() - return self._keys + try: + return self._metadata["fields"] + except KeyError: + if self.attached(): + self._session.send() + while self.attached() and "fields" not in self._metadata: + self._session.fetch() + return self._metadata.get("fields") def records(self): """ Generator for records obtained from this result. @@ -873,6 +886,8 @@ def summary(self): :returns: The :class:`.ResultSummary` for this result """ self.detach() + if self._summary is None: + self._summary = BoltStatementResultSummary(**self._metadata) return self._summary def consume(self): @@ -908,13 +923,9 @@ def peek(self): :returns: the next :class:`.Record` or :const:`None` if none remain """ - hydrate = self._hydrant.hydrate - zipper = self.zipper - keys = self.keys() records = self._records if records: - values = records[0] - return zipper(keys, hydrate(values)) + return records[0] if not self.attached(): return None if self.attached(): @@ -922,8 +933,7 @@ def peek(self): while self.attached() and not records: self._session.fetch() if records: - values = records[0] - return zipper(keys, hydrate(values)) + return records[0] return None def graph(self): @@ -941,47 +951,8 @@ class BoltStatementResult(StatementResult): """ A handler for the result of Cypher statement execution. """ - @classmethod - def zipper(cls, k, v): - return Record(zip(k, v)) - - def __init__(self, session, run_response, pull_all_response): - from neobolt.exceptions import CypherError - - super(BoltStatementResult, self).__init__(session, PackStreamHydrator(session._connection.protocol_version)) - - all_metadata = {} - - def on_header(metadata): - # Called on receipt of the result header. - all_metadata.update(metadata) - self._keys = tuple(metadata.get("fields", ())) - - def on_records(records): - # Called on receipt of one or more result records. - self._records.extend(map(lambda record: self.zipper(self.keys(), self._hydrant.hydrate(record)), records)) - - def on_footer(metadata): - # Called on receipt of the result footer. - connection = self.session._connection - all_metadata.update(metadata, statement=self.statement, parameters=self.parameters, - server=connection.server, protocol_version=connection.protocol_version) - self._summary = BoltStatementResultSummary(**all_metadata) - self._session, session_ = None, self._session - session_.detach(self) - - def on_failure(metadata): - # Called on execution failure. - self.session.reset() - on_footer(metadata) - raise CypherError.hydrate(**metadata) - - run_response.on_success = on_header - run_response.on_failure = on_failure - - pull_all_response.on_records = on_records - pull_all_response.on_success = on_footer - pull_all_response.on_failure = on_failure + def __init__(self, session, hydrant, metadata): + super(BoltStatementResult, self).__init__(session, hydrant, metadata) def value(self, item=0, default=None): """ Return the remainder of the result as a list of values. diff --git a/neo4j/compat/__init__.py b/neo4j/compat/__init__.py index adccc600c..e265d2f21 100644 --- a/neo4j/compat/__init__.py +++ b/neo4j/compat/__init__.py @@ -126,3 +126,25 @@ def perf_counter(): from urllib.parse import urlparse, parse_qs except ImportError: from urlparse import urlparse, parse_qs + + +def deprecated(message): + """ Decorator for deprecating functions and methods. + + :: + + @deprecated("'foo' has been deprecated in favour of 'bar'") + def foo(x): + pass + + """ + def f__(f): + def f_(*args, **kwargs): + from warnings import warn + warn(message, category=DeprecationWarning, stacklevel=2) + return f(*args, **kwargs) + f_.__name__ = f.__name__ + f_.__doc__ = f.__doc__ + f_.__dict__.update(f.__dict__) + return f_ + return f__ diff --git a/neo4j/meta.py b/neo4j/meta.py index 40595fe0e..9bb07a58f 100644 --- a/neo4j/meta.py +++ b/neo4j/meta.py @@ -21,25 +21,3 @@ # This version number will be automatically set in release-prepare build. version = "1.7.0.dev0" - - -def deprecated(message): - """ Decorator for deprecating functions and methods. - - :: - - @deprecated("'foo' has been deprecated in favour of 'bar'") - def foo(x): - pass - - """ - def f__(f): - def f_(*args, **kwargs): - from warnings import warn - warn(message, category=DeprecationWarning, stacklevel=2) - return f(*args, **kwargs) - f_.__name__ = f.__name__ - f_.__doc__ = f.__doc__ - f_.__dict__.update(f.__dict__) - return f_ - return f__ diff --git a/neo4j/v1/types/__init__.py b/neo4j/v1/types/__init__.py index 2b5406c93..bca5518c8 100644 --- a/neo4j/v1/types/__init__.py +++ b/neo4j/v1/types/__init__.py @@ -26,6 +26,7 @@ """ +from neo4j import Record from neo4j.compat import map_type, string, integer, ustr # These classes are imported in order to retain backward compatibility with 1.5. @@ -75,6 +76,10 @@ def hydrate_(obj): return tuple(map(hydrate_, values)) + def hydrate_records(self, keys, record_values): + for values in record_values: + yield Record(zip(keys, self.hydrate(values))) + class PackStreamDehydrator(object): diff --git a/neo4j/v1/types/graph.py b/neo4j/v1/types/graph.py index 315e50dc4..7b59e1d6d 100644 --- a/neo4j/v1/types/graph.py +++ b/neo4j/v1/types/graph.py @@ -25,8 +25,7 @@ from collections import Mapping -from neo4j.compat import xstr -from neo4j.meta import deprecated +from neo4j.compat import xstr, deprecated __all__ = [ diff --git a/requirements.txt b/requirements.txt index 142f24131..c6320730f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -neobolt==1.7.0a2 +neobolt>=1.7.0a2 neotime diff --git a/setup.py b/setup.py index b4ab8c490..2ca4b7a78 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ from neo4j.meta import version install_requires = [ - "neobolt==1.7.0a2", + "neobolt>=1.7.0a2", "neotime", ] classifiers = [ diff --git a/test/stub/test_accesslevel.py b/test/stub/test_accesslevel.py index 197184253..191c6e9e9 100644 --- a/test/stub/test_accesslevel.py +++ b/test/stub/test_accesslevel.py @@ -133,8 +133,10 @@ def unit_of_work_2(tx): return total value = session.read_transaction(unit_of_work_1) + assert session.last_bookmark() == "bookmark:1" assert value == 1 value = session.write_transaction(unit_of_work_2) + assert session.last_bookmark() == "bookmark:2" assert value == 2 def test_write_tx_then_read_tx(self): From cfec2c4e6616bf44d4ed5e5d0e6886ab91e87a88 Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Wed, 1 Aug 2018 10:38:42 +0100 Subject: [PATCH 3/8] Rolled commit and rollback into parent functions --- neo4j/__init__.py | 81 ++++++++++++++++++----------------------------- 1 file changed, 30 insertions(+), 51 deletions(-) diff --git a/neo4j/__init__.py b/neo4j/__init__.py index bfd3f17b4..20e0c52f5 100644 --- a/neo4j/__init__.py +++ b/neo4j/__init__.py @@ -232,7 +232,7 @@ class RoutingDriver(Driver): def __new__(cls, uri, **config): from neobolt.addressing import SocketAddress - from neobolt.bolt.connection import DEFAULT_PORT + from neobolt.bolt.connection import DEFAULT_PORT, connect from neobolt.routing import RoutingConnectionPool from neobolt.security import SecurityPlan cls._check_uri(uri) @@ -247,7 +247,6 @@ def __new__(cls, uri, **config): raise ValueError("TRUST_ON_FIRST_USE is not compatible with routing") def connector(address, error_handler): - from neobolt.bolt.connection import connect return connect(address, security_plan.ssl_context, error_handler, **config) pool = RoutingConnectionPool(connector, initial_address, routing_context, initial_address, **config) @@ -337,10 +336,9 @@ def __init__(self, acquirer, access_mode, **parameters): pass # for compatibility def __del__(self): - from neobolt.exceptions import ServiceUnavailable try: self.close() - except (SessionError, ServiceUnavailable): + except: pass def __enter__(self): @@ -519,10 +517,7 @@ def last_bookmark(self): def has_transaction(self): return bool(self._transaction) - def _create_transaction(self): - self._transaction = Transaction(self, on_close=self._destroy_transaction) - - def _destroy_transaction(self): + def _close_transaction(self): self._transaction = None def begin_transaction(self, bookmark=None): @@ -546,10 +541,7 @@ def begin_transaction(self, bookmark=None): _warned_about_transaction_bookmarks = True self._bookmarks = [bookmark] - self._create_transaction() - self._connect() - self._begin() - return self._transaction + return self._open_transaction() def commit_transaction(self): """ Commit the current transaction. @@ -557,10 +549,18 @@ def commit_transaction(self): :returns: the bookmark returned from the server, if any :raise: :class:`.TransactionError` if no transaction is currently open """ - if not self.has_transaction(): + self._assert_open() + if not self._transaction: raise TransactionError("No transaction to commit") - self._transaction = None - bookmark = self._commit() + metadata = {} + try: + cx = self._connection + cx.run(u"COMMIT", {}, metadata) + cx.pull_all(metadata) + finally: + self._disconnect(sync=True) + self._transaction = None + bookmark = metadata.get("bookmark") self._bookmarks = [bookmark] return bookmark @@ -569,17 +569,17 @@ def rollback_transaction(self): :raise: :class:`.TransactionError` if no transaction is currently open """ - from neobolt.exceptions import ServiceUnavailable - if not self.has_transaction(): + self._assert_open() + if not self._transaction: raise TransactionError("No transaction to rollback") - self._destroy_transaction() - self._rollback() - - def reset(self): - """ Reset the session. - """ - self._destroy_transaction() - self._connection.reset() + metadata = {} + try: + cx = self._connection + cx.run(u"ROLLBACK", {}, metadata) + cx.pull_all(metadata) + finally: + self._disconnect(sync=True) + self._transaction = None def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs): from neobolt.exceptions import ConnectionExpired, TransientError, ServiceUnavailable @@ -593,10 +593,7 @@ def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs): t0 = perf_counter() while True: try: - self._create_transaction() - self._connect(access_mode) - self._begin() - tx = self._transaction + tx = self._open_transaction(access_mode) try: result = unit_of_work(tx, *args, **kwargs) except: @@ -656,7 +653,9 @@ def _run(self, statement, parameters): ) return result - def _begin(self): + def _open_transaction(self, access_mode=None): + self._transaction = Transaction(self, on_close=self._close_transaction) + self._connect(access_mode) self._assert_open() metadata = {} parameters = {} @@ -666,27 +665,7 @@ def _begin(self): cx = self._connection cx.run(u"BEGIN", parameters, metadata) cx.pull_all(metadata) - - def _commit(self): - self._assert_open() - metadata = {} - try: - cx = self._connection - cx.run(u"COMMIT", {}, metadata) - cx.pull_all(metadata) - finally: - self._disconnect(sync=True) - return metadata.get("bookmark") - - def _rollback(self): - self._assert_open() - metadata = {} - try: - cx = self._connection - cx.run(u"ROLLBACK", {}, metadata) - cx.pull_all(metadata) - finally: - self._disconnect(sync=True) + return self._transaction class Transaction(object): From a619273414fcbfd844512fb19e6e028b6f9c8d01 Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Thu, 2 Aug 2018 13:28:55 +0100 Subject: [PATCH 4/8] Message wrappers --- neo4j/__init__.py | 132 ++++++++---------- test/stub/scripts/bookmark_chain.script | 8 +- .../bookmark_chain_with_autocommit.script | 8 +- test/stub/scripts/database_unavailable.script | 2 +- test/stub/scripts/error_in_tx.script | 4 +- .../forbidden_on_read_only_database.script | 2 +- test/stub/scripts/not_a_leader.script | 2 +- test/stub/scripts/return_1_in_tx.script | 4 +- test/stub/scripts/return_1_in_tx_twice.script | 8 +- test/stub/scripts/return_1_twice_in_tx.script | 4 +- test/stub/scripts/return_2_in_tx.script | 4 +- .../scripts/user_canceled_tx.script.script | 4 +- test/stub/test_bookmarking.py | 4 +- 13 files changed, 83 insertions(+), 103 deletions(-) diff --git a/neo4j/__init__.py b/neo4j/__init__.py index 20e0c52f5..1a00c8336 100644 --- a/neo4j/__init__.py +++ b/neo4j/__init__.py @@ -313,9 +313,12 @@ class Session(object): # The last result received. _last_result = None - # The collection of bookmarks after which the next + # The set of bookmarks after which the next # :class:`.Transaction` should be carried out. - _bookmarks = () + _bookmarks_in = None + + # The bookmark returned from the last commit. + _bookmark_out = None # Default maximum time to keep retrying failed transactions. _max_retry_time = default_config["max_retry_time"] @@ -327,9 +330,11 @@ def __init__(self, acquirer, access_mode, **parameters): self._default_access_mode = access_mode for key, value in parameters.items(): if key == "bookmark": - self._bookmarks = [value] if value else [] + if value: + self._bookmarks_in = tuple([value]) elif key == "bookmarks": - self._bookmarks = value or [] + if value: + self._bookmarks_in = tuple(value) elif key == "max_retry_time": self._max_retry_time = value else: @@ -417,18 +422,35 @@ def run(self, statement, parameters=None, **kwparameters): """ from neobolt.exceptions import ConnectionExpired - if self.closed(): - raise SessionError("Session closed") + self._assert_open() if not statement: raise ValueError("Cannot run an empty statement") - if not self.has_transaction(): + if not self._connection: self._connect() + cx = self._connection + protocol_version = cx.protocol_version + server = cx.server statement = ustr(statement) - parameters = fix_parameters(dict(parameters or {}, **kwparameters), self._connection.protocol_version, - supports_bytes=self._connection.server.supports_bytes()) - result = self._run(statement, parameters) + parameters = fix_parameters(dict(parameters or {}, **kwparameters), protocol_version, + supports_bytes=server.supports_bytes()) + + hydrant = PackStreamHydrator(protocol_version) + metadata = { + "statement": statement, + "parameters": parameters, + "server": server, + "protocol_version": protocol_version, + } + self._last_result = result = BoltStatementResult(self, hydrant, metadata) + cx.run(statement, parameters, metadata) + cx.pull_all( + metadata, + on_records=lambda records: result._records.extend( + hydrant.hydrate_records(result.keys(), records)), + on_summary=lambda: result.detach(sync=False), + ) if not self.has_transaction(): try: @@ -503,16 +525,16 @@ def detach(self, result, sync=True): result._session = None return count + def next_bookmarks(self): + """ The set of bookmarks to be passed into the next + :class:`.Transaction`. + """ + return self._bookmarks_in + def last_bookmark(self): """ The bookmark returned by the last :class:`.Transaction`. """ - last = None - for bookmark in self._bookmarks: - if last is None: - last = bookmark - else: - last = last_bookmark(last, bookmark) - return last + return self._bookmark_out def has_transaction(self): return bool(self._transaction) @@ -529,6 +551,7 @@ def begin_transaction(self, bookmark=None): :returns: new :class:`.Transaction` instance. :raise: :class:`.TransactionError` if a transaction is already open """ + self._assert_open() if self.has_transaction(): raise TransactionError("Explicit transaction already open") @@ -539,9 +562,15 @@ def begin_transaction(self, bookmark=None): from warnings import warn warn("Passing bookmarks at transaction level is deprecated", category=DeprecationWarning, stacklevel=2) _warned_about_transaction_bookmarks = True - self._bookmarks = [bookmark] + self._bookmarks_in = tuple([bookmark]) - return self._open_transaction() + self._open_transaction() + return self._transaction + + def _open_transaction(self, access_mode=None): + self._transaction = Transaction(self, on_close=self._close_transaction) + self._connect(access_mode) + self._connection.begin(self._bookmarks_in, {}) def commit_transaction(self): """ Commit the current transaction. @@ -554,14 +583,13 @@ def commit_transaction(self): raise TransactionError("No transaction to commit") metadata = {} try: - cx = self._connection - cx.run(u"COMMIT", {}, metadata) - cx.pull_all(metadata) + self._connection.commit(metadata) finally: self._disconnect(sync=True) self._transaction = None bookmark = metadata.get("bookmark") - self._bookmarks = [bookmark] + self._bookmarks_in = tuple([bookmark]) + self._bookmark_out = bookmark return bookmark def rollback_transaction(self): @@ -574,9 +602,7 @@ def rollback_transaction(self): raise TransactionError("No transaction to rollback") metadata = {} try: - cx = self._connection - cx.run(u"ROLLBACK", {}, metadata) - cx.pull_all(metadata) + self._connection.rollback(metadata) finally: self._disconnect(sync=True) self._transaction = None @@ -593,7 +619,8 @@ def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs): t0 = perf_counter() while True: try: - tx = self._open_transaction(access_mode) + self._open_transaction(access_mode) + tx = self._transaction try: result = unit_of_work(tx, *args, **kwargs) except: @@ -624,49 +651,17 @@ def _run_transaction(self, access_mode, unit_of_work, *args, **kwargs): raise ServiceUnavailable("Transaction failed") def read_transaction(self, unit_of_work, *args, **kwargs): + self._assert_open() return self._run_transaction(READ_ACCESS, unit_of_work, *args, **kwargs) def write_transaction(self, unit_of_work, *args, **kwargs): + self._assert_open() return self._run_transaction(WRITE_ACCESS, unit_of_work, *args, **kwargs) def _assert_open(self): if self.closed(): raise SessionError("Session closed") - def _run(self, statement, parameters): - self._assert_open() - cx = self._connection - hydrant = PackStreamHydrator(cx.protocol_version) - metadata = { - "statement": statement, - "parameters": parameters, - "server": cx.server, - "protocol_version": cx.protocol_version, - } - self._last_result = result = BoltStatementResult(self, hydrant, metadata) - cx.run(statement, parameters, metadata) - cx.pull_all( - metadata, - on_records=lambda records: result._records.extend( - hydrant.hydrate_records(result.keys(), records)), - on_summary=lambda: result.detach(sync=False), - ) - return result - - def _open_transaction(self, access_mode=None): - self._transaction = Transaction(self, on_close=self._close_transaction) - self._connect(access_mode) - self._assert_open() - metadata = {} - parameters = {} - if self._bookmarks: - parameters["bookmark"] = self.last_bookmark() # TODO: remove in 2.0 - parameters["bookmarks"] = self._bookmarks - cx = self._connection - cx.run(u"BEGIN", parameters, metadata) - cx.pull_all(metadata) - return self._transaction - class Transaction(object): """ Container for multiple Cypher queries to be executed within @@ -1401,21 +1396,6 @@ def iter_items(iterable): yield key, value -def last_bookmark(b0, b1): - """ Return the latest of two bookmarks by looking for the maximum - integer value following the last colon in the bookmark string. - """ - n = [None, None] - _, _, n[0] = b0.rpartition(":") - _, _, n[1] = b1.rpartition(":") - for i in range(2): - try: - n[i] = int(n[i]) - except ValueError: - raise ValueError("Invalid bookmark: {}".format(b0)) - return b0 if n[0] > n[1] else b1 - - def retry_delay_generator(initial_delay, multiplier, jitter_factor): delay = initial_delay while True: diff --git a/test/stub/scripts/bookmark_chain.script b/test/stub/scripts/bookmark_chain.script index cb96bbbce..824b1413f 100644 --- a/test/stub/scripts/bookmark_chain.script +++ b/test/stub/scripts/bookmark_chain.script @@ -2,19 +2,19 @@ !: AUTO RESET C: RUN "BEGIN" {"bookmark": "bookmark:1", "bookmarks": ["bookmark:0", "bookmark:1"]} - PULL_ALL + DISCARD_ALL S: SUCCESS {} SUCCESS {} C: RUN "COMMIT" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"bookmark": "bookmark:2", "bookmarks": ["bookmark:2"]} SUCCESS {} C: RUN "BEGIN" {"bookmark": "bookmark:2", "bookmarks": ["bookmark:2"]} - PULL_ALL + DISCARD_ALL S: SUCCESS {} SUCCESS {} C: RUN "COMMIT" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"bookmark": "bookmark:3", "bookmarks": ["bookmark:3"]} SUCCESS {} diff --git a/test/stub/scripts/bookmark_chain_with_autocommit.script b/test/stub/scripts/bookmark_chain_with_autocommit.script index d06d3c7df..730555b39 100644 --- a/test/stub/scripts/bookmark_chain_with_autocommit.script +++ b/test/stub/scripts/bookmark_chain_with_autocommit.script @@ -2,11 +2,11 @@ !: AUTO RESET C: RUN "BEGIN" {"bookmark": "bookmark:1", "bookmarks": ["bookmark:1"]} - PULL_ALL + DISCARD_ALL S: SUCCESS {} SUCCESS {} C: RUN "COMMIT" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"bookmark": "bookmark:2", "bookmarks": ["bookmark:2"]} SUCCESS {} @@ -16,10 +16,10 @@ S: SUCCESS {"bookmark": "bookmark:x", "bookmarks": ["bookmark:x"]} SUCCESS {} C: RUN "BEGIN" {"bookmark": "bookmark:2", "bookmarks": ["bookmark:2"]} - PULL_ALL + DISCARD_ALL S: SUCCESS {} SUCCESS {} C: RUN "COMMIT" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"bookmark": "bookmark:3", "bookmarks": ["bookmark:3"]} SUCCESS {} diff --git a/test/stub/scripts/database_unavailable.script b/test/stub/scripts/database_unavailable.script index b426a4ce7..7ee406d80 100644 --- a/test/stub/scripts/database_unavailable.script +++ b/test/stub/scripts/database_unavailable.script @@ -1,6 +1,6 @@ !: AUTO INIT !: AUTO RESET -!: AUTO PULL_ALL +!: AUTO DISCARD_ALL !: AUTO RUN "ROLLBACK" {} !: AUTO RUN "BEGIN" {} !: AUTO RUN "COMMIT" {} diff --git a/test/stub/scripts/error_in_tx.script b/test/stub/scripts/error_in_tx.script index 6db16cd4f..893857f85 100644 --- a/test/stub/scripts/error_in_tx.script +++ b/test/stub/scripts/error_in_tx.script @@ -2,7 +2,7 @@ !: AUTO RESET C: RUN "BEGIN" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"fields": []} SUCCESS {} @@ -15,6 +15,6 @@ C: RESET S: SUCCESS {} C: RUN "ROLLBACK" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {} SUCCESS {} diff --git a/test/stub/scripts/forbidden_on_read_only_database.script b/test/stub/scripts/forbidden_on_read_only_database.script index 2e1dfd094..64ec1c8b9 100644 --- a/test/stub/scripts/forbidden_on_read_only_database.script +++ b/test/stub/scripts/forbidden_on_read_only_database.script @@ -1,6 +1,6 @@ !: AUTO INIT !: AUTO RESET -!: AUTO PULL_ALL +!: AUTO DISCARD_ALL !: AUTO RUN "ROLLBACK" {} !: AUTO RUN "BEGIN" {} !: AUTO RUN "COMMIT" {} diff --git a/test/stub/scripts/not_a_leader.script b/test/stub/scripts/not_a_leader.script index 3408e859b..53f8be333 100644 --- a/test/stub/scripts/not_a_leader.script +++ b/test/stub/scripts/not_a_leader.script @@ -1,6 +1,6 @@ !: AUTO INIT !: AUTO RESET -!: AUTO PULL_ALL +!: AUTO DISCARD_ALL !: AUTO RUN "ROLLBACK" {} !: AUTO RUN "BEGIN" {} !: AUTO RUN "COMMIT" {} diff --git a/test/stub/scripts/return_1_in_tx.script b/test/stub/scripts/return_1_in_tx.script index 6af156095..54817b82c 100644 --- a/test/stub/scripts/return_1_in_tx.script +++ b/test/stub/scripts/return_1_in_tx.script @@ -2,7 +2,7 @@ !: AUTO RESET C: RUN "BEGIN" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"fields": []} SUCCESS {} @@ -13,6 +13,6 @@ S: SUCCESS {"fields": ["1"]} SUCCESS {} C: RUN "COMMIT" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"bookmark": "bookmark:1", "bookmarks": ["bookmark:1"]} SUCCESS {} diff --git a/test/stub/scripts/return_1_in_tx_twice.script b/test/stub/scripts/return_1_in_tx_twice.script index a19d66aa0..aef5eb3e3 100644 --- a/test/stub/scripts/return_1_in_tx_twice.script +++ b/test/stub/scripts/return_1_in_tx_twice.script @@ -2,7 +2,7 @@ !: AUTO RESET C: RUN "BEGIN" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"fields": []} SUCCESS {} @@ -13,12 +13,12 @@ S: SUCCESS {"fields": ["1"]} SUCCESS {} C: RUN "COMMIT" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"bookmark": "bookmark:1", "bookmarks": ["bookmark:1"]} SUCCESS {} C: RUN "BEGIN" {"bookmark": "bookmark:1", "bookmarks": ["bookmark:1"]} - PULL_ALL + DISCARD_ALL S: SUCCESS {"fields": []} SUCCESS {} @@ -29,6 +29,6 @@ S: SUCCESS {"fields": ["1"]} SUCCESS {} C: RUN "COMMIT" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"bookmark": "bookmark:2", "bookmarks": ["bookmark:2"]} SUCCESS {} diff --git a/test/stub/scripts/return_1_twice_in_tx.script b/test/stub/scripts/return_1_twice_in_tx.script index c7f1b0500..6fc0881fe 100644 --- a/test/stub/scripts/return_1_twice_in_tx.script +++ b/test/stub/scripts/return_1_twice_in_tx.script @@ -2,7 +2,7 @@ !: AUTO RESET C: RUN "BEGIN" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"fields": []} SUCCESS {} @@ -19,6 +19,6 @@ S: SUCCESS {"fields": ["x"]} SUCCESS {} C: RUN "COMMIT" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"bookmark": "bookmark:1", "bookmarks": ["bookmark:1"]} SUCCESS {} diff --git a/test/stub/scripts/return_2_in_tx.script b/test/stub/scripts/return_2_in_tx.script index d05c57062..73146dc5b 100644 --- a/test/stub/scripts/return_2_in_tx.script +++ b/test/stub/scripts/return_2_in_tx.script @@ -2,7 +2,7 @@ !: AUTO RESET C: RUN "BEGIN" {"bookmark": "bookmark:1", "bookmarks": ["bookmark:1"]} - PULL_ALL + DISCARD_ALL S: SUCCESS {"fields": []} SUCCESS {} @@ -13,6 +13,6 @@ S: SUCCESS {"fields": ["2"]} SUCCESS {} C: RUN "COMMIT" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"bookmark": "bookmark:2", "bookmarks": ["bookmark:2"]} SUCCESS {} diff --git a/test/stub/scripts/user_canceled_tx.script.script b/test/stub/scripts/user_canceled_tx.script.script index e72eacf19..844fa8de5 100644 --- a/test/stub/scripts/user_canceled_tx.script.script +++ b/test/stub/scripts/user_canceled_tx.script.script @@ -2,7 +2,7 @@ !: AUTO RESET C: RUN "BEGIN" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {"fields": []} SUCCESS {} @@ -15,6 +15,6 @@ C: RESET S: SUCCESS {} C: RUN "ROLLBACK" {} - PULL_ALL + DISCARD_ALL S: SUCCESS {} SUCCESS {} \ No newline at end of file diff --git a/test/stub/test_bookmarking.py b/test/stub/test_bookmarking.py index 4c8e5871e..b9727811c 100644 --- a/test/stub/test_bookmarking.py +++ b/test/stub/test_bookmarking.py @@ -38,14 +38,14 @@ def test_should_be_able_to_set_bookmark(self): uri = "bolt+routing://localhost:9001" with GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False) as driver: with driver.session(bookmark="X") as session: - assert session.last_bookmark() == "X" + assert session.next_bookmarks() == ("X",) def test_should_be_able_to_set_multiple_bookmarks(self): with StubCluster({9001: "router.script"}): uri = "bolt+routing://localhost:9001" with GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False) as driver: with driver.session(bookmarks=[":1", ":2"]) as session: - assert session.last_bookmark() == ":2" + assert session.next_bookmarks() == (":1", ":2") def test_should_automatically_chain_bookmarks(self): with StubCluster({9001: "router.script", 9004: "bookmark_chain.script"}): From 9522843b420dd2cf6235a736c5732cf9401618f8 Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Tue, 7 Aug 2018 11:47:25 +0100 Subject: [PATCH 5/8] Aligned with bulk restructuring of connector --- neo4j/__init__.py | 17 ++++++++--------- neo4j/v1/types/spatial.py | 2 +- neo4j/v1/types/temporal.py | 2 +- test/integration/test_driver.py | 4 +++- test/stub/test_routingdriver.py | 10 +++++----- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/neo4j/__init__.py b/neo4j/__init__.py index 1a00c8336..0f800fce2 100644 --- a/neo4j/__init__.py +++ b/neo4j/__init__.py @@ -191,8 +191,7 @@ class DirectDriver(Driver): def __new__(cls, uri, **config): from neobolt.addressing import SocketAddress - from neobolt.bolt.connection import DEFAULT_PORT, connect - from neobolt.direct import DirectConnectionPool + from neobolt.direct import DirectConnectionPool, DEFAULT_PORT, connect from neobolt.security import SecurityPlan cls._check_uri(uri) if SocketAddress.parse_routing_context(uri): @@ -232,7 +231,7 @@ class RoutingDriver(Driver): def __new__(cls, uri, **config): from neobolt.addressing import SocketAddress - from neobolt.bolt.connection import DEFAULT_PORT, connect + from neobolt.direct import DEFAULT_PORT, connect from neobolt.routing import RoutingConnectionPool from neobolt.security import SecurityPlan cls._check_uri(uri) @@ -434,7 +433,7 @@ def run(self, statement, parameters=None, **kwparameters): statement = ustr(statement) parameters = fix_parameters(dict(parameters or {}, **kwparameters), protocol_version, - supports_bytes=server.supports_bytes()) + supports_bytes=server.supports("bytes")) hydrant = PackStreamHydrator(protocol_version) metadata = { @@ -444,9 +443,9 @@ def run(self, statement, parameters=None, **kwparameters): "protocol_version": protocol_version, } self._last_result = result = BoltStatementResult(self, hydrant, metadata) - cx.run(statement, parameters, metadata) + cx.run(statement, parameters, on_success=metadata.update) cx.pull_all( - metadata, + on_success=metadata.update, on_records=lambda records: result._records.extend( hydrant.hydrate_records(result.keys(), records)), on_summary=lambda: result.detach(sync=False), @@ -570,7 +569,7 @@ def begin_transaction(self, bookmark=None): def _open_transaction(self, access_mode=None): self._transaction = Transaction(self, on_close=self._close_transaction) self._connect(access_mode) - self._connection.begin(self._bookmarks_in, {}) + self._connection.begin(self._bookmarks_in) def commit_transaction(self): """ Commit the current transaction. @@ -583,7 +582,7 @@ def commit_transaction(self): raise TransactionError("No transaction to commit") metadata = {} try: - self._connection.commit(metadata) + self._connection.commit(on_success=metadata.update) finally: self._disconnect(sync=True) self._transaction = None @@ -602,7 +601,7 @@ def rollback_transaction(self): raise TransactionError("No transaction to rollback") metadata = {} try: - self._connection.rollback(metadata) + self._connection.rollback(on_success=metadata.update) finally: self._disconnect(sync=True) self._transaction = None diff --git a/neo4j/v1/types/spatial.py b/neo4j/v1/types/spatial.py index 7e104cbb4..23cfeb1d1 100644 --- a/neo4j/v1/types/spatial.py +++ b/neo4j/v1/types/spatial.py @@ -24,7 +24,7 @@ """ -from neobolt.packstream.structure import Structure +from neobolt.packstream import Structure __all__ = [ diff --git a/neo4j/v1/types/temporal.py b/neo4j/v1/types/temporal.py index 983e6ae19..a819b1d95 100644 --- a/neo4j/v1/types/temporal.py +++ b/neo4j/v1/types/temporal.py @@ -31,7 +31,7 @@ from neotime import Duration, Date, Time, DateTime from pytz import FixedOffset, timezone, utc -from neobolt.packstream.structure import Structure +from neobolt.packstream import Structure UNIX_EPOCH_DATE = Date(1970, 1, 1) diff --git a/test/integration/test_driver.py b/test/integration/test_driver.py index efba79311..47b83ab4e 100644 --- a/test/integration/test_driver.py +++ b/test/integration/test_driver.py @@ -19,8 +19,10 @@ # limitations under the License. -from neobolt.bolt import DEFAULT_PORT +from neobolt.direct import DEFAULT_PORT + from neo4j.v1 import GraphDatabase, Driver, ServiceUnavailable + from test.integration.tools import IntegrationTestCase diff --git a/test/stub/test_routingdriver.py b/test/stub/test_routingdriver.py index 9db0e23ff..668a1a346 100644 --- a/test/stub/test_routingdriver.py +++ b/test/stub/test_routingdriver.py @@ -19,9 +19,9 @@ # limitations under the License. -from neobolt.bolt import ProtocolError, ServiceUnavailable -from neobolt.config import LOAD_BALANCING_STRATEGY_ROUND_ROBIN -from neobolt.routing import LeastConnectedLoadBalancingStrategy, RoundRobinLoadBalancingStrategy +from neobolt.exceptions import ServiceUnavailable +from neobolt.routing import LeastConnectedLoadBalancingStrategy, RoundRobinLoadBalancingStrategy, \ + LOAD_BALANCING_STRATEGY_ROUND_ROBIN, RoutingProtocolError from neo4j.exceptions import ClientError from neo4j.v1 import GraphDatabase, READ_ACCESS, WRITE_ACCESS, SessionExpired, RoutingDriver, TransientError @@ -47,7 +47,7 @@ def test_cannot_discover_servers_on_non_router(self): def test_cannot_discover_servers_on_silent_router(self): with StubCluster({9001: "silent_router.script"}): uri = "bolt+routing://127.0.0.1:9001" - with self.assertRaises(ProtocolError): + with self.assertRaises(RoutingProtocolError): with GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False): pass @@ -217,7 +217,7 @@ def test_should_serve_read_when_missing_writer(self): def test_should_error_when_missing_reader(self): with StubCluster({9001: "router_no_readers.script"}): uri = "bolt+routing://127.0.0.1:9001" - with self.assertRaises(ProtocolError): + with self.assertRaises(RoutingProtocolError): GraphDatabase.driver(uri, auth=self.auth_token, encrypted=False) def test_default_load_balancing_strategy_is_least_connected(self): From 105cefbab5eb9716b461b31e5942696a2c6f0f97 Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Tue, 7 Aug 2018 16:11:17 +0100 Subject: [PATCH 6/8] Secure by default --- neo4j/__init__.py | 24 ++++++++++++++++-------- test/integration/test_security.py | 4 ++++ test/integration/test_session.py | 8 ++++++-- test/requirements.txt | 2 +- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/neo4j/__init__.py b/neo4j/__init__.py index 0f800fce2..f9ec81f5a 100644 --- a/neo4j/__init__.py +++ b/neo4j/__init__.py @@ -191,8 +191,9 @@ class DirectDriver(Driver): def __new__(cls, uri, **config): from neobolt.addressing import SocketAddress - from neobolt.direct import DirectConnectionPool, DEFAULT_PORT, connect - from neobolt.security import SecurityPlan + from neobolt.compat.ssl import SSL_AVAILABLE + from neobolt.direct import ConnectionPool, DEFAULT_PORT, connect + from neobolt.security import ENCRYPTION_OFF, ENCRYPTION_ON, SecurityPlan cls._check_uri(uri) if SocketAddress.parse_routing_context(uri): raise ValueError("Parameters are not supported with scheme 'bolt'. Given URI: '%s'." % uri) @@ -203,13 +204,15 @@ def __new__(cls, uri, **config): # the connection pool may contain multiple IP address keys, one for # an old address and one for a new address. instance.address = SocketAddress.from_uri(uri, DEFAULT_PORT) + if config.get("encrypted") is None: + config["encrypted"] = ENCRYPTION_ON if SSL_AVAILABLE else ENCRYPTION_OFF instance.security_plan = security_plan = SecurityPlan.build(**config) instance.encrypted = security_plan.encrypted - def connector(address, error_handler): - return connect(address, security_plan.ssl_context, error_handler, **config) + def connector(address, **kwargs): + return connect(address, **dict(config, **kwargs)) - pool = DirectConnectionPool(connector, instance.address, **config) + pool = ConnectionPool(connector, instance.address, **config) pool.release(pool.acquire()) instance._pool = pool instance._max_retry_time = config.get("max_retry_time", default_config["max_retry_time"]) @@ -231,12 +234,15 @@ class RoutingDriver(Driver): def __new__(cls, uri, **config): from neobolt.addressing import SocketAddress + from neobolt.compat.ssl import SSL_AVAILABLE from neobolt.direct import DEFAULT_PORT, connect from neobolt.routing import RoutingConnectionPool - from neobolt.security import SecurityPlan + from neobolt.security import ENCRYPTION_OFF, ENCRYPTION_ON, SecurityPlan cls._check_uri(uri) instance = object.__new__(cls) instance.initial_address = initial_address = SocketAddress.from_uri(uri, DEFAULT_PORT) + if config.get("encrypted") is None: + config["encrypted"] = ENCRYPTION_ON if SSL_AVAILABLE else ENCRYPTION_OFF instance.security_plan = security_plan = SecurityPlan.build(**config) instance.encrypted = security_plan.encrypted routing_context = SocketAddress.parse_routing_context(uri) @@ -245,8 +251,8 @@ def __new__(cls, uri, **config): # scenario right now raise ValueError("TRUST_ON_FIRST_USE is not compatible with routing") - def connector(address, error_handler): - return connect(address, security_plan.ssl_context, error_handler, **config) + def connector(address, **kwargs): + return connect(address, **dict(config, **kwargs)) pool = RoutingConnectionPool(connector, initial_address, routing_context, initial_address, **config) try: @@ -1003,6 +1009,8 @@ def __init__(self, **metadata): self.counters = SummaryCounters(metadata.get("stats", {})) self.result_available_after = metadata.get("result_available_after") self.result_consumed_after = metadata.get("result_consumed_after") + self.t_first = metadata.get("t_first") + self.t_last = metadata.get("t_last") if "plan" in metadata: self.plan = _make_plan(metadata["plan"]) if "profile" in metadata: diff --git a/test/integration/test_security.py b/test/integration/test_security.py index c8c2b0be5..51232d159 100644 --- a/test/integration/test_security.py +++ b/test/integration/test_security.py @@ -29,6 +29,10 @@ class SecurityTestCase(IntegrationTestCase): + def test_secure_by_default(self): + with GraphDatabase.driver(self.bolt_uri, auth=self.auth_token) as driver: + self.assertTrue(driver.encrypted) + def test_insecure_session_uses_normal_socket(self): with GraphDatabase.driver(self.bolt_uri, auth=self.auth_token, encrypted=False) as driver: with driver.session() as session: diff --git a/test/integration/test_session.py b/test/integration/test_session.py index 744ad7667..a290be3bb 100644 --- a/test/integration/test_session.py +++ b/test/integration/test_session.py @@ -232,8 +232,12 @@ def test_contains_time_information(self): raise SkipTest("Execution times are not supported before server 3.1") with self.driver.session() as session: summary = session.run("UNWIND range(1,1000) AS n RETURN n AS number").consume() - assert isinstance(summary.result_consumed_after, int) - assert isinstance(summary.result_available_after, int) + if self.protocol_version() >= 3: + self.assertIsInstance(summary.t_first, int) + self.assertIsInstance(summary.t_last, int) + else: + self.assertIsInstance(summary.result_available_after, int) + self.assertIsInstance(summary.result_consumed_after, int) class ResetTestCase(DirectIntegrationTestCase): diff --git a/test/requirements.txt b/test/requirements.txt index 31f901c0f..0713b78f2 100644 --- a/test/requirements.txt +++ b/test/requirements.txt @@ -1,4 +1,4 @@ -boltkit +boltkit>=1.0.34 coverage mock pytest From 3e29221ea5120c2b0ce559132fe46f88cfc0e813 Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Wed, 8 Aug 2018 16:52:33 +0100 Subject: [PATCH 7/8] Latest connector --- requirements.txt | 2 +- setup.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/requirements.txt b/requirements.txt index c6320730f..549580e5d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -neobolt>=1.7.0a2 +neobolt>=1.7.0b1 neotime diff --git a/setup.py b/setup.py index 2ca4b7a78..ec0da8928 100644 --- a/setup.py +++ b/setup.py @@ -30,7 +30,7 @@ from neo4j.meta import version install_requires = [ - "neobolt>=1.7.0a2", + "neobolt>=1.7.0b1", "neotime", ] classifiers = [ From d130eab47d1986f47837519f8c4930bc4c643641 Mon Sep 17 00:00:00 2001 From: Nigel Small Date: Thu, 9 Aug 2018 09:37:52 +0100 Subject: [PATCH 8/8] Fixed rollback bug --- neo4j/__init__.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/neo4j/__init__.py b/neo4j/__init__.py index f9ec81f5a..87e41fba1 100644 --- a/neo4j/__init__.py +++ b/neo4j/__init__.py @@ -191,9 +191,8 @@ class DirectDriver(Driver): def __new__(cls, uri, **config): from neobolt.addressing import SocketAddress - from neobolt.compat.ssl import SSL_AVAILABLE from neobolt.direct import ConnectionPool, DEFAULT_PORT, connect - from neobolt.security import ENCRYPTION_OFF, ENCRYPTION_ON, SecurityPlan + from neobolt.security import ENCRYPTION_OFF, ENCRYPTION_ON, SSL_AVAILABLE, SecurityPlan cls._check_uri(uri) if SocketAddress.parse_routing_context(uri): raise ValueError("Parameters are not supported with scheme 'bolt'. Given URI: '%s'." % uri) @@ -234,10 +233,9 @@ class RoutingDriver(Driver): def __new__(cls, uri, **config): from neobolt.addressing import SocketAddress - from neobolt.compat.ssl import SSL_AVAILABLE from neobolt.direct import DEFAULT_PORT, connect from neobolt.routing import RoutingConnectionPool - from neobolt.security import ENCRYPTION_OFF, ENCRYPTION_ON, SecurityPlan + from neobolt.security import ENCRYPTION_OFF, ENCRYPTION_ON, SSL_AVAILABLE, SecurityPlan cls._check_uri(uri) instance = object.__new__(cls) instance.initial_address = initial_address = SocketAddress.from_uri(uri, DEFAULT_PORT) @@ -441,6 +439,9 @@ def run(self, statement, parameters=None, **kwparameters): parameters = fix_parameters(dict(parameters or {}, **kwparameters), protocol_version, supports_bytes=server.supports("bytes")) + def fail(_): + self._close_transaction() + hydrant = PackStreamHydrator(protocol_version) metadata = { "statement": statement, @@ -449,11 +450,12 @@ def run(self, statement, parameters=None, **kwparameters): "protocol_version": protocol_version, } self._last_result = result = BoltStatementResult(self, hydrant, metadata) - cx.run(statement, parameters, on_success=metadata.update) + cx.run(statement, parameters, on_success=metadata.update, on_failure=fail) cx.pull_all( - on_success=metadata.update, on_records=lambda records: result._records.extend( hydrant.hydrate_records(result.keys(), records)), + on_success=metadata.update, + on_failure=fail, on_summary=lambda: result.detach(sync=False), )