/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/_static_tuple_c.c

  • Committer: Martin
  • Date: 2017-06-09 16:31:49 UTC
  • mto: This revision was merged to the branch mainline in revision 6673.
  • Revision ID: gzlist@googlemail.com-20170609163149-liveiasey25480q6
Make InventoryDeltaError use string formatting, and repr for fileids

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
 
29
29
/* Pyrex 0.9.6.4 exports _simple_set_pyx_api as
30
30
 * import__simple_set_pyx(), while Pyrex 0.9.8.5 and Cython 0.11.3 export them
31
 
 * as import_bzrlib___simple_set_pyx(). As such, we just #define one to be
 
31
 * as import_breezy___simple_set_pyx(). As such, we just #define one to be
32
32
 * equivalent to the other in our internal code.
33
33
 */
34
 
#define import__simple_set_pyx import_bzrlib___simple_set_pyx
 
34
#define import__simple_set_pyx import_breezy___simple_set_pyx
35
35
#include "_simple_set_pyx_api.h"
36
36
 
37
37
#if defined(__GNUC__)
703
703
    return 0;
704
704
}
705
705
 
 
706
 
 
707
static PyObject *
 
708
StaticTuple_sizeof(StaticTuple *self)
 
709
{
 
710
        Py_ssize_t res;
 
711
 
 
712
        res = _PyObject_SIZE(&StaticTuple_Type) + (int)self->size * sizeof(void*);
 
713
        return PyInt_FromSsize_t(res);
 
714
}
 
715
 
 
716
 
 
717
 
706
718
static char StaticTuple_doc[] =
707
719
    "C implementation of a StaticTuple structure."
708
720
    "\n This is used as StaticTuple(item1, item2, item3)"
722
734
     "Create a StaticTuple from a given sequence. This functions"
723
735
     " the same as the tuple() constructor."},
724
736
    {"__reduce__", (PyCFunction)StaticTuple_reduce, METH_NOARGS, StaticTuple_reduce_doc},
 
737
    {"__sizeof__",  (PyCFunction)StaticTuple_sizeof, METH_NOARGS}, 
725
738
    {NULL, NULL} /* sentinel */
726
739
};
727
740
 
769
782
PyTypeObject StaticTuple_Type = {
770
783
    PyObject_HEAD_INIT(NULL)
771
784
    0,                                           /* ob_size */
772
 
    "bzrlib._static_tuple_c.StaticTuple",        /* tp_name */
 
785
    "breezy._static_tuple_c.StaticTuple",        /* tp_name */
773
786
    sizeof(StaticTuple),                         /* tp_basicsize */
774
787
    sizeof(PyObject *),                          /* tp_itemsize */
775
788
    (destructor)StaticTuple_dealloc,             /* tp_dealloc */
881
894
     * versus how pyrex 0.9.8 and cython 0.11 export it.
882
895
     * Namely 0.9.6 exports import__simple_set_pyx and tries to
883
896
     * "import _simple_set_pyx" but it is available only as
884
 
     * "import bzrlib._simple_set_pyx"
 
897
     * "import breezy._simple_set_pyx"
885
898
     * It is a shame to hack up sys.modules, but that is what we've got to do.
886
899
     */
887
900
    PyObject *sys_module = NULL, *modules = NULL, *set_module = NULL;
890
903
    /* Clear out the current ImportError exception, and try again. */
891
904
    PyErr_Clear();
892
905
    /* Note that this only seems to work if somewhere else imports
893
 
     * bzrlib._simple_set_pyx before importing bzrlib._static_tuple_c
 
906
     * breezy._simple_set_pyx before importing breezy._static_tuple_c
894
907
     */
895
 
    set_module = PyImport_ImportModule("bzrlib._simple_set_pyx");
 
908
    set_module = PyImport_ImportModule("breezy._simple_set_pyx");
896
909
    if (set_module == NULL) {
897
910
        goto end;
898
911
    }
907
920
    }
908
921
    PyDict_SetItemString(modules, "_simple_set_pyx", set_module);
909
922
    /* Now that we have hacked it in, try the import again. */
910
 
    retval = import_bzrlib___simple_set_pyx();
 
923
    retval = import_breezy___simple_set_pyx();
911
924
end:
912
925
    Py_XDECREF(set_module);
913
926
    Py_XDECREF(sys_module);
932
945
 
933
946
    Py_INCREF(&StaticTuple_Type);
934
947
    PyModule_AddObject(m, "StaticTuple", (PyObject *)&StaticTuple_Type);
935
 
    if (import_bzrlib___simple_set_pyx() == -1
 
948
    if (import_breezy___simple_set_pyx() == -1
936
949
        && _workaround_pyrex_096() == -1)
937
950
    {
938
951
        return;