1 /* Generated by Cython 0.29.23 */
2
3 #ifndef PY_SSIZE_T_CLEAN
4 #define PY_SSIZE_T_CLEAN
5 #endif /* PY_SSIZE_T_CLEAN */
6 #include "Python.h"
7 #ifndef Py_PYTHON_H
8 #error Python headers needed to compile C extensions, please install development version of Python.
9 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
10 #error Cython requires Python 2.6+ or Python 3.3+.
11 #else
12 #define CYTHON_ABI "0_29_23"
13 #define CYTHON_HEX_VERSION 0x001D17F0
14 #define CYTHON_FUTURE_DIVISION 1
15 #include <stddef.h>
16 #ifndef offsetof
17 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
18 #endif
19 #if !defined(WIN32) && !defined(MS_WINDOWS)
20 #ifndef __stdcall
21 #define __stdcall
22 #endif
23 #ifndef __cdecl
24 #define __cdecl
25 #endif
26 #ifndef __fastcall
27 #define __fastcall
28 #endif
29 #endif
30 #ifndef DL_IMPORT
31 #define DL_IMPORT(t) t
32 #endif
33 #ifndef DL_EXPORT
34 #define DL_EXPORT(t) t
35 #endif
36 #define __PYX_COMMA ,
37 #ifndef HAVE_LONG_LONG
38 #if PY_VERSION_HEX >= 0x02070000
39 #define HAVE_LONG_LONG
40 #endif
41 #endif
42 #ifndef PY_LONG_LONG
43 #define PY_LONG_LONG LONG_LONG
44 #endif
45 #ifndef Py_HUGE_VAL
46 #define Py_HUGE_VAL HUGE_VAL
47 #endif
48 #ifdef PYPY_VERSION
49 #define CYTHON_COMPILING_IN_PYPY 1
50 #define CYTHON_COMPILING_IN_PYSTON 0
51 #define CYTHON_COMPILING_IN_CPYTHON 0
52 #undef CYTHON_USE_TYPE_SLOTS
53 #define CYTHON_USE_TYPE_SLOTS 0
54 #undef CYTHON_USE_PYTYPE_LOOKUP
55 #define CYTHON_USE_PYTYPE_LOOKUP 0
56 #if PY_VERSION_HEX < 0x03050000
57 #undef CYTHON_USE_ASYNC_SLOTS
58 #define CYTHON_USE_ASYNC_SLOTS 0
59 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
60 #define CYTHON_USE_ASYNC_SLOTS 1
61 #endif
62 #undef CYTHON_USE_PYLIST_INTERNALS
63 #define CYTHON_USE_PYLIST_INTERNALS 0
64 #undef CYTHON_USE_UNICODE_INTERNALS
65 #define CYTHON_USE_UNICODE_INTERNALS 0
66 #undef CYTHON_USE_UNICODE_WRITER
67 #define CYTHON_USE_UNICODE_WRITER 0
68 #undef CYTHON_USE_PYLONG_INTERNALS
69 #define CYTHON_USE_PYLONG_INTERNALS 0
70 #undef CYTHON_AVOID_BORROWED_REFS
71 #define CYTHON_AVOID_BORROWED_REFS 1
72 #undef CYTHON_ASSUME_SAFE_MACROS
73 #define CYTHON_ASSUME_SAFE_MACROS 0
74 #undef CYTHON_UNPACK_METHODS
75 #define CYTHON_UNPACK_METHODS 0
76 #undef CYTHON_FAST_THREAD_STATE
77 #define CYTHON_FAST_THREAD_STATE 0
78 #undef CYTHON_FAST_PYCALL
79 #define CYTHON_FAST_PYCALL 0
80 #undef CYTHON_PEP489_MULTI_PHASE_INIT
81 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
82 #undef CYTHON_USE_TP_FINALIZE
83 #define CYTHON_USE_TP_FINALIZE 0
84 #undef CYTHON_USE_DICT_VERSIONS
85 #define CYTHON_USE_DICT_VERSIONS 0
86 #undef CYTHON_USE_EXC_INFO_STACK
87 #define CYTHON_USE_EXC_INFO_STACK 0
88 #elif defined(PYSTON_VERSION)
89 #define CYTHON_COMPILING_IN_PYPY 0
90 #define CYTHON_COMPILING_IN_PYSTON 1
91 #define CYTHON_COMPILING_IN_CPYTHON 0
92 #ifndef CYTHON_USE_TYPE_SLOTS
93 #define CYTHON_USE_TYPE_SLOTS 1
94 #endif
95 #undef CYTHON_USE_PYTYPE_LOOKUP
96 #define CYTHON_USE_PYTYPE_LOOKUP 0
97 #undef CYTHON_USE_ASYNC_SLOTS
98 #define CYTHON_USE_ASYNC_SLOTS 0
99 #undef CYTHON_USE_PYLIST_INTERNALS
100 #define CYTHON_USE_PYLIST_INTERNALS 0
101 #ifndef CYTHON_USE_UNICODE_INTERNALS
102 #define CYTHON_USE_UNICODE_INTERNALS 1
103 #endif
104 #undef CYTHON_USE_UNICODE_WRITER
105 #define CYTHON_USE_UNICODE_WRITER 0
106 #undef CYTHON_USE_PYLONG_INTERNALS
107 #define CYTHON_USE_PYLONG_INTERNALS 0
108 #ifndef CYTHON_AVOID_BORROWED_REFS
109 #define CYTHON_AVOID_BORROWED_REFS 0
110 #endif
111 #ifndef CYTHON_ASSUME_SAFE_MACROS
112 #define CYTHON_ASSUME_SAFE_MACROS 1
113 #endif
114 #ifndef CYTHON_UNPACK_METHODS
115 #define CYTHON_UNPACK_METHODS 1
116 #endif
117 #undef CYTHON_FAST_THREAD_STATE
118 #define CYTHON_FAST_THREAD_STATE 0
119 #undef CYTHON_FAST_PYCALL
120 #define CYTHON_FAST_PYCALL 0
121 #undef CYTHON_PEP489_MULTI_PHASE_INIT
122 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
123 #undef CYTHON_USE_TP_FINALIZE
124 #define CYTHON_USE_TP_FINALIZE 0
125 #undef CYTHON_USE_DICT_VERSIONS
126 #define CYTHON_USE_DICT_VERSIONS 0
127 #undef CYTHON_USE_EXC_INFO_STACK
128 #define CYTHON_USE_EXC_INFO_STACK 0
129 #else
130 #define CYTHON_COMPILING_IN_PYPY 0
131 #define CYTHON_COMPILING_IN_PYSTON 0
132 #define CYTHON_COMPILING_IN_CPYTHON 1
133 #ifndef CYTHON_USE_TYPE_SLOTS
134 #define CYTHON_USE_TYPE_SLOTS 1
135 #endif
136 #if PY_VERSION_HEX < 0x02070000
137 #undef CYTHON_USE_PYTYPE_LOOKUP
138 #define CYTHON_USE_PYTYPE_LOOKUP 0
139 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
140 #define CYTHON_USE_PYTYPE_LOOKUP 1
141 #endif
142 #if PY_MAJOR_VERSION < 3
143 #undef CYTHON_USE_ASYNC_SLOTS
144 #define CYTHON_USE_ASYNC_SLOTS 0
145 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
146 #define CYTHON_USE_ASYNC_SLOTS 1
147 #endif
148 #if PY_VERSION_HEX < 0x02070000
149 #undef CYTHON_USE_PYLONG_INTERNALS
150 #define CYTHON_USE_PYLONG_INTERNALS 0
151 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
152 #define CYTHON_USE_PYLONG_INTERNALS 1
153 #endif
154 #ifndef CYTHON_USE_PYLIST_INTERNALS
155 #define CYTHON_USE_PYLIST_INTERNALS 1
156 #endif
157 #ifndef CYTHON_USE_UNICODE_INTERNALS
158 #define CYTHON_USE_UNICODE_INTERNALS 1
159 #endif
160 #if PY_VERSION_HEX < 0x030300F0
161 #undef CYTHON_USE_UNICODE_WRITER
162 #define CYTHON_USE_UNICODE_WRITER 0
163 #elif !defined(CYTHON_USE_UNICODE_WRITER)
164 #define CYTHON_USE_UNICODE_WRITER 1
165 #endif
166 #ifndef CYTHON_AVOID_BORROWED_REFS
167 #define CYTHON_AVOID_BORROWED_REFS 0
168 #endif
169 #ifndef CYTHON_ASSUME_SAFE_MACROS
170 #define CYTHON_ASSUME_SAFE_MACROS 1
171 #endif
172 #ifndef CYTHON_UNPACK_METHODS
173 #define CYTHON_UNPACK_METHODS 1
174 #endif
175 #ifndef CYTHON_FAST_THREAD_STATE
176 #define CYTHON_FAST_THREAD_STATE 1
177 #endif
178 #ifndef CYTHON_FAST_PYCALL
179 #define CYTHON_FAST_PYCALL 1
180 #endif
181 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
182 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
183 #endif
184 #ifndef CYTHON_USE_TP_FINALIZE
185 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
186 #endif
187 #ifndef CYTHON_USE_DICT_VERSIONS
188 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
189 #endif
190 #ifndef CYTHON_USE_EXC_INFO_STACK
191 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
192 #endif
193 #endif
194 #if !defined(CYTHON_FAST_PYCCALL)
195 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
196 #endif
197 #if CYTHON_USE_PYLONG_INTERNALS
198 #include "longintrepr.h"
199 #undef SHIFT
200 #undef BASE
201 #undef MASK
202 #ifdef SIZEOF_VOID_P
203 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
204 #endif
205 #endif
206 #ifndef __has_attribute
207 #define __has_attribute(x) 0
208 #endif
209 #ifndef __has_cpp_attribute
210 #define __has_cpp_attribute(x) 0
211 #endif
212 #ifndef CYTHON_RESTRICT
213 #if defined(__GNUC__)
214 #define CYTHON_RESTRICT __restrict__
215 #elif defined(_MSC_VER) && _MSC_VER >= 1400
216 #define CYTHON_RESTRICT __restrict
217 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
218 #define CYTHON_RESTRICT restrict
219 #else
220 #define CYTHON_RESTRICT
221 #endif
222 #endif
223 #ifndef CYTHON_UNUSED
224 # if defined(__GNUC__)
225 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
226 # define CYTHON_UNUSED __attribute__ ((__unused__))
227 # else
228 # define CYTHON_UNUSED
229 # endif
230 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
231 # define CYTHON_UNUSED __attribute__ ((__unused__))
232 # else
233 # define CYTHON_UNUSED
234 # endif
235 #endif
236 #ifndef CYTHON_MAYBE_UNUSED_VAR
237 # if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)238 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
239 # else
240 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
241 # endif
242 #endif
243 #ifndef CYTHON_NCP_UNUSED
244 # if CYTHON_COMPILING_IN_CPYTHON
245 # define CYTHON_NCP_UNUSED
246 # else
247 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
248 # endif
249 #endif
250 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
251 #ifdef _MSC_VER
252 #ifndef _MSC_STDINT_H_
253 #if _MSC_VER < 1300
254 typedef unsigned char uint8_t;
255 typedef unsigned int uint32_t;
256 #else
257 typedef unsigned __int8 uint8_t;
258 typedef unsigned __int32 uint32_t;
259 #endif
260 #endif
261 #else
262 #include <stdint.h>
263 #endif
264 #ifndef CYTHON_FALLTHROUGH
265 #if defined(__cplusplus) && __cplusplus >= 201103L
266 #if __has_cpp_attribute(fallthrough)
267 #define CYTHON_FALLTHROUGH [[fallthrough]]
268 #elif __has_cpp_attribute(clang::fallthrough)
269 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
270 #elif __has_cpp_attribute(gnu::fallthrough)
271 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
272 #endif
273 #endif
274 #ifndef CYTHON_FALLTHROUGH
275 #if __has_attribute(fallthrough)
276 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
277 #else
278 #define CYTHON_FALLTHROUGH
279 #endif
280 #endif
281 #if defined(__clang__ ) && defined(__apple_build_version__)
282 #if __apple_build_version__ < 7000000
283 #undef CYTHON_FALLTHROUGH
284 #define CYTHON_FALLTHROUGH
285 #endif
286 #endif
287 #endif
288
289 #ifndef CYTHON_INLINE
290 #if defined(__clang__)
291 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
292 #elif defined(__GNUC__)
293 #define CYTHON_INLINE __inline__
294 #elif defined(_MSC_VER)
295 #define CYTHON_INLINE __inline
296 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
297 #define CYTHON_INLINE inline
298 #else
299 #define CYTHON_INLINE
300 #endif
301 #endif
302
303 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
304 #define Py_OptimizeFlag 0
305 #endif
306 #define __PYX_BUILD_PY_SSIZE_T "n"
307 #define CYTHON_FORMAT_SSIZE_T "z"
308 #if PY_MAJOR_VERSION < 3
309 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
310 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
311 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
312 #define __Pyx_DefaultClassType PyClass_Type
313 #else
314 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
315 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
316 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
317 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
318 #else
319 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
320 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
321 #endif
322 #define __Pyx_DefaultClassType PyType_Type
323 #endif
324 #ifndef Py_TPFLAGS_CHECKTYPES
325 #define Py_TPFLAGS_CHECKTYPES 0
326 #endif
327 #ifndef Py_TPFLAGS_HAVE_INDEX
328 #define Py_TPFLAGS_HAVE_INDEX 0
329 #endif
330 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
331 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
332 #endif
333 #ifndef Py_TPFLAGS_HAVE_FINALIZE
334 #define Py_TPFLAGS_HAVE_FINALIZE 0
335 #endif
336 #ifndef METH_STACKLESS
337 #define METH_STACKLESS 0
338 #endif
339 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
340 #ifndef METH_FASTCALL
341 #define METH_FASTCALL 0x80
342 #endif
343 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
344 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
345 Py_ssize_t nargs, PyObject *kwnames);
346 #else
347 #define __Pyx_PyCFunctionFast _PyCFunctionFast
348 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
349 #endif
350 #if CYTHON_FAST_PYCCALL
351 #define __Pyx_PyFastCFunction_Check(func)\
352 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
353 #else
354 #define __Pyx_PyFastCFunction_Check(func) 0
355 #endif
356 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
357 #define PyObject_Malloc(s) PyMem_Malloc(s)
358 #define PyObject_Free(p) PyMem_Free(p)
359 #define PyObject_Realloc(p) PyMem_Realloc(p)
360 #endif
361 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
362 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
363 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
364 #define PyMem_RawFree(p) PyMem_Free(p)
365 #endif
366 #if CYTHON_COMPILING_IN_PYSTON
367 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
368 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
369 #else
370 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
371 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
372 #endif
373 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
374 #define __Pyx_PyThreadState_Current PyThreadState_GET()
375 #elif PY_VERSION_HEX >= 0x03060000
376 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
377 #elif PY_VERSION_HEX >= 0x03000000
378 #define __Pyx_PyThreadState_Current PyThreadState_GET()
379 #else
380 #define __Pyx_PyThreadState_Current _PyThreadState_Current
381 #endif
382 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
383 #include "pythread.h"
384 #define Py_tss_NEEDS_INIT 0
385 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)386 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
387 *key = PyThread_create_key();
388 return 0;
389 }
PyThread_tss_alloc(void)390 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
391 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
392 *key = Py_tss_NEEDS_INIT;
393 return key;
394 }
PyThread_tss_free(Py_tss_t * key)395 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
396 PyObject_Free(key);
397 }
PyThread_tss_is_created(Py_tss_t * key)398 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
399 return *key != Py_tss_NEEDS_INIT;
400 }
PyThread_tss_delete(Py_tss_t * key)401 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
402 PyThread_delete_key(*key);
403 *key = Py_tss_NEEDS_INIT;
404 }
PyThread_tss_set(Py_tss_t * key,void * value)405 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
406 return PyThread_set_key_value(*key, value);
407 }
PyThread_tss_get(Py_tss_t * key)408 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
409 return PyThread_get_key_value(*key);
410 }
411 #endif
412 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
413 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
414 #else
415 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
416 #endif
417 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
418 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
419 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
420 #else
421 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
422 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
423 #endif
424 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
425 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
426 #else
427 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
428 #endif
429 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
430 #define CYTHON_PEP393_ENABLED 1
431 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
432 0 : _PyUnicode_Ready((PyObject *)(op)))
433 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
434 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
435 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
436 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
437 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
438 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
439 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
440 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
441 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
442 #else
443 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
444 #endif
445 #else
446 #define CYTHON_PEP393_ENABLED 0
447 #define PyUnicode_1BYTE_KIND 1
448 #define PyUnicode_2BYTE_KIND 2
449 #define PyUnicode_4BYTE_KIND 4
450 #define __Pyx_PyUnicode_READY(op) (0)
451 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
452 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
453 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
454 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
455 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
456 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
457 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
458 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
459 #endif
460 #if CYTHON_COMPILING_IN_PYPY
461 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
462 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
463 #else
464 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
465 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
466 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
467 #endif
468 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
469 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
470 #endif
471 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
472 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
473 #endif
474 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
475 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
476 #endif
477 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
478 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
479 #if PY_MAJOR_VERSION >= 3
480 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
481 #else
482 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
483 #endif
484 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
485 #define PyObject_ASCII(o) PyObject_Repr(o)
486 #endif
487 #if PY_MAJOR_VERSION >= 3
488 #define PyBaseString_Type PyUnicode_Type
489 #define PyStringObject PyUnicodeObject
490 #define PyString_Type PyUnicode_Type
491 #define PyString_Check PyUnicode_Check
492 #define PyString_CheckExact PyUnicode_CheckExact
493 #ifndef PyObject_Unicode
494 #define PyObject_Unicode PyObject_Str
495 #endif
496 #endif
497 #if PY_MAJOR_VERSION >= 3
498 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
499 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
500 #else
501 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
502 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
503 #endif
504 #ifndef PySet_CheckExact
505 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
506 #endif
507 #if PY_VERSION_HEX >= 0x030900A4
508 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
509 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
510 #else
511 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
512 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
513 #endif
514 #if CYTHON_ASSUME_SAFE_MACROS
515 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
516 #else
517 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
518 #endif
519 #if PY_MAJOR_VERSION >= 3
520 #define PyIntObject PyLongObject
521 #define PyInt_Type PyLong_Type
522 #define PyInt_Check(op) PyLong_Check(op)
523 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
524 #define PyInt_FromString PyLong_FromString
525 #define PyInt_FromUnicode PyLong_FromUnicode
526 #define PyInt_FromLong PyLong_FromLong
527 #define PyInt_FromSize_t PyLong_FromSize_t
528 #define PyInt_FromSsize_t PyLong_FromSsize_t
529 #define PyInt_AsLong PyLong_AsLong
530 #define PyInt_AS_LONG PyLong_AS_LONG
531 #define PyInt_AsSsize_t PyLong_AsSsize_t
532 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
533 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
534 #define PyNumber_Int PyNumber_Long
535 #endif
536 #if PY_MAJOR_VERSION >= 3
537 #define PyBoolObject PyLongObject
538 #endif
539 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
540 #ifndef PyUnicode_InternFromString
541 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
542 #endif
543 #endif
544 #if PY_VERSION_HEX < 0x030200A4
545 typedef long Py_hash_t;
546 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
547 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
548 #else
549 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
550 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
551 #endif
552 #if PY_MAJOR_VERSION >= 3
553 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
554 #else
555 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
556 #endif
557 #if CYTHON_USE_ASYNC_SLOTS
558 #if PY_VERSION_HEX >= 0x030500B1
559 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
560 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
561 #else
562 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
563 #endif
564 #else
565 #define __Pyx_PyType_AsAsync(obj) NULL
566 #endif
567 #ifndef __Pyx_PyAsyncMethodsStruct
568 typedef struct {
569 unaryfunc am_await;
570 unaryfunc am_aiter;
571 unaryfunc am_anext;
572 } __Pyx_PyAsyncMethodsStruct;
573 #endif
574
575 #if defined(WIN32) || defined(MS_WINDOWS)
576 #define _USE_MATH_DEFINES
577 #endif
578 #include <math.h>
579 #ifdef NAN
580 #define __PYX_NAN() ((float) NAN)
581 #else
__PYX_NAN()582 static CYTHON_INLINE float __PYX_NAN() {
583 float value;
584 memset(&value, 0xFF, sizeof(value));
585 return value;
586 }
587 #endif
588 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
589 #define __Pyx_truncl trunc
590 #else
591 #define __Pyx_truncl truncl
592 #endif
593
594 #define __PYX_MARK_ERR_POS(f_index, lineno) \
595 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
596 #define __PYX_ERR(f_index, lineno, Ln_error) \
597 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
598
599 #ifndef __PYX_EXTERN_C
600 #ifdef __cplusplus
601 #define __PYX_EXTERN_C extern "C"
602 #else
603 #define __PYX_EXTERN_C extern
604 #endif
605 #endif
606
607 #define __PYX_HAVE__borg__platform__linux
608 #define __PYX_HAVE_API__borg__platform__linux
609 /* Early includes */
610 #include <errno.h>
611 #include <stdint.h>
612 #include "sys/types.h"
613 #include "sys/acl.h"
614 #include "acl/libacl.h"
615 #include "linux/fs.h"
616 #include "sys/ioctl.h"
617 #include "unistd.h"
618 #include "string.h"
619 #ifdef _OPENMP
620 #include <omp.h>
621 #endif /* _OPENMP */
622
623 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
624 #define CYTHON_WITHOUT_ASSERTIONS
625 #endif
626
627 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
628 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
629
630 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
631 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
632 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
633 #define __PYX_DEFAULT_STRING_ENCODING ""
634 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
635 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
636 #define __Pyx_uchar_cast(c) ((unsigned char)c)
637 #define __Pyx_long_cast(x) ((long)x)
638 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
639 (sizeof(type) < sizeof(Py_ssize_t)) ||\
640 (sizeof(type) > sizeof(Py_ssize_t) &&\
641 likely(v < (type)PY_SSIZE_T_MAX ||\
642 v == (type)PY_SSIZE_T_MAX) &&\
643 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
644 v == (type)PY_SSIZE_T_MIN))) ||\
645 (sizeof(type) == sizeof(Py_ssize_t) &&\
646 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
647 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)648 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
649 return (size_t) i < (size_t) limit;
650 }
651 #if defined (__cplusplus) && __cplusplus >= 201103L
652 #include <cstdlib>
653 #define __Pyx_sst_abs(value) std::abs(value)
654 #elif SIZEOF_INT >= SIZEOF_SIZE_T
655 #define __Pyx_sst_abs(value) abs(value)
656 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
657 #define __Pyx_sst_abs(value) labs(value)
658 #elif defined (_MSC_VER)
659 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
660 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
661 #define __Pyx_sst_abs(value) llabs(value)
662 #elif defined (__GNUC__)
663 #define __Pyx_sst_abs(value) __builtin_llabs(value)
664 #else
665 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
666 #endif
667 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
668 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
669 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
670 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
671 #define __Pyx_PyBytes_FromString PyBytes_FromString
672 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
673 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
674 #if PY_MAJOR_VERSION < 3
675 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
676 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
677 #else
678 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
679 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
680 #endif
681 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
682 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
683 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
684 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
685 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
686 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
687 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
688 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
689 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
690 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
691 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
692 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
693 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
694 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
695 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
696 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)697 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
698 const Py_UNICODE *u_end = u;
699 while (*u_end++) ;
700 return (size_t)(u_end - u - 1);
701 }
702 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
703 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
704 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
705 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
706 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
707 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
708 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
709 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
710 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
711 #define __Pyx_PySequence_Tuple(obj)\
712 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
713 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
714 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
715 #if CYTHON_ASSUME_SAFE_MACROS
716 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
717 #else
718 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
719 #endif
720 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
721 #if PY_MAJOR_VERSION >= 3
722 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
723 #else
724 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
725 #endif
726 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
727 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
728 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)729 static int __Pyx_init_sys_getdefaultencoding_params(void) {
730 PyObject* sys;
731 PyObject* default_encoding = NULL;
732 PyObject* ascii_chars_u = NULL;
733 PyObject* ascii_chars_b = NULL;
734 const char* default_encoding_c;
735 sys = PyImport_ImportModule("sys");
736 if (!sys) goto bad;
737 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
738 Py_DECREF(sys);
739 if (!default_encoding) goto bad;
740 default_encoding_c = PyBytes_AsString(default_encoding);
741 if (!default_encoding_c) goto bad;
742 if (strcmp(default_encoding_c, "ascii") == 0) {
743 __Pyx_sys_getdefaultencoding_not_ascii = 0;
744 } else {
745 char ascii_chars[128];
746 int c;
747 for (c = 0; c < 128; c++) {
748 ascii_chars[c] = c;
749 }
750 __Pyx_sys_getdefaultencoding_not_ascii = 1;
751 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
752 if (!ascii_chars_u) goto bad;
753 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
754 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
755 PyErr_Format(
756 PyExc_ValueError,
757 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
758 default_encoding_c);
759 goto bad;
760 }
761 Py_DECREF(ascii_chars_u);
762 Py_DECREF(ascii_chars_b);
763 }
764 Py_DECREF(default_encoding);
765 return 0;
766 bad:
767 Py_XDECREF(default_encoding);
768 Py_XDECREF(ascii_chars_u);
769 Py_XDECREF(ascii_chars_b);
770 return -1;
771 }
772 #endif
773 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
774 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
775 #else
776 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
777 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
778 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)779 static int __Pyx_init_sys_getdefaultencoding_params(void) {
780 PyObject* sys;
781 PyObject* default_encoding = NULL;
782 char* default_encoding_c;
783 sys = PyImport_ImportModule("sys");
784 if (!sys) goto bad;
785 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
786 Py_DECREF(sys);
787 if (!default_encoding) goto bad;
788 default_encoding_c = PyBytes_AsString(default_encoding);
789 if (!default_encoding_c) goto bad;
790 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
791 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
792 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
793 Py_DECREF(default_encoding);
794 return 0;
795 bad:
796 Py_XDECREF(default_encoding);
797 return -1;
798 }
799 #endif
800 #endif
801
802
803 /* Test for GCC > 2.95 */
804 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
805 #define likely(x) __builtin_expect(!!(x), 1)
806 #define unlikely(x) __builtin_expect(!!(x), 0)
807 #else /* !__GNUC__ or GCC < 2.95 */
808 #define likely(x) (x)
809 #define unlikely(x) (x)
810 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)811 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
812
813 static PyObject *__pyx_m = NULL;
814 static PyObject *__pyx_d;
815 static PyObject *__pyx_b;
816 static PyObject *__pyx_cython_runtime = NULL;
817 static PyObject *__pyx_empty_tuple;
818 static PyObject *__pyx_empty_bytes;
819 static PyObject *__pyx_empty_unicode;
820 static int __pyx_lineno;
821 static int __pyx_clineno = 0;
822 static const char * __pyx_cfilenm= __FILE__;
823 static const char *__pyx_filename;
824
825
826 static const char *__pyx_f[] = {
827 "src/borg/platform/linux.pyx",
828 };
829
830 /*--- Type declarations ---*/
831
832 /* --- Runtime support code (head) --- */
833 /* Refnanny.proto */
834 #ifndef CYTHON_REFNANNY
835 #define CYTHON_REFNANNY 0
836 #endif
837 #if CYTHON_REFNANNY
838 typedef struct {
839 void (*INCREF)(void*, PyObject*, int);
840 void (*DECREF)(void*, PyObject*, int);
841 void (*GOTREF)(void*, PyObject*, int);
842 void (*GIVEREF)(void*, PyObject*, int);
843 void* (*SetupContext)(const char*, int, const char*);
844 void (*FinishContext)(void**);
845 } __Pyx_RefNannyAPIStruct;
846 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
847 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
848 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
849 #ifdef WITH_THREAD
850 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
851 if (acquire_gil) {\
852 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
853 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
854 PyGILState_Release(__pyx_gilstate_save);\
855 } else {\
856 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
857 }
858 #else
859 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
860 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
861 #endif
862 #define __Pyx_RefNannyFinishContext()\
863 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
864 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
865 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
866 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
867 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
868 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
869 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
870 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
871 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
872 #else
873 #define __Pyx_RefNannyDeclarations
874 #define __Pyx_RefNannySetupContext(name, acquire_gil)
875 #define __Pyx_RefNannyFinishContext()
876 #define __Pyx_INCREF(r) Py_INCREF(r)
877 #define __Pyx_DECREF(r) Py_DECREF(r)
878 #define __Pyx_GOTREF(r)
879 #define __Pyx_GIVEREF(r)
880 #define __Pyx_XINCREF(r) Py_XINCREF(r)
881 #define __Pyx_XDECREF(r) Py_XDECREF(r)
882 #define __Pyx_XGOTREF(r)
883 #define __Pyx_XGIVEREF(r)
884 #endif
885 #define __Pyx_XDECREF_SET(r, v) do {\
886 PyObject *tmp = (PyObject *) r;\
887 r = v; __Pyx_XDECREF(tmp);\
888 } while (0)
889 #define __Pyx_DECREF_SET(r, v) do {\
890 PyObject *tmp = (PyObject *) r;\
891 r = v; __Pyx_DECREF(tmp);\
892 } while (0)
893 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
894 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
895
896 /* PyObjectGetAttrStr.proto */
897 #if CYTHON_USE_TYPE_SLOTS
898 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
899 #else
900 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
901 #endif
902
903 /* GetBuiltinName.proto */
904 static PyObject *__Pyx_GetBuiltinName(PyObject *name);
905
906 /* RaiseArgTupleInvalid.proto */
907 static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
908 Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
909
910 /* RaiseDoubleKeywords.proto */
911 static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
912
913 /* ParseKeywords.proto */
914 static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[],\
915 PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args,\
916 const char* function_name);
917
918 /* PyDictVersioning.proto */
919 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
920 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
921 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
922 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
923 (version_var) = __PYX_GET_DICT_VERSION(dict);\
924 (cache_var) = (value);
925 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
926 static PY_UINT64_T __pyx_dict_version = 0;\
927 static PyObject *__pyx_dict_cached_value = NULL;\
928 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
929 (VAR) = __pyx_dict_cached_value;\
930 } else {\
931 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
932 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
933 }\
934 }
935 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
936 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
937 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
938 #else
939 #define __PYX_GET_DICT_VERSION(dict) (0)
940 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
941 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
942 #endif
943
944 /* GetModuleGlobalName.proto */
945 #if CYTHON_USE_DICT_VERSIONS
946 #define __Pyx_GetModuleGlobalName(var, name) {\
947 static PY_UINT64_T __pyx_dict_version = 0;\
948 static PyObject *__pyx_dict_cached_value = NULL;\
949 (var) = (likely(__pyx_dict_version == __PYX_GET_DICT_VERSION(__pyx_d))) ?\
950 (likely(__pyx_dict_cached_value) ? __Pyx_NewRef(__pyx_dict_cached_value) : __Pyx_GetBuiltinName(name)) :\
951 __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
952 }
953 #define __Pyx_GetModuleGlobalNameUncached(var, name) {\
954 PY_UINT64_T __pyx_dict_version;\
955 PyObject *__pyx_dict_cached_value;\
956 (var) = __Pyx__GetModuleGlobalName(name, &__pyx_dict_version, &__pyx_dict_cached_value);\
957 }
958 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value);
959 #else
960 #define __Pyx_GetModuleGlobalName(var, name) (var) = __Pyx__GetModuleGlobalName(name)
961 #define __Pyx_GetModuleGlobalNameUncached(var, name) (var) = __Pyx__GetModuleGlobalName(name)
962 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name);
963 #endif
964
965 /* PyObjectCall.proto */
966 #if CYTHON_COMPILING_IN_CPYTHON
967 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
968 #else
969 #define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
970 #endif
971
972 /* PyCFunctionFastCall.proto */
973 #if CYTHON_FAST_PYCCALL
974 static CYTHON_INLINE PyObject *__Pyx_PyCFunction_FastCall(PyObject *func, PyObject **args, Py_ssize_t nargs);
975 #else
976 #define __Pyx_PyCFunction_FastCall(func, args, nargs) (assert(0), NULL)
977 #endif
978
979 /* PyFunctionFastCall.proto */
980 #if CYTHON_FAST_PYCALL
981 #define __Pyx_PyFunction_FastCall(func, args, nargs)\
982 __Pyx_PyFunction_FastCallDict((func), (args), (nargs), NULL)
983 #if 1 || PY_VERSION_HEX < 0x030600B1
984 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs);
985 #else
986 #define __Pyx_PyFunction_FastCallDict(func, args, nargs, kwargs) _PyFunction_FastCallDict(func, args, nargs, kwargs)
987 #endif
988 #define __Pyx_BUILD_ASSERT_EXPR(cond)\
989 (sizeof(char [1 - 2*!(cond)]) - 1)
990 #ifndef Py_MEMBER_SIZE
991 #define Py_MEMBER_SIZE(type, member) sizeof(((type *)0)->member)
992 #endif
993 static size_t __pyx_pyframe_localsplus_offset = 0;
994 #include "frameobject.h"
995 #define __Pxy_PyFrame_Initialize_Offsets()\
996 ((void)__Pyx_BUILD_ASSERT_EXPR(sizeof(PyFrameObject) == offsetof(PyFrameObject, f_localsplus) + Py_MEMBER_SIZE(PyFrameObject, f_localsplus)),\
997 (void)(__pyx_pyframe_localsplus_offset = ((size_t)PyFrame_Type.tp_basicsize) - Py_MEMBER_SIZE(PyFrameObject, f_localsplus)))
998 #define __Pyx_PyFrame_GetLocalsplus(frame)\
999 (assert(__pyx_pyframe_localsplus_offset), (PyObject **)(((char *)(frame)) + __pyx_pyframe_localsplus_offset))
1000 #endif
1001
1002 /* PyObjectCall2Args.proto */
1003 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2);
1004
1005 /* PyObjectCallMethO.proto */
1006 #if CYTHON_COMPILING_IN_CPYTHON
1007 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
1008 #endif
1009
1010 /* PyObjectCallOneArg.proto */
1011 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
1012
1013 /* IterFinish.proto */
1014 static CYTHON_INLINE int __Pyx_IterFinish(void);
1015
1016 /* PyObjectCallNoArg.proto */
1017 #if CYTHON_COMPILING_IN_CPYTHON
1018 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
1019 #else
1020 #define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
1021 #endif
1022
1023 /* PyObjectGetMethod.proto */
1024 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method);
1025
1026 /* PyObjectCallMethod0.proto */
1027 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name);
1028
1029 /* RaiseNeedMoreValuesToUnpack.proto */
1030 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
1031
1032 /* RaiseTooManyValuesToUnpack.proto */
1033 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
1034
1035 /* UnpackItemEndCheck.proto */
1036 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
1037
1038 /* RaiseNoneIterError.proto */
1039 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void);
1040
1041 /* UnpackTupleError.proto */
1042 static void __Pyx_UnpackTupleError(PyObject *, Py_ssize_t index);
1043
1044 /* UnpackTuple2.proto */
1045 #define __Pyx_unpack_tuple2(tuple, value1, value2, is_tuple, has_known_size, decref_tuple)\
1046 (likely(is_tuple || PyTuple_Check(tuple)) ?\
1047 (likely(has_known_size || PyTuple_GET_SIZE(tuple) == 2) ?\
1048 __Pyx_unpack_tuple2_exact(tuple, value1, value2, decref_tuple) :\
1049 (__Pyx_UnpackTupleError(tuple, 2), -1)) :\
1050 __Pyx_unpack_tuple2_generic(tuple, value1, value2, has_known_size, decref_tuple))
1051 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
1052 PyObject* tuple, PyObject** value1, PyObject** value2, int decref_tuple);
1053 static int __Pyx_unpack_tuple2_generic(
1054 PyObject* tuple, PyObject** value1, PyObject** value2, int has_known_size, int decref_tuple);
1055
1056 /* dict_iter.proto */
1057 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* dict, int is_dict, PyObject* method_name,
1058 Py_ssize_t* p_orig_length, int* p_is_dict);
1059 static CYTHON_INLINE int __Pyx_dict_iter_next(PyObject* dict_or_iter, Py_ssize_t orig_length, Py_ssize_t* ppos,
1060 PyObject** pkey, PyObject** pvalue, PyObject** pitem, int is_dict);
1061
1062 /* IncludeStringH.proto */
1063 #include <string.h>
1064
1065 /* decode_c_string_utf16.proto */
__Pyx_PyUnicode_DecodeUTF16(const char * s,Py_ssize_t size,const char * errors)1066 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s, Py_ssize_t size, const char *errors) {
1067 int byteorder = 0;
1068 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1069 }
__Pyx_PyUnicode_DecodeUTF16LE(const char * s,Py_ssize_t size,const char * errors)1070 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char *s, Py_ssize_t size, const char *errors) {
1071 int byteorder = -1;
1072 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1073 }
__Pyx_PyUnicode_DecodeUTF16BE(const char * s,Py_ssize_t size,const char * errors)1074 static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char *s, Py_ssize_t size, const char *errors) {
1075 int byteorder = 1;
1076 return PyUnicode_DecodeUTF16(s, size, errors, &byteorder);
1077 }
1078
1079 /* decode_c_string.proto */
1080 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
1081 const char* cstring, Py_ssize_t start, Py_ssize_t stop,
1082 const char* encoding, const char* errors,
1083 PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors));
1084
1085 /* PyThreadStateGet.proto */
1086 #if CYTHON_FAST_THREAD_STATE
1087 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
1088 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
1089 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
1090 #else
1091 #define __Pyx_PyThreadState_declare
1092 #define __Pyx_PyThreadState_assign
1093 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
1094 #endif
1095
1096 /* PyErrFetchRestore.proto */
1097 #if CYTHON_FAST_THREAD_STATE
1098 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
1099 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
1100 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
1101 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
1102 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
1103 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1104 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1105 #if CYTHON_COMPILING_IN_CPYTHON
1106 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
1107 #else
1108 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1109 #endif
1110 #else
1111 #define __Pyx_PyErr_Clear() PyErr_Clear()
1112 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
1113 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
1114 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
1115 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
1116 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
1117 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
1118 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
1119 #endif
1120
1121 /* RaiseException.proto */
1122 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
1123
1124 /* GetException.proto */
1125 #if CYTHON_FAST_THREAD_STATE
1126 #define __Pyx_GetException(type, value, tb) __Pyx__GetException(__pyx_tstate, type, value, tb)
1127 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1128 #else
1129 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
1130 #endif
1131
1132 /* SwapException.proto */
1133 #if CYTHON_FAST_THREAD_STATE
1134 #define __Pyx_ExceptionSwap(type, value, tb) __Pyx__ExceptionSwap(__pyx_tstate, type, value, tb)
1135 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1136 #else
1137 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
1138 #endif
1139
1140 /* GetTopmostException.proto */
1141 #if CYTHON_USE_EXC_INFO_STACK
1142 static _PyErr_StackItem * __Pyx_PyErr_GetTopmostException(PyThreadState *tstate);
1143 #endif
1144
1145 /* SaveResetException.proto */
1146 #if CYTHON_FAST_THREAD_STATE
1147 #define __Pyx_ExceptionSave(type, value, tb) __Pyx__ExceptionSave(__pyx_tstate, type, value, tb)
1148 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
1149 #define __Pyx_ExceptionReset(type, value, tb) __Pyx__ExceptionReset(__pyx_tstate, type, value, tb)
1150 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
1151 #else
1152 #define __Pyx_ExceptionSave(type, value, tb) PyErr_GetExcInfo(type, value, tb)
1153 #define __Pyx_ExceptionReset(type, value, tb) PyErr_SetExcInfo(type, value, tb)
1154 #endif
1155
1156 /* PyErrExceptionMatches.proto */
1157 #if CYTHON_FAST_THREAD_STATE
1158 #define __Pyx_PyErr_ExceptionMatches(err) __Pyx_PyErr_ExceptionMatchesInState(__pyx_tstate, err)
1159 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err);
1160 #else
1161 #define __Pyx_PyErr_ExceptionMatches(err) PyErr_ExceptionMatches(err)
1162 #endif
1163
1164 /* GetItemInt.proto */
1165 #define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1166 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1167 __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) :\
1168 (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) :\
1169 __Pyx_GetItemInt_Generic(o, to_py_func(i))))
1170 #define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1171 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1172 __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1173 (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
1174 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
1175 int wraparound, int boundscheck);
1176 #define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1177 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1178 __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) :\
1179 (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
1180 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
1181 int wraparound, int boundscheck);
1182 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
1183 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
1184 int is_list, int wraparound, int boundscheck);
1185
1186 /* BytesEquals.proto */
1187 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
1188
1189 /* UnicodeEquals.proto */
1190 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
1191
1192 /* SetItemInt.proto */
1193 #define __Pyx_SetItemInt(o, i, v, type, is_signed, to_py_func, is_list, wraparound, boundscheck)\
1194 (__Pyx_fits_Py_ssize_t(i, type, is_signed) ?\
1195 __Pyx_SetItemInt_Fast(o, (Py_ssize_t)i, v, is_list, wraparound, boundscheck) :\
1196 (is_list ? (PyErr_SetString(PyExc_IndexError, "list assignment index out of range"), -1) :\
1197 __Pyx_SetItemInt_Generic(o, to_py_func(i), v)))
1198 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v);
1199 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v,
1200 int is_list, int wraparound, int boundscheck);
1201
1202 /* ListAppend.proto */
1203 #if CYTHON_USE_PYLIST_INTERNALS && CYTHON_ASSUME_SAFE_MACROS
__Pyx_PyList_Append(PyObject * list,PyObject * x)1204 static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
1205 PyListObject* L = (PyListObject*) list;
1206 Py_ssize_t len = Py_SIZE(list);
1207 if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
1208 Py_INCREF(x);
1209 PyList_SET_ITEM(list, len, x);
1210 __Pyx_SET_SIZE(list, len + 1);
1211 return 0;
1212 }
1213 return PyList_Append(list, x);
1214 }
1215 #else
1216 #define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
1217 #endif
1218
1219 /* SliceObject.proto */
1220 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
1221 PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
1222 PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
1223 int has_cstart, int has_cstop, int wraparound);
1224
1225 /* PyIntCompare.proto */
1226 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1227
1228 /* PyIntCompare.proto */
1229 static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, long intval, long inplace);
1230
1231 /* PyObjectSetAttrStr.proto */
1232 #if CYTHON_USE_TYPE_SLOTS
1233 #define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o, n, NULL)
1234 static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value);
1235 #else
1236 #define __Pyx_PyObject_DelAttrStr(o,n) PyObject_DelAttr(o,n)
1237 #define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
1238 #endif
1239
1240 /* Import.proto */
1241 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
1242
1243 /* ImportFrom.proto */
1244 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
1245
1246 /* PySequenceContains.proto */
__Pyx_PySequence_ContainsTF(PyObject * item,PyObject * seq,int eq)1247 static CYTHON_INLINE int __Pyx_PySequence_ContainsTF(PyObject* item, PyObject* seq, int eq) {
1248 int result = PySequence_Contains(seq, item);
1249 return unlikely(result < 0) ? result : (result == (eq == Py_EQ));
1250 }
1251
1252 /* CalculateMetaclass.proto */
1253 static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
1254
1255 /* Py3ClassCreate.proto */
1256 static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
1257 PyObject *mkw, PyObject *modname, PyObject *doc);
1258 static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
1259 PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
1260
1261 /* FetchCommonType.proto */
1262 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
1263
1264 /* CythonFunctionShared.proto */
1265 #define __Pyx_CyFunction_USED 1
1266 #define __Pyx_CYFUNCTION_STATICMETHOD 0x01
1267 #define __Pyx_CYFUNCTION_CLASSMETHOD 0x02
1268 #define __Pyx_CYFUNCTION_CCLASS 0x04
1269 #define __Pyx_CyFunction_GetClosure(f)\
1270 (((__pyx_CyFunctionObject *) (f))->func_closure)
1271 #define __Pyx_CyFunction_GetClassObj(f)\
1272 (((__pyx_CyFunctionObject *) (f))->func_classobj)
1273 #define __Pyx_CyFunction_Defaults(type, f)\
1274 ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
1275 #define __Pyx_CyFunction_SetDefaultsGetter(f, g)\
1276 ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
1277 typedef struct {
1278 PyCFunctionObject func;
1279 #if PY_VERSION_HEX < 0x030500A0
1280 PyObject *func_weakreflist;
1281 #endif
1282 PyObject *func_dict;
1283 PyObject *func_name;
1284 PyObject *func_qualname;
1285 PyObject *func_doc;
1286 PyObject *func_globals;
1287 PyObject *func_code;
1288 PyObject *func_closure;
1289 PyObject *func_classobj;
1290 void *defaults;
1291 int defaults_pyobjects;
1292 size_t defaults_size; // used by FusedFunction for copying defaults
1293 int flags;
1294 PyObject *defaults_tuple;
1295 PyObject *defaults_kwdict;
1296 PyObject *(*defaults_getter)(PyObject *);
1297 PyObject *func_annotations;
1298 } __pyx_CyFunctionObject;
1299 static PyTypeObject *__pyx_CyFunctionType = 0;
1300 #define __Pyx_CyFunction_Check(obj) (__Pyx_TypeCheck(obj, __pyx_CyFunctionType))
1301 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject* op, PyMethodDef *ml,
1302 int flags, PyObject* qualname,
1303 PyObject *self,
1304 PyObject *module, PyObject *globals,
1305 PyObject* code);
1306 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
1307 size_t size,
1308 int pyobjects);
1309 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
1310 PyObject *tuple);
1311 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
1312 PyObject *dict);
1313 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
1314 PyObject *dict);
1315 static int __pyx_CyFunction_init(void);
1316
1317 /* CythonFunction.proto */
1318 static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml,
1319 int flags, PyObject* qualname,
1320 PyObject *closure,
1321 PyObject *module, PyObject *globals,
1322 PyObject* code);
1323
1324 /* SetNameInClass.proto */
1325 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
1326 #define __Pyx_SetNameInClass(ns, name, value)\
1327 (likely(PyDict_CheckExact(ns)) ? _PyDict_SetItem_KnownHash(ns, name, value, ((PyASCIIObject *) name)->hash) : PyObject_SetItem(ns, name, value))
1328 #elif CYTHON_COMPILING_IN_CPYTHON
1329 #define __Pyx_SetNameInClass(ns, name, value)\
1330 (likely(PyDict_CheckExact(ns)) ? PyDict_SetItem(ns, name, value) : PyObject_SetItem(ns, name, value))
1331 #else
1332 #define __Pyx_SetNameInClass(ns, name, value) PyObject_SetItem(ns, name, value)
1333 #endif
1334
1335 /* CyFunctionClassCell.proto */
1336 static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj);
1337
1338 /* CLineInTraceback.proto */
1339 #ifdef CYTHON_CLINE_IN_TRACEBACK
1340 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
1341 #else
1342 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
1343 #endif
1344
1345 /* CodeObjectCache.proto */
1346 typedef struct {
1347 PyCodeObject* code_object;
1348 int code_line;
1349 } __Pyx_CodeObjectCacheEntry;
1350 struct __Pyx_CodeObjectCache {
1351 int count;
1352 int max_count;
1353 __Pyx_CodeObjectCacheEntry* entries;
1354 };
1355 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
1356 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
1357 static PyCodeObject *__pyx_find_code_object(int code_line);
1358 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
1359
1360 /* AddTraceback.proto */
1361 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1362 int py_line, const char *filename);
1363
1364 /* GCCDiagnostics.proto */
1365 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
1366 #define __Pyx_HAS_GCC_DIAGNOSTIC
1367 #endif
1368
1369 /* CIntToPy.proto */
1370 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
1371
1372 /* CIntFromPy.proto */
1373 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
1374
1375 /* CIntToPy.proto */
1376 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
1377
1378 /* CIntToPy.proto */
1379 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value);
1380
1381 /* CIntFromPy.proto */
1382 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
1383
1384 /* FastTypeChecks.proto */
1385 #if CYTHON_COMPILING_IN_CPYTHON
1386 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1387 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1388 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1389 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1390 #else
1391 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1392 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1393 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1394 #endif
1395 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1396
1397 /* CheckBinaryVersion.proto */
1398 static int __Pyx_check_binary_version(void);
1399
1400 /* InitStrings.proto */
1401 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1402
1403
1404 /* Module declarations from 'libc' */
1405
1406 /* Module declarations from 'libc.errno' */
1407
1408 /* Module declarations from 'libc.stdint' */
1409
1410 /* Module declarations from 'borg.platform.linux' */
1411 static unsigned int __pyx_v_4borg_8platform_5linux_PAGE_MASK;
1412 static PyObject *__pyx_f_4borg_8platform_5linux_acl_append_numeric_ids(PyObject *); /*proto*/
1413 static PyObject *__pyx_f_4borg_8platform_5linux_acl_numeric_ids(PyObject *); /*proto*/
1414 static PyObject *__pyx_f_4borg_8platform_5linux__sync_file_range(PyObject *, PyObject *, PyObject *, PyObject *); /*proto*/
1415 #define __Pyx_MODULE_NAME "borg.platform.linux"
1416 extern int __pyx_module_is_main_borg__platform__linux;
1417 int __pyx_module_is_main_borg__platform__linux = 0;
1418
1419 /* Implementation of 'borg.platform.linux' */
1420 static PyObject *__pyx_builtin_ImportError;
1421 static PyObject *__pyx_builtin_OSError;
1422 static PyObject *__pyx_builtin_super;
1423 static const char __pyx_k_[] = "\n";
1424 static const char __pyx_k_M[] = "M";
1425 static const char __pyx_k_p[] = "p";
1426 static const char __pyx_k__2[] = ":";
1427 static const char __pyx_k__4[] = "";
1428 static const char __pyx_k__6[] = " *#.*";
1429 static const char __pyx_k_fd[] = "fd";
1430 static const char __pyx_k_os[] = "os";
1431 static const char __pyx_k_re[] = "re";
1432 static const char __pyx_k_st[] = "st";
1433 static const char __pyx_k_acl[] = "acl";
1434 static const char __pyx_k_doc[] = "__doc__";
1435 static const char __pyx_k_get[] = "get";
1436 static const char __pyx_k_sub[] = "sub";
1437 static const char __pyx_k_base[] = "base";
1438 static const char __pyx_k_data[] = "data";
1439 static const char __pyx_k_init[] = "__init__";
1440 static const char __pyx_k_item[] = "item";
1441 static const char __pyx_k_main[] = "__main__";
1442 static const char __pyx_k_mode[] = "mode";
1443 static const char __pyx_k_name[] = "__name__";
1444 static const char __pyx_k_open[] = "open";
1445 static const char __pyx_k_path[] = "path";
1446 static const char __pyx_k_self[] = "self";
1447 static const char __pyx_k_stat[] = "stat";
1448 static const char __pyx_k_sync[] = "sync";
1449 static const char __pyx_k_test[] = "__test__";
1450 static const char __pyx_k_user[] = "user";
1451 static const char __pyx_k_close[] = "close";
1452 static const char __pyx_k_entry[] = "entry";
1453 static const char __pyx_k_flags[] = "flags";
1454 static const char __pyx_k_flush[] = "flush";
1455 static const char __pyx_k_group[] = "group";
1456 static const char __pyx_k_items[] = "items";
1457 static const char __pyx_k_posix[] = "posix";
1458 static const char __pyx_k_split[] = "split";
1459 static const char __pyx_k_super[] = "super";
1460 static const char __pyx_k_write[] = "write";
1461 static const char __pyx_k_1_1_04[] = "1.1_04";
1462 static const char __pyx_k_binary[] = "binary";
1463 static const char __pyx_k_fields[] = "fields";
1464 static const char __pyx_k_fileno[] = "fileno";
1465 static const char __pyx_k_import[] = "__import__";
1466 static const char __pyx_k_module[] = "__module__";
1467 static const char __pyx_k_offset[] = "offset";
1468 static const char __pyx_k_swidth[] = "swidth";
1469 static const char __pyx_k_OSError[] = "OSError";
1470 static const char __pyx_k_S_ISBLK[] = "S_ISBLK";
1471 static const char __pyx_k_S_ISCHR[] = "S_ISCHR";
1472 static const char __pyx_k_S_ISLNK[] = "S_ISLNK";
1473 static const char __pyx_k_acl_get[] = "acl_get";
1474 static const char __pyx_k_acl_set[] = "acl_set";
1475 static const char __pyx_k_compile[] = "compile";
1476 static const char __pyx_k_entries[] = "entries";
1477 static const char __pyx_k_helpers[] = "helpers";
1478 static const char __pyx_k_open_fd[] = "open_fd";
1479 static const char __pyx_k_prepare[] = "__prepare__";
1480 static const char __pyx_k_st_mode[] = "st_mode";
1481 static const char __pyx_k_DONTNEED[] = "DONTNEED";
1482 static const char __pyx_k_O_RDONLY[] = "O_RDONLY";
1483 static const char __pyx_k_SyncFile[] = "SyncFile";
1484 static const char __pyx_k_bsd_flag[] = "bsd_flag";
1485 static const char __pyx_k_fsencode[] = "fsencode";
1486 static const char __pyx_k_qualname[] = "__qualname__";
1487 static const char __pyx_k_strerror[] = "strerror";
1488 static const char __pyx_k_user2uid[] = "user2uid";
1489 static const char __pyx_k_UF_APPEND[] = "UF_APPEND";
1490 static const char __pyx_k_UF_NODUMP[] = "UF_NODUMP";
1491 static const char __pyx_k_bsd_flags[] = "bsd_flags";
1492 static const char __pyx_k_converter[] = "converter";
1493 static const char __pyx_k_fdatasync[] = "fdatasync";
1494 static const char __pyx_k_get_flags[] = "get_flags";
1495 static const char __pyx_k_group2gid[] = "group2gid";
1496 static const char __pyx_k_last_sync[] = "last_sync";
1497 static const char __pyx_k_metaclass[] = "__metaclass__";
1498 static const char __pyx_k_set_flags[] = "set_flags";
1499 static const char __pyx_k_O_NOFOLLOW[] = "O_NOFOLLOW";
1500 static const char __pyx_k_O_NONBLOCK[] = "O_NONBLOCK";
1501 static const char __pyx_k_access_acl[] = "access_acl";
1502 static const char __pyx_k_acl_access[] = "acl_access";
1503 static const char __pyx_k_comment_re[] = "_comment_re";
1504 static const char __pyx_k_linux_flag[] = "linux_flag";
1505 static const char __pyx_k_subprocess[] = "subprocess";
1506 static const char __pyx_k_API_VERSION[] = "API_VERSION";
1507 static const char __pyx_k_ImportError[] = "ImportError";
1508 static const char __pyx_k_access_text[] = "access_text";
1509 static const char __pyx_k_acl_default[] = "acl_default";
1510 static const char __pyx_k_default_acl[] = "default_acl";
1511 static const char __pyx_k_linux_flags[] = "linux_flags";
1512 static const char __pyx_k_safe_decode[] = "safe_decode";
1513 static const char __pyx_k_safe_encode[] = "safe_encode";
1514 static const char __pyx_k_workarounds[] = "workarounds";
1515 static const char __pyx_k_BaseSyncFile[] = "BaseSyncFile";
1516 static const char __pyx_k_UF_IMMUTABLE[] = "UF_IMMUTABLE";
1517 static const char __pyx_k_basesyncfile[] = "basesyncfile";
1518 static const char __pyx_k_default_text[] = "default_text";
1519 static const char __pyx_k_error_number[] = "error_number";
1520 static const char __pyx_k_pending_sync[] = "pending_sync";
1521 static const char __pyx_k_safe_fadvise[] = "safe_fadvise";
1522 static const char __pyx_k_write_window[] = "write_window";
1523 static const char __pyx_k_SyncFile_sync[] = "SyncFile.sync";
1524 static const char __pyx_k_UF_COMPRESSED[] = "UF_COMPRESSED";
1525 static const char __pyx_k_numeric_owner[] = "numeric_owner";
1526 static const char __pyx_k_syncfilerange[] = "syncfilerange";
1527 static const char __pyx_k_SyncFile_write[] = "SyncFile.write";
1528 static const char __pyx_k_SyncFile___init[] = "SyncFile.__init__";
1529 static const char __pyx_k_follow_symlinks[] = "follow_symlinks";
1530 static const char __pyx_k_sync_file_range[] = "sync_file_range";
1531 static const char __pyx_k_BSD_TO_LINUX_FLAGS[] = "BSD_TO_LINUX_FLAGS";
1532 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1533 static const char __pyx_k_borg_platform_linux[] = "borg.platform.linux";
1534 static const char __pyx_k_SYNC_FILE_RANGE_WRITE[] = "SYNC_FILE_RANGE_WRITE";
1535 static const char __pyx_k_acl_use_local_uid_gid[] = "acl_use_local_uid_gid";
1536 static const char __pyx_k_SYNC_FILE_RANGE_LOADED[] = "SYNC_FILE_RANGE_LOADED";
1537 static const char __pyx_k_length_d_not_page_aligned[] = "length %d not page-aligned";
1538 static const char __pyx_k_offset_d_not_page_aligned[] = "offset %d not page-aligned";
1539 static const char __pyx_k_SYNC_FILE_RANGE_WAIT_AFTER[] = "SYNC_FILE_RANGE_WAIT_AFTER";
1540 static const char __pyx_k_SYNC_FILE_RANGE_WAIT_BEFORE[] = "SYNC_FILE_RANGE_WAIT_BEFORE";
1541 static const char __pyx_k_src_borg_platform_linux_pyx[] = "src/borg/platform/linux.pyx";
1542 static const char __pyx_k_posix_acl_use_stored_uid_gid[] = "posix_acl_use_stored_uid_gid";
1543 static const char __pyx_k_Implemented_using_sync_file_ran[] = "\n Implemented using sync_file_range for asynchronous write-out and fdatasync for actual durability.\n\n \"write-out\" means that dirty pages (= data that was written) are submitted to an I/O queue and will be send to\n disk in the immediate future.\n ";
1544 static PyObject *__pyx_kp_u_;
1545 static PyObject *__pyx_kp_u_1_1_04;
1546 static PyObject *__pyx_n_s_API_VERSION;
1547 static PyObject *__pyx_n_s_BSD_TO_LINUX_FLAGS;
1548 static PyObject *__pyx_n_s_BaseSyncFile;
1549 static PyObject *__pyx_n_u_DONTNEED;
1550 static PyObject *__pyx_kp_s_Implemented_using_sync_file_ran;
1551 static PyObject *__pyx_n_s_ImportError;
1552 static PyObject *__pyx_n_s_M;
1553 static PyObject *__pyx_n_s_OSError;
1554 static PyObject *__pyx_n_s_O_NOFOLLOW;
1555 static PyObject *__pyx_n_s_O_NONBLOCK;
1556 static PyObject *__pyx_n_s_O_RDONLY;
1557 static PyObject *__pyx_n_s_SYNC_FILE_RANGE_LOADED;
1558 static PyObject *__pyx_n_s_SYNC_FILE_RANGE_WAIT_AFTER;
1559 static PyObject *__pyx_n_s_SYNC_FILE_RANGE_WAIT_BEFORE;
1560 static PyObject *__pyx_n_s_SYNC_FILE_RANGE_WRITE;
1561 static PyObject *__pyx_n_s_S_ISBLK;
1562 static PyObject *__pyx_n_s_S_ISCHR;
1563 static PyObject *__pyx_n_s_S_ISLNK;
1564 static PyObject *__pyx_n_s_SyncFile;
1565 static PyObject *__pyx_n_s_SyncFile___init;
1566 static PyObject *__pyx_n_s_SyncFile_sync;
1567 static PyObject *__pyx_n_s_SyncFile_write;
1568 static PyObject *__pyx_n_s_UF_APPEND;
1569 static PyObject *__pyx_n_s_UF_COMPRESSED;
1570 static PyObject *__pyx_n_s_UF_IMMUTABLE;
1571 static PyObject *__pyx_n_s_UF_NODUMP;
1572 static PyObject *__pyx_kp_u__2;
1573 static PyObject *__pyx_kp_u__4;
1574 static PyObject *__pyx_kp_u__6;
1575 static PyObject *__pyx_n_s_access_acl;
1576 static PyObject *__pyx_n_s_access_text;
1577 static PyObject *__pyx_n_s_acl;
1578 static PyObject *__pyx_n_u_acl_access;
1579 static PyObject *__pyx_n_u_acl_default;
1580 static PyObject *__pyx_n_s_acl_get;
1581 static PyObject *__pyx_n_s_acl_set;
1582 static PyObject *__pyx_n_s_acl_use_local_uid_gid;
1583 static PyObject *__pyx_n_s_base;
1584 static PyObject *__pyx_n_u_basesyncfile;
1585 static PyObject *__pyx_n_s_binary;
1586 static PyObject *__pyx_n_s_borg_platform_linux;
1587 static PyObject *__pyx_n_s_bsd_flag;
1588 static PyObject *__pyx_n_s_bsd_flags;
1589 static PyObject *__pyx_n_s_cline_in_traceback;
1590 static PyObject *__pyx_n_s_close;
1591 static PyObject *__pyx_n_s_comment_re;
1592 static PyObject *__pyx_n_s_compile;
1593 static PyObject *__pyx_n_s_converter;
1594 static PyObject *__pyx_n_s_data;
1595 static PyObject *__pyx_n_s_default_acl;
1596 static PyObject *__pyx_n_s_default_text;
1597 static PyObject *__pyx_n_s_doc;
1598 static PyObject *__pyx_n_s_entries;
1599 static PyObject *__pyx_n_s_entry;
1600 static PyObject *__pyx_n_s_error_number;
1601 static PyObject *__pyx_n_s_fd;
1602 static PyObject *__pyx_n_s_fdatasync;
1603 static PyObject *__pyx_n_s_fields;
1604 static PyObject *__pyx_n_s_fileno;
1605 static PyObject *__pyx_n_s_flags;
1606 static PyObject *__pyx_n_s_flush;
1607 static PyObject *__pyx_n_s_follow_symlinks;
1608 static PyObject *__pyx_n_s_fsencode;
1609 static PyObject *__pyx_n_s_get;
1610 static PyObject *__pyx_n_s_get_flags;
1611 static PyObject *__pyx_n_u_group;
1612 static PyObject *__pyx_n_s_group2gid;
1613 static PyObject *__pyx_n_s_helpers;
1614 static PyObject *__pyx_n_s_import;
1615 static PyObject *__pyx_n_s_init;
1616 static PyObject *__pyx_n_s_item;
1617 static PyObject *__pyx_n_s_items;
1618 static PyObject *__pyx_n_s_last_sync;
1619 static PyObject *__pyx_kp_u_length_d_not_page_aligned;
1620 static PyObject *__pyx_n_s_linux_flag;
1621 static PyObject *__pyx_n_s_linux_flags;
1622 static PyObject *__pyx_n_s_main;
1623 static PyObject *__pyx_n_s_metaclass;
1624 static PyObject *__pyx_n_u_mode;
1625 static PyObject *__pyx_n_s_module;
1626 static PyObject *__pyx_n_s_name;
1627 static PyObject *__pyx_n_s_numeric_owner;
1628 static PyObject *__pyx_n_s_offset;
1629 static PyObject *__pyx_kp_u_offset_d_not_page_aligned;
1630 static PyObject *__pyx_n_s_open;
1631 static PyObject *__pyx_n_s_open_fd;
1632 static PyObject *__pyx_n_s_os;
1633 static PyObject *__pyx_n_s_p;
1634 static PyObject *__pyx_n_s_path;
1635 static PyObject *__pyx_n_s_pending_sync;
1636 static PyObject *__pyx_n_s_posix;
1637 static PyObject *__pyx_n_s_posix_acl_use_stored_uid_gid;
1638 static PyObject *__pyx_n_s_prepare;
1639 static PyObject *__pyx_n_s_qualname;
1640 static PyObject *__pyx_n_s_re;
1641 static PyObject *__pyx_n_s_safe_decode;
1642 static PyObject *__pyx_n_s_safe_encode;
1643 static PyObject *__pyx_n_s_safe_fadvise;
1644 static PyObject *__pyx_n_s_self;
1645 static PyObject *__pyx_n_s_set_flags;
1646 static PyObject *__pyx_n_s_split;
1647 static PyObject *__pyx_kp_s_src_borg_platform_linux_pyx;
1648 static PyObject *__pyx_n_s_st;
1649 static PyObject *__pyx_n_s_st_mode;
1650 static PyObject *__pyx_n_s_stat;
1651 static PyObject *__pyx_n_s_strerror;
1652 static PyObject *__pyx_n_s_sub;
1653 static PyObject *__pyx_n_s_subprocess;
1654 static PyObject *__pyx_n_s_super;
1655 static PyObject *__pyx_n_s_swidth;
1656 static PyObject *__pyx_n_s_sync;
1657 static PyObject *__pyx_n_s_sync_file_range;
1658 static PyObject *__pyx_n_s_syncfilerange;
1659 static PyObject *__pyx_n_s_test;
1660 static PyObject *__pyx_n_u_user;
1661 static PyObject *__pyx_n_s_user2uid;
1662 static PyObject *__pyx_n_s_workarounds;
1663 static PyObject *__pyx_n_s_write;
1664 static PyObject *__pyx_n_s_write_window;
1665 static PyObject *__pyx_pf_4borg_8platform_5linux_set_flags(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_bsd_flags, PyObject *__pyx_v_fd); /* proto */
1666 static PyObject *__pyx_pf_4borg_8platform_5linux_2get_flags(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_st); /* proto */
1667 static PyObject *__pyx_pf_4borg_8platform_5linux_4acl_use_local_uid_gid(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_acl); /* proto */
1668 static PyObject *__pyx_pf_4borg_8platform_5linux_6acl_get(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_item, PyObject *__pyx_v_st, PyObject *__pyx_v_numeric_owner); /* proto */
1669 static PyObject *__pyx_pf_4borg_8platform_5linux_8acl_set(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_item, PyObject *__pyx_v_numeric_owner); /* proto */
1670 static PyObject *__pyx_pf_4borg_8platform_5linux_8SyncFile___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_path, PyObject *__pyx_v_binary); /* proto */
1671 static PyObject *__pyx_pf_4borg_8platform_5linux_8SyncFile_2write(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_data); /* proto */
1672 static PyObject *__pyx_pf_4borg_8platform_5linux_8SyncFile_4sync(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
1673 static PyObject *__pyx_int_0;
1674 static PyObject *__pyx_int_3;
1675 static PyObject *__pyx_slice__3;
1676 static PyObject *__pyx_tuple__5;
1677 static PyObject *__pyx_tuple__7;
1678 static PyObject *__pyx_tuple__9;
1679 static PyObject *__pyx_tuple__11;
1680 static PyObject *__pyx_tuple__13;
1681 static PyObject *__pyx_tuple__15;
1682 static PyObject *__pyx_tuple__17;
1683 static PyObject *__pyx_tuple__19;
1684 static PyObject *__pyx_tuple__20;
1685 static PyObject *__pyx_tuple__22;
1686 static PyObject *__pyx_codeobj__8;
1687 static PyObject *__pyx_codeobj__10;
1688 static PyObject *__pyx_codeobj__12;
1689 static PyObject *__pyx_codeobj__14;
1690 static PyObject *__pyx_codeobj__16;
1691 static PyObject *__pyx_codeobj__18;
1692 static PyObject *__pyx_codeobj__21;
1693 static PyObject *__pyx_codeobj__23;
1694 /* Late includes */
1695
1696 /* "borg/platform/linux.pyx":76
1697 *
1698 *
1699 * def set_flags(path, bsd_flags, fd=None): # <<<<<<<<<<<<<<
1700 * if fd is None:
1701 * st = os.stat(path, follow_symlinks=False)
1702 */
1703
1704 /* Python wrapper */
1705 static PyObject *__pyx_pw_4borg_8platform_5linux_1set_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
1706 static PyMethodDef __pyx_mdef_4borg_8platform_5linux_1set_flags = {"set_flags", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4borg_8platform_5linux_1set_flags, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_4borg_8platform_5linux_1set_flags(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)1707 static PyObject *__pyx_pw_4borg_8platform_5linux_1set_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
1708 PyObject *__pyx_v_path = 0;
1709 PyObject *__pyx_v_bsd_flags = 0;
1710 PyObject *__pyx_v_fd = 0;
1711 int __pyx_lineno = 0;
1712 const char *__pyx_filename = NULL;
1713 int __pyx_clineno = 0;
1714 PyObject *__pyx_r = 0;
1715 __Pyx_RefNannyDeclarations
1716 __Pyx_RefNannySetupContext("set_flags (wrapper)", 0);
1717 {
1718 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,&__pyx_n_s_bsd_flags,&__pyx_n_s_fd,0};
1719 PyObject* values[3] = {0,0,0};
1720 values[2] = ((PyObject *)Py_None);
1721 if (unlikely(__pyx_kwds)) {
1722 Py_ssize_t kw_args;
1723 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
1724 switch (pos_args) {
1725 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1726 CYTHON_FALLTHROUGH;
1727 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1728 CYTHON_FALLTHROUGH;
1729 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1730 CYTHON_FALLTHROUGH;
1731 case 0: break;
1732 default: goto __pyx_L5_argtuple_error;
1733 }
1734 kw_args = PyDict_Size(__pyx_kwds);
1735 switch (pos_args) {
1736 case 0:
1737 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
1738 else goto __pyx_L5_argtuple_error;
1739 CYTHON_FALLTHROUGH;
1740 case 1:
1741 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_bsd_flags)) != 0)) kw_args--;
1742 else {
1743 __Pyx_RaiseArgtupleInvalid("set_flags", 0, 2, 3, 1); __PYX_ERR(0, 76, __pyx_L3_error)
1744 }
1745 CYTHON_FALLTHROUGH;
1746 case 2:
1747 if (kw_args > 0) {
1748 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_fd);
1749 if (value) { values[2] = value; kw_args--; }
1750 }
1751 }
1752 if (unlikely(kw_args > 0)) {
1753 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "set_flags") < 0)) __PYX_ERR(0, 76, __pyx_L3_error)
1754 }
1755 } else {
1756 switch (PyTuple_GET_SIZE(__pyx_args)) {
1757 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
1758 CYTHON_FALLTHROUGH;
1759 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
1760 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
1761 break;
1762 default: goto __pyx_L5_argtuple_error;
1763 }
1764 }
1765 __pyx_v_path = values[0];
1766 __pyx_v_bsd_flags = values[1];
1767 __pyx_v_fd = values[2];
1768 }
1769 goto __pyx_L4_argument_unpacking_done;
1770 __pyx_L5_argtuple_error:;
1771 __Pyx_RaiseArgtupleInvalid("set_flags", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 76, __pyx_L3_error)
1772 __pyx_L3_error:;
1773 __Pyx_AddTraceback("borg.platform.linux.set_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
1774 __Pyx_RefNannyFinishContext();
1775 return NULL;
1776 __pyx_L4_argument_unpacking_done:;
1777 __pyx_r = __pyx_pf_4borg_8platform_5linux_set_flags(__pyx_self, __pyx_v_path, __pyx_v_bsd_flags, __pyx_v_fd);
1778
1779 /* function exit code */
1780 __Pyx_RefNannyFinishContext();
1781 return __pyx_r;
1782 }
1783
__pyx_pf_4borg_8platform_5linux_set_flags(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_path,PyObject * __pyx_v_bsd_flags,PyObject * __pyx_v_fd)1784 static PyObject *__pyx_pf_4borg_8platform_5linux_set_flags(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_bsd_flags, PyObject *__pyx_v_fd) {
1785 PyObject *__pyx_v_st = NULL;
1786 int __pyx_v_flags;
1787 PyObject *__pyx_v_bsd_flag = NULL;
1788 PyObject *__pyx_v_linux_flag = NULL;
1789 PyObject *__pyx_v_open_fd = NULL;
1790 int __pyx_v_error_number;
1791 PyObject *__pyx_r = NULL;
1792 __Pyx_RefNannyDeclarations
1793 int __pyx_t_1;
1794 int __pyx_t_2;
1795 PyObject *__pyx_t_3 = NULL;
1796 PyObject *__pyx_t_4 = NULL;
1797 PyObject *__pyx_t_5 = NULL;
1798 PyObject *__pyx_t_6 = NULL;
1799 Py_ssize_t __pyx_t_7;
1800 Py_ssize_t __pyx_t_8;
1801 int __pyx_t_9;
1802 int __pyx_t_10;
1803 PyObject *__pyx_t_11 = NULL;
1804 char *__pyx_t_12;
1805 char const *__pyx_t_13;
1806 PyObject *__pyx_t_14 = NULL;
1807 PyObject *__pyx_t_15 = NULL;
1808 PyObject *__pyx_t_16 = NULL;
1809 PyObject *__pyx_t_17 = NULL;
1810 PyObject *__pyx_t_18 = NULL;
1811 PyObject *__pyx_t_19 = NULL;
1812 int __pyx_lineno = 0;
1813 const char *__pyx_filename = NULL;
1814 int __pyx_clineno = 0;
1815 __Pyx_RefNannySetupContext("set_flags", 0);
1816 __Pyx_INCREF(__pyx_v_fd);
1817
1818 /* "borg/platform/linux.pyx":77
1819 *
1820 * def set_flags(path, bsd_flags, fd=None):
1821 * if fd is None: # <<<<<<<<<<<<<<
1822 * st = os.stat(path, follow_symlinks=False)
1823 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode):
1824 */
1825 __pyx_t_1 = (__pyx_v_fd == Py_None);
1826 __pyx_t_2 = (__pyx_t_1 != 0);
1827 if (__pyx_t_2) {
1828
1829 /* "borg/platform/linux.pyx":78
1830 * def set_flags(path, bsd_flags, fd=None):
1831 * if fd is None:
1832 * st = os.stat(path, follow_symlinks=False) # <<<<<<<<<<<<<<
1833 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode):
1834 * # see comment in get_flags()
1835 */
1836 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
1837 __Pyx_GOTREF(__pyx_t_3);
1838 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_stat); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 78, __pyx_L1_error)
1839 __Pyx_GOTREF(__pyx_t_4);
1840 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1841 __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 78, __pyx_L1_error)
1842 __Pyx_GOTREF(__pyx_t_3);
1843 __Pyx_INCREF(__pyx_v_path);
1844 __Pyx_GIVEREF(__pyx_v_path);
1845 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_v_path);
1846 __pyx_t_5 = __Pyx_PyDict_NewPresized(1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 78, __pyx_L1_error)
1847 __Pyx_GOTREF(__pyx_t_5);
1848 if (PyDict_SetItem(__pyx_t_5, __pyx_n_s_follow_symlinks, Py_False) < 0) __PYX_ERR(0, 78, __pyx_L1_error)
1849 __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_3, __pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 78, __pyx_L1_error)
1850 __Pyx_GOTREF(__pyx_t_6);
1851 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1852 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1853 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1854 __pyx_v_st = __pyx_t_6;
1855 __pyx_t_6 = 0;
1856
1857 /* "borg/platform/linux.pyx":79
1858 * if fd is None:
1859 * st = os.stat(path, follow_symlinks=False)
1860 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode): # <<<<<<<<<<<<<<
1861 * # see comment in get_flags()
1862 * return
1863 */
1864 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_stat); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 79, __pyx_L1_error)
1865 __Pyx_GOTREF(__pyx_t_5);
1866 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_S_ISBLK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)
1867 __Pyx_GOTREF(__pyx_t_3);
1868 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1869 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_st, __pyx_n_s_st_mode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 79, __pyx_L1_error)
1870 __Pyx_GOTREF(__pyx_t_5);
1871 __pyx_t_4 = NULL;
1872 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
1873 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
1874 if (likely(__pyx_t_4)) {
1875 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1876 __Pyx_INCREF(__pyx_t_4);
1877 __Pyx_INCREF(function);
1878 __Pyx_DECREF_SET(__pyx_t_3, function);
1879 }
1880 }
1881 __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
1882 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1883 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1884 if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 79, __pyx_L1_error)
1885 __Pyx_GOTREF(__pyx_t_6);
1886 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1887 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 79, __pyx_L1_error)
1888 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1889 if (!__pyx_t_1) {
1890 } else {
1891 __pyx_t_2 = __pyx_t_1;
1892 goto __pyx_L5_bool_binop_done;
1893 }
1894 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_stat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)
1895 __Pyx_GOTREF(__pyx_t_3);
1896 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_S_ISCHR); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 79, __pyx_L1_error)
1897 __Pyx_GOTREF(__pyx_t_5);
1898 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1899 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_st, __pyx_n_s_st_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)
1900 __Pyx_GOTREF(__pyx_t_3);
1901 __pyx_t_4 = NULL;
1902 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
1903 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_5);
1904 if (likely(__pyx_t_4)) {
1905 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
1906 __Pyx_INCREF(__pyx_t_4);
1907 __Pyx_INCREF(function);
1908 __Pyx_DECREF_SET(__pyx_t_5, function);
1909 }
1910 }
1911 __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3);
1912 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1913 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1914 if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 79, __pyx_L1_error)
1915 __Pyx_GOTREF(__pyx_t_6);
1916 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1917 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 79, __pyx_L1_error)
1918 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1919 if (!__pyx_t_1) {
1920 } else {
1921 __pyx_t_2 = __pyx_t_1;
1922 goto __pyx_L5_bool_binop_done;
1923 }
1924 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_stat); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 79, __pyx_L1_error)
1925 __Pyx_GOTREF(__pyx_t_5);
1926 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_S_ISLNK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 79, __pyx_L1_error)
1927 __Pyx_GOTREF(__pyx_t_3);
1928 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1929 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_st, __pyx_n_s_st_mode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 79, __pyx_L1_error)
1930 __Pyx_GOTREF(__pyx_t_5);
1931 __pyx_t_4 = NULL;
1932 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
1933 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
1934 if (likely(__pyx_t_4)) {
1935 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
1936 __Pyx_INCREF(__pyx_t_4);
1937 __Pyx_INCREF(function);
1938 __Pyx_DECREF_SET(__pyx_t_3, function);
1939 }
1940 }
1941 __pyx_t_6 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_t_5) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_5);
1942 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
1943 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1944 if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 79, __pyx_L1_error)
1945 __Pyx_GOTREF(__pyx_t_6);
1946 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1947 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 79, __pyx_L1_error)
1948 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1949 __pyx_t_2 = __pyx_t_1;
1950 __pyx_L5_bool_binop_done:;
1951 if (__pyx_t_2) {
1952
1953 /* "borg/platform/linux.pyx":81
1954 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode):
1955 * # see comment in get_flags()
1956 * return # <<<<<<<<<<<<<<
1957 * cdef int flags = 0
1958 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
1959 */
1960 __Pyx_XDECREF(__pyx_r);
1961 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1962 goto __pyx_L0;
1963
1964 /* "borg/platform/linux.pyx":79
1965 * if fd is None:
1966 * st = os.stat(path, follow_symlinks=False)
1967 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode): # <<<<<<<<<<<<<<
1968 * # see comment in get_flags()
1969 * return
1970 */
1971 }
1972
1973 /* "borg/platform/linux.pyx":77
1974 *
1975 * def set_flags(path, bsd_flags, fd=None):
1976 * if fd is None: # <<<<<<<<<<<<<<
1977 * st = os.stat(path, follow_symlinks=False)
1978 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode):
1979 */
1980 }
1981
1982 /* "borg/platform/linux.pyx":82
1983 * # see comment in get_flags()
1984 * return
1985 * cdef int flags = 0 # <<<<<<<<<<<<<<
1986 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
1987 * if bsd_flags & bsd_flag:
1988 */
1989 __pyx_v_flags = 0;
1990
1991 /* "borg/platform/linux.pyx":83
1992 * return
1993 * cdef int flags = 0
1994 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items(): # <<<<<<<<<<<<<<
1995 * if bsd_flags & bsd_flag:
1996 * flags |= linux_flag
1997 */
1998 __pyx_t_7 = 0;
1999 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_BSD_TO_LINUX_FLAGS); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 83, __pyx_L1_error)
2000 __Pyx_GOTREF(__pyx_t_3);
2001 if (unlikely(__pyx_t_3 == Py_None)) {
2002 PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
2003 __PYX_ERR(0, 83, __pyx_L1_error)
2004 }
2005 __pyx_t_5 = __Pyx_dict_iterator(__pyx_t_3, 0, __pyx_n_s_items, (&__pyx_t_8), (&__pyx_t_9)); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 83, __pyx_L1_error)
2006 __Pyx_GOTREF(__pyx_t_5);
2007 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2008 __Pyx_XDECREF(__pyx_t_6);
2009 __pyx_t_6 = __pyx_t_5;
2010 __pyx_t_5 = 0;
2011 while (1) {
2012 __pyx_t_10 = __Pyx_dict_iter_next(__pyx_t_6, __pyx_t_8, &__pyx_t_7, &__pyx_t_5, &__pyx_t_3, NULL, __pyx_t_9);
2013 if (unlikely(__pyx_t_10 == 0)) break;
2014 if (unlikely(__pyx_t_10 == -1)) __PYX_ERR(0, 83, __pyx_L1_error)
2015 __Pyx_GOTREF(__pyx_t_5);
2016 __Pyx_GOTREF(__pyx_t_3);
2017 __Pyx_XDECREF_SET(__pyx_v_bsd_flag, __pyx_t_5);
2018 __pyx_t_5 = 0;
2019 __Pyx_XDECREF_SET(__pyx_v_linux_flag, __pyx_t_3);
2020 __pyx_t_3 = 0;
2021
2022 /* "borg/platform/linux.pyx":84
2023 * cdef int flags = 0
2024 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
2025 * if bsd_flags & bsd_flag: # <<<<<<<<<<<<<<
2026 * flags |= linux_flag
2027 * open_fd = fd is None
2028 */
2029 __pyx_t_3 = PyNumber_And(__pyx_v_bsd_flags, __pyx_v_bsd_flag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 84, __pyx_L1_error)
2030 __Pyx_GOTREF(__pyx_t_3);
2031 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 84, __pyx_L1_error)
2032 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2033 if (__pyx_t_2) {
2034
2035 /* "borg/platform/linux.pyx":85
2036 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
2037 * if bsd_flags & bsd_flag:
2038 * flags |= linux_flag # <<<<<<<<<<<<<<
2039 * open_fd = fd is None
2040 * if open_fd:
2041 */
2042 __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 85, __pyx_L1_error)
2043 __Pyx_GOTREF(__pyx_t_3);
2044 __pyx_t_5 = PyNumber_InPlaceOr(__pyx_t_3, __pyx_v_linux_flag); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 85, __pyx_L1_error)
2045 __Pyx_GOTREF(__pyx_t_5);
2046 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2047 __pyx_t_10 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_10 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 85, __pyx_L1_error)
2048 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2049 __pyx_v_flags = __pyx_t_10;
2050
2051 /* "borg/platform/linux.pyx":84
2052 * cdef int flags = 0
2053 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
2054 * if bsd_flags & bsd_flag: # <<<<<<<<<<<<<<
2055 * flags |= linux_flag
2056 * open_fd = fd is None
2057 */
2058 }
2059 }
2060 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2061
2062 /* "borg/platform/linux.pyx":86
2063 * if bsd_flags & bsd_flag:
2064 * flags |= linux_flag
2065 * open_fd = fd is None # <<<<<<<<<<<<<<
2066 * if open_fd:
2067 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2068 */
2069 __pyx_t_2 = (__pyx_v_fd == Py_None);
2070 __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_t_2); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 86, __pyx_L1_error)
2071 __Pyx_GOTREF(__pyx_t_6);
2072 __pyx_v_open_fd = __pyx_t_6;
2073 __pyx_t_6 = 0;
2074
2075 /* "borg/platform/linux.pyx":87
2076 * flags |= linux_flag
2077 * open_fd = fd is None
2078 * if open_fd: # <<<<<<<<<<<<<<
2079 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2080 * try:
2081 */
2082 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_open_fd); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 87, __pyx_L1_error)
2083 if (__pyx_t_2) {
2084
2085 /* "borg/platform/linux.pyx":88
2086 * open_fd = fd is None
2087 * if open_fd:
2088 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW) # <<<<<<<<<<<<<<
2089 * try:
2090 * if ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1:
2091 */
2092 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error)
2093 __Pyx_GOTREF(__pyx_t_5);
2094 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_open); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 88, __pyx_L1_error)
2095 __Pyx_GOTREF(__pyx_t_3);
2096 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2097 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error)
2098 __Pyx_GOTREF(__pyx_t_5);
2099 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_O_RDONLY); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
2100 __Pyx_GOTREF(__pyx_t_4);
2101 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2102 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error)
2103 __Pyx_GOTREF(__pyx_t_5);
2104 __pyx_t_11 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_O_NONBLOCK); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error)
2105 __Pyx_GOTREF(__pyx_t_11);
2106 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2107 __pyx_t_5 = PyNumber_Or(__pyx_t_4, __pyx_t_11); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error)
2108 __Pyx_GOTREF(__pyx_t_5);
2109 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2110 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
2111 __Pyx_GetModuleGlobalName(__pyx_t_11, __pyx_n_s_os); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error)
2112 __Pyx_GOTREF(__pyx_t_11);
2113 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_11, __pyx_n_s_O_NOFOLLOW); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 88, __pyx_L1_error)
2114 __Pyx_GOTREF(__pyx_t_4);
2115 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
2116 __pyx_t_11 = PyNumber_Or(__pyx_t_5, __pyx_t_4); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 88, __pyx_L1_error)
2117 __Pyx_GOTREF(__pyx_t_11);
2118 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2119 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2120 __pyx_t_4 = NULL;
2121 __pyx_t_9 = 0;
2122 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2123 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
2124 if (likely(__pyx_t_4)) {
2125 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2126 __Pyx_INCREF(__pyx_t_4);
2127 __Pyx_INCREF(function);
2128 __Pyx_DECREF_SET(__pyx_t_3, function);
2129 __pyx_t_9 = 1;
2130 }
2131 }
2132 #if CYTHON_FAST_PYCALL
2133 if (PyFunction_Check(__pyx_t_3)) {
2134 PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_path, __pyx_t_11};
2135 __pyx_t_6 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 88, __pyx_L1_error)
2136 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2137 __Pyx_GOTREF(__pyx_t_6);
2138 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
2139 } else
2140 #endif
2141 #if CYTHON_FAST_PYCCALL
2142 if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
2143 PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_v_path, __pyx_t_11};
2144 __pyx_t_6 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_9, 2+__pyx_t_9); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 88, __pyx_L1_error)
2145 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2146 __Pyx_GOTREF(__pyx_t_6);
2147 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
2148 } else
2149 #endif
2150 {
2151 __pyx_t_5 = PyTuple_New(2+__pyx_t_9); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 88, __pyx_L1_error)
2152 __Pyx_GOTREF(__pyx_t_5);
2153 if (__pyx_t_4) {
2154 __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __pyx_t_4 = NULL;
2155 }
2156 __Pyx_INCREF(__pyx_v_path);
2157 __Pyx_GIVEREF(__pyx_v_path);
2158 PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_9, __pyx_v_path);
2159 __Pyx_GIVEREF(__pyx_t_11);
2160 PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_9, __pyx_t_11);
2161 __pyx_t_11 = 0;
2162 __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 88, __pyx_L1_error)
2163 __Pyx_GOTREF(__pyx_t_6);
2164 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2165 }
2166 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2167 __Pyx_DECREF_SET(__pyx_v_fd, __pyx_t_6);
2168 __pyx_t_6 = 0;
2169
2170 /* "borg/platform/linux.pyx":87
2171 * flags |= linux_flag
2172 * open_fd = fd is None
2173 * if open_fd: # <<<<<<<<<<<<<<
2174 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2175 * try:
2176 */
2177 }
2178
2179 /* "borg/platform/linux.pyx":89
2180 * if open_fd:
2181 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2182 * try: # <<<<<<<<<<<<<<
2183 * if ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1:
2184 * error_number = errno.errno
2185 */
2186 /*try:*/ {
2187
2188 /* "borg/platform/linux.pyx":90
2189 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2190 * try:
2191 * if ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1: # <<<<<<<<<<<<<<
2192 * error_number = errno.errno
2193 * if error_number != errno.EOPNOTSUPP:
2194 */
2195 __pyx_t_9 = __Pyx_PyInt_As_int(__pyx_v_fd); if (unlikely((__pyx_t_9 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 90, __pyx_L13_error)
2196 __pyx_t_2 = ((ioctl(__pyx_t_9, FS_IOC_SETFLAGS, (&__pyx_v_flags)) == -1L) != 0);
2197 if (__pyx_t_2) {
2198
2199 /* "borg/platform/linux.pyx":91
2200 * try:
2201 * if ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1:
2202 * error_number = errno.errno # <<<<<<<<<<<<<<
2203 * if error_number != errno.EOPNOTSUPP:
2204 * raise OSError(error_number, strerror(error_number).decode(), path)
2205 */
2206 __pyx_v_error_number = errno;
2207
2208 /* "borg/platform/linux.pyx":92
2209 * if ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1:
2210 * error_number = errno.errno
2211 * if error_number != errno.EOPNOTSUPP: # <<<<<<<<<<<<<<
2212 * raise OSError(error_number, strerror(error_number).decode(), path)
2213 * finally:
2214 */
2215 __pyx_t_2 = ((__pyx_v_error_number != EOPNOTSUPP) != 0);
2216 if (unlikely(__pyx_t_2)) {
2217
2218 /* "borg/platform/linux.pyx":93
2219 * error_number = errno.errno
2220 * if error_number != errno.EOPNOTSUPP:
2221 * raise OSError(error_number, strerror(error_number).decode(), path) # <<<<<<<<<<<<<<
2222 * finally:
2223 * if open_fd:
2224 */
2225 __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_error_number); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 93, __pyx_L13_error)
2226 __Pyx_GOTREF(__pyx_t_6);
2227 __pyx_t_12 = strerror(__pyx_v_error_number);
2228 __pyx_t_3 = __Pyx_decode_c_string(__pyx_t_12, 0, strlen(__pyx_t_12), NULL, NULL, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L13_error)
2229 __Pyx_GOTREF(__pyx_t_3);
2230 __pyx_t_5 = PyTuple_New(3); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 93, __pyx_L13_error)
2231 __Pyx_GOTREF(__pyx_t_5);
2232 __Pyx_GIVEREF(__pyx_t_6);
2233 PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6);
2234 __Pyx_INCREF(__pyx_t_3);
2235 __Pyx_GIVEREF(__pyx_t_3);
2236 PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_3);
2237 __Pyx_INCREF(__pyx_v_path);
2238 __Pyx_GIVEREF(__pyx_v_path);
2239 PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_v_path);
2240 __pyx_t_6 = 0;
2241 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2242 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_5, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 93, __pyx_L13_error)
2243 __Pyx_GOTREF(__pyx_t_3);
2244 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2245 __Pyx_Raise(__pyx_t_3, 0, 0, 0);
2246 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2247 __PYX_ERR(0, 93, __pyx_L13_error)
2248
2249 /* "borg/platform/linux.pyx":92
2250 * if ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1:
2251 * error_number = errno.errno
2252 * if error_number != errno.EOPNOTSUPP: # <<<<<<<<<<<<<<
2253 * raise OSError(error_number, strerror(error_number).decode(), path)
2254 * finally:
2255 */
2256 }
2257
2258 /* "borg/platform/linux.pyx":90
2259 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2260 * try:
2261 * if ioctl(fd, FS_IOC_SETFLAGS, &flags) == -1: # <<<<<<<<<<<<<<
2262 * error_number = errno.errno
2263 * if error_number != errno.EOPNOTSUPP:
2264 */
2265 }
2266 }
2267
2268 /* "borg/platform/linux.pyx":95
2269 * raise OSError(error_number, strerror(error_number).decode(), path)
2270 * finally:
2271 * if open_fd: # <<<<<<<<<<<<<<
2272 * os.close(fd)
2273 *
2274 */
2275 /*finally:*/ {
2276 /*normal exit:*/{
2277 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_open_fd); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 95, __pyx_L1_error)
2278 if (__pyx_t_2) {
2279
2280 /* "borg/platform/linux.pyx":96
2281 * finally:
2282 * if open_fd:
2283 * os.close(fd) # <<<<<<<<<<<<<<
2284 *
2285 *
2286 */
2287 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_os); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L1_error)
2288 __Pyx_GOTREF(__pyx_t_5);
2289 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_close); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 96, __pyx_L1_error)
2290 __Pyx_GOTREF(__pyx_t_6);
2291 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2292 __pyx_t_5 = NULL;
2293 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_6))) {
2294 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
2295 if (likely(__pyx_t_5)) {
2296 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
2297 __Pyx_INCREF(__pyx_t_5);
2298 __Pyx_INCREF(function);
2299 __Pyx_DECREF_SET(__pyx_t_6, function);
2300 }
2301 }
2302 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_6, __pyx_t_5, __pyx_v_fd) : __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_fd);
2303 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2304 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L1_error)
2305 __Pyx_GOTREF(__pyx_t_3);
2306 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2307 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2308
2309 /* "borg/platform/linux.pyx":95
2310 * raise OSError(error_number, strerror(error_number).decode(), path)
2311 * finally:
2312 * if open_fd: # <<<<<<<<<<<<<<
2313 * os.close(fd)
2314 *
2315 */
2316 }
2317 goto __pyx_L14;
2318 }
2319 __pyx_L13_error:;
2320 /*exception exit:*/{
2321 __Pyx_PyThreadState_declare
2322 __Pyx_PyThreadState_assign
2323 __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
2324 __Pyx_XDECREF(__pyx_t_11); __pyx_t_11 = 0;
2325 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2326 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2327 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2328 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2329 if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_17, &__pyx_t_18, &__pyx_t_19);
2330 if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16) < 0)) __Pyx_ErrFetch(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
2331 __Pyx_XGOTREF(__pyx_t_14);
2332 __Pyx_XGOTREF(__pyx_t_15);
2333 __Pyx_XGOTREF(__pyx_t_16);
2334 __Pyx_XGOTREF(__pyx_t_17);
2335 __Pyx_XGOTREF(__pyx_t_18);
2336 __Pyx_XGOTREF(__pyx_t_19);
2337 __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_13 = __pyx_filename;
2338 {
2339 __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_open_fd); if (unlikely(__pyx_t_2 < 0)) __PYX_ERR(0, 95, __pyx_L19_error)
2340 if (__pyx_t_2) {
2341
2342 /* "borg/platform/linux.pyx":96
2343 * finally:
2344 * if open_fd:
2345 * os.close(fd) # <<<<<<<<<<<<<<
2346 *
2347 *
2348 */
2349 __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 96, __pyx_L19_error)
2350 __Pyx_GOTREF(__pyx_t_6);
2351 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_close); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 96, __pyx_L19_error)
2352 __Pyx_GOTREF(__pyx_t_5);
2353 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2354 __pyx_t_6 = NULL;
2355 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
2356 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
2357 if (likely(__pyx_t_6)) {
2358 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
2359 __Pyx_INCREF(__pyx_t_6);
2360 __Pyx_INCREF(function);
2361 __Pyx_DECREF_SET(__pyx_t_5, function);
2362 }
2363 }
2364 __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_fd) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_fd);
2365 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
2366 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 96, __pyx_L19_error)
2367 __Pyx_GOTREF(__pyx_t_3);
2368 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2369 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2370
2371 /* "borg/platform/linux.pyx":95
2372 * raise OSError(error_number, strerror(error_number).decode(), path)
2373 * finally:
2374 * if open_fd: # <<<<<<<<<<<<<<
2375 * os.close(fd)
2376 *
2377 */
2378 }
2379 }
2380 if (PY_MAJOR_VERSION >= 3) {
2381 __Pyx_XGIVEREF(__pyx_t_17);
2382 __Pyx_XGIVEREF(__pyx_t_18);
2383 __Pyx_XGIVEREF(__pyx_t_19);
2384 __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
2385 }
2386 __Pyx_XGIVEREF(__pyx_t_14);
2387 __Pyx_XGIVEREF(__pyx_t_15);
2388 __Pyx_XGIVEREF(__pyx_t_16);
2389 __Pyx_ErrRestore(__pyx_t_14, __pyx_t_15, __pyx_t_16);
2390 __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
2391 __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_13;
2392 goto __pyx_L1_error;
2393 __pyx_L19_error:;
2394 if (PY_MAJOR_VERSION >= 3) {
2395 __Pyx_XGIVEREF(__pyx_t_17);
2396 __Pyx_XGIVEREF(__pyx_t_18);
2397 __Pyx_XGIVEREF(__pyx_t_19);
2398 __Pyx_ExceptionReset(__pyx_t_17, __pyx_t_18, __pyx_t_19);
2399 }
2400 __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
2401 __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
2402 __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
2403 __pyx_t_17 = 0; __pyx_t_18 = 0; __pyx_t_19 = 0;
2404 goto __pyx_L1_error;
2405 }
2406 __pyx_L14:;
2407 }
2408
2409 /* "borg/platform/linux.pyx":76
2410 *
2411 *
2412 * def set_flags(path, bsd_flags, fd=None): # <<<<<<<<<<<<<<
2413 * if fd is None:
2414 * st = os.stat(path, follow_symlinks=False)
2415 */
2416
2417 /* function exit code */
2418 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
2419 goto __pyx_L0;
2420 __pyx_L1_error:;
2421 __Pyx_XDECREF(__pyx_t_3);
2422 __Pyx_XDECREF(__pyx_t_4);
2423 __Pyx_XDECREF(__pyx_t_5);
2424 __Pyx_XDECREF(__pyx_t_6);
2425 __Pyx_XDECREF(__pyx_t_11);
2426 __Pyx_AddTraceback("borg.platform.linux.set_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
2427 __pyx_r = NULL;
2428 __pyx_L0:;
2429 __Pyx_XDECREF(__pyx_v_st);
2430 __Pyx_XDECREF(__pyx_v_bsd_flag);
2431 __Pyx_XDECREF(__pyx_v_linux_flag);
2432 __Pyx_XDECREF(__pyx_v_open_fd);
2433 __Pyx_XDECREF(__pyx_v_fd);
2434 __Pyx_XGIVEREF(__pyx_r);
2435 __Pyx_RefNannyFinishContext();
2436 return __pyx_r;
2437 }
2438
2439 /* "borg/platform/linux.pyx":99
2440 *
2441 *
2442 * def get_flags(path, st): # <<<<<<<<<<<<<<
2443 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode):
2444 * # avoid opening devices files - trying to open non-present devices can be rather slow.
2445 */
2446
2447 /* Python wrapper */
2448 static PyObject *__pyx_pw_4borg_8platform_5linux_3get_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
2449 static PyMethodDef __pyx_mdef_4borg_8platform_5linux_3get_flags = {"get_flags", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4borg_8platform_5linux_3get_flags, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_4borg_8platform_5linux_3get_flags(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)2450 static PyObject *__pyx_pw_4borg_8platform_5linux_3get_flags(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
2451 PyObject *__pyx_v_path = 0;
2452 PyObject *__pyx_v_st = 0;
2453 int __pyx_lineno = 0;
2454 const char *__pyx_filename = NULL;
2455 int __pyx_clineno = 0;
2456 PyObject *__pyx_r = 0;
2457 __Pyx_RefNannyDeclarations
2458 __Pyx_RefNannySetupContext("get_flags (wrapper)", 0);
2459 {
2460 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,&__pyx_n_s_st,0};
2461 PyObject* values[2] = {0,0};
2462 if (unlikely(__pyx_kwds)) {
2463 Py_ssize_t kw_args;
2464 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
2465 switch (pos_args) {
2466 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2467 CYTHON_FALLTHROUGH;
2468 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2469 CYTHON_FALLTHROUGH;
2470 case 0: break;
2471 default: goto __pyx_L5_argtuple_error;
2472 }
2473 kw_args = PyDict_Size(__pyx_kwds);
2474 switch (pos_args) {
2475 case 0:
2476 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
2477 else goto __pyx_L5_argtuple_error;
2478 CYTHON_FALLTHROUGH;
2479 case 1:
2480 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_st)) != 0)) kw_args--;
2481 else {
2482 __Pyx_RaiseArgtupleInvalid("get_flags", 1, 2, 2, 1); __PYX_ERR(0, 99, __pyx_L3_error)
2483 }
2484 }
2485 if (unlikely(kw_args > 0)) {
2486 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "get_flags") < 0)) __PYX_ERR(0, 99, __pyx_L3_error)
2487 }
2488 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
2489 goto __pyx_L5_argtuple_error;
2490 } else {
2491 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
2492 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
2493 }
2494 __pyx_v_path = values[0];
2495 __pyx_v_st = values[1];
2496 }
2497 goto __pyx_L4_argument_unpacking_done;
2498 __pyx_L5_argtuple_error:;
2499 __Pyx_RaiseArgtupleInvalid("get_flags", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 99, __pyx_L3_error)
2500 __pyx_L3_error:;
2501 __Pyx_AddTraceback("borg.platform.linux.get_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
2502 __Pyx_RefNannyFinishContext();
2503 return NULL;
2504 __pyx_L4_argument_unpacking_done:;
2505 __pyx_r = __pyx_pf_4borg_8platform_5linux_2get_flags(__pyx_self, __pyx_v_path, __pyx_v_st);
2506
2507 /* function exit code */
2508 __Pyx_RefNannyFinishContext();
2509 return __pyx_r;
2510 }
2511
__pyx_pf_4borg_8platform_5linux_2get_flags(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_path,PyObject * __pyx_v_st)2512 static PyObject *__pyx_pf_4borg_8platform_5linux_2get_flags(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_st) {
2513 int __pyx_v_linux_flags;
2514 PyObject *__pyx_v_fd = NULL;
2515 PyObject *__pyx_v_bsd_flags = NULL;
2516 PyObject *__pyx_v_bsd_flag = NULL;
2517 PyObject *__pyx_v_linux_flag = NULL;
2518 PyObject *__pyx_r = NULL;
2519 __Pyx_RefNannyDeclarations
2520 int __pyx_t_1;
2521 PyObject *__pyx_t_2 = NULL;
2522 PyObject *__pyx_t_3 = NULL;
2523 PyObject *__pyx_t_4 = NULL;
2524 PyObject *__pyx_t_5 = NULL;
2525 int __pyx_t_6;
2526 PyObject *__pyx_t_7 = NULL;
2527 PyObject *__pyx_t_8 = NULL;
2528 PyObject *__pyx_t_9 = NULL;
2529 PyObject *__pyx_t_10 = NULL;
2530 int __pyx_t_11;
2531 int __pyx_t_12;
2532 char const *__pyx_t_13;
2533 PyObject *__pyx_t_14 = NULL;
2534 PyObject *__pyx_t_15 = NULL;
2535 PyObject *__pyx_t_16 = NULL;
2536 Py_ssize_t __pyx_t_17;
2537 Py_ssize_t __pyx_t_18;
2538 int __pyx_lineno = 0;
2539 const char *__pyx_filename = NULL;
2540 int __pyx_clineno = 0;
2541 __Pyx_RefNannySetupContext("get_flags", 0);
2542
2543 /* "borg/platform/linux.pyx":100
2544 *
2545 * def get_flags(path, st):
2546 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode): # <<<<<<<<<<<<<<
2547 * # avoid opening devices files - trying to open non-present devices can be rather slow.
2548 * # avoid opening symlinks, O_NOFOLLOW would make the open() fail anyway.
2549 */
2550 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_stat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error)
2551 __Pyx_GOTREF(__pyx_t_3);
2552 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_S_ISBLK); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error)
2553 __Pyx_GOTREF(__pyx_t_4);
2554 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2555 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_st, __pyx_n_s_st_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error)
2556 __Pyx_GOTREF(__pyx_t_3);
2557 __pyx_t_5 = NULL;
2558 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
2559 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
2560 if (likely(__pyx_t_5)) {
2561 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
2562 __Pyx_INCREF(__pyx_t_5);
2563 __Pyx_INCREF(function);
2564 __Pyx_DECREF_SET(__pyx_t_4, function);
2565 }
2566 }
2567 __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
2568 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2569 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2570 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
2571 __Pyx_GOTREF(__pyx_t_2);
2572 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2573 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 100, __pyx_L1_error)
2574 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2575 if (!__pyx_t_6) {
2576 } else {
2577 __pyx_t_1 = __pyx_t_6;
2578 goto __pyx_L4_bool_binop_done;
2579 }
2580 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_stat); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error)
2581 __Pyx_GOTREF(__pyx_t_4);
2582 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_S_ISCHR); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error)
2583 __Pyx_GOTREF(__pyx_t_3);
2584 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2585 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_st, __pyx_n_s_st_mode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error)
2586 __Pyx_GOTREF(__pyx_t_4);
2587 __pyx_t_5 = NULL;
2588 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2589 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
2590 if (likely(__pyx_t_5)) {
2591 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2592 __Pyx_INCREF(__pyx_t_5);
2593 __Pyx_INCREF(function);
2594 __Pyx_DECREF_SET(__pyx_t_3, function);
2595 }
2596 }
2597 __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_5, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
2598 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2599 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2600 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
2601 __Pyx_GOTREF(__pyx_t_2);
2602 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2603 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 100, __pyx_L1_error)
2604 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2605 if (!__pyx_t_6) {
2606 } else {
2607 __pyx_t_1 = __pyx_t_6;
2608 goto __pyx_L4_bool_binop_done;
2609 }
2610 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_stat); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error)
2611 __Pyx_GOTREF(__pyx_t_3);
2612 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_S_ISLNK); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 100, __pyx_L1_error)
2613 __Pyx_GOTREF(__pyx_t_4);
2614 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2615 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_st, __pyx_n_s_st_mode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 100, __pyx_L1_error)
2616 __Pyx_GOTREF(__pyx_t_3);
2617 __pyx_t_5 = NULL;
2618 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
2619 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
2620 if (likely(__pyx_t_5)) {
2621 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
2622 __Pyx_INCREF(__pyx_t_5);
2623 __Pyx_INCREF(function);
2624 __Pyx_DECREF_SET(__pyx_t_4, function);
2625 }
2626 }
2627 __pyx_t_2 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_5, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_3);
2628 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2629 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2630 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 100, __pyx_L1_error)
2631 __Pyx_GOTREF(__pyx_t_2);
2632 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2633 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 100, __pyx_L1_error)
2634 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2635 __pyx_t_1 = __pyx_t_6;
2636 __pyx_L4_bool_binop_done:;
2637 if (__pyx_t_1) {
2638
2639 /* "borg/platform/linux.pyx":103
2640 * # avoid opening devices files - trying to open non-present devices can be rather slow.
2641 * # avoid opening symlinks, O_NOFOLLOW would make the open() fail anyway.
2642 * return 0 # <<<<<<<<<<<<<<
2643 * cdef int linux_flags
2644 * try:
2645 */
2646 __Pyx_XDECREF(__pyx_r);
2647 __Pyx_INCREF(__pyx_int_0);
2648 __pyx_r = __pyx_int_0;
2649 goto __pyx_L0;
2650
2651 /* "borg/platform/linux.pyx":100
2652 *
2653 * def get_flags(path, st):
2654 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode): # <<<<<<<<<<<<<<
2655 * # avoid opening devices files - trying to open non-present devices can be rather slow.
2656 * # avoid opening symlinks, O_NOFOLLOW would make the open() fail anyway.
2657 */
2658 }
2659
2660 /* "borg/platform/linux.pyx":105
2661 * return 0
2662 * cdef int linux_flags
2663 * try: # <<<<<<<<<<<<<<
2664 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2665 * except OSError:
2666 */
2667 {
2668 __Pyx_PyThreadState_declare
2669 __Pyx_PyThreadState_assign
2670 __Pyx_ExceptionSave(&__pyx_t_7, &__pyx_t_8, &__pyx_t_9);
2671 __Pyx_XGOTREF(__pyx_t_7);
2672 __Pyx_XGOTREF(__pyx_t_8);
2673 __Pyx_XGOTREF(__pyx_t_9);
2674 /*try:*/ {
2675
2676 /* "borg/platform/linux.pyx":106
2677 * cdef int linux_flags
2678 * try:
2679 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW) # <<<<<<<<<<<<<<
2680 * except OSError:
2681 * return 0
2682 */
2683 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L7_error)
2684 __Pyx_GOTREF(__pyx_t_4);
2685 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_open); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 106, __pyx_L7_error)
2686 __Pyx_GOTREF(__pyx_t_3);
2687 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2688 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L7_error)
2689 __Pyx_GOTREF(__pyx_t_4);
2690 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_O_RDONLY); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L7_error)
2691 __Pyx_GOTREF(__pyx_t_5);
2692 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2693 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_os); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L7_error)
2694 __Pyx_GOTREF(__pyx_t_4);
2695 __pyx_t_10 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_O_NONBLOCK); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 106, __pyx_L7_error)
2696 __Pyx_GOTREF(__pyx_t_10);
2697 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2698 __pyx_t_4 = PyNumber_Or(__pyx_t_5, __pyx_t_10); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L7_error)
2699 __Pyx_GOTREF(__pyx_t_4);
2700 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2701 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2702 __Pyx_GetModuleGlobalName(__pyx_t_10, __pyx_n_s_os); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 106, __pyx_L7_error)
2703 __Pyx_GOTREF(__pyx_t_10);
2704 __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_t_10, __pyx_n_s_O_NOFOLLOW); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 106, __pyx_L7_error)
2705 __Pyx_GOTREF(__pyx_t_5);
2706 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2707 __pyx_t_10 = PyNumber_Or(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 106, __pyx_L7_error)
2708 __Pyx_GOTREF(__pyx_t_10);
2709 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2710 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2711 __pyx_t_5 = NULL;
2712 __pyx_t_11 = 0;
2713 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2714 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
2715 if (likely(__pyx_t_5)) {
2716 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2717 __Pyx_INCREF(__pyx_t_5);
2718 __Pyx_INCREF(function);
2719 __Pyx_DECREF_SET(__pyx_t_3, function);
2720 __pyx_t_11 = 1;
2721 }
2722 }
2723 #if CYTHON_FAST_PYCALL
2724 if (PyFunction_Check(__pyx_t_3)) {
2725 PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_path, __pyx_t_10};
2726 __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L7_error)
2727 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2728 __Pyx_GOTREF(__pyx_t_2);
2729 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2730 } else
2731 #endif
2732 #if CYTHON_FAST_PYCCALL
2733 if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
2734 PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_v_path, __pyx_t_10};
2735 __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L7_error)
2736 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2737 __Pyx_GOTREF(__pyx_t_2);
2738 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
2739 } else
2740 #endif
2741 {
2742 __pyx_t_4 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 106, __pyx_L7_error)
2743 __Pyx_GOTREF(__pyx_t_4);
2744 if (__pyx_t_5) {
2745 __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_5); __pyx_t_5 = NULL;
2746 }
2747 __Pyx_INCREF(__pyx_v_path);
2748 __Pyx_GIVEREF(__pyx_v_path);
2749 PyTuple_SET_ITEM(__pyx_t_4, 0+__pyx_t_11, __pyx_v_path);
2750 __Pyx_GIVEREF(__pyx_t_10);
2751 PyTuple_SET_ITEM(__pyx_t_4, 1+__pyx_t_11, __pyx_t_10);
2752 __pyx_t_10 = 0;
2753 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_4, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 106, __pyx_L7_error)
2754 __Pyx_GOTREF(__pyx_t_2);
2755 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2756 }
2757 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2758 __pyx_v_fd = __pyx_t_2;
2759 __pyx_t_2 = 0;
2760
2761 /* "borg/platform/linux.pyx":105
2762 * return 0
2763 * cdef int linux_flags
2764 * try: # <<<<<<<<<<<<<<
2765 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2766 * except OSError:
2767 */
2768 }
2769 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2770 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
2771 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
2772 goto __pyx_L12_try_end;
2773 __pyx_L7_error:;
2774 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2775 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2776 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2777 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2778 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2779
2780 /* "borg/platform/linux.pyx":107
2781 * try:
2782 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2783 * except OSError: # <<<<<<<<<<<<<<
2784 * return 0
2785 * try:
2786 */
2787 __pyx_t_11 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_OSError);
2788 if (__pyx_t_11) {
2789 __Pyx_AddTraceback("borg.platform.linux.get_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
2790 if (__Pyx_GetException(&__pyx_t_2, &__pyx_t_3, &__pyx_t_4) < 0) __PYX_ERR(0, 107, __pyx_L9_except_error)
2791 __Pyx_GOTREF(__pyx_t_2);
2792 __Pyx_GOTREF(__pyx_t_3);
2793 __Pyx_GOTREF(__pyx_t_4);
2794
2795 /* "borg/platform/linux.pyx":108
2796 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2797 * except OSError:
2798 * return 0 # <<<<<<<<<<<<<<
2799 * try:
2800 * if ioctl(fd, FS_IOC_GETFLAGS, &linux_flags) == -1:
2801 */
2802 __Pyx_XDECREF(__pyx_r);
2803 __Pyx_INCREF(__pyx_int_0);
2804 __pyx_r = __pyx_int_0;
2805 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2806 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2807 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2808 goto __pyx_L10_except_return;
2809 }
2810 goto __pyx_L9_except_error;
2811 __pyx_L9_except_error:;
2812
2813 /* "borg/platform/linux.pyx":105
2814 * return 0
2815 * cdef int linux_flags
2816 * try: # <<<<<<<<<<<<<<
2817 * fd = os.open(path, os.O_RDONLY|os.O_NONBLOCK|os.O_NOFOLLOW)
2818 * except OSError:
2819 */
2820 __Pyx_XGIVEREF(__pyx_t_7);
2821 __Pyx_XGIVEREF(__pyx_t_8);
2822 __Pyx_XGIVEREF(__pyx_t_9);
2823 __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
2824 goto __pyx_L1_error;
2825 __pyx_L10_except_return:;
2826 __Pyx_XGIVEREF(__pyx_t_7);
2827 __Pyx_XGIVEREF(__pyx_t_8);
2828 __Pyx_XGIVEREF(__pyx_t_9);
2829 __Pyx_ExceptionReset(__pyx_t_7, __pyx_t_8, __pyx_t_9);
2830 goto __pyx_L0;
2831 __pyx_L12_try_end:;
2832 }
2833
2834 /* "borg/platform/linux.pyx":109
2835 * except OSError:
2836 * return 0
2837 * try: # <<<<<<<<<<<<<<
2838 * if ioctl(fd, FS_IOC_GETFLAGS, &linux_flags) == -1:
2839 * return 0
2840 */
2841 /*try:*/ {
2842
2843 /* "borg/platform/linux.pyx":110
2844 * return 0
2845 * try:
2846 * if ioctl(fd, FS_IOC_GETFLAGS, &linux_flags) == -1: # <<<<<<<<<<<<<<
2847 * return 0
2848 * finally:
2849 */
2850 __pyx_t_11 = __Pyx_PyInt_As_int(__pyx_v_fd); if (unlikely((__pyx_t_11 == (int)-1) && PyErr_Occurred())) __PYX_ERR(0, 110, __pyx_L16_error)
2851 __pyx_t_1 = ((ioctl(__pyx_t_11, FS_IOC_GETFLAGS, (&__pyx_v_linux_flags)) == -1L) != 0);
2852 if (__pyx_t_1) {
2853
2854 /* "borg/platform/linux.pyx":111
2855 * try:
2856 * if ioctl(fd, FS_IOC_GETFLAGS, &linux_flags) == -1:
2857 * return 0 # <<<<<<<<<<<<<<
2858 * finally:
2859 * os.close(fd)
2860 */
2861 __Pyx_XDECREF(__pyx_r);
2862 __Pyx_INCREF(__pyx_int_0);
2863 __pyx_r = __pyx_int_0;
2864 goto __pyx_L15_return;
2865
2866 /* "borg/platform/linux.pyx":110
2867 * return 0
2868 * try:
2869 * if ioctl(fd, FS_IOC_GETFLAGS, &linux_flags) == -1: # <<<<<<<<<<<<<<
2870 * return 0
2871 * finally:
2872 */
2873 }
2874 }
2875
2876 /* "borg/platform/linux.pyx":113
2877 * return 0
2878 * finally:
2879 * os.close(fd) # <<<<<<<<<<<<<<
2880 * bsd_flags = 0
2881 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
2882 */
2883 /*finally:*/ {
2884 /*normal exit:*/{
2885 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L1_error)
2886 __Pyx_GOTREF(__pyx_t_3);
2887 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
2888 __Pyx_GOTREF(__pyx_t_2);
2889 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2890 __pyx_t_3 = NULL;
2891 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
2892 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
2893 if (likely(__pyx_t_3)) {
2894 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2895 __Pyx_INCREF(__pyx_t_3);
2896 __Pyx_INCREF(function);
2897 __Pyx_DECREF_SET(__pyx_t_2, function);
2898 }
2899 }
2900 __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_fd) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_fd);
2901 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2902 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error)
2903 __Pyx_GOTREF(__pyx_t_4);
2904 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2905 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2906 goto __pyx_L17;
2907 }
2908 __pyx_L16_error:;
2909 /*exception exit:*/{
2910 __Pyx_PyThreadState_declare
2911 __Pyx_PyThreadState_assign
2912 __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
2913 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
2914 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2915 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2916 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
2917 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
2918 if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
2919 if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7) < 0)) __Pyx_ErrFetch(&__pyx_t_9, &__pyx_t_8, &__pyx_t_7);
2920 __Pyx_XGOTREF(__pyx_t_9);
2921 __Pyx_XGOTREF(__pyx_t_8);
2922 __Pyx_XGOTREF(__pyx_t_7);
2923 __Pyx_XGOTREF(__pyx_t_14);
2924 __Pyx_XGOTREF(__pyx_t_15);
2925 __Pyx_XGOTREF(__pyx_t_16);
2926 __pyx_t_11 = __pyx_lineno; __pyx_t_12 = __pyx_clineno; __pyx_t_13 = __pyx_filename;
2927 {
2928 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L20_error)
2929 __Pyx_GOTREF(__pyx_t_2);
2930 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_close); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L20_error)
2931 __Pyx_GOTREF(__pyx_t_3);
2932 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2933 __pyx_t_2 = NULL;
2934 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
2935 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
2936 if (likely(__pyx_t_2)) {
2937 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
2938 __Pyx_INCREF(__pyx_t_2);
2939 __Pyx_INCREF(function);
2940 __Pyx_DECREF_SET(__pyx_t_3, function);
2941 }
2942 }
2943 __pyx_t_4 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_fd) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_fd);
2944 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
2945 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L20_error)
2946 __Pyx_GOTREF(__pyx_t_4);
2947 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2948 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
2949 }
2950 if (PY_MAJOR_VERSION >= 3) {
2951 __Pyx_XGIVEREF(__pyx_t_14);
2952 __Pyx_XGIVEREF(__pyx_t_15);
2953 __Pyx_XGIVEREF(__pyx_t_16);
2954 __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
2955 }
2956 __Pyx_XGIVEREF(__pyx_t_9);
2957 __Pyx_XGIVEREF(__pyx_t_8);
2958 __Pyx_XGIVEREF(__pyx_t_7);
2959 __Pyx_ErrRestore(__pyx_t_9, __pyx_t_8, __pyx_t_7);
2960 __pyx_t_9 = 0; __pyx_t_8 = 0; __pyx_t_7 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
2961 __pyx_lineno = __pyx_t_11; __pyx_clineno = __pyx_t_12; __pyx_filename = __pyx_t_13;
2962 goto __pyx_L1_error;
2963 __pyx_L20_error:;
2964 if (PY_MAJOR_VERSION >= 3) {
2965 __Pyx_XGIVEREF(__pyx_t_14);
2966 __Pyx_XGIVEREF(__pyx_t_15);
2967 __Pyx_XGIVEREF(__pyx_t_16);
2968 __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
2969 }
2970 __Pyx_XDECREF(__pyx_t_9); __pyx_t_9 = 0;
2971 __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
2972 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
2973 __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
2974 goto __pyx_L1_error;
2975 }
2976 __pyx_L15_return: {
2977 __pyx_t_16 = __pyx_r;
2978 __pyx_r = 0;
2979 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 113, __pyx_L1_error)
2980 __Pyx_GOTREF(__pyx_t_3);
2981 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 113, __pyx_L1_error)
2982 __Pyx_GOTREF(__pyx_t_2);
2983 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2984 __pyx_t_3 = NULL;
2985 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
2986 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
2987 if (likely(__pyx_t_3)) {
2988 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
2989 __Pyx_INCREF(__pyx_t_3);
2990 __Pyx_INCREF(function);
2991 __Pyx_DECREF_SET(__pyx_t_2, function);
2992 }
2993 }
2994 __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_3, __pyx_v_fd) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_fd);
2995 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
2996 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 113, __pyx_L1_error)
2997 __Pyx_GOTREF(__pyx_t_4);
2998 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2999 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3000 __pyx_r = __pyx_t_16;
3001 __pyx_t_16 = 0;
3002 goto __pyx_L0;
3003 }
3004 __pyx_L17:;
3005 }
3006
3007 /* "borg/platform/linux.pyx":114
3008 * finally:
3009 * os.close(fd)
3010 * bsd_flags = 0 # <<<<<<<<<<<<<<
3011 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
3012 * if linux_flags & linux_flag:
3013 */
3014 __Pyx_INCREF(__pyx_int_0);
3015 __pyx_v_bsd_flags = __pyx_int_0;
3016
3017 /* "borg/platform/linux.pyx":115
3018 * os.close(fd)
3019 * bsd_flags = 0
3020 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items(): # <<<<<<<<<<<<<<
3021 * if linux_flags & linux_flag:
3022 * bsd_flags |= bsd_flag
3023 */
3024 __pyx_t_17 = 0;
3025 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_BSD_TO_LINUX_FLAGS); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 115, __pyx_L1_error)
3026 __Pyx_GOTREF(__pyx_t_2);
3027 if (unlikely(__pyx_t_2 == Py_None)) {
3028 PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%.30s'", "items");
3029 __PYX_ERR(0, 115, __pyx_L1_error)
3030 }
3031 __pyx_t_3 = __Pyx_dict_iterator(__pyx_t_2, 0, __pyx_n_s_items, (&__pyx_t_18), (&__pyx_t_12)); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 115, __pyx_L1_error)
3032 __Pyx_GOTREF(__pyx_t_3);
3033 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3034 __Pyx_XDECREF(__pyx_t_4);
3035 __pyx_t_4 = __pyx_t_3;
3036 __pyx_t_3 = 0;
3037 while (1) {
3038 __pyx_t_11 = __Pyx_dict_iter_next(__pyx_t_4, __pyx_t_18, &__pyx_t_17, &__pyx_t_3, &__pyx_t_2, NULL, __pyx_t_12);
3039 if (unlikely(__pyx_t_11 == 0)) break;
3040 if (unlikely(__pyx_t_11 == -1)) __PYX_ERR(0, 115, __pyx_L1_error)
3041 __Pyx_GOTREF(__pyx_t_3);
3042 __Pyx_GOTREF(__pyx_t_2);
3043 __Pyx_XDECREF_SET(__pyx_v_bsd_flag, __pyx_t_3);
3044 __pyx_t_3 = 0;
3045 __Pyx_XDECREF_SET(__pyx_v_linux_flag, __pyx_t_2);
3046 __pyx_t_2 = 0;
3047
3048 /* "borg/platform/linux.pyx":116
3049 * bsd_flags = 0
3050 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
3051 * if linux_flags & linux_flag: # <<<<<<<<<<<<<<
3052 * bsd_flags |= bsd_flag
3053 * return bsd_flags
3054 */
3055 __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_linux_flags); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 116, __pyx_L1_error)
3056 __Pyx_GOTREF(__pyx_t_2);
3057 __pyx_t_3 = PyNumber_And(__pyx_t_2, __pyx_v_linux_flag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 116, __pyx_L1_error)
3058 __Pyx_GOTREF(__pyx_t_3);
3059 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3060 __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_1 < 0)) __PYX_ERR(0, 116, __pyx_L1_error)
3061 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3062 if (__pyx_t_1) {
3063
3064 /* "borg/platform/linux.pyx":117
3065 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
3066 * if linux_flags & linux_flag:
3067 * bsd_flags |= bsd_flag # <<<<<<<<<<<<<<
3068 * return bsd_flags
3069 *
3070 */
3071 __pyx_t_3 = PyNumber_InPlaceOr(__pyx_v_bsd_flags, __pyx_v_bsd_flag); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 117, __pyx_L1_error)
3072 __Pyx_GOTREF(__pyx_t_3);
3073 __Pyx_DECREF_SET(__pyx_v_bsd_flags, __pyx_t_3);
3074 __pyx_t_3 = 0;
3075
3076 /* "borg/platform/linux.pyx":116
3077 * bsd_flags = 0
3078 * for bsd_flag, linux_flag in BSD_TO_LINUX_FLAGS.items():
3079 * if linux_flags & linux_flag: # <<<<<<<<<<<<<<
3080 * bsd_flags |= bsd_flag
3081 * return bsd_flags
3082 */
3083 }
3084 }
3085 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3086
3087 /* "borg/platform/linux.pyx":118
3088 * if linux_flags & linux_flag:
3089 * bsd_flags |= bsd_flag
3090 * return bsd_flags # <<<<<<<<<<<<<<
3091 *
3092 *
3093 */
3094 __Pyx_XDECREF(__pyx_r);
3095 __Pyx_INCREF(__pyx_v_bsd_flags);
3096 __pyx_r = __pyx_v_bsd_flags;
3097 goto __pyx_L0;
3098
3099 /* "borg/platform/linux.pyx":99
3100 *
3101 *
3102 * def get_flags(path, st): # <<<<<<<<<<<<<<
3103 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode):
3104 * # avoid opening devices files - trying to open non-present devices can be rather slow.
3105 */
3106
3107 /* function exit code */
3108 __pyx_L1_error:;
3109 __Pyx_XDECREF(__pyx_t_2);
3110 __Pyx_XDECREF(__pyx_t_3);
3111 __Pyx_XDECREF(__pyx_t_4);
3112 __Pyx_XDECREF(__pyx_t_5);
3113 __Pyx_XDECREF(__pyx_t_10);
3114 __Pyx_AddTraceback("borg.platform.linux.get_flags", __pyx_clineno, __pyx_lineno, __pyx_filename);
3115 __pyx_r = NULL;
3116 __pyx_L0:;
3117 __Pyx_XDECREF(__pyx_v_fd);
3118 __Pyx_XDECREF(__pyx_v_bsd_flags);
3119 __Pyx_XDECREF(__pyx_v_bsd_flag);
3120 __Pyx_XDECREF(__pyx_v_linux_flag);
3121 __Pyx_XGIVEREF(__pyx_r);
3122 __Pyx_RefNannyFinishContext();
3123 return __pyx_r;
3124 }
3125
3126 /* "borg/platform/linux.pyx":121
3127 *
3128 *
3129 * def acl_use_local_uid_gid(acl): # <<<<<<<<<<<<<<
3130 * """Replace the user/group field with the local uid/gid if possible
3131 * """
3132 */
3133
3134 /* Python wrapper */
3135 static PyObject *__pyx_pw_4borg_8platform_5linux_5acl_use_local_uid_gid(PyObject *__pyx_self, PyObject *__pyx_v_acl); /*proto*/
3136 static char __pyx_doc_4borg_8platform_5linux_4acl_use_local_uid_gid[] = "Replace the user/group field with the local uid/gid if possible\n ";
3137 static PyMethodDef __pyx_mdef_4borg_8platform_5linux_5acl_use_local_uid_gid = {"acl_use_local_uid_gid", (PyCFunction)__pyx_pw_4borg_8platform_5linux_5acl_use_local_uid_gid, METH_O, __pyx_doc_4borg_8platform_5linux_4acl_use_local_uid_gid};
__pyx_pw_4borg_8platform_5linux_5acl_use_local_uid_gid(PyObject * __pyx_self,PyObject * __pyx_v_acl)3138 static PyObject *__pyx_pw_4borg_8platform_5linux_5acl_use_local_uid_gid(PyObject *__pyx_self, PyObject *__pyx_v_acl) {
3139 PyObject *__pyx_r = 0;
3140 __Pyx_RefNannyDeclarations
3141 __Pyx_RefNannySetupContext("acl_use_local_uid_gid (wrapper)", 0);
3142 __pyx_r = __pyx_pf_4borg_8platform_5linux_4acl_use_local_uid_gid(__pyx_self, ((PyObject *)__pyx_v_acl));
3143
3144 /* function exit code */
3145 __Pyx_RefNannyFinishContext();
3146 return __pyx_r;
3147 }
3148
__pyx_pf_4borg_8platform_5linux_4acl_use_local_uid_gid(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_acl)3149 static PyObject *__pyx_pf_4borg_8platform_5linux_4acl_use_local_uid_gid(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_acl) {
3150 PyObject *__pyx_v_entries = NULL;
3151 PyObject *__pyx_v_entry = NULL;
3152 PyObject *__pyx_v_fields = NULL;
3153 PyObject *__pyx_r = NULL;
3154 __Pyx_RefNannyDeclarations
3155 PyObject *__pyx_t_1 = NULL;
3156 PyObject *__pyx_t_2 = NULL;
3157 PyObject *__pyx_t_3 = NULL;
3158 PyObject *__pyx_t_4 = NULL;
3159 Py_ssize_t __pyx_t_5;
3160 PyObject *(*__pyx_t_6)(PyObject *);
3161 int __pyx_t_7;
3162 int __pyx_t_8;
3163 PyObject *__pyx_t_9 = NULL;
3164 PyObject *__pyx_t_10 = NULL;
3165 int __pyx_t_11;
3166 PyObject *__pyx_t_12 = NULL;
3167 int __pyx_t_13;
3168 int __pyx_lineno = 0;
3169 const char *__pyx_filename = NULL;
3170 int __pyx_clineno = 0;
3171 __Pyx_RefNannySetupContext("acl_use_local_uid_gid", 0);
3172
3173 /* "borg/platform/linux.pyx":124
3174 * """Replace the user/group field with the local uid/gid if possible
3175 * """
3176 * entries = [] # <<<<<<<<<<<<<<
3177 * for entry in safe_decode(acl).split('\n'):
3178 * if entry:
3179 */
3180 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 124, __pyx_L1_error)
3181 __Pyx_GOTREF(__pyx_t_1);
3182 __pyx_v_entries = ((PyObject*)__pyx_t_1);
3183 __pyx_t_1 = 0;
3184
3185 /* "borg/platform/linux.pyx":125
3186 * """
3187 * entries = []
3188 * for entry in safe_decode(acl).split('\n'): # <<<<<<<<<<<<<<
3189 * if entry:
3190 * fields = entry.split(':')
3191 */
3192 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_safe_decode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error)
3193 __Pyx_GOTREF(__pyx_t_3);
3194 __pyx_t_4 = NULL;
3195 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3196 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_3);
3197 if (likely(__pyx_t_4)) {
3198 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3199 __Pyx_INCREF(__pyx_t_4);
3200 __Pyx_INCREF(function);
3201 __Pyx_DECREF_SET(__pyx_t_3, function);
3202 }
3203 }
3204 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_4, __pyx_v_acl) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_acl);
3205 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3206 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 125, __pyx_L1_error)
3207 __Pyx_GOTREF(__pyx_t_2);
3208 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3209 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error)
3210 __Pyx_GOTREF(__pyx_t_3);
3211 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3212 __pyx_t_2 = NULL;
3213 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
3214 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
3215 if (likely(__pyx_t_2)) {
3216 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3217 __Pyx_INCREF(__pyx_t_2);
3218 __Pyx_INCREF(function);
3219 __Pyx_DECREF_SET(__pyx_t_3, function);
3220 }
3221 }
3222 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_kp_u_) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_kp_u_);
3223 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3224 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
3225 __Pyx_GOTREF(__pyx_t_1);
3226 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3227 if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
3228 __pyx_t_3 = __pyx_t_1; __Pyx_INCREF(__pyx_t_3); __pyx_t_5 = 0;
3229 __pyx_t_6 = NULL;
3230 } else {
3231 __pyx_t_5 = -1; __pyx_t_3 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 125, __pyx_L1_error)
3232 __Pyx_GOTREF(__pyx_t_3);
3233 __pyx_t_6 = Py_TYPE(__pyx_t_3)->tp_iternext; if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 125, __pyx_L1_error)
3234 }
3235 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3236 for (;;) {
3237 if (likely(!__pyx_t_6)) {
3238 if (likely(PyList_CheckExact(__pyx_t_3))) {
3239 if (__pyx_t_5 >= PyList_GET_SIZE(__pyx_t_3)) break;
3240 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3241 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 125, __pyx_L1_error)
3242 #else
3243 __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
3244 __Pyx_GOTREF(__pyx_t_1);
3245 #endif
3246 } else {
3247 if (__pyx_t_5 >= PyTuple_GET_SIZE(__pyx_t_3)) break;
3248 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3249 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_3, __pyx_t_5); __Pyx_INCREF(__pyx_t_1); __pyx_t_5++; if (unlikely(0 < 0)) __PYX_ERR(0, 125, __pyx_L1_error)
3250 #else
3251 __pyx_t_1 = PySequence_ITEM(__pyx_t_3, __pyx_t_5); __pyx_t_5++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 125, __pyx_L1_error)
3252 __Pyx_GOTREF(__pyx_t_1);
3253 #endif
3254 }
3255 } else {
3256 __pyx_t_1 = __pyx_t_6(__pyx_t_3);
3257 if (unlikely(!__pyx_t_1)) {
3258 PyObject* exc_type = PyErr_Occurred();
3259 if (exc_type) {
3260 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
3261 else __PYX_ERR(0, 125, __pyx_L1_error)
3262 }
3263 break;
3264 }
3265 __Pyx_GOTREF(__pyx_t_1);
3266 }
3267 __Pyx_XDECREF_SET(__pyx_v_entry, __pyx_t_1);
3268 __pyx_t_1 = 0;
3269
3270 /* "borg/platform/linux.pyx":126
3271 * entries = []
3272 * for entry in safe_decode(acl).split('\n'):
3273 * if entry: # <<<<<<<<<<<<<<
3274 * fields = entry.split(':')
3275 * if fields[0] == 'user' and fields[1]:
3276 */
3277 __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_v_entry); if (unlikely(__pyx_t_7 < 0)) __PYX_ERR(0, 126, __pyx_L1_error)
3278 if (__pyx_t_7) {
3279
3280 /* "borg/platform/linux.pyx":127
3281 * for entry in safe_decode(acl).split('\n'):
3282 * if entry:
3283 * fields = entry.split(':') # <<<<<<<<<<<<<<
3284 * if fields[0] == 'user' and fields[1]:
3285 * fields[1] = str(user2uid(fields[1], fields[3]))
3286 */
3287 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entry, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 127, __pyx_L1_error)
3288 __Pyx_GOTREF(__pyx_t_2);
3289 __pyx_t_4 = NULL;
3290 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3291 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
3292 if (likely(__pyx_t_4)) {
3293 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3294 __Pyx_INCREF(__pyx_t_4);
3295 __Pyx_INCREF(function);
3296 __Pyx_DECREF_SET(__pyx_t_2, function);
3297 }
3298 }
3299 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_kp_u__2) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u__2);
3300 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3301 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 127, __pyx_L1_error)
3302 __Pyx_GOTREF(__pyx_t_1);
3303 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3304 __Pyx_XDECREF_SET(__pyx_v_fields, __pyx_t_1);
3305 __pyx_t_1 = 0;
3306
3307 /* "borg/platform/linux.pyx":128
3308 * if entry:
3309 * fields = entry.split(':')
3310 * if fields[0] == 'user' and fields[1]: # <<<<<<<<<<<<<<
3311 * fields[1] = str(user2uid(fields[1], fields[3]))
3312 * elif fields[0] == 'group' and fields[1]:
3313 */
3314 __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_fields, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
3315 __Pyx_GOTREF(__pyx_t_1);
3316 __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_1, __pyx_n_u_user, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 128, __pyx_L1_error)
3317 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3318 if (__pyx_t_8) {
3319 } else {
3320 __pyx_t_7 = __pyx_t_8;
3321 goto __pyx_L7_bool_binop_done;
3322 }
3323 __pyx_t_1 = __Pyx_GetItemInt(__pyx_v_fields, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 128, __pyx_L1_error)
3324 __Pyx_GOTREF(__pyx_t_1);
3325 __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 128, __pyx_L1_error)
3326 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3327 __pyx_t_7 = __pyx_t_8;
3328 __pyx_L7_bool_binop_done:;
3329 if (__pyx_t_7) {
3330
3331 /* "borg/platform/linux.pyx":129
3332 * fields = entry.split(':')
3333 * if fields[0] == 'user' and fields[1]:
3334 * fields[1] = str(user2uid(fields[1], fields[3])) # <<<<<<<<<<<<<<
3335 * elif fields[0] == 'group' and fields[1]:
3336 * fields[1] = str(group2gid(fields[1], fields[3]))
3337 */
3338 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_user2uid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
3339 __Pyx_GOTREF(__pyx_t_2);
3340 __pyx_t_4 = __Pyx_GetItemInt(__pyx_v_fields, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 129, __pyx_L1_error)
3341 __Pyx_GOTREF(__pyx_t_4);
3342 __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_fields, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 129, __pyx_L1_error)
3343 __Pyx_GOTREF(__pyx_t_9);
3344 __pyx_t_10 = NULL;
3345 __pyx_t_11 = 0;
3346 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
3347 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
3348 if (likely(__pyx_t_10)) {
3349 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3350 __Pyx_INCREF(__pyx_t_10);
3351 __Pyx_INCREF(function);
3352 __Pyx_DECREF_SET(__pyx_t_2, function);
3353 __pyx_t_11 = 1;
3354 }
3355 }
3356 #if CYTHON_FAST_PYCALL
3357 if (PyFunction_Check(__pyx_t_2)) {
3358 PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_4, __pyx_t_9};
3359 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
3360 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
3361 __Pyx_GOTREF(__pyx_t_1);
3362 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3363 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
3364 } else
3365 #endif
3366 #if CYTHON_FAST_PYCCALL
3367 if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
3368 PyObject *__pyx_temp[3] = {__pyx_t_10, __pyx_t_4, __pyx_t_9};
3369 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
3370 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
3371 __Pyx_GOTREF(__pyx_t_1);
3372 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3373 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
3374 } else
3375 #endif
3376 {
3377 __pyx_t_12 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 129, __pyx_L1_error)
3378 __Pyx_GOTREF(__pyx_t_12);
3379 if (__pyx_t_10) {
3380 __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_12, 0, __pyx_t_10); __pyx_t_10 = NULL;
3381 }
3382 __Pyx_GIVEREF(__pyx_t_4);
3383 PyTuple_SET_ITEM(__pyx_t_12, 0+__pyx_t_11, __pyx_t_4);
3384 __Pyx_GIVEREF(__pyx_t_9);
3385 PyTuple_SET_ITEM(__pyx_t_12, 1+__pyx_t_11, __pyx_t_9);
3386 __pyx_t_4 = 0;
3387 __pyx_t_9 = 0;
3388 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_12, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 129, __pyx_L1_error)
3389 __Pyx_GOTREF(__pyx_t_1);
3390 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
3391 }
3392 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3393 __pyx_t_2 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 129, __pyx_L1_error)
3394 __Pyx_GOTREF(__pyx_t_2);
3395 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3396 if (unlikely(__Pyx_SetItemInt(__pyx_v_fields, 1, __pyx_t_2, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 129, __pyx_L1_error)
3397 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3398
3399 /* "borg/platform/linux.pyx":128
3400 * if entry:
3401 * fields = entry.split(':')
3402 * if fields[0] == 'user' and fields[1]: # <<<<<<<<<<<<<<
3403 * fields[1] = str(user2uid(fields[1], fields[3]))
3404 * elif fields[0] == 'group' and fields[1]:
3405 */
3406 goto __pyx_L6;
3407 }
3408
3409 /* "borg/platform/linux.pyx":130
3410 * if fields[0] == 'user' and fields[1]:
3411 * fields[1] = str(user2uid(fields[1], fields[3]))
3412 * elif fields[0] == 'group' and fields[1]: # <<<<<<<<<<<<<<
3413 * fields[1] = str(group2gid(fields[1], fields[3]))
3414 * entries.append(':'.join(fields[:3]))
3415 */
3416 __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_fields, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
3417 __Pyx_GOTREF(__pyx_t_2);
3418 __pyx_t_8 = (__Pyx_PyUnicode_Equals(__pyx_t_2, __pyx_n_u_group, Py_EQ)); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 130, __pyx_L1_error)
3419 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3420 if (__pyx_t_8) {
3421 } else {
3422 __pyx_t_7 = __pyx_t_8;
3423 goto __pyx_L9_bool_binop_done;
3424 }
3425 __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_fields, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 130, __pyx_L1_error)
3426 __Pyx_GOTREF(__pyx_t_2);
3427 __pyx_t_8 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_8 < 0)) __PYX_ERR(0, 130, __pyx_L1_error)
3428 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3429 __pyx_t_7 = __pyx_t_8;
3430 __pyx_L9_bool_binop_done:;
3431 if (__pyx_t_7) {
3432
3433 /* "borg/platform/linux.pyx":131
3434 * fields[1] = str(user2uid(fields[1], fields[3]))
3435 * elif fields[0] == 'group' and fields[1]:
3436 * fields[1] = str(group2gid(fields[1], fields[3])) # <<<<<<<<<<<<<<
3437 * entries.append(':'.join(fields[:3]))
3438 * return safe_encode('\n'.join(entries))
3439 */
3440 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_group2gid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
3441 __Pyx_GOTREF(__pyx_t_1);
3442 __pyx_t_12 = __Pyx_GetItemInt(__pyx_v_fields, 1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 131, __pyx_L1_error)
3443 __Pyx_GOTREF(__pyx_t_12);
3444 __pyx_t_9 = __Pyx_GetItemInt(__pyx_v_fields, 3, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 131, __pyx_L1_error)
3445 __Pyx_GOTREF(__pyx_t_9);
3446 __pyx_t_4 = NULL;
3447 __pyx_t_11 = 0;
3448 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
3449 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
3450 if (likely(__pyx_t_4)) {
3451 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
3452 __Pyx_INCREF(__pyx_t_4);
3453 __Pyx_INCREF(function);
3454 __Pyx_DECREF_SET(__pyx_t_1, function);
3455 __pyx_t_11 = 1;
3456 }
3457 }
3458 #if CYTHON_FAST_PYCALL
3459 if (PyFunction_Check(__pyx_t_1)) {
3460 PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_12, __pyx_t_9};
3461 __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
3462 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3463 __Pyx_GOTREF(__pyx_t_2);
3464 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
3465 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
3466 } else
3467 #endif
3468 #if CYTHON_FAST_PYCCALL
3469 if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
3470 PyObject *__pyx_temp[3] = {__pyx_t_4, __pyx_t_12, __pyx_t_9};
3471 __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_11, 2+__pyx_t_11); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
3472 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
3473 __Pyx_GOTREF(__pyx_t_2);
3474 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
3475 __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
3476 } else
3477 #endif
3478 {
3479 __pyx_t_10 = PyTuple_New(2+__pyx_t_11); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 131, __pyx_L1_error)
3480 __Pyx_GOTREF(__pyx_t_10);
3481 if (__pyx_t_4) {
3482 __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_4); __pyx_t_4 = NULL;
3483 }
3484 __Pyx_GIVEREF(__pyx_t_12);
3485 PyTuple_SET_ITEM(__pyx_t_10, 0+__pyx_t_11, __pyx_t_12);
3486 __Pyx_GIVEREF(__pyx_t_9);
3487 PyTuple_SET_ITEM(__pyx_t_10, 1+__pyx_t_11, __pyx_t_9);
3488 __pyx_t_12 = 0;
3489 __pyx_t_9 = 0;
3490 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_10, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 131, __pyx_L1_error)
3491 __Pyx_GOTREF(__pyx_t_2);
3492 __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
3493 }
3494 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3495 __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 131, __pyx_L1_error)
3496 __Pyx_GOTREF(__pyx_t_1);
3497 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3498 if (unlikely(__Pyx_SetItemInt(__pyx_v_fields, 1, __pyx_t_1, long, 1, __Pyx_PyInt_From_long, 0, 0, 1) < 0)) __PYX_ERR(0, 131, __pyx_L1_error)
3499 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3500
3501 /* "borg/platform/linux.pyx":130
3502 * if fields[0] == 'user' and fields[1]:
3503 * fields[1] = str(user2uid(fields[1], fields[3]))
3504 * elif fields[0] == 'group' and fields[1]: # <<<<<<<<<<<<<<
3505 * fields[1] = str(group2gid(fields[1], fields[3]))
3506 * entries.append(':'.join(fields[:3]))
3507 */
3508 }
3509 __pyx_L6:;
3510
3511 /* "borg/platform/linux.pyx":132
3512 * elif fields[0] == 'group' and fields[1]:
3513 * fields[1] = str(group2gid(fields[1], fields[3]))
3514 * entries.append(':'.join(fields[:3])) # <<<<<<<<<<<<<<
3515 * return safe_encode('\n'.join(entries))
3516 *
3517 */
3518 __pyx_t_1 = __Pyx_PyObject_GetSlice(__pyx_v_fields, 0, 3, NULL, NULL, &__pyx_slice__3, 0, 1, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 132, __pyx_L1_error)
3519 __Pyx_GOTREF(__pyx_t_1);
3520 __pyx_t_2 = PyUnicode_Join(__pyx_kp_u__2, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 132, __pyx_L1_error)
3521 __Pyx_GOTREF(__pyx_t_2);
3522 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3523 __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_entries, __pyx_t_2); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 132, __pyx_L1_error)
3524 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3525
3526 /* "borg/platform/linux.pyx":126
3527 * entries = []
3528 * for entry in safe_decode(acl).split('\n'):
3529 * if entry: # <<<<<<<<<<<<<<
3530 * fields = entry.split(':')
3531 * if fields[0] == 'user' and fields[1]:
3532 */
3533 }
3534
3535 /* "borg/platform/linux.pyx":125
3536 * """
3537 * entries = []
3538 * for entry in safe_decode(acl).split('\n'): # <<<<<<<<<<<<<<
3539 * if entry:
3540 * fields = entry.split(':')
3541 */
3542 }
3543 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3544
3545 /* "borg/platform/linux.pyx":133
3546 * fields[1] = str(group2gid(fields[1], fields[3]))
3547 * entries.append(':'.join(fields[:3]))
3548 * return safe_encode('\n'.join(entries)) # <<<<<<<<<<<<<<
3549 *
3550 *
3551 */
3552 __Pyx_XDECREF(__pyx_r);
3553 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_safe_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 133, __pyx_L1_error)
3554 __Pyx_GOTREF(__pyx_t_2);
3555 __pyx_t_1 = PyUnicode_Join(__pyx_kp_u_, __pyx_v_entries); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 133, __pyx_L1_error)
3556 __Pyx_GOTREF(__pyx_t_1);
3557 __pyx_t_10 = NULL;
3558 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
3559 __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
3560 if (likely(__pyx_t_10)) {
3561 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3562 __Pyx_INCREF(__pyx_t_10);
3563 __Pyx_INCREF(function);
3564 __Pyx_DECREF_SET(__pyx_t_2, function);
3565 }
3566 }
3567 __pyx_t_3 = (__pyx_t_10) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_10, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1);
3568 __Pyx_XDECREF(__pyx_t_10); __pyx_t_10 = 0;
3569 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3570 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 133, __pyx_L1_error)
3571 __Pyx_GOTREF(__pyx_t_3);
3572 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3573 __pyx_r = __pyx_t_3;
3574 __pyx_t_3 = 0;
3575 goto __pyx_L0;
3576
3577 /* "borg/platform/linux.pyx":121
3578 *
3579 *
3580 * def acl_use_local_uid_gid(acl): # <<<<<<<<<<<<<<
3581 * """Replace the user/group field with the local uid/gid if possible
3582 * """
3583 */
3584
3585 /* function exit code */
3586 __pyx_L1_error:;
3587 __Pyx_XDECREF(__pyx_t_1);
3588 __Pyx_XDECREF(__pyx_t_2);
3589 __Pyx_XDECREF(__pyx_t_3);
3590 __Pyx_XDECREF(__pyx_t_4);
3591 __Pyx_XDECREF(__pyx_t_9);
3592 __Pyx_XDECREF(__pyx_t_10);
3593 __Pyx_XDECREF(__pyx_t_12);
3594 __Pyx_AddTraceback("borg.platform.linux.acl_use_local_uid_gid", __pyx_clineno, __pyx_lineno, __pyx_filename);
3595 __pyx_r = NULL;
3596 __pyx_L0:;
3597 __Pyx_XDECREF(__pyx_v_entries);
3598 __Pyx_XDECREF(__pyx_v_entry);
3599 __Pyx_XDECREF(__pyx_v_fields);
3600 __Pyx_XGIVEREF(__pyx_r);
3601 __Pyx_RefNannyFinishContext();
3602 return __pyx_r;
3603 }
3604
3605 /* "borg/platform/linux.pyx":136
3606 *
3607 *
3608 * cdef acl_append_numeric_ids(acl): # <<<<<<<<<<<<<<
3609 * """Extend the "POSIX 1003.1e draft standard 17" format with an additional uid/gid field
3610 * """
3611 */
3612
__pyx_f_4borg_8platform_5linux_acl_append_numeric_ids(PyObject * __pyx_v_acl)3613 static PyObject *__pyx_f_4borg_8platform_5linux_acl_append_numeric_ids(PyObject *__pyx_v_acl) {
3614 PyObject *__pyx_v_entries = NULL;
3615 PyObject *__pyx_v_entry = NULL;
3616 PyObject *__pyx_v_type = NULL;
3617 PyObject *__pyx_v_name = NULL;
3618 PyObject *__pyx_v_permission = NULL;
3619 PyObject *__pyx_r = NULL;
3620 __Pyx_RefNannyDeclarations
3621 PyObject *__pyx_t_1 = NULL;
3622 PyObject *__pyx_t_2 = NULL;
3623 PyObject *__pyx_t_3 = NULL;
3624 PyObject *__pyx_t_4 = NULL;
3625 PyObject *__pyx_t_5 = NULL;
3626 PyObject *__pyx_t_6 = NULL;
3627 int __pyx_t_7;
3628 Py_ssize_t __pyx_t_8;
3629 PyObject *(*__pyx_t_9)(PyObject *);
3630 int __pyx_t_10;
3631 PyObject *(*__pyx_t_11)(PyObject *);
3632 int __pyx_t_12;
3633 int __pyx_t_13;
3634 int __pyx_lineno = 0;
3635 const char *__pyx_filename = NULL;
3636 int __pyx_clineno = 0;
3637 __Pyx_RefNannySetupContext("acl_append_numeric_ids", 0);
3638
3639 /* "borg/platform/linux.pyx":139
3640 * """Extend the "POSIX 1003.1e draft standard 17" format with an additional uid/gid field
3641 * """
3642 * entries = [] # <<<<<<<<<<<<<<
3643 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'):
3644 * if entry:
3645 */
3646 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 139, __pyx_L1_error)
3647 __Pyx_GOTREF(__pyx_t_1);
3648 __pyx_v_entries = ((PyObject*)__pyx_t_1);
3649 __pyx_t_1 = 0;
3650
3651 /* "borg/platform/linux.pyx":140
3652 * """
3653 * entries = []
3654 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'): # <<<<<<<<<<<<<<
3655 * if entry:
3656 * type, name, permission = entry.split(':')
3657 */
3658 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_comment_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
3659 __Pyx_GOTREF(__pyx_t_3);
3660 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sub); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
3661 __Pyx_GOTREF(__pyx_t_4);
3662 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3663 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_safe_decode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 140, __pyx_L1_error)
3664 __Pyx_GOTREF(__pyx_t_5);
3665 __pyx_t_6 = NULL;
3666 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
3667 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
3668 if (likely(__pyx_t_6)) {
3669 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
3670 __Pyx_INCREF(__pyx_t_6);
3671 __Pyx_INCREF(function);
3672 __Pyx_DECREF_SET(__pyx_t_5, function);
3673 }
3674 }
3675 __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_acl) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_acl);
3676 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3677 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 140, __pyx_L1_error)
3678 __Pyx_GOTREF(__pyx_t_3);
3679 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3680 __pyx_t_5 = NULL;
3681 __pyx_t_7 = 0;
3682 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
3683 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
3684 if (likely(__pyx_t_5)) {
3685 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3686 __Pyx_INCREF(__pyx_t_5);
3687 __Pyx_INCREF(function);
3688 __Pyx_DECREF_SET(__pyx_t_4, function);
3689 __pyx_t_7 = 1;
3690 }
3691 }
3692 #if CYTHON_FAST_PYCALL
3693 if (PyFunction_Check(__pyx_t_4)) {
3694 PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_u__4, __pyx_t_3};
3695 __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
3696 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3697 __Pyx_GOTREF(__pyx_t_2);
3698 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3699 } else
3700 #endif
3701 #if CYTHON_FAST_PYCCALL
3702 if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
3703 PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_u__4, __pyx_t_3};
3704 __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
3705 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
3706 __Pyx_GOTREF(__pyx_t_2);
3707 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3708 } else
3709 #endif
3710 {
3711 __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 140, __pyx_L1_error)
3712 __Pyx_GOTREF(__pyx_t_6);
3713 if (__pyx_t_5) {
3714 __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
3715 }
3716 __Pyx_INCREF(__pyx_kp_u__4);
3717 __Pyx_GIVEREF(__pyx_kp_u__4);
3718 PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_u__4);
3719 __Pyx_GIVEREF(__pyx_t_3);
3720 PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_3);
3721 __pyx_t_3 = 0;
3722 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 140, __pyx_L1_error)
3723 __Pyx_GOTREF(__pyx_t_2);
3724 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
3725 }
3726 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3727 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
3728 __Pyx_GOTREF(__pyx_t_4);
3729 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3730 __pyx_t_2 = NULL;
3731 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
3732 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
3733 if (likely(__pyx_t_2)) {
3734 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
3735 __Pyx_INCREF(__pyx_t_2);
3736 __Pyx_INCREF(function);
3737 __Pyx_DECREF_SET(__pyx_t_4, function);
3738 }
3739 }
3740 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_kp_u_) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_);
3741 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
3742 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
3743 __Pyx_GOTREF(__pyx_t_1);
3744 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
3745 if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
3746 __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
3747 __pyx_t_9 = NULL;
3748 } else {
3749 __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 140, __pyx_L1_error)
3750 __Pyx_GOTREF(__pyx_t_4);
3751 __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 140, __pyx_L1_error)
3752 }
3753 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3754 for (;;) {
3755 if (likely(!__pyx_t_9)) {
3756 if (likely(PyList_CheckExact(__pyx_t_4))) {
3757 if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
3758 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3759 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 140, __pyx_L1_error)
3760 #else
3761 __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
3762 __Pyx_GOTREF(__pyx_t_1);
3763 #endif
3764 } else {
3765 if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
3766 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3767 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 140, __pyx_L1_error)
3768 #else
3769 __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 140, __pyx_L1_error)
3770 __Pyx_GOTREF(__pyx_t_1);
3771 #endif
3772 }
3773 } else {
3774 __pyx_t_1 = __pyx_t_9(__pyx_t_4);
3775 if (unlikely(!__pyx_t_1)) {
3776 PyObject* exc_type = PyErr_Occurred();
3777 if (exc_type) {
3778 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
3779 else __PYX_ERR(0, 140, __pyx_L1_error)
3780 }
3781 break;
3782 }
3783 __Pyx_GOTREF(__pyx_t_1);
3784 }
3785 __Pyx_XDECREF_SET(__pyx_v_entry, __pyx_t_1);
3786 __pyx_t_1 = 0;
3787
3788 /* "borg/platform/linux.pyx":141
3789 * entries = []
3790 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'):
3791 * if entry: # <<<<<<<<<<<<<<
3792 * type, name, permission = entry.split(':')
3793 * if name and type == 'user':
3794 */
3795 __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_entry); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 141, __pyx_L1_error)
3796 if (__pyx_t_10) {
3797
3798 /* "borg/platform/linux.pyx":142
3799 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'):
3800 * if entry:
3801 * type, name, permission = entry.split(':') # <<<<<<<<<<<<<<
3802 * if name and type == 'user':
3803 * entries.append(':'.join([type, name, permission, str(user2uid(name, name))]))
3804 */
3805 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entry, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
3806 __Pyx_GOTREF(__pyx_t_2);
3807 __pyx_t_6 = NULL;
3808 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
3809 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
3810 if (likely(__pyx_t_6)) {
3811 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
3812 __Pyx_INCREF(__pyx_t_6);
3813 __Pyx_INCREF(function);
3814 __Pyx_DECREF_SET(__pyx_t_2, function);
3815 }
3816 }
3817 __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_kp_u__2) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u__2);
3818 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3819 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 142, __pyx_L1_error)
3820 __Pyx_GOTREF(__pyx_t_1);
3821 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3822 if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
3823 PyObject* sequence = __pyx_t_1;
3824 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
3825 if (unlikely(size != 3)) {
3826 if (size > 3) __Pyx_RaiseTooManyValuesError(3);
3827 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
3828 __PYX_ERR(0, 142, __pyx_L1_error)
3829 }
3830 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
3831 if (likely(PyTuple_CheckExact(sequence))) {
3832 __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
3833 __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
3834 __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2);
3835 } else {
3836 __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
3837 __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
3838 __pyx_t_3 = PyList_GET_ITEM(sequence, 2);
3839 }
3840 __Pyx_INCREF(__pyx_t_2);
3841 __Pyx_INCREF(__pyx_t_6);
3842 __Pyx_INCREF(__pyx_t_3);
3843 #else
3844 __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 142, __pyx_L1_error)
3845 __Pyx_GOTREF(__pyx_t_2);
3846 __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 142, __pyx_L1_error)
3847 __Pyx_GOTREF(__pyx_t_6);
3848 __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 142, __pyx_L1_error)
3849 __Pyx_GOTREF(__pyx_t_3);
3850 #endif
3851 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3852 } else {
3853 Py_ssize_t index = -1;
3854 __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 142, __pyx_L1_error)
3855 __Pyx_GOTREF(__pyx_t_5);
3856 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3857 __pyx_t_11 = Py_TYPE(__pyx_t_5)->tp_iternext;
3858 index = 0; __pyx_t_2 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L6_unpacking_failed;
3859 __Pyx_GOTREF(__pyx_t_2);
3860 index = 1; __pyx_t_6 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
3861 __Pyx_GOTREF(__pyx_t_6);
3862 index = 2; __pyx_t_3 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
3863 __Pyx_GOTREF(__pyx_t_3);
3864 if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_5), 3) < 0) __PYX_ERR(0, 142, __pyx_L1_error)
3865 __pyx_t_11 = NULL;
3866 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3867 goto __pyx_L7_unpacking_done;
3868 __pyx_L6_unpacking_failed:;
3869 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
3870 __pyx_t_11 = NULL;
3871 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
3872 __PYX_ERR(0, 142, __pyx_L1_error)
3873 __pyx_L7_unpacking_done:;
3874 }
3875 __Pyx_XDECREF_SET(__pyx_v_type, __pyx_t_2);
3876 __pyx_t_2 = 0;
3877 __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_6);
3878 __pyx_t_6 = 0;
3879 __Pyx_XDECREF_SET(__pyx_v_permission, __pyx_t_3);
3880 __pyx_t_3 = 0;
3881
3882 /* "borg/platform/linux.pyx":143
3883 * if entry:
3884 * type, name, permission = entry.split(':')
3885 * if name and type == 'user': # <<<<<<<<<<<<<<
3886 * entries.append(':'.join([type, name, permission, str(user2uid(name, name))]))
3887 * elif name and type == 'group':
3888 */
3889 __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 143, __pyx_L1_error)
3890 if (__pyx_t_12) {
3891 } else {
3892 __pyx_t_10 = __pyx_t_12;
3893 goto __pyx_L9_bool_binop_done;
3894 }
3895 __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_v_type, __pyx_n_u_user, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 143, __pyx_L1_error)
3896 __pyx_t_10 = __pyx_t_12;
3897 __pyx_L9_bool_binop_done:;
3898 if (__pyx_t_10) {
3899
3900 /* "borg/platform/linux.pyx":144
3901 * type, name, permission = entry.split(':')
3902 * if name and type == 'user':
3903 * entries.append(':'.join([type, name, permission, str(user2uid(name, name))])) # <<<<<<<<<<<<<<
3904 * elif name and type == 'group':
3905 * entries.append(':'.join([type, name, permission, str(group2gid(name, name))]))
3906 */
3907 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_user2uid); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
3908 __Pyx_GOTREF(__pyx_t_3);
3909 __pyx_t_6 = NULL;
3910 __pyx_t_7 = 0;
3911 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
3912 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
3913 if (likely(__pyx_t_6)) {
3914 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
3915 __Pyx_INCREF(__pyx_t_6);
3916 __Pyx_INCREF(function);
3917 __Pyx_DECREF_SET(__pyx_t_3, function);
3918 __pyx_t_7 = 1;
3919 }
3920 }
3921 #if CYTHON_FAST_PYCALL
3922 if (PyFunction_Check(__pyx_t_3)) {
3923 PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_name, __pyx_v_name};
3924 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
3925 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3926 __Pyx_GOTREF(__pyx_t_1);
3927 } else
3928 #endif
3929 #if CYTHON_FAST_PYCCALL
3930 if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
3931 PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_name, __pyx_v_name};
3932 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
3933 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
3934 __Pyx_GOTREF(__pyx_t_1);
3935 } else
3936 #endif
3937 {
3938 __pyx_t_2 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 144, __pyx_L1_error)
3939 __Pyx_GOTREF(__pyx_t_2);
3940 if (__pyx_t_6) {
3941 __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
3942 }
3943 __Pyx_INCREF(__pyx_v_name);
3944 __Pyx_GIVEREF(__pyx_v_name);
3945 PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_name);
3946 __Pyx_INCREF(__pyx_v_name);
3947 __Pyx_GIVEREF(__pyx_v_name);
3948 PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, __pyx_v_name);
3949 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
3950 __Pyx_GOTREF(__pyx_t_1);
3951 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
3952 }
3953 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3954 __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
3955 __Pyx_GOTREF(__pyx_t_3);
3956 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3957 __pyx_t_1 = PyList_New(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 144, __pyx_L1_error)
3958 __Pyx_GOTREF(__pyx_t_1);
3959 __Pyx_INCREF(__pyx_v_type);
3960 __Pyx_GIVEREF(__pyx_v_type);
3961 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_v_type);
3962 __Pyx_INCREF(__pyx_v_name);
3963 __Pyx_GIVEREF(__pyx_v_name);
3964 PyList_SET_ITEM(__pyx_t_1, 1, __pyx_v_name);
3965 __Pyx_INCREF(__pyx_v_permission);
3966 __Pyx_GIVEREF(__pyx_v_permission);
3967 PyList_SET_ITEM(__pyx_t_1, 2, __pyx_v_permission);
3968 __Pyx_GIVEREF(__pyx_t_3);
3969 PyList_SET_ITEM(__pyx_t_1, 3, __pyx_t_3);
3970 __pyx_t_3 = 0;
3971 __pyx_t_3 = PyUnicode_Join(__pyx_kp_u__2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 144, __pyx_L1_error)
3972 __Pyx_GOTREF(__pyx_t_3);
3973 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
3974 __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_entries, __pyx_t_3); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 144, __pyx_L1_error)
3975 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
3976
3977 /* "borg/platform/linux.pyx":143
3978 * if entry:
3979 * type, name, permission = entry.split(':')
3980 * if name and type == 'user': # <<<<<<<<<<<<<<
3981 * entries.append(':'.join([type, name, permission, str(user2uid(name, name))]))
3982 * elif name and type == 'group':
3983 */
3984 goto __pyx_L8;
3985 }
3986
3987 /* "borg/platform/linux.pyx":145
3988 * if name and type == 'user':
3989 * entries.append(':'.join([type, name, permission, str(user2uid(name, name))]))
3990 * elif name and type == 'group': # <<<<<<<<<<<<<<
3991 * entries.append(':'.join([type, name, permission, str(group2gid(name, name))]))
3992 * else:
3993 */
3994 __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 145, __pyx_L1_error)
3995 if (__pyx_t_12) {
3996 } else {
3997 __pyx_t_10 = __pyx_t_12;
3998 goto __pyx_L11_bool_binop_done;
3999 }
4000 __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_v_type, __pyx_n_u_group, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 145, __pyx_L1_error)
4001 __pyx_t_10 = __pyx_t_12;
4002 __pyx_L11_bool_binop_done:;
4003 if (__pyx_t_10) {
4004
4005 /* "borg/platform/linux.pyx":146
4006 * entries.append(':'.join([type, name, permission, str(user2uid(name, name))]))
4007 * elif name and type == 'group':
4008 * entries.append(':'.join([type, name, permission, str(group2gid(name, name))])) # <<<<<<<<<<<<<<
4009 * else:
4010 * entries.append(entry)
4011 */
4012 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_group2gid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
4013 __Pyx_GOTREF(__pyx_t_1);
4014 __pyx_t_2 = NULL;
4015 __pyx_t_7 = 0;
4016 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
4017 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_1);
4018 if (likely(__pyx_t_2)) {
4019 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
4020 __Pyx_INCREF(__pyx_t_2);
4021 __Pyx_INCREF(function);
4022 __Pyx_DECREF_SET(__pyx_t_1, function);
4023 __pyx_t_7 = 1;
4024 }
4025 }
4026 #if CYTHON_FAST_PYCALL
4027 if (PyFunction_Check(__pyx_t_1)) {
4028 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_name, __pyx_v_name};
4029 __pyx_t_3 = __Pyx_PyFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error)
4030 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4031 __Pyx_GOTREF(__pyx_t_3);
4032 } else
4033 #endif
4034 #if CYTHON_FAST_PYCCALL
4035 if (__Pyx_PyFastCFunction_Check(__pyx_t_1)) {
4036 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_name, __pyx_v_name};
4037 __pyx_t_3 = __Pyx_PyCFunction_FastCall(__pyx_t_1, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error)
4038 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4039 __Pyx_GOTREF(__pyx_t_3);
4040 } else
4041 #endif
4042 {
4043 __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 146, __pyx_L1_error)
4044 __Pyx_GOTREF(__pyx_t_6);
4045 if (__pyx_t_2) {
4046 __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
4047 }
4048 __Pyx_INCREF(__pyx_v_name);
4049 __Pyx_GIVEREF(__pyx_v_name);
4050 PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_v_name);
4051 __Pyx_INCREF(__pyx_v_name);
4052 __Pyx_GIVEREF(__pyx_v_name);
4053 PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_name);
4054 __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error)
4055 __Pyx_GOTREF(__pyx_t_3);
4056 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4057 }
4058 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4059 __pyx_t_1 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
4060 __Pyx_GOTREF(__pyx_t_1);
4061 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4062 __pyx_t_3 = PyList_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 146, __pyx_L1_error)
4063 __Pyx_GOTREF(__pyx_t_3);
4064 __Pyx_INCREF(__pyx_v_type);
4065 __Pyx_GIVEREF(__pyx_v_type);
4066 PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_type);
4067 __Pyx_INCREF(__pyx_v_name);
4068 __Pyx_GIVEREF(__pyx_v_name);
4069 PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_name);
4070 __Pyx_INCREF(__pyx_v_permission);
4071 __Pyx_GIVEREF(__pyx_v_permission);
4072 PyList_SET_ITEM(__pyx_t_3, 2, __pyx_v_permission);
4073 __Pyx_GIVEREF(__pyx_t_1);
4074 PyList_SET_ITEM(__pyx_t_3, 3, __pyx_t_1);
4075 __pyx_t_1 = 0;
4076 __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 146, __pyx_L1_error)
4077 __Pyx_GOTREF(__pyx_t_1);
4078 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4079 __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_entries, __pyx_t_1); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 146, __pyx_L1_error)
4080 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4081
4082 /* "borg/platform/linux.pyx":145
4083 * if name and type == 'user':
4084 * entries.append(':'.join([type, name, permission, str(user2uid(name, name))]))
4085 * elif name and type == 'group': # <<<<<<<<<<<<<<
4086 * entries.append(':'.join([type, name, permission, str(group2gid(name, name))]))
4087 * else:
4088 */
4089 goto __pyx_L8;
4090 }
4091
4092 /* "borg/platform/linux.pyx":148
4093 * entries.append(':'.join([type, name, permission, str(group2gid(name, name))]))
4094 * else:
4095 * entries.append(entry) # <<<<<<<<<<<<<<
4096 * return safe_encode('\n'.join(entries))
4097 *
4098 */
4099 /*else*/ {
4100 __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_entries, __pyx_v_entry); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 148, __pyx_L1_error)
4101 }
4102 __pyx_L8:;
4103
4104 /* "borg/platform/linux.pyx":141
4105 * entries = []
4106 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'):
4107 * if entry: # <<<<<<<<<<<<<<
4108 * type, name, permission = entry.split(':')
4109 * if name and type == 'user':
4110 */
4111 }
4112
4113 /* "borg/platform/linux.pyx":140
4114 * """
4115 * entries = []
4116 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'): # <<<<<<<<<<<<<<
4117 * if entry:
4118 * type, name, permission = entry.split(':')
4119 */
4120 }
4121 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4122
4123 /* "borg/platform/linux.pyx":149
4124 * else:
4125 * entries.append(entry)
4126 * return safe_encode('\n'.join(entries)) # <<<<<<<<<<<<<<
4127 *
4128 *
4129 */
4130 __Pyx_XDECREF(__pyx_r);
4131 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_safe_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 149, __pyx_L1_error)
4132 __Pyx_GOTREF(__pyx_t_1);
4133 __pyx_t_3 = PyUnicode_Join(__pyx_kp_u_, __pyx_v_entries); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 149, __pyx_L1_error)
4134 __Pyx_GOTREF(__pyx_t_3);
4135 __pyx_t_6 = NULL;
4136 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
4137 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
4138 if (likely(__pyx_t_6)) {
4139 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
4140 __Pyx_INCREF(__pyx_t_6);
4141 __Pyx_INCREF(function);
4142 __Pyx_DECREF_SET(__pyx_t_1, function);
4143 }
4144 }
4145 __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
4146 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
4147 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4148 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 149, __pyx_L1_error)
4149 __Pyx_GOTREF(__pyx_t_4);
4150 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4151 __pyx_r = __pyx_t_4;
4152 __pyx_t_4 = 0;
4153 goto __pyx_L0;
4154
4155 /* "borg/platform/linux.pyx":136
4156 *
4157 *
4158 * cdef acl_append_numeric_ids(acl): # <<<<<<<<<<<<<<
4159 * """Extend the "POSIX 1003.1e draft standard 17" format with an additional uid/gid field
4160 * """
4161 */
4162
4163 /* function exit code */
4164 __pyx_L1_error:;
4165 __Pyx_XDECREF(__pyx_t_1);
4166 __Pyx_XDECREF(__pyx_t_2);
4167 __Pyx_XDECREF(__pyx_t_3);
4168 __Pyx_XDECREF(__pyx_t_4);
4169 __Pyx_XDECREF(__pyx_t_5);
4170 __Pyx_XDECREF(__pyx_t_6);
4171 __Pyx_AddTraceback("borg.platform.linux.acl_append_numeric_ids", __pyx_clineno, __pyx_lineno, __pyx_filename);
4172 __pyx_r = 0;
4173 __pyx_L0:;
4174 __Pyx_XDECREF(__pyx_v_entries);
4175 __Pyx_XDECREF(__pyx_v_entry);
4176 __Pyx_XDECREF(__pyx_v_type);
4177 __Pyx_XDECREF(__pyx_v_name);
4178 __Pyx_XDECREF(__pyx_v_permission);
4179 __Pyx_XGIVEREF(__pyx_r);
4180 __Pyx_RefNannyFinishContext();
4181 return __pyx_r;
4182 }
4183
4184 /* "borg/platform/linux.pyx":152
4185 *
4186 *
4187 * cdef acl_numeric_ids(acl): # <<<<<<<<<<<<<<
4188 * """Replace the "POSIX 1003.1e draft standard 17" user/group field with uid/gid
4189 * """
4190 */
4191
__pyx_f_4borg_8platform_5linux_acl_numeric_ids(PyObject * __pyx_v_acl)4192 static PyObject *__pyx_f_4borg_8platform_5linux_acl_numeric_ids(PyObject *__pyx_v_acl) {
4193 PyObject *__pyx_v_entries = NULL;
4194 PyObject *__pyx_v_entry = NULL;
4195 PyObject *__pyx_v_type = NULL;
4196 PyObject *__pyx_v_name = NULL;
4197 PyObject *__pyx_v_permission = NULL;
4198 PyObject *__pyx_v_uid = NULL;
4199 PyObject *__pyx_v_gid = NULL;
4200 PyObject *__pyx_r = NULL;
4201 __Pyx_RefNannyDeclarations
4202 PyObject *__pyx_t_1 = NULL;
4203 PyObject *__pyx_t_2 = NULL;
4204 PyObject *__pyx_t_3 = NULL;
4205 PyObject *__pyx_t_4 = NULL;
4206 PyObject *__pyx_t_5 = NULL;
4207 PyObject *__pyx_t_6 = NULL;
4208 int __pyx_t_7;
4209 Py_ssize_t __pyx_t_8;
4210 PyObject *(*__pyx_t_9)(PyObject *);
4211 int __pyx_t_10;
4212 PyObject *(*__pyx_t_11)(PyObject *);
4213 int __pyx_t_12;
4214 int __pyx_t_13;
4215 int __pyx_lineno = 0;
4216 const char *__pyx_filename = NULL;
4217 int __pyx_clineno = 0;
4218 __Pyx_RefNannySetupContext("acl_numeric_ids", 0);
4219
4220 /* "borg/platform/linux.pyx":155
4221 * """Replace the "POSIX 1003.1e draft standard 17" user/group field with uid/gid
4222 * """
4223 * entries = [] # <<<<<<<<<<<<<<
4224 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'):
4225 * if entry:
4226 */
4227 __pyx_t_1 = PyList_New(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 155, __pyx_L1_error)
4228 __Pyx_GOTREF(__pyx_t_1);
4229 __pyx_v_entries = ((PyObject*)__pyx_t_1);
4230 __pyx_t_1 = 0;
4231
4232 /* "borg/platform/linux.pyx":156
4233 * """
4234 * entries = []
4235 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'): # <<<<<<<<<<<<<<
4236 * if entry:
4237 * type, name, permission = entry.split(':')
4238 */
4239 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_comment_re); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error)
4240 __Pyx_GOTREF(__pyx_t_3);
4241 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_sub); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
4242 __Pyx_GOTREF(__pyx_t_4);
4243 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4244 __Pyx_GetModuleGlobalName(__pyx_t_5, __pyx_n_s_safe_decode); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 156, __pyx_L1_error)
4245 __Pyx_GOTREF(__pyx_t_5);
4246 __pyx_t_6 = NULL;
4247 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_5))) {
4248 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
4249 if (likely(__pyx_t_6)) {
4250 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
4251 __Pyx_INCREF(__pyx_t_6);
4252 __Pyx_INCREF(function);
4253 __Pyx_DECREF_SET(__pyx_t_5, function);
4254 }
4255 }
4256 __pyx_t_3 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_5, __pyx_t_6, __pyx_v_acl) : __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_acl);
4257 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
4258 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 156, __pyx_L1_error)
4259 __Pyx_GOTREF(__pyx_t_3);
4260 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4261 __pyx_t_5 = NULL;
4262 __pyx_t_7 = 0;
4263 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
4264 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
4265 if (likely(__pyx_t_5)) {
4266 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4267 __Pyx_INCREF(__pyx_t_5);
4268 __Pyx_INCREF(function);
4269 __Pyx_DECREF_SET(__pyx_t_4, function);
4270 __pyx_t_7 = 1;
4271 }
4272 }
4273 #if CYTHON_FAST_PYCALL
4274 if (PyFunction_Check(__pyx_t_4)) {
4275 PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_u__4, __pyx_t_3};
4276 __pyx_t_2 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
4277 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
4278 __Pyx_GOTREF(__pyx_t_2);
4279 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4280 } else
4281 #endif
4282 #if CYTHON_FAST_PYCCALL
4283 if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
4284 PyObject *__pyx_temp[3] = {__pyx_t_5, __pyx_kp_u__4, __pyx_t_3};
4285 __pyx_t_2 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
4286 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
4287 __Pyx_GOTREF(__pyx_t_2);
4288 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4289 } else
4290 #endif
4291 {
4292 __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 156, __pyx_L1_error)
4293 __Pyx_GOTREF(__pyx_t_6);
4294 if (__pyx_t_5) {
4295 __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
4296 }
4297 __Pyx_INCREF(__pyx_kp_u__4);
4298 __Pyx_GIVEREF(__pyx_kp_u__4);
4299 PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_kp_u__4);
4300 __Pyx_GIVEREF(__pyx_t_3);
4301 PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_t_3);
4302 __pyx_t_3 = 0;
4303 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 156, __pyx_L1_error)
4304 __Pyx_GOTREF(__pyx_t_2);
4305 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4306 }
4307 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4308 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_split); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
4309 __Pyx_GOTREF(__pyx_t_4);
4310 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4311 __pyx_t_2 = NULL;
4312 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
4313 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
4314 if (likely(__pyx_t_2)) {
4315 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
4316 __Pyx_INCREF(__pyx_t_2);
4317 __Pyx_INCREF(function);
4318 __Pyx_DECREF_SET(__pyx_t_4, function);
4319 }
4320 }
4321 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_2, __pyx_kp_u_) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_kp_u_);
4322 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4323 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
4324 __Pyx_GOTREF(__pyx_t_1);
4325 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4326 if (likely(PyList_CheckExact(__pyx_t_1)) || PyTuple_CheckExact(__pyx_t_1)) {
4327 __pyx_t_4 = __pyx_t_1; __Pyx_INCREF(__pyx_t_4); __pyx_t_8 = 0;
4328 __pyx_t_9 = NULL;
4329 } else {
4330 __pyx_t_8 = -1; __pyx_t_4 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 156, __pyx_L1_error)
4331 __Pyx_GOTREF(__pyx_t_4);
4332 __pyx_t_9 = Py_TYPE(__pyx_t_4)->tp_iternext; if (unlikely(!__pyx_t_9)) __PYX_ERR(0, 156, __pyx_L1_error)
4333 }
4334 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4335 for (;;) {
4336 if (likely(!__pyx_t_9)) {
4337 if (likely(PyList_CheckExact(__pyx_t_4))) {
4338 if (__pyx_t_8 >= PyList_GET_SIZE(__pyx_t_4)) break;
4339 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4340 __pyx_t_1 = PyList_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 156, __pyx_L1_error)
4341 #else
4342 __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
4343 __Pyx_GOTREF(__pyx_t_1);
4344 #endif
4345 } else {
4346 if (__pyx_t_8 >= PyTuple_GET_SIZE(__pyx_t_4)) break;
4347 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4348 __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_4, __pyx_t_8); __Pyx_INCREF(__pyx_t_1); __pyx_t_8++; if (unlikely(0 < 0)) __PYX_ERR(0, 156, __pyx_L1_error)
4349 #else
4350 __pyx_t_1 = PySequence_ITEM(__pyx_t_4, __pyx_t_8); __pyx_t_8++; if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 156, __pyx_L1_error)
4351 __Pyx_GOTREF(__pyx_t_1);
4352 #endif
4353 }
4354 } else {
4355 __pyx_t_1 = __pyx_t_9(__pyx_t_4);
4356 if (unlikely(!__pyx_t_1)) {
4357 PyObject* exc_type = PyErr_Occurred();
4358 if (exc_type) {
4359 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
4360 else __PYX_ERR(0, 156, __pyx_L1_error)
4361 }
4362 break;
4363 }
4364 __Pyx_GOTREF(__pyx_t_1);
4365 }
4366 __Pyx_XDECREF_SET(__pyx_v_entry, __pyx_t_1);
4367 __pyx_t_1 = 0;
4368
4369 /* "borg/platform/linux.pyx":157
4370 * entries = []
4371 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'):
4372 * if entry: # <<<<<<<<<<<<<<
4373 * type, name, permission = entry.split(':')
4374 * if name and type == 'user':
4375 */
4376 __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_v_entry); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 157, __pyx_L1_error)
4377 if (__pyx_t_10) {
4378
4379 /* "borg/platform/linux.pyx":158
4380 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'):
4381 * if entry:
4382 * type, name, permission = entry.split(':') # <<<<<<<<<<<<<<
4383 * if name and type == 'user':
4384 * uid = str(user2uid(name, name))
4385 */
4386 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_entry, __pyx_n_s_split); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error)
4387 __Pyx_GOTREF(__pyx_t_2);
4388 __pyx_t_6 = NULL;
4389 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_2))) {
4390 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_2);
4391 if (likely(__pyx_t_6)) {
4392 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
4393 __Pyx_INCREF(__pyx_t_6);
4394 __Pyx_INCREF(function);
4395 __Pyx_DECREF_SET(__pyx_t_2, function);
4396 }
4397 }
4398 __pyx_t_1 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_6, __pyx_kp_u__2) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_kp_u__2);
4399 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
4400 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 158, __pyx_L1_error)
4401 __Pyx_GOTREF(__pyx_t_1);
4402 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4403 if ((likely(PyTuple_CheckExact(__pyx_t_1))) || (PyList_CheckExact(__pyx_t_1))) {
4404 PyObject* sequence = __pyx_t_1;
4405 Py_ssize_t size = __Pyx_PySequence_SIZE(sequence);
4406 if (unlikely(size != 3)) {
4407 if (size > 3) __Pyx_RaiseTooManyValuesError(3);
4408 else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
4409 __PYX_ERR(0, 158, __pyx_L1_error)
4410 }
4411 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
4412 if (likely(PyTuple_CheckExact(sequence))) {
4413 __pyx_t_2 = PyTuple_GET_ITEM(sequence, 0);
4414 __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1);
4415 __pyx_t_3 = PyTuple_GET_ITEM(sequence, 2);
4416 } else {
4417 __pyx_t_2 = PyList_GET_ITEM(sequence, 0);
4418 __pyx_t_6 = PyList_GET_ITEM(sequence, 1);
4419 __pyx_t_3 = PyList_GET_ITEM(sequence, 2);
4420 }
4421 __Pyx_INCREF(__pyx_t_2);
4422 __Pyx_INCREF(__pyx_t_6);
4423 __Pyx_INCREF(__pyx_t_3);
4424 #else
4425 __pyx_t_2 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 158, __pyx_L1_error)
4426 __Pyx_GOTREF(__pyx_t_2);
4427 __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 158, __pyx_L1_error)
4428 __Pyx_GOTREF(__pyx_t_6);
4429 __pyx_t_3 = PySequence_ITEM(sequence, 2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 158, __pyx_L1_error)
4430 __Pyx_GOTREF(__pyx_t_3);
4431 #endif
4432 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4433 } else {
4434 Py_ssize_t index = -1;
4435 __pyx_t_5 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 158, __pyx_L1_error)
4436 __Pyx_GOTREF(__pyx_t_5);
4437 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4438 __pyx_t_11 = Py_TYPE(__pyx_t_5)->tp_iternext;
4439 index = 0; __pyx_t_2 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_2)) goto __pyx_L6_unpacking_failed;
4440 __Pyx_GOTREF(__pyx_t_2);
4441 index = 1; __pyx_t_6 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_6)) goto __pyx_L6_unpacking_failed;
4442 __Pyx_GOTREF(__pyx_t_6);
4443 index = 2; __pyx_t_3 = __pyx_t_11(__pyx_t_5); if (unlikely(!__pyx_t_3)) goto __pyx_L6_unpacking_failed;
4444 __Pyx_GOTREF(__pyx_t_3);
4445 if (__Pyx_IternextUnpackEndCheck(__pyx_t_11(__pyx_t_5), 3) < 0) __PYX_ERR(0, 158, __pyx_L1_error)
4446 __pyx_t_11 = NULL;
4447 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4448 goto __pyx_L7_unpacking_done;
4449 __pyx_L6_unpacking_failed:;
4450 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
4451 __pyx_t_11 = NULL;
4452 if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
4453 __PYX_ERR(0, 158, __pyx_L1_error)
4454 __pyx_L7_unpacking_done:;
4455 }
4456 __Pyx_XDECREF_SET(__pyx_v_type, __pyx_t_2);
4457 __pyx_t_2 = 0;
4458 __Pyx_XDECREF_SET(__pyx_v_name, __pyx_t_6);
4459 __pyx_t_6 = 0;
4460 __Pyx_XDECREF_SET(__pyx_v_permission, __pyx_t_3);
4461 __pyx_t_3 = 0;
4462
4463 /* "borg/platform/linux.pyx":159
4464 * if entry:
4465 * type, name, permission = entry.split(':')
4466 * if name and type == 'user': # <<<<<<<<<<<<<<
4467 * uid = str(user2uid(name, name))
4468 * entries.append(':'.join([type, uid, permission, uid]))
4469 */
4470 __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 159, __pyx_L1_error)
4471 if (__pyx_t_12) {
4472 } else {
4473 __pyx_t_10 = __pyx_t_12;
4474 goto __pyx_L9_bool_binop_done;
4475 }
4476 __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_v_type, __pyx_n_u_user, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 159, __pyx_L1_error)
4477 __pyx_t_10 = __pyx_t_12;
4478 __pyx_L9_bool_binop_done:;
4479 if (__pyx_t_10) {
4480
4481 /* "borg/platform/linux.pyx":160
4482 * type, name, permission = entry.split(':')
4483 * if name and type == 'user':
4484 * uid = str(user2uid(name, name)) # <<<<<<<<<<<<<<
4485 * entries.append(':'.join([type, uid, permission, uid]))
4486 * elif name and type == 'group':
4487 */
4488 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_user2uid); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
4489 __Pyx_GOTREF(__pyx_t_3);
4490 __pyx_t_6 = NULL;
4491 __pyx_t_7 = 0;
4492 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
4493 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
4494 if (likely(__pyx_t_6)) {
4495 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
4496 __Pyx_INCREF(__pyx_t_6);
4497 __Pyx_INCREF(function);
4498 __Pyx_DECREF_SET(__pyx_t_3, function);
4499 __pyx_t_7 = 1;
4500 }
4501 }
4502 #if CYTHON_FAST_PYCALL
4503 if (PyFunction_Check(__pyx_t_3)) {
4504 PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_name, __pyx_v_name};
4505 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
4506 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
4507 __Pyx_GOTREF(__pyx_t_1);
4508 } else
4509 #endif
4510 #if CYTHON_FAST_PYCCALL
4511 if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
4512 PyObject *__pyx_temp[3] = {__pyx_t_6, __pyx_v_name, __pyx_v_name};
4513 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
4514 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
4515 __Pyx_GOTREF(__pyx_t_1);
4516 } else
4517 #endif
4518 {
4519 __pyx_t_2 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 160, __pyx_L1_error)
4520 __Pyx_GOTREF(__pyx_t_2);
4521 if (__pyx_t_6) {
4522 __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6); __pyx_t_6 = NULL;
4523 }
4524 __Pyx_INCREF(__pyx_v_name);
4525 __Pyx_GIVEREF(__pyx_v_name);
4526 PyTuple_SET_ITEM(__pyx_t_2, 0+__pyx_t_7, __pyx_v_name);
4527 __Pyx_INCREF(__pyx_v_name);
4528 __Pyx_GIVEREF(__pyx_v_name);
4529 PyTuple_SET_ITEM(__pyx_t_2, 1+__pyx_t_7, __pyx_v_name);
4530 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_2, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 160, __pyx_L1_error)
4531 __Pyx_GOTREF(__pyx_t_1);
4532 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4533 }
4534 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4535 __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 160, __pyx_L1_error)
4536 __Pyx_GOTREF(__pyx_t_3);
4537 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4538 __Pyx_XDECREF_SET(__pyx_v_uid, __pyx_t_3);
4539 __pyx_t_3 = 0;
4540
4541 /* "borg/platform/linux.pyx":161
4542 * if name and type == 'user':
4543 * uid = str(user2uid(name, name))
4544 * entries.append(':'.join([type, uid, permission, uid])) # <<<<<<<<<<<<<<
4545 * elif name and type == 'group':
4546 * gid = str(group2gid(name, name))
4547 */
4548 __pyx_t_3 = PyList_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 161, __pyx_L1_error)
4549 __Pyx_GOTREF(__pyx_t_3);
4550 __Pyx_INCREF(__pyx_v_type);
4551 __Pyx_GIVEREF(__pyx_v_type);
4552 PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_type);
4553 __Pyx_INCREF(__pyx_v_uid);
4554 __Pyx_GIVEREF(__pyx_v_uid);
4555 PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_uid);
4556 __Pyx_INCREF(__pyx_v_permission);
4557 __Pyx_GIVEREF(__pyx_v_permission);
4558 PyList_SET_ITEM(__pyx_t_3, 2, __pyx_v_permission);
4559 __Pyx_INCREF(__pyx_v_uid);
4560 __Pyx_GIVEREF(__pyx_v_uid);
4561 PyList_SET_ITEM(__pyx_t_3, 3, __pyx_v_uid);
4562 __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 161, __pyx_L1_error)
4563 __Pyx_GOTREF(__pyx_t_1);
4564 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4565 __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_entries, __pyx_t_1); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 161, __pyx_L1_error)
4566 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4567
4568 /* "borg/platform/linux.pyx":159
4569 * if entry:
4570 * type, name, permission = entry.split(':')
4571 * if name and type == 'user': # <<<<<<<<<<<<<<
4572 * uid = str(user2uid(name, name))
4573 * entries.append(':'.join([type, uid, permission, uid]))
4574 */
4575 goto __pyx_L8;
4576 }
4577
4578 /* "borg/platform/linux.pyx":162
4579 * uid = str(user2uid(name, name))
4580 * entries.append(':'.join([type, uid, permission, uid]))
4581 * elif name and type == 'group': # <<<<<<<<<<<<<<
4582 * gid = str(group2gid(name, name))
4583 * entries.append(':'.join([type, gid, permission, gid]))
4584 */
4585 __pyx_t_12 = __Pyx_PyObject_IsTrue(__pyx_v_name); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 162, __pyx_L1_error)
4586 if (__pyx_t_12) {
4587 } else {
4588 __pyx_t_10 = __pyx_t_12;
4589 goto __pyx_L11_bool_binop_done;
4590 }
4591 __pyx_t_12 = (__Pyx_PyUnicode_Equals(__pyx_v_type, __pyx_n_u_group, Py_EQ)); if (unlikely(__pyx_t_12 < 0)) __PYX_ERR(0, 162, __pyx_L1_error)
4592 __pyx_t_10 = __pyx_t_12;
4593 __pyx_L11_bool_binop_done:;
4594 if (__pyx_t_10) {
4595
4596 /* "borg/platform/linux.pyx":163
4597 * entries.append(':'.join([type, uid, permission, uid]))
4598 * elif name and type == 'group':
4599 * gid = str(group2gid(name, name)) # <<<<<<<<<<<<<<
4600 * entries.append(':'.join([type, gid, permission, gid]))
4601 * else:
4602 */
4603 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_group2gid); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error)
4604 __Pyx_GOTREF(__pyx_t_3);
4605 __pyx_t_2 = NULL;
4606 __pyx_t_7 = 0;
4607 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
4608 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
4609 if (likely(__pyx_t_2)) {
4610 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
4611 __Pyx_INCREF(__pyx_t_2);
4612 __Pyx_INCREF(function);
4613 __Pyx_DECREF_SET(__pyx_t_3, function);
4614 __pyx_t_7 = 1;
4615 }
4616 }
4617 #if CYTHON_FAST_PYCALL
4618 if (PyFunction_Check(__pyx_t_3)) {
4619 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_name, __pyx_v_name};
4620 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
4621 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4622 __Pyx_GOTREF(__pyx_t_1);
4623 } else
4624 #endif
4625 #if CYTHON_FAST_PYCCALL
4626 if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
4627 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_name, __pyx_v_name};
4628 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_7, 2+__pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
4629 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4630 __Pyx_GOTREF(__pyx_t_1);
4631 } else
4632 #endif
4633 {
4634 __pyx_t_6 = PyTuple_New(2+__pyx_t_7); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 163, __pyx_L1_error)
4635 __Pyx_GOTREF(__pyx_t_6);
4636 if (__pyx_t_2) {
4637 __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
4638 }
4639 __Pyx_INCREF(__pyx_v_name);
4640 __Pyx_GIVEREF(__pyx_v_name);
4641 PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_7, __pyx_v_name);
4642 __Pyx_INCREF(__pyx_v_name);
4643 __Pyx_GIVEREF(__pyx_v_name);
4644 PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_7, __pyx_v_name);
4645 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 163, __pyx_L1_error)
4646 __Pyx_GOTREF(__pyx_t_1);
4647 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
4648 }
4649 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4650 __pyx_t_3 = __Pyx_PyObject_CallOneArg(((PyObject *)(&PyUnicode_Type)), __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 163, __pyx_L1_error)
4651 __Pyx_GOTREF(__pyx_t_3);
4652 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4653 __Pyx_XDECREF_SET(__pyx_v_gid, __pyx_t_3);
4654 __pyx_t_3 = 0;
4655
4656 /* "borg/platform/linux.pyx":164
4657 * elif name and type == 'group':
4658 * gid = str(group2gid(name, name))
4659 * entries.append(':'.join([type, gid, permission, gid])) # <<<<<<<<<<<<<<
4660 * else:
4661 * entries.append(entry)
4662 */
4663 __pyx_t_3 = PyList_New(4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 164, __pyx_L1_error)
4664 __Pyx_GOTREF(__pyx_t_3);
4665 __Pyx_INCREF(__pyx_v_type);
4666 __Pyx_GIVEREF(__pyx_v_type);
4667 PyList_SET_ITEM(__pyx_t_3, 0, __pyx_v_type);
4668 __Pyx_INCREF(__pyx_v_gid);
4669 __Pyx_GIVEREF(__pyx_v_gid);
4670 PyList_SET_ITEM(__pyx_t_3, 1, __pyx_v_gid);
4671 __Pyx_INCREF(__pyx_v_permission);
4672 __Pyx_GIVEREF(__pyx_v_permission);
4673 PyList_SET_ITEM(__pyx_t_3, 2, __pyx_v_permission);
4674 __Pyx_INCREF(__pyx_v_gid);
4675 __Pyx_GIVEREF(__pyx_v_gid);
4676 PyList_SET_ITEM(__pyx_t_3, 3, __pyx_v_gid);
4677 __pyx_t_1 = PyUnicode_Join(__pyx_kp_u__2, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 164, __pyx_L1_error)
4678 __Pyx_GOTREF(__pyx_t_1);
4679 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4680 __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_entries, __pyx_t_1); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 164, __pyx_L1_error)
4681 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4682
4683 /* "borg/platform/linux.pyx":162
4684 * uid = str(user2uid(name, name))
4685 * entries.append(':'.join([type, uid, permission, uid]))
4686 * elif name and type == 'group': # <<<<<<<<<<<<<<
4687 * gid = str(group2gid(name, name))
4688 * entries.append(':'.join([type, gid, permission, gid]))
4689 */
4690 goto __pyx_L8;
4691 }
4692
4693 /* "borg/platform/linux.pyx":166
4694 * entries.append(':'.join([type, gid, permission, gid]))
4695 * else:
4696 * entries.append(entry) # <<<<<<<<<<<<<<
4697 * return safe_encode('\n'.join(entries))
4698 *
4699 */
4700 /*else*/ {
4701 __pyx_t_13 = __Pyx_PyList_Append(__pyx_v_entries, __pyx_v_entry); if (unlikely(__pyx_t_13 == ((int)-1))) __PYX_ERR(0, 166, __pyx_L1_error)
4702 }
4703 __pyx_L8:;
4704
4705 /* "borg/platform/linux.pyx":157
4706 * entries = []
4707 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'):
4708 * if entry: # <<<<<<<<<<<<<<
4709 * type, name, permission = entry.split(':')
4710 * if name and type == 'user':
4711 */
4712 }
4713
4714 /* "borg/platform/linux.pyx":156
4715 * """
4716 * entries = []
4717 * for entry in _comment_re.sub('', safe_decode(acl)).split('\n'): # <<<<<<<<<<<<<<
4718 * if entry:
4719 * type, name, permission = entry.split(':')
4720 */
4721 }
4722 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
4723
4724 /* "borg/platform/linux.pyx":167
4725 * else:
4726 * entries.append(entry)
4727 * return safe_encode('\n'.join(entries)) # <<<<<<<<<<<<<<
4728 *
4729 *
4730 */
4731 __Pyx_XDECREF(__pyx_r);
4732 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_safe_encode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 167, __pyx_L1_error)
4733 __Pyx_GOTREF(__pyx_t_1);
4734 __pyx_t_3 = PyUnicode_Join(__pyx_kp_u_, __pyx_v_entries); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 167, __pyx_L1_error)
4735 __Pyx_GOTREF(__pyx_t_3);
4736 __pyx_t_6 = NULL;
4737 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
4738 __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
4739 if (likely(__pyx_t_6)) {
4740 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
4741 __Pyx_INCREF(__pyx_t_6);
4742 __Pyx_INCREF(function);
4743 __Pyx_DECREF_SET(__pyx_t_1, function);
4744 }
4745 }
4746 __pyx_t_4 = (__pyx_t_6) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_6, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3);
4747 __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
4748 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4749 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 167, __pyx_L1_error)
4750 __Pyx_GOTREF(__pyx_t_4);
4751 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4752 __pyx_r = __pyx_t_4;
4753 __pyx_t_4 = 0;
4754 goto __pyx_L0;
4755
4756 /* "borg/platform/linux.pyx":152
4757 *
4758 *
4759 * cdef acl_numeric_ids(acl): # <<<<<<<<<<<<<<
4760 * """Replace the "POSIX 1003.1e draft standard 17" user/group field with uid/gid
4761 * """
4762 */
4763
4764 /* function exit code */
4765 __pyx_L1_error:;
4766 __Pyx_XDECREF(__pyx_t_1);
4767 __Pyx_XDECREF(__pyx_t_2);
4768 __Pyx_XDECREF(__pyx_t_3);
4769 __Pyx_XDECREF(__pyx_t_4);
4770 __Pyx_XDECREF(__pyx_t_5);
4771 __Pyx_XDECREF(__pyx_t_6);
4772 __Pyx_AddTraceback("borg.platform.linux.acl_numeric_ids", __pyx_clineno, __pyx_lineno, __pyx_filename);
4773 __pyx_r = 0;
4774 __pyx_L0:;
4775 __Pyx_XDECREF(__pyx_v_entries);
4776 __Pyx_XDECREF(__pyx_v_entry);
4777 __Pyx_XDECREF(__pyx_v_type);
4778 __Pyx_XDECREF(__pyx_v_name);
4779 __Pyx_XDECREF(__pyx_v_permission);
4780 __Pyx_XDECREF(__pyx_v_uid);
4781 __Pyx_XDECREF(__pyx_v_gid);
4782 __Pyx_XGIVEREF(__pyx_r);
4783 __Pyx_RefNannyFinishContext();
4784 return __pyx_r;
4785 }
4786
4787 /* "borg/platform/linux.pyx":170
4788 *
4789 *
4790 * def acl_get(path, item, st, numeric_owner=False): # <<<<<<<<<<<<<<
4791 * cdef acl_t default_acl = NULL
4792 * cdef acl_t access_acl = NULL
4793 */
4794
4795 /* Python wrapper */
4796 static PyObject *__pyx_pw_4borg_8platform_5linux_7acl_get(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
4797 static PyMethodDef __pyx_mdef_4borg_8platform_5linux_7acl_get = {"acl_get", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4borg_8platform_5linux_7acl_get, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_4borg_8platform_5linux_7acl_get(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)4798 static PyObject *__pyx_pw_4borg_8platform_5linux_7acl_get(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
4799 PyObject *__pyx_v_path = 0;
4800 PyObject *__pyx_v_item = 0;
4801 PyObject *__pyx_v_st = 0;
4802 PyObject *__pyx_v_numeric_owner = 0;
4803 int __pyx_lineno = 0;
4804 const char *__pyx_filename = NULL;
4805 int __pyx_clineno = 0;
4806 PyObject *__pyx_r = 0;
4807 __Pyx_RefNannyDeclarations
4808 __Pyx_RefNannySetupContext("acl_get (wrapper)", 0);
4809 {
4810 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,&__pyx_n_s_item,&__pyx_n_s_st,&__pyx_n_s_numeric_owner,0};
4811 PyObject* values[4] = {0,0,0,0};
4812 values[3] = ((PyObject *)Py_False);
4813 if (unlikely(__pyx_kwds)) {
4814 Py_ssize_t kw_args;
4815 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
4816 switch (pos_args) {
4817 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4818 CYTHON_FALLTHROUGH;
4819 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4820 CYTHON_FALLTHROUGH;
4821 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4822 CYTHON_FALLTHROUGH;
4823 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4824 CYTHON_FALLTHROUGH;
4825 case 0: break;
4826 default: goto __pyx_L5_argtuple_error;
4827 }
4828 kw_args = PyDict_Size(__pyx_kwds);
4829 switch (pos_args) {
4830 case 0:
4831 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
4832 else goto __pyx_L5_argtuple_error;
4833 CYTHON_FALLTHROUGH;
4834 case 1:
4835 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_item)) != 0)) kw_args--;
4836 else {
4837 __Pyx_RaiseArgtupleInvalid("acl_get", 0, 3, 4, 1); __PYX_ERR(0, 170, __pyx_L3_error)
4838 }
4839 CYTHON_FALLTHROUGH;
4840 case 2:
4841 if (likely((values[2] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_st)) != 0)) kw_args--;
4842 else {
4843 __Pyx_RaiseArgtupleInvalid("acl_get", 0, 3, 4, 2); __PYX_ERR(0, 170, __pyx_L3_error)
4844 }
4845 CYTHON_FALLTHROUGH;
4846 case 3:
4847 if (kw_args > 0) {
4848 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_numeric_owner);
4849 if (value) { values[3] = value; kw_args--; }
4850 }
4851 }
4852 if (unlikely(kw_args > 0)) {
4853 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "acl_get") < 0)) __PYX_ERR(0, 170, __pyx_L3_error)
4854 }
4855 } else {
4856 switch (PyTuple_GET_SIZE(__pyx_args)) {
4857 case 4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
4858 CYTHON_FALLTHROUGH;
4859 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
4860 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
4861 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
4862 break;
4863 default: goto __pyx_L5_argtuple_error;
4864 }
4865 }
4866 __pyx_v_path = values[0];
4867 __pyx_v_item = values[1];
4868 __pyx_v_st = values[2];
4869 __pyx_v_numeric_owner = values[3];
4870 }
4871 goto __pyx_L4_argument_unpacking_done;
4872 __pyx_L5_argtuple_error:;
4873 __Pyx_RaiseArgtupleInvalid("acl_get", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 170, __pyx_L3_error)
4874 __pyx_L3_error:;
4875 __Pyx_AddTraceback("borg.platform.linux.acl_get", __pyx_clineno, __pyx_lineno, __pyx_filename);
4876 __Pyx_RefNannyFinishContext();
4877 return NULL;
4878 __pyx_L4_argument_unpacking_done:;
4879 __pyx_r = __pyx_pf_4borg_8platform_5linux_6acl_get(__pyx_self, __pyx_v_path, __pyx_v_item, __pyx_v_st, __pyx_v_numeric_owner);
4880
4881 /* function exit code */
4882 __Pyx_RefNannyFinishContext();
4883 return __pyx_r;
4884 }
4885
__pyx_pf_4borg_8platform_5linux_6acl_get(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_path,PyObject * __pyx_v_item,PyObject * __pyx_v_st,PyObject * __pyx_v_numeric_owner)4886 static PyObject *__pyx_pf_4borg_8platform_5linux_6acl_get(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_item, PyObject *__pyx_v_st, PyObject *__pyx_v_numeric_owner) {
4887 acl_t __pyx_v_default_acl;
4888 acl_t __pyx_v_access_acl;
4889 char *__pyx_v_default_text;
4890 char *__pyx_v_access_text;
4891 PyObject *__pyx_v_p = NULL;
4892 PyObject *(*__pyx_v_converter)(PyObject *);
4893 PyObject *__pyx_r = NULL;
4894 __Pyx_RefNannyDeclarations
4895 PyObject *__pyx_t_1 = NULL;
4896 PyObject *__pyx_t_2 = NULL;
4897 PyObject *__pyx_t_3 = NULL;
4898 int __pyx_t_4;
4899 PyObject *__pyx_t_5 = NULL;
4900 int __pyx_t_6;
4901 char const *__pyx_t_7;
4902 char const *__pyx_t_8;
4903 int __pyx_t_9;
4904 int __pyx_t_10;
4905 char const *__pyx_t_11;
4906 PyObject *__pyx_t_12 = NULL;
4907 PyObject *__pyx_t_13 = NULL;
4908 PyObject *__pyx_t_14 = NULL;
4909 PyObject *__pyx_t_15 = NULL;
4910 PyObject *__pyx_t_16 = NULL;
4911 PyObject *__pyx_t_17 = NULL;
4912 int __pyx_lineno = 0;
4913 const char *__pyx_filename = NULL;
4914 int __pyx_clineno = 0;
4915 __Pyx_RefNannySetupContext("acl_get", 0);
4916
4917 /* "borg/platform/linux.pyx":171
4918 *
4919 * def acl_get(path, item, st, numeric_owner=False):
4920 * cdef acl_t default_acl = NULL # <<<<<<<<<<<<<<
4921 * cdef acl_t access_acl = NULL
4922 * cdef char *default_text = NULL
4923 */
4924 __pyx_v_default_acl = NULL;
4925
4926 /* "borg/platform/linux.pyx":172
4927 * def acl_get(path, item, st, numeric_owner=False):
4928 * cdef acl_t default_acl = NULL
4929 * cdef acl_t access_acl = NULL # <<<<<<<<<<<<<<
4930 * cdef char *default_text = NULL
4931 * cdef char *access_text = NULL
4932 */
4933 __pyx_v_access_acl = NULL;
4934
4935 /* "borg/platform/linux.pyx":173
4936 * cdef acl_t default_acl = NULL
4937 * cdef acl_t access_acl = NULL
4938 * cdef char *default_text = NULL # <<<<<<<<<<<<<<
4939 * cdef char *access_text = NULL
4940 *
4941 */
4942 __pyx_v_default_text = NULL;
4943
4944 /* "borg/platform/linux.pyx":174
4945 * cdef acl_t access_acl = NULL
4946 * cdef char *default_text = NULL
4947 * cdef char *access_text = NULL # <<<<<<<<<<<<<<
4948 *
4949 * p = <bytes>os.fsencode(path)
4950 */
4951 __pyx_v_access_text = NULL;
4952
4953 /* "borg/platform/linux.pyx":176
4954 * cdef char *access_text = NULL
4955 *
4956 * p = <bytes>os.fsencode(path) # <<<<<<<<<<<<<<
4957 * if stat.S_ISLNK(st.st_mode) or acl_extended_file(p) <= 0:
4958 * return
4959 */
4960 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_os); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 176, __pyx_L1_error)
4961 __Pyx_GOTREF(__pyx_t_2);
4962 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_fsencode); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 176, __pyx_L1_error)
4963 __Pyx_GOTREF(__pyx_t_3);
4964 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
4965 __pyx_t_2 = NULL;
4966 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
4967 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
4968 if (likely(__pyx_t_2)) {
4969 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
4970 __Pyx_INCREF(__pyx_t_2);
4971 __Pyx_INCREF(function);
4972 __Pyx_DECREF_SET(__pyx_t_3, function);
4973 }
4974 }
4975 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_v_path) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_path);
4976 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
4977 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 176, __pyx_L1_error)
4978 __Pyx_GOTREF(__pyx_t_1);
4979 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
4980 __pyx_t_3 = __pyx_t_1;
4981 __Pyx_INCREF(__pyx_t_3);
4982 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4983 __pyx_v_p = ((PyObject*)__pyx_t_3);
4984 __pyx_t_3 = 0;
4985
4986 /* "borg/platform/linux.pyx":177
4987 *
4988 * p = <bytes>os.fsencode(path)
4989 * if stat.S_ISLNK(st.st_mode) or acl_extended_file(p) <= 0: # <<<<<<<<<<<<<<
4990 * return
4991 * if numeric_owner:
4992 */
4993 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_stat); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
4994 __Pyx_GOTREF(__pyx_t_1);
4995 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_S_ISLNK); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 177, __pyx_L1_error)
4996 __Pyx_GOTREF(__pyx_t_2);
4997 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
4998 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_st, __pyx_n_s_st_mode); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 177, __pyx_L1_error)
4999 __Pyx_GOTREF(__pyx_t_1);
5000 __pyx_t_5 = NULL;
5001 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
5002 __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
5003 if (likely(__pyx_t_5)) {
5004 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
5005 __Pyx_INCREF(__pyx_t_5);
5006 __Pyx_INCREF(function);
5007 __Pyx_DECREF_SET(__pyx_t_2, function);
5008 }
5009 }
5010 __pyx_t_3 = (__pyx_t_5) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_5, __pyx_t_1) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_1);
5011 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5012 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5013 if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 177, __pyx_L1_error)
5014 __Pyx_GOTREF(__pyx_t_3);
5015 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5016 __pyx_t_6 = __Pyx_PyObject_IsTrue(__pyx_t_3); if (unlikely(__pyx_t_6 < 0)) __PYX_ERR(0, 177, __pyx_L1_error)
5017 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5018 if (!__pyx_t_6) {
5019 } else {
5020 __pyx_t_4 = __pyx_t_6;
5021 goto __pyx_L4_bool_binop_done;
5022 }
5023 if (unlikely(__pyx_v_p == Py_None)) {
5024 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
5025 __PYX_ERR(0, 177, __pyx_L1_error)
5026 }
5027 __pyx_t_7 = __Pyx_PyBytes_AsString(__pyx_v_p); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 177, __pyx_L1_error)
5028 __pyx_t_6 = ((acl_extended_file(__pyx_t_7) <= 0) != 0);
5029 __pyx_t_4 = __pyx_t_6;
5030 __pyx_L4_bool_binop_done:;
5031 if (__pyx_t_4) {
5032
5033 /* "borg/platform/linux.pyx":178
5034 * p = <bytes>os.fsencode(path)
5035 * if stat.S_ISLNK(st.st_mode) or acl_extended_file(p) <= 0:
5036 * return # <<<<<<<<<<<<<<
5037 * if numeric_owner:
5038 * converter = acl_numeric_ids
5039 */
5040 __Pyx_XDECREF(__pyx_r);
5041 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5042 goto __pyx_L0;
5043
5044 /* "borg/platform/linux.pyx":177
5045 *
5046 * p = <bytes>os.fsencode(path)
5047 * if stat.S_ISLNK(st.st_mode) or acl_extended_file(p) <= 0: # <<<<<<<<<<<<<<
5048 * return
5049 * if numeric_owner:
5050 */
5051 }
5052
5053 /* "borg/platform/linux.pyx":179
5054 * if stat.S_ISLNK(st.st_mode) or acl_extended_file(p) <= 0:
5055 * return
5056 * if numeric_owner: # <<<<<<<<<<<<<<
5057 * converter = acl_numeric_ids
5058 * else:
5059 */
5060 __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_v_numeric_owner); if (unlikely(__pyx_t_4 < 0)) __PYX_ERR(0, 179, __pyx_L1_error)
5061 if (__pyx_t_4) {
5062
5063 /* "borg/platform/linux.pyx":180
5064 * return
5065 * if numeric_owner:
5066 * converter = acl_numeric_ids # <<<<<<<<<<<<<<
5067 * else:
5068 * converter = acl_append_numeric_ids
5069 */
5070 __pyx_v_converter = __pyx_f_4borg_8platform_5linux_acl_numeric_ids;
5071
5072 /* "borg/platform/linux.pyx":179
5073 * if stat.S_ISLNK(st.st_mode) or acl_extended_file(p) <= 0:
5074 * return
5075 * if numeric_owner: # <<<<<<<<<<<<<<
5076 * converter = acl_numeric_ids
5077 * else:
5078 */
5079 goto __pyx_L6;
5080 }
5081
5082 /* "borg/platform/linux.pyx":182
5083 * converter = acl_numeric_ids
5084 * else:
5085 * converter = acl_append_numeric_ids # <<<<<<<<<<<<<<
5086 * try:
5087 * access_acl = acl_get_file(p, ACL_TYPE_ACCESS)
5088 */
5089 /*else*/ {
5090 __pyx_v_converter = __pyx_f_4borg_8platform_5linux_acl_append_numeric_ids;
5091 }
5092 __pyx_L6:;
5093
5094 /* "borg/platform/linux.pyx":183
5095 * else:
5096 * converter = acl_append_numeric_ids
5097 * try: # <<<<<<<<<<<<<<
5098 * access_acl = acl_get_file(p, ACL_TYPE_ACCESS)
5099 * if access_acl:
5100 */
5101 /*try:*/ {
5102
5103 /* "borg/platform/linux.pyx":184
5104 * converter = acl_append_numeric_ids
5105 * try:
5106 * access_acl = acl_get_file(p, ACL_TYPE_ACCESS) # <<<<<<<<<<<<<<
5107 * if access_acl:
5108 * access_text = acl_to_text(access_acl, NULL)
5109 */
5110 if (unlikely(__pyx_v_p == Py_None)) {
5111 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
5112 __PYX_ERR(0, 184, __pyx_L8_error)
5113 }
5114 __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_p); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 184, __pyx_L8_error)
5115 __pyx_v_access_acl = acl_get_file(__pyx_t_8, ACL_TYPE_ACCESS);
5116
5117 /* "borg/platform/linux.pyx":185
5118 * try:
5119 * access_acl = acl_get_file(p, ACL_TYPE_ACCESS)
5120 * if access_acl: # <<<<<<<<<<<<<<
5121 * access_text = acl_to_text(access_acl, NULL)
5122 * if access_text:
5123 */
5124 __pyx_t_4 = (__pyx_v_access_acl != 0);
5125 if (__pyx_t_4) {
5126
5127 /* "borg/platform/linux.pyx":186
5128 * access_acl = acl_get_file(p, ACL_TYPE_ACCESS)
5129 * if access_acl:
5130 * access_text = acl_to_text(access_acl, NULL) # <<<<<<<<<<<<<<
5131 * if access_text:
5132 * item['acl_access'] = converter(access_text)
5133 */
5134 __pyx_v_access_text = acl_to_text(__pyx_v_access_acl, NULL);
5135
5136 /* "borg/platform/linux.pyx":187
5137 * if access_acl:
5138 * access_text = acl_to_text(access_acl, NULL)
5139 * if access_text: # <<<<<<<<<<<<<<
5140 * item['acl_access'] = converter(access_text)
5141 * default_acl = acl_get_file(p, ACL_TYPE_DEFAULT)
5142 */
5143 __pyx_t_4 = (__pyx_v_access_text != 0);
5144 if (__pyx_t_4) {
5145
5146 /* "borg/platform/linux.pyx":188
5147 * access_text = acl_to_text(access_acl, NULL)
5148 * if access_text:
5149 * item['acl_access'] = converter(access_text) # <<<<<<<<<<<<<<
5150 * default_acl = acl_get_file(p, ACL_TYPE_DEFAULT)
5151 * if default_acl:
5152 */
5153 __pyx_t_3 = __Pyx_PyBytes_FromString(__pyx_v_access_text); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 188, __pyx_L8_error)
5154 __Pyx_GOTREF(__pyx_t_3);
5155 __pyx_t_2 = __pyx_v_converter(__pyx_t_3); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 188, __pyx_L8_error)
5156 __Pyx_GOTREF(__pyx_t_2);
5157 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5158 if (unlikely(PyObject_SetItem(__pyx_v_item, __pyx_n_u_acl_access, __pyx_t_2) < 0)) __PYX_ERR(0, 188, __pyx_L8_error)
5159 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5160
5161 /* "borg/platform/linux.pyx":187
5162 * if access_acl:
5163 * access_text = acl_to_text(access_acl, NULL)
5164 * if access_text: # <<<<<<<<<<<<<<
5165 * item['acl_access'] = converter(access_text)
5166 * default_acl = acl_get_file(p, ACL_TYPE_DEFAULT)
5167 */
5168 }
5169
5170 /* "borg/platform/linux.pyx":185
5171 * try:
5172 * access_acl = acl_get_file(p, ACL_TYPE_ACCESS)
5173 * if access_acl: # <<<<<<<<<<<<<<
5174 * access_text = acl_to_text(access_acl, NULL)
5175 * if access_text:
5176 */
5177 }
5178
5179 /* "borg/platform/linux.pyx":189
5180 * if access_text:
5181 * item['acl_access'] = converter(access_text)
5182 * default_acl = acl_get_file(p, ACL_TYPE_DEFAULT) # <<<<<<<<<<<<<<
5183 * if default_acl:
5184 * default_text = acl_to_text(default_acl, NULL)
5185 */
5186 if (unlikely(__pyx_v_p == Py_None)) {
5187 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
5188 __PYX_ERR(0, 189, __pyx_L8_error)
5189 }
5190 __pyx_t_8 = __Pyx_PyBytes_AsString(__pyx_v_p); if (unlikely((!__pyx_t_8) && PyErr_Occurred())) __PYX_ERR(0, 189, __pyx_L8_error)
5191 __pyx_v_default_acl = acl_get_file(__pyx_t_8, ACL_TYPE_DEFAULT);
5192
5193 /* "borg/platform/linux.pyx":190
5194 * item['acl_access'] = converter(access_text)
5195 * default_acl = acl_get_file(p, ACL_TYPE_DEFAULT)
5196 * if default_acl: # <<<<<<<<<<<<<<
5197 * default_text = acl_to_text(default_acl, NULL)
5198 * if default_text:
5199 */
5200 __pyx_t_4 = (__pyx_v_default_acl != 0);
5201 if (__pyx_t_4) {
5202
5203 /* "borg/platform/linux.pyx":191
5204 * default_acl = acl_get_file(p, ACL_TYPE_DEFAULT)
5205 * if default_acl:
5206 * default_text = acl_to_text(default_acl, NULL) # <<<<<<<<<<<<<<
5207 * if default_text:
5208 * item['acl_default'] = converter(default_text)
5209 */
5210 __pyx_v_default_text = acl_to_text(__pyx_v_default_acl, NULL);
5211
5212 /* "borg/platform/linux.pyx":192
5213 * if default_acl:
5214 * default_text = acl_to_text(default_acl, NULL)
5215 * if default_text: # <<<<<<<<<<<<<<
5216 * item['acl_default'] = converter(default_text)
5217 * finally:
5218 */
5219 __pyx_t_4 = (__pyx_v_default_text != 0);
5220 if (__pyx_t_4) {
5221
5222 /* "borg/platform/linux.pyx":193
5223 * default_text = acl_to_text(default_acl, NULL)
5224 * if default_text:
5225 * item['acl_default'] = converter(default_text) # <<<<<<<<<<<<<<
5226 * finally:
5227 * acl_free(default_text)
5228 */
5229 __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_default_text); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 193, __pyx_L8_error)
5230 __Pyx_GOTREF(__pyx_t_2);
5231 __pyx_t_3 = __pyx_v_converter(__pyx_t_2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 193, __pyx_L8_error)
5232 __Pyx_GOTREF(__pyx_t_3);
5233 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5234 if (unlikely(PyObject_SetItem(__pyx_v_item, __pyx_n_u_acl_default, __pyx_t_3) < 0)) __PYX_ERR(0, 193, __pyx_L8_error)
5235 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5236
5237 /* "borg/platform/linux.pyx":192
5238 * if default_acl:
5239 * default_text = acl_to_text(default_acl, NULL)
5240 * if default_text: # <<<<<<<<<<<<<<
5241 * item['acl_default'] = converter(default_text)
5242 * finally:
5243 */
5244 }
5245
5246 /* "borg/platform/linux.pyx":190
5247 * item['acl_access'] = converter(access_text)
5248 * default_acl = acl_get_file(p, ACL_TYPE_DEFAULT)
5249 * if default_acl: # <<<<<<<<<<<<<<
5250 * default_text = acl_to_text(default_acl, NULL)
5251 * if default_text:
5252 */
5253 }
5254 }
5255
5256 /* "borg/platform/linux.pyx":195
5257 * item['acl_default'] = converter(default_text)
5258 * finally:
5259 * acl_free(default_text) # <<<<<<<<<<<<<<
5260 * acl_free(default_acl)
5261 * acl_free(access_text)
5262 */
5263 /*finally:*/ {
5264 /*normal exit:*/{
5265 (void)(acl_free(__pyx_v_default_text));
5266
5267 /* "borg/platform/linux.pyx":196
5268 * finally:
5269 * acl_free(default_text)
5270 * acl_free(default_acl) # <<<<<<<<<<<<<<
5271 * acl_free(access_text)
5272 * acl_free(access_acl)
5273 */
5274 (void)(acl_free(__pyx_v_default_acl));
5275
5276 /* "borg/platform/linux.pyx":197
5277 * acl_free(default_text)
5278 * acl_free(default_acl)
5279 * acl_free(access_text) # <<<<<<<<<<<<<<
5280 * acl_free(access_acl)
5281 *
5282 */
5283 (void)(acl_free(__pyx_v_access_text));
5284
5285 /* "borg/platform/linux.pyx":198
5286 * acl_free(default_acl)
5287 * acl_free(access_text)
5288 * acl_free(access_acl) # <<<<<<<<<<<<<<
5289 *
5290 *
5291 */
5292 (void)(acl_free(__pyx_v_access_acl));
5293 goto __pyx_L9;
5294 }
5295 __pyx_L8_error:;
5296 /*exception exit:*/{
5297 __Pyx_PyThreadState_declare
5298 __Pyx_PyThreadState_assign
5299 __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
5300 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
5301 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5302 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5303 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
5304 if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_15, &__pyx_t_16, &__pyx_t_17);
5305 if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_12, &__pyx_t_13, &__pyx_t_14);
5306 __Pyx_XGOTREF(__pyx_t_12);
5307 __Pyx_XGOTREF(__pyx_t_13);
5308 __Pyx_XGOTREF(__pyx_t_14);
5309 __Pyx_XGOTREF(__pyx_t_15);
5310 __Pyx_XGOTREF(__pyx_t_16);
5311 __Pyx_XGOTREF(__pyx_t_17);
5312 __pyx_t_9 = __pyx_lineno; __pyx_t_10 = __pyx_clineno; __pyx_t_11 = __pyx_filename;
5313 {
5314
5315 /* "borg/platform/linux.pyx":195
5316 * item['acl_default'] = converter(default_text)
5317 * finally:
5318 * acl_free(default_text) # <<<<<<<<<<<<<<
5319 * acl_free(default_acl)
5320 * acl_free(access_text)
5321 */
5322 (void)(acl_free(__pyx_v_default_text));
5323
5324 /* "borg/platform/linux.pyx":196
5325 * finally:
5326 * acl_free(default_text)
5327 * acl_free(default_acl) # <<<<<<<<<<<<<<
5328 * acl_free(access_text)
5329 * acl_free(access_acl)
5330 */
5331 (void)(acl_free(__pyx_v_default_acl));
5332
5333 /* "borg/platform/linux.pyx":197
5334 * acl_free(default_text)
5335 * acl_free(default_acl)
5336 * acl_free(access_text) # <<<<<<<<<<<<<<
5337 * acl_free(access_acl)
5338 *
5339 */
5340 (void)(acl_free(__pyx_v_access_text));
5341
5342 /* "borg/platform/linux.pyx":198
5343 * acl_free(default_acl)
5344 * acl_free(access_text)
5345 * acl_free(access_acl) # <<<<<<<<<<<<<<
5346 *
5347 *
5348 */
5349 (void)(acl_free(__pyx_v_access_acl));
5350 }
5351 if (PY_MAJOR_VERSION >= 3) {
5352 __Pyx_XGIVEREF(__pyx_t_15);
5353 __Pyx_XGIVEREF(__pyx_t_16);
5354 __Pyx_XGIVEREF(__pyx_t_17);
5355 __Pyx_ExceptionReset(__pyx_t_15, __pyx_t_16, __pyx_t_17);
5356 }
5357 __Pyx_XGIVEREF(__pyx_t_12);
5358 __Pyx_XGIVEREF(__pyx_t_13);
5359 __Pyx_XGIVEREF(__pyx_t_14);
5360 __Pyx_ErrRestore(__pyx_t_12, __pyx_t_13, __pyx_t_14);
5361 __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0; __pyx_t_17 = 0;
5362 __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_10; __pyx_filename = __pyx_t_11;
5363 goto __pyx_L1_error;
5364 }
5365 __pyx_L9:;
5366 }
5367
5368 /* "borg/platform/linux.pyx":170
5369 *
5370 *
5371 * def acl_get(path, item, st, numeric_owner=False): # <<<<<<<<<<<<<<
5372 * cdef acl_t default_acl = NULL
5373 * cdef acl_t access_acl = NULL
5374 */
5375
5376 /* function exit code */
5377 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5378 goto __pyx_L0;
5379 __pyx_L1_error:;
5380 __Pyx_XDECREF(__pyx_t_1);
5381 __Pyx_XDECREF(__pyx_t_2);
5382 __Pyx_XDECREF(__pyx_t_3);
5383 __Pyx_XDECREF(__pyx_t_5);
5384 __Pyx_AddTraceback("borg.platform.linux.acl_get", __pyx_clineno, __pyx_lineno, __pyx_filename);
5385 __pyx_r = NULL;
5386 __pyx_L0:;
5387 __Pyx_XDECREF(__pyx_v_p);
5388 __Pyx_XGIVEREF(__pyx_r);
5389 __Pyx_RefNannyFinishContext();
5390 return __pyx_r;
5391 }
5392
5393 /* "borg/platform/linux.pyx":201
5394 *
5395 *
5396 * def acl_set(path, item, numeric_owner=False): # <<<<<<<<<<<<<<
5397 * cdef acl_t access_acl = NULL
5398 * cdef acl_t default_acl = NULL
5399 */
5400
5401 /* Python wrapper */
5402 static PyObject *__pyx_pw_4borg_8platform_5linux_9acl_set(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
5403 static PyMethodDef __pyx_mdef_4borg_8platform_5linux_9acl_set = {"acl_set", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4borg_8platform_5linux_9acl_set, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_4borg_8platform_5linux_9acl_set(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)5404 static PyObject *__pyx_pw_4borg_8platform_5linux_9acl_set(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
5405 PyObject *__pyx_v_path = 0;
5406 PyObject *__pyx_v_item = 0;
5407 PyObject *__pyx_v_numeric_owner = 0;
5408 int __pyx_lineno = 0;
5409 const char *__pyx_filename = NULL;
5410 int __pyx_clineno = 0;
5411 PyObject *__pyx_r = 0;
5412 __Pyx_RefNannyDeclarations
5413 __Pyx_RefNannySetupContext("acl_set (wrapper)", 0);
5414 {
5415 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_path,&__pyx_n_s_item,&__pyx_n_s_numeric_owner,0};
5416 PyObject* values[3] = {0,0,0};
5417 values[2] = ((PyObject *)Py_False);
5418 if (unlikely(__pyx_kwds)) {
5419 Py_ssize_t kw_args;
5420 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
5421 switch (pos_args) {
5422 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5423 CYTHON_FALLTHROUGH;
5424 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5425 CYTHON_FALLTHROUGH;
5426 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5427 CYTHON_FALLTHROUGH;
5428 case 0: break;
5429 default: goto __pyx_L5_argtuple_error;
5430 }
5431 kw_args = PyDict_Size(__pyx_kwds);
5432 switch (pos_args) {
5433 case 0:
5434 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
5435 else goto __pyx_L5_argtuple_error;
5436 CYTHON_FALLTHROUGH;
5437 case 1:
5438 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_item)) != 0)) kw_args--;
5439 else {
5440 __Pyx_RaiseArgtupleInvalid("acl_set", 0, 2, 3, 1); __PYX_ERR(0, 201, __pyx_L3_error)
5441 }
5442 CYTHON_FALLTHROUGH;
5443 case 2:
5444 if (kw_args > 0) {
5445 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_numeric_owner);
5446 if (value) { values[2] = value; kw_args--; }
5447 }
5448 }
5449 if (unlikely(kw_args > 0)) {
5450 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "acl_set") < 0)) __PYX_ERR(0, 201, __pyx_L3_error)
5451 }
5452 } else {
5453 switch (PyTuple_GET_SIZE(__pyx_args)) {
5454 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
5455 CYTHON_FALLTHROUGH;
5456 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
5457 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
5458 break;
5459 default: goto __pyx_L5_argtuple_error;
5460 }
5461 }
5462 __pyx_v_path = values[0];
5463 __pyx_v_item = values[1];
5464 __pyx_v_numeric_owner = values[2];
5465 }
5466 goto __pyx_L4_argument_unpacking_done;
5467 __pyx_L5_argtuple_error:;
5468 __Pyx_RaiseArgtupleInvalid("acl_set", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 201, __pyx_L3_error)
5469 __pyx_L3_error:;
5470 __Pyx_AddTraceback("borg.platform.linux.acl_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
5471 __Pyx_RefNannyFinishContext();
5472 return NULL;
5473 __pyx_L4_argument_unpacking_done:;
5474 __pyx_r = __pyx_pf_4borg_8platform_5linux_8acl_set(__pyx_self, __pyx_v_path, __pyx_v_item, __pyx_v_numeric_owner);
5475
5476 /* function exit code */
5477 __Pyx_RefNannyFinishContext();
5478 return __pyx_r;
5479 }
5480
__pyx_pf_4borg_8platform_5linux_8acl_set(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_path,PyObject * __pyx_v_item,PyObject * __pyx_v_numeric_owner)5481 static PyObject *__pyx_pf_4borg_8platform_5linux_8acl_set(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_path, PyObject *__pyx_v_item, PyObject *__pyx_v_numeric_owner) {
5482 acl_t __pyx_v_access_acl;
5483 acl_t __pyx_v_default_acl;
5484 PyObject *__pyx_v_p = NULL;
5485 PyObject *__pyx_v_converter = NULL;
5486 PyObject *__pyx_v_access_text = NULL;
5487 PyObject *__pyx_v_default_text = NULL;
5488 PyObject *__pyx_r = NULL;
5489 __Pyx_RefNannyDeclarations
5490 PyObject *__pyx_t_1 = NULL;
5491 PyObject *__pyx_t_2 = NULL;
5492 PyObject *__pyx_t_3 = NULL;
5493 PyObject *__pyx_t_4 = NULL;
5494 int __pyx_t_5;
5495 char const *__pyx_t_6;
5496 char const *__pyx_t_7;
5497 int __pyx_t_8;
5498 int __pyx_t_9;
5499 char const *__pyx_t_10;
5500 PyObject *__pyx_t_11 = NULL;
5501 PyObject *__pyx_t_12 = NULL;
5502 PyObject *__pyx_t_13 = NULL;
5503 PyObject *__pyx_t_14 = NULL;
5504 PyObject *__pyx_t_15 = NULL;
5505 PyObject *__pyx_t_16 = NULL;
5506 char const *__pyx_t_17;
5507 int __pyx_lineno = 0;
5508 const char *__pyx_filename = NULL;
5509 int __pyx_clineno = 0;
5510 __Pyx_RefNannySetupContext("acl_set", 0);
5511
5512 /* "borg/platform/linux.pyx":202
5513 *
5514 * def acl_set(path, item, numeric_owner=False):
5515 * cdef acl_t access_acl = NULL # <<<<<<<<<<<<<<
5516 * cdef acl_t default_acl = NULL
5517 *
5518 */
5519 __pyx_v_access_acl = NULL;
5520
5521 /* "borg/platform/linux.pyx":203
5522 * def acl_set(path, item, numeric_owner=False):
5523 * cdef acl_t access_acl = NULL
5524 * cdef acl_t default_acl = NULL # <<<<<<<<<<<<<<
5525 *
5526 * if stat.S_ISLNK(item.get('mode', 0)):
5527 */
5528 __pyx_v_default_acl = NULL;
5529
5530 /* "borg/platform/linux.pyx":205
5531 * cdef acl_t default_acl = NULL
5532 *
5533 * if stat.S_ISLNK(item.get('mode', 0)): # <<<<<<<<<<<<<<
5534 * # Linux does not support setting ACLs on symlinks
5535 * return
5536 */
5537 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_stat); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error)
5538 __Pyx_GOTREF(__pyx_t_2);
5539 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_S_ISLNK); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 205, __pyx_L1_error)
5540 __Pyx_GOTREF(__pyx_t_3);
5541 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5542 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_item, __pyx_n_s_get); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 205, __pyx_L1_error)
5543 __Pyx_GOTREF(__pyx_t_2);
5544 __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 205, __pyx_L1_error)
5545 __Pyx_GOTREF(__pyx_t_4);
5546 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
5547 __pyx_t_2 = NULL;
5548 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_3))) {
5549 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
5550 if (likely(__pyx_t_2)) {
5551 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
5552 __Pyx_INCREF(__pyx_t_2);
5553 __Pyx_INCREF(function);
5554 __Pyx_DECREF_SET(__pyx_t_3, function);
5555 }
5556 }
5557 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_Call2Args(__pyx_t_3, __pyx_t_2, __pyx_t_4) : __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_4);
5558 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5559 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5560 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 205, __pyx_L1_error)
5561 __Pyx_GOTREF(__pyx_t_1);
5562 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5563 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 205, __pyx_L1_error)
5564 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5565 if (__pyx_t_5) {
5566
5567 /* "borg/platform/linux.pyx":207
5568 * if stat.S_ISLNK(item.get('mode', 0)):
5569 * # Linux does not support setting ACLs on symlinks
5570 * return # <<<<<<<<<<<<<<
5571 *
5572 * p = <bytes>os.fsencode(path)
5573 */
5574 __Pyx_XDECREF(__pyx_r);
5575 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
5576 goto __pyx_L0;
5577
5578 /* "borg/platform/linux.pyx":205
5579 * cdef acl_t default_acl = NULL
5580 *
5581 * if stat.S_ISLNK(item.get('mode', 0)): # <<<<<<<<<<<<<<
5582 * # Linux does not support setting ACLs on symlinks
5583 * return
5584 */
5585 }
5586
5587 /* "borg/platform/linux.pyx":209
5588 * return
5589 *
5590 * p = <bytes>os.fsencode(path) # <<<<<<<<<<<<<<
5591 * if numeric_owner:
5592 * converter = posix_acl_use_stored_uid_gid
5593 */
5594 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 209, __pyx_L1_error)
5595 __Pyx_GOTREF(__pyx_t_3);
5596 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_fsencode); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 209, __pyx_L1_error)
5597 __Pyx_GOTREF(__pyx_t_4);
5598 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
5599 __pyx_t_3 = NULL;
5600 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
5601 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
5602 if (likely(__pyx_t_3)) {
5603 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
5604 __Pyx_INCREF(__pyx_t_3);
5605 __Pyx_INCREF(function);
5606 __Pyx_DECREF_SET(__pyx_t_4, function);
5607 }
5608 }
5609 __pyx_t_1 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_path) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_path);
5610 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5611 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 209, __pyx_L1_error)
5612 __Pyx_GOTREF(__pyx_t_1);
5613 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5614 __pyx_t_4 = __pyx_t_1;
5615 __Pyx_INCREF(__pyx_t_4);
5616 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5617 __pyx_v_p = ((PyObject*)__pyx_t_4);
5618 __pyx_t_4 = 0;
5619
5620 /* "borg/platform/linux.pyx":210
5621 *
5622 * p = <bytes>os.fsencode(path)
5623 * if numeric_owner: # <<<<<<<<<<<<<<
5624 * converter = posix_acl_use_stored_uid_gid
5625 * else:
5626 */
5627 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_numeric_owner); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 210, __pyx_L1_error)
5628 if (__pyx_t_5) {
5629
5630 /* "borg/platform/linux.pyx":211
5631 * p = <bytes>os.fsencode(path)
5632 * if numeric_owner:
5633 * converter = posix_acl_use_stored_uid_gid # <<<<<<<<<<<<<<
5634 * else:
5635 * converter = acl_use_local_uid_gid
5636 */
5637 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_posix_acl_use_stored_uid_gid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 211, __pyx_L1_error)
5638 __Pyx_GOTREF(__pyx_t_4);
5639 __pyx_v_converter = __pyx_t_4;
5640 __pyx_t_4 = 0;
5641
5642 /* "borg/platform/linux.pyx":210
5643 *
5644 * p = <bytes>os.fsencode(path)
5645 * if numeric_owner: # <<<<<<<<<<<<<<
5646 * converter = posix_acl_use_stored_uid_gid
5647 * else:
5648 */
5649 goto __pyx_L4;
5650 }
5651
5652 /* "borg/platform/linux.pyx":213
5653 * converter = posix_acl_use_stored_uid_gid
5654 * else:
5655 * converter = acl_use_local_uid_gid # <<<<<<<<<<<<<<
5656 * access_text = item.get('acl_access')
5657 * default_text = item.get('acl_default')
5658 */
5659 /*else*/ {
5660 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_acl_use_local_uid_gid); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 213, __pyx_L1_error)
5661 __Pyx_GOTREF(__pyx_t_4);
5662 __pyx_v_converter = __pyx_t_4;
5663 __pyx_t_4 = 0;
5664 }
5665 __pyx_L4:;
5666
5667 /* "borg/platform/linux.pyx":214
5668 * else:
5669 * converter = acl_use_local_uid_gid
5670 * access_text = item.get('acl_access') # <<<<<<<<<<<<<<
5671 * default_text = item.get('acl_default')
5672 * if access_text:
5673 */
5674 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_item, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 214, __pyx_L1_error)
5675 __Pyx_GOTREF(__pyx_t_1);
5676 __pyx_t_3 = NULL;
5677 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
5678 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
5679 if (likely(__pyx_t_3)) {
5680 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
5681 __Pyx_INCREF(__pyx_t_3);
5682 __Pyx_INCREF(function);
5683 __Pyx_DECREF_SET(__pyx_t_1, function);
5684 }
5685 }
5686 __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_n_u_acl_access) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_n_u_acl_access);
5687 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5688 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 214, __pyx_L1_error)
5689 __Pyx_GOTREF(__pyx_t_4);
5690 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5691 __pyx_v_access_text = __pyx_t_4;
5692 __pyx_t_4 = 0;
5693
5694 /* "borg/platform/linux.pyx":215
5695 * converter = acl_use_local_uid_gid
5696 * access_text = item.get('acl_access')
5697 * default_text = item.get('acl_default') # <<<<<<<<<<<<<<
5698 * if access_text:
5699 * try:
5700 */
5701 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_item, __pyx_n_s_get); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 215, __pyx_L1_error)
5702 __Pyx_GOTREF(__pyx_t_1);
5703 __pyx_t_3 = NULL;
5704 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
5705 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
5706 if (likely(__pyx_t_3)) {
5707 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
5708 __Pyx_INCREF(__pyx_t_3);
5709 __Pyx_INCREF(function);
5710 __Pyx_DECREF_SET(__pyx_t_1, function);
5711 }
5712 }
5713 __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_n_u_acl_default) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_n_u_acl_default);
5714 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5715 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 215, __pyx_L1_error)
5716 __Pyx_GOTREF(__pyx_t_4);
5717 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5718 __pyx_v_default_text = __pyx_t_4;
5719 __pyx_t_4 = 0;
5720
5721 /* "borg/platform/linux.pyx":216
5722 * access_text = item.get('acl_access')
5723 * default_text = item.get('acl_default')
5724 * if access_text: # <<<<<<<<<<<<<<
5725 * try:
5726 * access_acl = acl_from_text(<bytes>converter(access_text))
5727 */
5728 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_access_text); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 216, __pyx_L1_error)
5729 if (__pyx_t_5) {
5730
5731 /* "borg/platform/linux.pyx":217
5732 * default_text = item.get('acl_default')
5733 * if access_text:
5734 * try: # <<<<<<<<<<<<<<
5735 * access_acl = acl_from_text(<bytes>converter(access_text))
5736 * if access_acl:
5737 */
5738 /*try:*/ {
5739
5740 /* "borg/platform/linux.pyx":218
5741 * if access_text:
5742 * try:
5743 * access_acl = acl_from_text(<bytes>converter(access_text)) # <<<<<<<<<<<<<<
5744 * if access_acl:
5745 * acl_set_file(p, ACL_TYPE_ACCESS, access_acl)
5746 */
5747 __Pyx_INCREF(__pyx_v_converter);
5748 __pyx_t_1 = __pyx_v_converter; __pyx_t_3 = NULL;
5749 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
5750 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
5751 if (likely(__pyx_t_3)) {
5752 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
5753 __Pyx_INCREF(__pyx_t_3);
5754 __Pyx_INCREF(function);
5755 __Pyx_DECREF_SET(__pyx_t_1, function);
5756 }
5757 }
5758 __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_access_text) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_access_text);
5759 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5760 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 218, __pyx_L7_error)
5761 __Pyx_GOTREF(__pyx_t_4);
5762 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5763 if (unlikely(__pyx_t_4 == Py_None)) {
5764 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
5765 __PYX_ERR(0, 218, __pyx_L7_error)
5766 }
5767 __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 218, __pyx_L7_error)
5768 __pyx_v_access_acl = acl_from_text(__pyx_t_6);
5769 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5770
5771 /* "borg/platform/linux.pyx":219
5772 * try:
5773 * access_acl = acl_from_text(<bytes>converter(access_text))
5774 * if access_acl: # <<<<<<<<<<<<<<
5775 * acl_set_file(p, ACL_TYPE_ACCESS, access_acl)
5776 * finally:
5777 */
5778 __pyx_t_5 = (__pyx_v_access_acl != 0);
5779 if (__pyx_t_5) {
5780
5781 /* "borg/platform/linux.pyx":220
5782 * access_acl = acl_from_text(<bytes>converter(access_text))
5783 * if access_acl:
5784 * acl_set_file(p, ACL_TYPE_ACCESS, access_acl) # <<<<<<<<<<<<<<
5785 * finally:
5786 * acl_free(access_acl)
5787 */
5788 if (unlikely(__pyx_v_p == Py_None)) {
5789 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
5790 __PYX_ERR(0, 220, __pyx_L7_error)
5791 }
5792 __pyx_t_7 = __Pyx_PyBytes_AsString(__pyx_v_p); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 220, __pyx_L7_error)
5793 (void)(acl_set_file(__pyx_t_7, ACL_TYPE_ACCESS, __pyx_v_access_acl));
5794
5795 /* "borg/platform/linux.pyx":219
5796 * try:
5797 * access_acl = acl_from_text(<bytes>converter(access_text))
5798 * if access_acl: # <<<<<<<<<<<<<<
5799 * acl_set_file(p, ACL_TYPE_ACCESS, access_acl)
5800 * finally:
5801 */
5802 }
5803 }
5804
5805 /* "borg/platform/linux.pyx":222
5806 * acl_set_file(p, ACL_TYPE_ACCESS, access_acl)
5807 * finally:
5808 * acl_free(access_acl) # <<<<<<<<<<<<<<
5809 * if default_text:
5810 * try:
5811 */
5812 /*finally:*/ {
5813 /*normal exit:*/{
5814 (void)(acl_free(__pyx_v_access_acl));
5815 goto __pyx_L8;
5816 }
5817 __pyx_L7_error:;
5818 /*exception exit:*/{
5819 __Pyx_PyThreadState_declare
5820 __Pyx_PyThreadState_assign
5821 __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
5822 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
5823 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5824 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5825 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5826 if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
5827 if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13) < 0)) __Pyx_ErrFetch(&__pyx_t_11, &__pyx_t_12, &__pyx_t_13);
5828 __Pyx_XGOTREF(__pyx_t_11);
5829 __Pyx_XGOTREF(__pyx_t_12);
5830 __Pyx_XGOTREF(__pyx_t_13);
5831 __Pyx_XGOTREF(__pyx_t_14);
5832 __Pyx_XGOTREF(__pyx_t_15);
5833 __Pyx_XGOTREF(__pyx_t_16);
5834 __pyx_t_8 = __pyx_lineno; __pyx_t_9 = __pyx_clineno; __pyx_t_10 = __pyx_filename;
5835 {
5836 (void)(acl_free(__pyx_v_access_acl));
5837 }
5838 if (PY_MAJOR_VERSION >= 3) {
5839 __Pyx_XGIVEREF(__pyx_t_14);
5840 __Pyx_XGIVEREF(__pyx_t_15);
5841 __Pyx_XGIVEREF(__pyx_t_16);
5842 __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
5843 }
5844 __Pyx_XGIVEREF(__pyx_t_11);
5845 __Pyx_XGIVEREF(__pyx_t_12);
5846 __Pyx_XGIVEREF(__pyx_t_13);
5847 __Pyx_ErrRestore(__pyx_t_11, __pyx_t_12, __pyx_t_13);
5848 __pyx_t_11 = 0; __pyx_t_12 = 0; __pyx_t_13 = 0; __pyx_t_14 = 0; __pyx_t_15 = 0; __pyx_t_16 = 0;
5849 __pyx_lineno = __pyx_t_8; __pyx_clineno = __pyx_t_9; __pyx_filename = __pyx_t_10;
5850 goto __pyx_L1_error;
5851 }
5852 __pyx_L8:;
5853 }
5854
5855 /* "borg/platform/linux.pyx":216
5856 * access_text = item.get('acl_access')
5857 * default_text = item.get('acl_default')
5858 * if access_text: # <<<<<<<<<<<<<<
5859 * try:
5860 * access_acl = acl_from_text(<bytes>converter(access_text))
5861 */
5862 }
5863
5864 /* "borg/platform/linux.pyx":223
5865 * finally:
5866 * acl_free(access_acl)
5867 * if default_text: # <<<<<<<<<<<<<<
5868 * try:
5869 * default_acl = acl_from_text(<bytes>converter(default_text))
5870 */
5871 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_v_default_text); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 223, __pyx_L1_error)
5872 if (__pyx_t_5) {
5873
5874 /* "borg/platform/linux.pyx":224
5875 * acl_free(access_acl)
5876 * if default_text:
5877 * try: # <<<<<<<<<<<<<<
5878 * default_acl = acl_from_text(<bytes>converter(default_text))
5879 * if default_acl:
5880 */
5881 /*try:*/ {
5882
5883 /* "borg/platform/linux.pyx":225
5884 * if default_text:
5885 * try:
5886 * default_acl = acl_from_text(<bytes>converter(default_text)) # <<<<<<<<<<<<<<
5887 * if default_acl:
5888 * acl_set_file(p, ACL_TYPE_DEFAULT, default_acl)
5889 */
5890 __Pyx_INCREF(__pyx_v_converter);
5891 __pyx_t_1 = __pyx_v_converter; __pyx_t_3 = NULL;
5892 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_1))) {
5893 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_1);
5894 if (likely(__pyx_t_3)) {
5895 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
5896 __Pyx_INCREF(__pyx_t_3);
5897 __Pyx_INCREF(function);
5898 __Pyx_DECREF_SET(__pyx_t_1, function);
5899 }
5900 }
5901 __pyx_t_4 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_1, __pyx_t_3, __pyx_v_default_text) : __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_v_default_text);
5902 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5903 if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 225, __pyx_L14_error)
5904 __Pyx_GOTREF(__pyx_t_4);
5905 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
5906 if (unlikely(__pyx_t_4 == Py_None)) {
5907 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
5908 __PYX_ERR(0, 225, __pyx_L14_error)
5909 }
5910 __pyx_t_6 = __Pyx_PyBytes_AsString(__pyx_t_4); if (unlikely((!__pyx_t_6) && PyErr_Occurred())) __PYX_ERR(0, 225, __pyx_L14_error)
5911 __pyx_v_default_acl = acl_from_text(__pyx_t_6);
5912 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
5913
5914 /* "borg/platform/linux.pyx":226
5915 * try:
5916 * default_acl = acl_from_text(<bytes>converter(default_text))
5917 * if default_acl: # <<<<<<<<<<<<<<
5918 * acl_set_file(p, ACL_TYPE_DEFAULT, default_acl)
5919 * finally:
5920 */
5921 __pyx_t_5 = (__pyx_v_default_acl != 0);
5922 if (__pyx_t_5) {
5923
5924 /* "borg/platform/linux.pyx":227
5925 * default_acl = acl_from_text(<bytes>converter(default_text))
5926 * if default_acl:
5927 * acl_set_file(p, ACL_TYPE_DEFAULT, default_acl) # <<<<<<<<<<<<<<
5928 * finally:
5929 * acl_free(default_acl)
5930 */
5931 if (unlikely(__pyx_v_p == Py_None)) {
5932 PyErr_SetString(PyExc_TypeError, "expected bytes, NoneType found");
5933 __PYX_ERR(0, 227, __pyx_L14_error)
5934 }
5935 __pyx_t_7 = __Pyx_PyBytes_AsString(__pyx_v_p); if (unlikely((!__pyx_t_7) && PyErr_Occurred())) __PYX_ERR(0, 227, __pyx_L14_error)
5936 (void)(acl_set_file(__pyx_t_7, ACL_TYPE_DEFAULT, __pyx_v_default_acl));
5937
5938 /* "borg/platform/linux.pyx":226
5939 * try:
5940 * default_acl = acl_from_text(<bytes>converter(default_text))
5941 * if default_acl: # <<<<<<<<<<<<<<
5942 * acl_set_file(p, ACL_TYPE_DEFAULT, default_acl)
5943 * finally:
5944 */
5945 }
5946 }
5947
5948 /* "borg/platform/linux.pyx":229
5949 * acl_set_file(p, ACL_TYPE_DEFAULT, default_acl)
5950 * finally:
5951 * acl_free(default_acl) # <<<<<<<<<<<<<<
5952 *
5953 *
5954 */
5955 /*finally:*/ {
5956 /*normal exit:*/{
5957 (void)(acl_free(__pyx_v_default_acl));
5958 goto __pyx_L15;
5959 }
5960 __pyx_L14_error:;
5961 /*exception exit:*/{
5962 __Pyx_PyThreadState_declare
5963 __Pyx_PyThreadState_assign
5964 __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0;
5965 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
5966 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
5967 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
5968 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
5969 if (PY_MAJOR_VERSION >= 3) __Pyx_ExceptionSwap(&__pyx_t_13, &__pyx_t_12, &__pyx_t_11);
5970 if ((PY_MAJOR_VERSION < 3) || unlikely(__Pyx_GetException(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14) < 0)) __Pyx_ErrFetch(&__pyx_t_16, &__pyx_t_15, &__pyx_t_14);
5971 __Pyx_XGOTREF(__pyx_t_16);
5972 __Pyx_XGOTREF(__pyx_t_15);
5973 __Pyx_XGOTREF(__pyx_t_14);
5974 __Pyx_XGOTREF(__pyx_t_13);
5975 __Pyx_XGOTREF(__pyx_t_12);
5976 __Pyx_XGOTREF(__pyx_t_11);
5977 __pyx_t_9 = __pyx_lineno; __pyx_t_8 = __pyx_clineno; __pyx_t_17 = __pyx_filename;
5978 {
5979 (void)(acl_free(__pyx_v_default_acl));
5980 }
5981 if (PY_MAJOR_VERSION >= 3) {
5982 __Pyx_XGIVEREF(__pyx_t_13);
5983 __Pyx_XGIVEREF(__pyx_t_12);
5984 __Pyx_XGIVEREF(__pyx_t_11);
5985 __Pyx_ExceptionReset(__pyx_t_13, __pyx_t_12, __pyx_t_11);
5986 }
5987 __Pyx_XGIVEREF(__pyx_t_16);
5988 __Pyx_XGIVEREF(__pyx_t_15);
5989 __Pyx_XGIVEREF(__pyx_t_14);
5990 __Pyx_ErrRestore(__pyx_t_16, __pyx_t_15, __pyx_t_14);
5991 __pyx_t_16 = 0; __pyx_t_15 = 0; __pyx_t_14 = 0; __pyx_t_13 = 0; __pyx_t_12 = 0; __pyx_t_11 = 0;
5992 __pyx_lineno = __pyx_t_9; __pyx_clineno = __pyx_t_8; __pyx_filename = __pyx_t_17;
5993 goto __pyx_L1_error;
5994 }
5995 __pyx_L15:;
5996 }
5997
5998 /* "borg/platform/linux.pyx":223
5999 * finally:
6000 * acl_free(access_acl)
6001 * if default_text: # <<<<<<<<<<<<<<
6002 * try:
6003 * default_acl = acl_from_text(<bytes>converter(default_text))
6004 */
6005 }
6006
6007 /* "borg/platform/linux.pyx":201
6008 *
6009 *
6010 * def acl_set(path, item, numeric_owner=False): # <<<<<<<<<<<<<<
6011 * cdef acl_t access_acl = NULL
6012 * cdef acl_t default_acl = NULL
6013 */
6014
6015 /* function exit code */
6016 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6017 goto __pyx_L0;
6018 __pyx_L1_error:;
6019 __Pyx_XDECREF(__pyx_t_1);
6020 __Pyx_XDECREF(__pyx_t_2);
6021 __Pyx_XDECREF(__pyx_t_3);
6022 __Pyx_XDECREF(__pyx_t_4);
6023 __Pyx_AddTraceback("borg.platform.linux.acl_set", __pyx_clineno, __pyx_lineno, __pyx_filename);
6024 __pyx_r = NULL;
6025 __pyx_L0:;
6026 __Pyx_XDECREF(__pyx_v_p);
6027 __Pyx_XDECREF(__pyx_v_converter);
6028 __Pyx_XDECREF(__pyx_v_access_text);
6029 __Pyx_XDECREF(__pyx_v_default_text);
6030 __Pyx_XGIVEREF(__pyx_r);
6031 __Pyx_RefNannyFinishContext();
6032 return __pyx_r;
6033 }
6034
6035 /* "borg/platform/linux.pyx":232
6036 *
6037 *
6038 * cdef _sync_file_range(fd, offset, length, flags): # <<<<<<<<<<<<<<
6039 * assert offset & PAGE_MASK == 0, "offset %d not page-aligned" % offset
6040 * assert length & PAGE_MASK == 0, "length %d not page-aligned" % length
6041 */
6042
__pyx_f_4borg_8platform_5linux__sync_file_range(PyObject * __pyx_v_fd,PyObject * __pyx_v_offset,PyObject * __pyx_v_length,PyObject * __pyx_v_flags)6043 static PyObject *__pyx_f_4borg_8platform_5linux__sync_file_range(PyObject *__pyx_v_fd, PyObject *__pyx_v_offset, PyObject *__pyx_v_length, PyObject *__pyx_v_flags) {
6044 PyObject *__pyx_r = NULL;
6045 __Pyx_RefNannyDeclarations
6046 PyObject *__pyx_t_1 = NULL;
6047 PyObject *__pyx_t_2 = NULL;
6048 int __pyx_t_3;
6049 PyObject *__pyx_t_4 = NULL;
6050 int __pyx_t_5;
6051 PyObject *__pyx_t_6 = NULL;
6052 PyObject *__pyx_t_7 = NULL;
6053 int __pyx_lineno = 0;
6054 const char *__pyx_filename = NULL;
6055 int __pyx_clineno = 0;
6056 __Pyx_RefNannySetupContext("_sync_file_range", 0);
6057
6058 /* "borg/platform/linux.pyx":233
6059 *
6060 * cdef _sync_file_range(fd, offset, length, flags):
6061 * assert offset & PAGE_MASK == 0, "offset %d not page-aligned" % offset # <<<<<<<<<<<<<<
6062 * assert length & PAGE_MASK == 0, "length %d not page-aligned" % length
6063 * if sync_file_range(fd, offset, length, flags) != 0:
6064 */
6065 #ifndef CYTHON_WITHOUT_ASSERTIONS
6066 if (unlikely(!Py_OptimizeFlag)) {
6067 __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_4borg_8platform_5linux_PAGE_MASK); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error)
6068 __Pyx_GOTREF(__pyx_t_1);
6069 __pyx_t_2 = PyNumber_And(__pyx_v_offset, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 233, __pyx_L1_error)
6070 __Pyx_GOTREF(__pyx_t_2);
6071 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6072 __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error)
6073 __Pyx_GOTREF(__pyx_t_1);
6074 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6075 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 233, __pyx_L1_error)
6076 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6077 if (unlikely(!__pyx_t_3)) {
6078 __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_offset_d_not_page_aligned, __pyx_v_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 233, __pyx_L1_error)
6079 __Pyx_GOTREF(__pyx_t_1);
6080 PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
6081 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6082 __PYX_ERR(0, 233, __pyx_L1_error)
6083 }
6084 }
6085 #endif
6086
6087 /* "borg/platform/linux.pyx":234
6088 * cdef _sync_file_range(fd, offset, length, flags):
6089 * assert offset & PAGE_MASK == 0, "offset %d not page-aligned" % offset
6090 * assert length & PAGE_MASK == 0, "length %d not page-aligned" % length # <<<<<<<<<<<<<<
6091 * if sync_file_range(fd, offset, length, flags) != 0:
6092 * raise OSError(errno.errno, os.strerror(errno.errno))
6093 */
6094 #ifndef CYTHON_WITHOUT_ASSERTIONS
6095 if (unlikely(!Py_OptimizeFlag)) {
6096 __pyx_t_1 = __Pyx_PyInt_From_unsigned_int(__pyx_v_4borg_8platform_5linux_PAGE_MASK); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error)
6097 __Pyx_GOTREF(__pyx_t_1);
6098 __pyx_t_2 = PyNumber_And(__pyx_v_length, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 234, __pyx_L1_error)
6099 __Pyx_GOTREF(__pyx_t_2);
6100 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6101 __pyx_t_1 = __Pyx_PyInt_EqObjC(__pyx_t_2, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error)
6102 __Pyx_GOTREF(__pyx_t_1);
6103 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6104 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 234, __pyx_L1_error)
6105 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6106 if (unlikely(!__pyx_t_3)) {
6107 __pyx_t_1 = __Pyx_PyUnicode_FormatSafe(__pyx_kp_u_length_d_not_page_aligned, __pyx_v_length); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 234, __pyx_L1_error)
6108 __Pyx_GOTREF(__pyx_t_1);
6109 PyErr_SetObject(PyExc_AssertionError, __pyx_t_1);
6110 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6111 __PYX_ERR(0, 234, __pyx_L1_error)
6112 }
6113 }
6114 #endif
6115
6116 /* "borg/platform/linux.pyx":235
6117 * assert offset & PAGE_MASK == 0, "offset %d not page-aligned" % offset
6118 * assert length & PAGE_MASK == 0, "length %d not page-aligned" % length
6119 * if sync_file_range(fd, offset, length, flags) != 0: # <<<<<<<<<<<<<<
6120 * raise OSError(errno.errno, os.strerror(errno.errno))
6121 * safe_fadvise(fd, offset, length, 'DONTNEED')
6122 */
6123 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_sync_file_range); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L1_error)
6124 __Pyx_GOTREF(__pyx_t_2);
6125 __pyx_t_4 = NULL;
6126 __pyx_t_5 = 0;
6127 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
6128 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
6129 if (likely(__pyx_t_4)) {
6130 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
6131 __Pyx_INCREF(__pyx_t_4);
6132 __Pyx_INCREF(function);
6133 __Pyx_DECREF_SET(__pyx_t_2, function);
6134 __pyx_t_5 = 1;
6135 }
6136 }
6137 #if CYTHON_FAST_PYCALL
6138 if (PyFunction_Check(__pyx_t_2)) {
6139 PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_fd, __pyx_v_offset, __pyx_v_length, __pyx_v_flags};
6140 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error)
6141 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
6142 __Pyx_GOTREF(__pyx_t_1);
6143 } else
6144 #endif
6145 #if CYTHON_FAST_PYCCALL
6146 if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
6147 PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_v_fd, __pyx_v_offset, __pyx_v_length, __pyx_v_flags};
6148 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error)
6149 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
6150 __Pyx_GOTREF(__pyx_t_1);
6151 } else
6152 #endif
6153 {
6154 __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 235, __pyx_L1_error)
6155 __Pyx_GOTREF(__pyx_t_6);
6156 if (__pyx_t_4) {
6157 __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
6158 }
6159 __Pyx_INCREF(__pyx_v_fd);
6160 __Pyx_GIVEREF(__pyx_v_fd);
6161 PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_fd);
6162 __Pyx_INCREF(__pyx_v_offset);
6163 __Pyx_GIVEREF(__pyx_v_offset);
6164 PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_offset);
6165 __Pyx_INCREF(__pyx_v_length);
6166 __Pyx_GIVEREF(__pyx_v_length);
6167 PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_length);
6168 __Pyx_INCREF(__pyx_v_flags);
6169 __Pyx_GIVEREF(__pyx_v_flags);
6170 PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_v_flags);
6171 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 235, __pyx_L1_error)
6172 __Pyx_GOTREF(__pyx_t_1);
6173 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6174 }
6175 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6176 __pyx_t_2 = __Pyx_PyInt_NeObjC(__pyx_t_1, __pyx_int_0, 0, 0); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 235, __pyx_L1_error)
6177 __Pyx_GOTREF(__pyx_t_2);
6178 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6179 __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) __PYX_ERR(0, 235, __pyx_L1_error)
6180 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6181 if (unlikely(__pyx_t_3)) {
6182
6183 /* "borg/platform/linux.pyx":236
6184 * assert length & PAGE_MASK == 0, "length %d not page-aligned" % length
6185 * if sync_file_range(fd, offset, length, flags) != 0:
6186 * raise OSError(errno.errno, os.strerror(errno.errno)) # <<<<<<<<<<<<<<
6187 * safe_fadvise(fd, offset, length, 'DONTNEED')
6188 *
6189 */
6190 __pyx_t_2 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 236, __pyx_L1_error)
6191 __Pyx_GOTREF(__pyx_t_2);
6192 __Pyx_GetModuleGlobalName(__pyx_t_6, __pyx_n_s_os); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 236, __pyx_L1_error)
6193 __Pyx_GOTREF(__pyx_t_6);
6194 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_6, __pyx_n_s_strerror); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 236, __pyx_L1_error)
6195 __Pyx_GOTREF(__pyx_t_4);
6196 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6197 __pyx_t_6 = __Pyx_PyInt_From_int(errno); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 236, __pyx_L1_error)
6198 __Pyx_GOTREF(__pyx_t_6);
6199 __pyx_t_7 = NULL;
6200 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
6201 __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
6202 if (likely(__pyx_t_7)) {
6203 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6204 __Pyx_INCREF(__pyx_t_7);
6205 __Pyx_INCREF(function);
6206 __Pyx_DECREF_SET(__pyx_t_4, function);
6207 }
6208 }
6209 __pyx_t_1 = (__pyx_t_7) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_7, __pyx_t_6) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_6);
6210 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
6211 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6212 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error)
6213 __Pyx_GOTREF(__pyx_t_1);
6214 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6215 __pyx_t_4 = PyTuple_New(2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 236, __pyx_L1_error)
6216 __Pyx_GOTREF(__pyx_t_4);
6217 __Pyx_GIVEREF(__pyx_t_2);
6218 PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_2);
6219 __Pyx_GIVEREF(__pyx_t_1);
6220 PyTuple_SET_ITEM(__pyx_t_4, 1, __pyx_t_1);
6221 __pyx_t_2 = 0;
6222 __pyx_t_1 = 0;
6223 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_OSError, __pyx_t_4, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 236, __pyx_L1_error)
6224 __Pyx_GOTREF(__pyx_t_1);
6225 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6226 __Pyx_Raise(__pyx_t_1, 0, 0, 0);
6227 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6228 __PYX_ERR(0, 236, __pyx_L1_error)
6229
6230 /* "borg/platform/linux.pyx":235
6231 * assert offset & PAGE_MASK == 0, "offset %d not page-aligned" % offset
6232 * assert length & PAGE_MASK == 0, "length %d not page-aligned" % length
6233 * if sync_file_range(fd, offset, length, flags) != 0: # <<<<<<<<<<<<<<
6234 * raise OSError(errno.errno, os.strerror(errno.errno))
6235 * safe_fadvise(fd, offset, length, 'DONTNEED')
6236 */
6237 }
6238
6239 /* "borg/platform/linux.pyx":237
6240 * if sync_file_range(fd, offset, length, flags) != 0:
6241 * raise OSError(errno.errno, os.strerror(errno.errno))
6242 * safe_fadvise(fd, offset, length, 'DONTNEED') # <<<<<<<<<<<<<<
6243 *
6244 *
6245 */
6246 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_safe_fadvise); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 237, __pyx_L1_error)
6247 __Pyx_GOTREF(__pyx_t_4);
6248 __pyx_t_2 = NULL;
6249 __pyx_t_5 = 0;
6250 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_4))) {
6251 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_4);
6252 if (likely(__pyx_t_2)) {
6253 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6254 __Pyx_INCREF(__pyx_t_2);
6255 __Pyx_INCREF(function);
6256 __Pyx_DECREF_SET(__pyx_t_4, function);
6257 __pyx_t_5 = 1;
6258 }
6259 }
6260 #if CYTHON_FAST_PYCALL
6261 if (PyFunction_Check(__pyx_t_4)) {
6262 PyObject *__pyx_temp[5] = {__pyx_t_2, __pyx_v_fd, __pyx_v_offset, __pyx_v_length, __pyx_n_u_DONTNEED};
6263 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error)
6264 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6265 __Pyx_GOTREF(__pyx_t_1);
6266 } else
6267 #endif
6268 #if CYTHON_FAST_PYCCALL
6269 if (__Pyx_PyFastCFunction_Check(__pyx_t_4)) {
6270 PyObject *__pyx_temp[5] = {__pyx_t_2, __pyx_v_fd, __pyx_v_offset, __pyx_v_length, __pyx_n_u_DONTNEED};
6271 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_4, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error)
6272 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6273 __Pyx_GOTREF(__pyx_t_1);
6274 } else
6275 #endif
6276 {
6277 __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 237, __pyx_L1_error)
6278 __Pyx_GOTREF(__pyx_t_6);
6279 if (__pyx_t_2) {
6280 __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_2); __pyx_t_2 = NULL;
6281 }
6282 __Pyx_INCREF(__pyx_v_fd);
6283 __Pyx_GIVEREF(__pyx_v_fd);
6284 PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_v_fd);
6285 __Pyx_INCREF(__pyx_v_offset);
6286 __Pyx_GIVEREF(__pyx_v_offset);
6287 PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_v_offset);
6288 __Pyx_INCREF(__pyx_v_length);
6289 __Pyx_GIVEREF(__pyx_v_length);
6290 PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_v_length);
6291 __Pyx_INCREF(__pyx_n_u_DONTNEED);
6292 __Pyx_GIVEREF(__pyx_n_u_DONTNEED);
6293 PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_n_u_DONTNEED);
6294 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 237, __pyx_L1_error)
6295 __Pyx_GOTREF(__pyx_t_1);
6296 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6297 }
6298 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6299 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6300
6301 /* "borg/platform/linux.pyx":232
6302 *
6303 *
6304 * cdef _sync_file_range(fd, offset, length, flags): # <<<<<<<<<<<<<<
6305 * assert offset & PAGE_MASK == 0, "offset %d not page-aligned" % offset
6306 * assert length & PAGE_MASK == 0, "length %d not page-aligned" % length
6307 */
6308
6309 /* function exit code */
6310 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6311 goto __pyx_L0;
6312 __pyx_L1_error:;
6313 __Pyx_XDECREF(__pyx_t_1);
6314 __Pyx_XDECREF(__pyx_t_2);
6315 __Pyx_XDECREF(__pyx_t_4);
6316 __Pyx_XDECREF(__pyx_t_6);
6317 __Pyx_XDECREF(__pyx_t_7);
6318 __Pyx_AddTraceback("borg.platform.linux._sync_file_range", __pyx_clineno, __pyx_lineno, __pyx_filename);
6319 __pyx_r = 0;
6320 __pyx_L0:;
6321 __Pyx_XGIVEREF(__pyx_r);
6322 __Pyx_RefNannyFinishContext();
6323 return __pyx_r;
6324 }
6325
6326 /* "borg/platform/linux.pyx":259
6327 * """
6328 *
6329 * def __init__(self, path, binary=False): # <<<<<<<<<<<<<<
6330 * super().__init__(path, binary)
6331 * self.offset = 0
6332 */
6333
6334 /* Python wrapper */
6335 static PyObject *__pyx_pw_4borg_8platform_5linux_8SyncFile_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6336 static PyMethodDef __pyx_mdef_4borg_8platform_5linux_8SyncFile_1__init__ = {"__init__", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4borg_8platform_5linux_8SyncFile_1__init__, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_4borg_8platform_5linux_8SyncFile_1__init__(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6337 static PyObject *__pyx_pw_4borg_8platform_5linux_8SyncFile_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6338 PyObject *__pyx_v_self = 0;
6339 PyObject *__pyx_v_path = 0;
6340 PyObject *__pyx_v_binary = 0;
6341 int __pyx_lineno = 0;
6342 const char *__pyx_filename = NULL;
6343 int __pyx_clineno = 0;
6344 PyObject *__pyx_r = 0;
6345 __Pyx_RefNannyDeclarations
6346 __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
6347 {
6348 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_path,&__pyx_n_s_binary,0};
6349 PyObject* values[3] = {0,0,0};
6350 values[2] = ((PyObject *)((PyObject *)Py_False));
6351 if (unlikely(__pyx_kwds)) {
6352 Py_ssize_t kw_args;
6353 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6354 switch (pos_args) {
6355 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6356 CYTHON_FALLTHROUGH;
6357 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6358 CYTHON_FALLTHROUGH;
6359 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6360 CYTHON_FALLTHROUGH;
6361 case 0: break;
6362 default: goto __pyx_L5_argtuple_error;
6363 }
6364 kw_args = PyDict_Size(__pyx_kwds);
6365 switch (pos_args) {
6366 case 0:
6367 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
6368 else goto __pyx_L5_argtuple_error;
6369 CYTHON_FALLTHROUGH;
6370 case 1:
6371 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_path)) != 0)) kw_args--;
6372 else {
6373 __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); __PYX_ERR(0, 259, __pyx_L3_error)
6374 }
6375 CYTHON_FALLTHROUGH;
6376 case 2:
6377 if (kw_args > 0) {
6378 PyObject* value = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_binary);
6379 if (value) { values[2] = value; kw_args--; }
6380 }
6381 }
6382 if (unlikely(kw_args > 0)) {
6383 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) __PYX_ERR(0, 259, __pyx_L3_error)
6384 }
6385 } else {
6386 switch (PyTuple_GET_SIZE(__pyx_args)) {
6387 case 3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
6388 CYTHON_FALLTHROUGH;
6389 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6390 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6391 break;
6392 default: goto __pyx_L5_argtuple_error;
6393 }
6394 }
6395 __pyx_v_self = values[0];
6396 __pyx_v_path = values[1];
6397 __pyx_v_binary = values[2];
6398 }
6399 goto __pyx_L4_argument_unpacking_done;
6400 __pyx_L5_argtuple_error:;
6401 __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 259, __pyx_L3_error)
6402 __pyx_L3_error:;
6403 __Pyx_AddTraceback("borg.platform.linux.SyncFile.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
6404 __Pyx_RefNannyFinishContext();
6405 return NULL;
6406 __pyx_L4_argument_unpacking_done:;
6407 __pyx_r = __pyx_pf_4borg_8platform_5linux_8SyncFile___init__(__pyx_self, __pyx_v_self, __pyx_v_path, __pyx_v_binary);
6408
6409 /* function exit code */
6410 __Pyx_RefNannyFinishContext();
6411 return __pyx_r;
6412 }
6413
__pyx_pf_4borg_8platform_5linux_8SyncFile___init__(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_self,PyObject * __pyx_v_path,PyObject * __pyx_v_binary)6414 static PyObject *__pyx_pf_4borg_8platform_5linux_8SyncFile___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_path, PyObject *__pyx_v_binary) {
6415 PyObject *__pyx_r = NULL;
6416 __Pyx_RefNannyDeclarations
6417 PyObject *__pyx_t_1 = NULL;
6418 PyObject *__pyx_t_2 = NULL;
6419 PyObject *__pyx_t_3 = NULL;
6420 int __pyx_t_4;
6421 PyObject *__pyx_t_5 = NULL;
6422 int __pyx_lineno = 0;
6423 const char *__pyx_filename = NULL;
6424 int __pyx_clineno = 0;
6425 __Pyx_RefNannySetupContext("__init__", 0);
6426
6427 /* "borg/platform/linux.pyx":260
6428 *
6429 * def __init__(self, path, binary=False):
6430 * super().__init__(path, binary) # <<<<<<<<<<<<<<
6431 * self.offset = 0
6432 * self.write_window = (16 * 1024 ** 2) & ~PAGE_MASK
6433 */
6434 __pyx_t_2 = __Pyx_CyFunction_GetClassObj(__pyx_self);
6435 if (!__pyx_t_2) { PyErr_SetString(PyExc_SystemError, "super(): empty __class__ cell"); __PYX_ERR(0, 260, __pyx_L1_error) }
6436 __Pyx_INCREF(__pyx_t_2);
6437 __pyx_t_3 = PyTuple_New(2); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error)
6438 __Pyx_GOTREF(__pyx_t_3);
6439 __Pyx_GIVEREF(__pyx_t_2);
6440 PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_2);
6441 __Pyx_INCREF(__pyx_v_self);
6442 __Pyx_GIVEREF(__pyx_v_self);
6443 PyTuple_SET_ITEM(__pyx_t_3, 1, __pyx_v_self);
6444 __pyx_t_2 = 0;
6445 __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_super, __pyx_t_3, NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 260, __pyx_L1_error)
6446 __Pyx_GOTREF(__pyx_t_2);
6447 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6448 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_init); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 260, __pyx_L1_error)
6449 __Pyx_GOTREF(__pyx_t_3);
6450 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6451 __pyx_t_2 = NULL;
6452 __pyx_t_4 = 0;
6453 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
6454 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
6455 if (likely(__pyx_t_2)) {
6456 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
6457 __Pyx_INCREF(__pyx_t_2);
6458 __Pyx_INCREF(function);
6459 __Pyx_DECREF_SET(__pyx_t_3, function);
6460 __pyx_t_4 = 1;
6461 }
6462 }
6463 #if CYTHON_FAST_PYCALL
6464 if (PyFunction_Check(__pyx_t_3)) {
6465 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_path, __pyx_v_binary};
6466 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error)
6467 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6468 __Pyx_GOTREF(__pyx_t_1);
6469 } else
6470 #endif
6471 #if CYTHON_FAST_PYCCALL
6472 if (__Pyx_PyFastCFunction_Check(__pyx_t_3)) {
6473 PyObject *__pyx_temp[3] = {__pyx_t_2, __pyx_v_path, __pyx_v_binary};
6474 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_3, __pyx_temp+1-__pyx_t_4, 2+__pyx_t_4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error)
6475 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6476 __Pyx_GOTREF(__pyx_t_1);
6477 } else
6478 #endif
6479 {
6480 __pyx_t_5 = PyTuple_New(2+__pyx_t_4); if (unlikely(!__pyx_t_5)) __PYX_ERR(0, 260, __pyx_L1_error)
6481 __Pyx_GOTREF(__pyx_t_5);
6482 if (__pyx_t_2) {
6483 __Pyx_GIVEREF(__pyx_t_2); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2); __pyx_t_2 = NULL;
6484 }
6485 __Pyx_INCREF(__pyx_v_path);
6486 __Pyx_GIVEREF(__pyx_v_path);
6487 PyTuple_SET_ITEM(__pyx_t_5, 0+__pyx_t_4, __pyx_v_path);
6488 __Pyx_INCREF(__pyx_v_binary);
6489 __Pyx_GIVEREF(__pyx_v_binary);
6490 PyTuple_SET_ITEM(__pyx_t_5, 1+__pyx_t_4, __pyx_v_binary);
6491 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 260, __pyx_L1_error)
6492 __Pyx_GOTREF(__pyx_t_1);
6493 __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
6494 }
6495 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6496 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6497
6498 /* "borg/platform/linux.pyx":261
6499 * def __init__(self, path, binary=False):
6500 * super().__init__(path, binary)
6501 * self.offset = 0 # <<<<<<<<<<<<<<
6502 * self.write_window = (16 * 1024 ** 2) & ~PAGE_MASK
6503 * self.last_sync = 0
6504 */
6505 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_offset, __pyx_int_0) < 0) __PYX_ERR(0, 261, __pyx_L1_error)
6506
6507 /* "borg/platform/linux.pyx":262
6508 * super().__init__(path, binary)
6509 * self.offset = 0
6510 * self.write_window = (16 * 1024 ** 2) & ~PAGE_MASK # <<<<<<<<<<<<<<
6511 * self.last_sync = 0
6512 * self.pending_sync = None
6513 */
6514 __pyx_t_1 = __Pyx_PyInt_From_long((0x1000000 & (~__pyx_v_4borg_8platform_5linux_PAGE_MASK))); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 262, __pyx_L1_error)
6515 __Pyx_GOTREF(__pyx_t_1);
6516 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_write_window, __pyx_t_1) < 0) __PYX_ERR(0, 262, __pyx_L1_error)
6517 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6518
6519 /* "borg/platform/linux.pyx":263
6520 * self.offset = 0
6521 * self.write_window = (16 * 1024 ** 2) & ~PAGE_MASK
6522 * self.last_sync = 0 # <<<<<<<<<<<<<<
6523 * self.pending_sync = None
6524 *
6525 */
6526 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_last_sync, __pyx_int_0) < 0) __PYX_ERR(0, 263, __pyx_L1_error)
6527
6528 /* "borg/platform/linux.pyx":264
6529 * self.write_window = (16 * 1024 ** 2) & ~PAGE_MASK
6530 * self.last_sync = 0
6531 * self.pending_sync = None # <<<<<<<<<<<<<<
6532 *
6533 * def write(self, data):
6534 */
6535 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pending_sync, Py_None) < 0) __PYX_ERR(0, 264, __pyx_L1_error)
6536
6537 /* "borg/platform/linux.pyx":259
6538 * """
6539 *
6540 * def __init__(self, path, binary=False): # <<<<<<<<<<<<<<
6541 * super().__init__(path, binary)
6542 * self.offset = 0
6543 */
6544
6545 /* function exit code */
6546 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6547 goto __pyx_L0;
6548 __pyx_L1_error:;
6549 __Pyx_XDECREF(__pyx_t_1);
6550 __Pyx_XDECREF(__pyx_t_2);
6551 __Pyx_XDECREF(__pyx_t_3);
6552 __Pyx_XDECREF(__pyx_t_5);
6553 __Pyx_AddTraceback("borg.platform.linux.SyncFile.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
6554 __pyx_r = NULL;
6555 __pyx_L0:;
6556 __Pyx_XGIVEREF(__pyx_r);
6557 __Pyx_RefNannyFinishContext();
6558 return __pyx_r;
6559 }
6560
6561 /* "borg/platform/linux.pyx":266
6562 * self.pending_sync = None
6563 *
6564 * def write(self, data): # <<<<<<<<<<<<<<
6565 * self.offset += self.fd.write(data)
6566 * offset = self.offset & ~PAGE_MASK
6567 */
6568
6569 /* Python wrapper */
6570 static PyObject *__pyx_pw_4borg_8platform_5linux_8SyncFile_3write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
6571 static PyMethodDef __pyx_mdef_4borg_8platform_5linux_8SyncFile_3write = {"write", (PyCFunction)(void*)(PyCFunctionWithKeywords)__pyx_pw_4borg_8platform_5linux_8SyncFile_3write, METH_VARARGS|METH_KEYWORDS, 0};
__pyx_pw_4borg_8platform_5linux_8SyncFile_3write(PyObject * __pyx_self,PyObject * __pyx_args,PyObject * __pyx_kwds)6572 static PyObject *__pyx_pw_4borg_8platform_5linux_8SyncFile_3write(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
6573 PyObject *__pyx_v_self = 0;
6574 PyObject *__pyx_v_data = 0;
6575 int __pyx_lineno = 0;
6576 const char *__pyx_filename = NULL;
6577 int __pyx_clineno = 0;
6578 PyObject *__pyx_r = 0;
6579 __Pyx_RefNannyDeclarations
6580 __Pyx_RefNannySetupContext("write (wrapper)", 0);
6581 {
6582 static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_data,0};
6583 PyObject* values[2] = {0,0};
6584 if (unlikely(__pyx_kwds)) {
6585 Py_ssize_t kw_args;
6586 const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
6587 switch (pos_args) {
6588 case 2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6589 CYTHON_FALLTHROUGH;
6590 case 1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6591 CYTHON_FALLTHROUGH;
6592 case 0: break;
6593 default: goto __pyx_L5_argtuple_error;
6594 }
6595 kw_args = PyDict_Size(__pyx_kwds);
6596 switch (pos_args) {
6597 case 0:
6598 if (likely((values[0] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
6599 else goto __pyx_L5_argtuple_error;
6600 CYTHON_FALLTHROUGH;
6601 case 1:
6602 if (likely((values[1] = __Pyx_PyDict_GetItemStr(__pyx_kwds, __pyx_n_s_data)) != 0)) kw_args--;
6603 else {
6604 __Pyx_RaiseArgtupleInvalid("write", 1, 2, 2, 1); __PYX_ERR(0, 266, __pyx_L3_error)
6605 }
6606 }
6607 if (unlikely(kw_args > 0)) {
6608 if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "write") < 0)) __PYX_ERR(0, 266, __pyx_L3_error)
6609 }
6610 } else if (PyTuple_GET_SIZE(__pyx_args) != 2) {
6611 goto __pyx_L5_argtuple_error;
6612 } else {
6613 values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
6614 values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
6615 }
6616 __pyx_v_self = values[0];
6617 __pyx_v_data = values[1];
6618 }
6619 goto __pyx_L4_argument_unpacking_done;
6620 __pyx_L5_argtuple_error:;
6621 __Pyx_RaiseArgtupleInvalid("write", 1, 2, 2, PyTuple_GET_SIZE(__pyx_args)); __PYX_ERR(0, 266, __pyx_L3_error)
6622 __pyx_L3_error:;
6623 __Pyx_AddTraceback("borg.platform.linux.SyncFile.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
6624 __Pyx_RefNannyFinishContext();
6625 return NULL;
6626 __pyx_L4_argument_unpacking_done:;
6627 __pyx_r = __pyx_pf_4borg_8platform_5linux_8SyncFile_2write(__pyx_self, __pyx_v_self, __pyx_v_data);
6628
6629 /* function exit code */
6630 __Pyx_RefNannyFinishContext();
6631 return __pyx_r;
6632 }
6633
__pyx_pf_4borg_8platform_5linux_8SyncFile_2write(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_self,PyObject * __pyx_v_data)6634 static PyObject *__pyx_pf_4borg_8platform_5linux_8SyncFile_2write(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_data) {
6635 PyObject *__pyx_v_offset = NULL;
6636 PyObject *__pyx_r = NULL;
6637 __Pyx_RefNannyDeclarations
6638 PyObject *__pyx_t_1 = NULL;
6639 PyObject *__pyx_t_2 = NULL;
6640 PyObject *__pyx_t_3 = NULL;
6641 PyObject *__pyx_t_4 = NULL;
6642 int __pyx_t_5;
6643 PyObject *__pyx_t_6 = NULL;
6644 int __pyx_t_7;
6645 PyObject *__pyx_t_8 = NULL;
6646 int __pyx_lineno = 0;
6647 const char *__pyx_filename = NULL;
6648 int __pyx_clineno = 0;
6649 __Pyx_RefNannySetupContext("write", 0);
6650
6651 /* "borg/platform/linux.pyx":267
6652 *
6653 * def write(self, data):
6654 * self.offset += self.fd.write(data) # <<<<<<<<<<<<<<
6655 * offset = self.offset & ~PAGE_MASK
6656 * if offset >= self.last_sync + self.write_window:
6657 */
6658 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offset); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 267, __pyx_L1_error)
6659 __Pyx_GOTREF(__pyx_t_1);
6660 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fd); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 267, __pyx_L1_error)
6661 __Pyx_GOTREF(__pyx_t_3);
6662 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_write); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error)
6663 __Pyx_GOTREF(__pyx_t_4);
6664 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6665 __pyx_t_3 = NULL;
6666 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_4))) {
6667 __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_4);
6668 if (likely(__pyx_t_3)) {
6669 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
6670 __Pyx_INCREF(__pyx_t_3);
6671 __Pyx_INCREF(function);
6672 __Pyx_DECREF_SET(__pyx_t_4, function);
6673 }
6674 }
6675 __pyx_t_2 = (__pyx_t_3) ? __Pyx_PyObject_Call2Args(__pyx_t_4, __pyx_t_3, __pyx_v_data) : __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_data);
6676 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
6677 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 267, __pyx_L1_error)
6678 __Pyx_GOTREF(__pyx_t_2);
6679 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6680 __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 267, __pyx_L1_error)
6681 __Pyx_GOTREF(__pyx_t_4);
6682 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6683 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6684 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_offset, __pyx_t_4) < 0) __PYX_ERR(0, 267, __pyx_L1_error)
6685 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6686
6687 /* "borg/platform/linux.pyx":268
6688 * def write(self, data):
6689 * self.offset += self.fd.write(data)
6690 * offset = self.offset & ~PAGE_MASK # <<<<<<<<<<<<<<
6691 * if offset >= self.last_sync + self.write_window:
6692 * self.fd.flush()
6693 */
6694 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_offset); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 268, __pyx_L1_error)
6695 __Pyx_GOTREF(__pyx_t_4);
6696 __pyx_t_2 = __Pyx_PyInt_From_unsigned_int((~__pyx_v_4borg_8platform_5linux_PAGE_MASK)); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 268, __pyx_L1_error)
6697 __Pyx_GOTREF(__pyx_t_2);
6698 __pyx_t_1 = PyNumber_And(__pyx_t_4, __pyx_t_2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 268, __pyx_L1_error)
6699 __Pyx_GOTREF(__pyx_t_1);
6700 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6701 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6702 __pyx_v_offset = __pyx_t_1;
6703 __pyx_t_1 = 0;
6704
6705 /* "borg/platform/linux.pyx":269
6706 * self.offset += self.fd.write(data)
6707 * offset = self.offset & ~PAGE_MASK
6708 * if offset >= self.last_sync + self.write_window: # <<<<<<<<<<<<<<
6709 * self.fd.flush()
6710 * _sync_file_range(self.fileno, self.last_sync, offset - self.last_sync, SYNC_FILE_RANGE_WRITE)
6711 */
6712 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_sync); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 269, __pyx_L1_error)
6713 __Pyx_GOTREF(__pyx_t_1);
6714 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_write_window); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
6715 __Pyx_GOTREF(__pyx_t_2);
6716 __pyx_t_4 = PyNumber_Add(__pyx_t_1, __pyx_t_2); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 269, __pyx_L1_error)
6717 __Pyx_GOTREF(__pyx_t_4);
6718 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6719 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6720 __pyx_t_2 = PyObject_RichCompare(__pyx_v_offset, __pyx_t_4, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 269, __pyx_L1_error)
6721 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6722 __pyx_t_5 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_5 < 0)) __PYX_ERR(0, 269, __pyx_L1_error)
6723 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6724 if (__pyx_t_5) {
6725
6726 /* "borg/platform/linux.pyx":270
6727 * offset = self.offset & ~PAGE_MASK
6728 * if offset >= self.last_sync + self.write_window:
6729 * self.fd.flush() # <<<<<<<<<<<<<<
6730 * _sync_file_range(self.fileno, self.last_sync, offset - self.last_sync, SYNC_FILE_RANGE_WRITE)
6731 * if self.pending_sync is not None:
6732 */
6733 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fd); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 270, __pyx_L1_error)
6734 __Pyx_GOTREF(__pyx_t_4);
6735 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_4, __pyx_n_s_flush); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 270, __pyx_L1_error)
6736 __Pyx_GOTREF(__pyx_t_1);
6737 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6738 __pyx_t_4 = NULL;
6739 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_1))) {
6740 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
6741 if (likely(__pyx_t_4)) {
6742 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
6743 __Pyx_INCREF(__pyx_t_4);
6744 __Pyx_INCREF(function);
6745 __Pyx_DECREF_SET(__pyx_t_1, function);
6746 }
6747 }
6748 __pyx_t_2 = (__pyx_t_4) ? __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_4) : __Pyx_PyObject_CallNoArg(__pyx_t_1);
6749 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
6750 if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 270, __pyx_L1_error)
6751 __Pyx_GOTREF(__pyx_t_2);
6752 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6753 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6754
6755 /* "borg/platform/linux.pyx":271
6756 * if offset >= self.last_sync + self.write_window:
6757 * self.fd.flush()
6758 * _sync_file_range(self.fileno, self.last_sync, offset - self.last_sync, SYNC_FILE_RANGE_WRITE) # <<<<<<<<<<<<<<
6759 * if self.pending_sync is not None:
6760 * _sync_file_range(self.fileno, self.pending_sync, self.last_sync - self.pending_sync,
6761 */
6762 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fileno); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 271, __pyx_L1_error)
6763 __Pyx_GOTREF(__pyx_t_2);
6764 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_sync); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 271, __pyx_L1_error)
6765 __Pyx_GOTREF(__pyx_t_1);
6766 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_sync); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error)
6767 __Pyx_GOTREF(__pyx_t_4);
6768 __pyx_t_3 = PyNumber_Subtract(__pyx_v_offset, __pyx_t_4); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 271, __pyx_L1_error)
6769 __Pyx_GOTREF(__pyx_t_3);
6770 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6771 __Pyx_GetModuleGlobalName(__pyx_t_4, __pyx_n_s_SYNC_FILE_RANGE_WRITE); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 271, __pyx_L1_error)
6772 __Pyx_GOTREF(__pyx_t_4);
6773 __pyx_t_6 = __pyx_f_4borg_8platform_5linux__sync_file_range(__pyx_t_2, __pyx_t_1, __pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 271, __pyx_L1_error)
6774 __Pyx_GOTREF(__pyx_t_6);
6775 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6776 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6777 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6778 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6779 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6780
6781 /* "borg/platform/linux.pyx":272
6782 * self.fd.flush()
6783 * _sync_file_range(self.fileno, self.last_sync, offset - self.last_sync, SYNC_FILE_RANGE_WRITE)
6784 * if self.pending_sync is not None: # <<<<<<<<<<<<<<
6785 * _sync_file_range(self.fileno, self.pending_sync, self.last_sync - self.pending_sync,
6786 * SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WAIT_AFTER)
6787 */
6788 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pending_sync); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 272, __pyx_L1_error)
6789 __Pyx_GOTREF(__pyx_t_6);
6790 __pyx_t_5 = (__pyx_t_6 != Py_None);
6791 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6792 __pyx_t_7 = (__pyx_t_5 != 0);
6793 if (__pyx_t_7) {
6794
6795 /* "borg/platform/linux.pyx":273
6796 * _sync_file_range(self.fileno, self.last_sync, offset - self.last_sync, SYNC_FILE_RANGE_WRITE)
6797 * if self.pending_sync is not None:
6798 * _sync_file_range(self.fileno, self.pending_sync, self.last_sync - self.pending_sync, # <<<<<<<<<<<<<<
6799 * SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WAIT_AFTER)
6800 * self.pending_sync = self.last_sync
6801 */
6802 __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fileno); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 273, __pyx_L1_error)
6803 __Pyx_GOTREF(__pyx_t_6);
6804 __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pending_sync); if (unlikely(!__pyx_t_4)) __PYX_ERR(0, 273, __pyx_L1_error)
6805 __Pyx_GOTREF(__pyx_t_4);
6806 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_sync); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error)
6807 __Pyx_GOTREF(__pyx_t_3);
6808 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_pending_sync); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 273, __pyx_L1_error)
6809 __Pyx_GOTREF(__pyx_t_1);
6810 __pyx_t_2 = PyNumber_Subtract(__pyx_t_3, __pyx_t_1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 273, __pyx_L1_error)
6811 __Pyx_GOTREF(__pyx_t_2);
6812 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6813 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6814
6815 /* "borg/platform/linux.pyx":274
6816 * if self.pending_sync is not None:
6817 * _sync_file_range(self.fileno, self.pending_sync, self.last_sync - self.pending_sync,
6818 * SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WAIT_AFTER) # <<<<<<<<<<<<<<
6819 * self.pending_sync = self.last_sync
6820 * self.last_sync = offset
6821 */
6822 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_SYNC_FILE_RANGE_WRITE); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
6823 __Pyx_GOTREF(__pyx_t_1);
6824 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_SYNC_FILE_RANGE_WAIT_BEFORE); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
6825 __Pyx_GOTREF(__pyx_t_3);
6826 __pyx_t_8 = PyNumber_Or(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_8)) __PYX_ERR(0, 274, __pyx_L1_error)
6827 __Pyx_GOTREF(__pyx_t_8);
6828 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6829 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6830 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_SYNC_FILE_RANGE_WAIT_AFTER); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 274, __pyx_L1_error)
6831 __Pyx_GOTREF(__pyx_t_3);
6832 __pyx_t_1 = PyNumber_Or(__pyx_t_8, __pyx_t_3); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 274, __pyx_L1_error)
6833 __Pyx_GOTREF(__pyx_t_1);
6834 __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
6835 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6836
6837 /* "borg/platform/linux.pyx":273
6838 * _sync_file_range(self.fileno, self.last_sync, offset - self.last_sync, SYNC_FILE_RANGE_WRITE)
6839 * if self.pending_sync is not None:
6840 * _sync_file_range(self.fileno, self.pending_sync, self.last_sync - self.pending_sync, # <<<<<<<<<<<<<<
6841 * SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WAIT_AFTER)
6842 * self.pending_sync = self.last_sync
6843 */
6844 __pyx_t_3 = __pyx_f_4borg_8platform_5linux__sync_file_range(__pyx_t_6, __pyx_t_4, __pyx_t_2, __pyx_t_1); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 273, __pyx_L1_error)
6845 __Pyx_GOTREF(__pyx_t_3);
6846 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
6847 __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
6848 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6849 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6850 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6851
6852 /* "borg/platform/linux.pyx":272
6853 * self.fd.flush()
6854 * _sync_file_range(self.fileno, self.last_sync, offset - self.last_sync, SYNC_FILE_RANGE_WRITE)
6855 * if self.pending_sync is not None: # <<<<<<<<<<<<<<
6856 * _sync_file_range(self.fileno, self.pending_sync, self.last_sync - self.pending_sync,
6857 * SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WAIT_AFTER)
6858 */
6859 }
6860
6861 /* "borg/platform/linux.pyx":275
6862 * _sync_file_range(self.fileno, self.pending_sync, self.last_sync - self.pending_sync,
6863 * SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WAIT_AFTER)
6864 * self.pending_sync = self.last_sync # <<<<<<<<<<<<<<
6865 * self.last_sync = offset
6866 *
6867 */
6868 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_last_sync); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 275, __pyx_L1_error)
6869 __Pyx_GOTREF(__pyx_t_3);
6870 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_pending_sync, __pyx_t_3) < 0) __PYX_ERR(0, 275, __pyx_L1_error)
6871 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6872
6873 /* "borg/platform/linux.pyx":276
6874 * SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_BEFORE | SYNC_FILE_RANGE_WAIT_AFTER)
6875 * self.pending_sync = self.last_sync
6876 * self.last_sync = offset # <<<<<<<<<<<<<<
6877 *
6878 * def sync(self):
6879 */
6880 if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_last_sync, __pyx_v_offset) < 0) __PYX_ERR(0, 276, __pyx_L1_error)
6881
6882 /* "borg/platform/linux.pyx":269
6883 * self.offset += self.fd.write(data)
6884 * offset = self.offset & ~PAGE_MASK
6885 * if offset >= self.last_sync + self.write_window: # <<<<<<<<<<<<<<
6886 * self.fd.flush()
6887 * _sync_file_range(self.fileno, self.last_sync, offset - self.last_sync, SYNC_FILE_RANGE_WRITE)
6888 */
6889 }
6890
6891 /* "borg/platform/linux.pyx":266
6892 * self.pending_sync = None
6893 *
6894 * def write(self, data): # <<<<<<<<<<<<<<
6895 * self.offset += self.fd.write(data)
6896 * offset = self.offset & ~PAGE_MASK
6897 */
6898
6899 /* function exit code */
6900 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
6901 goto __pyx_L0;
6902 __pyx_L1_error:;
6903 __Pyx_XDECREF(__pyx_t_1);
6904 __Pyx_XDECREF(__pyx_t_2);
6905 __Pyx_XDECREF(__pyx_t_3);
6906 __Pyx_XDECREF(__pyx_t_4);
6907 __Pyx_XDECREF(__pyx_t_6);
6908 __Pyx_XDECREF(__pyx_t_8);
6909 __Pyx_AddTraceback("borg.platform.linux.SyncFile.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
6910 __pyx_r = NULL;
6911 __pyx_L0:;
6912 __Pyx_XDECREF(__pyx_v_offset);
6913 __Pyx_XGIVEREF(__pyx_r);
6914 __Pyx_RefNannyFinishContext();
6915 return __pyx_r;
6916 }
6917
6918 /* "borg/platform/linux.pyx":278
6919 * self.last_sync = offset
6920 *
6921 * def sync(self): # <<<<<<<<<<<<<<
6922 * self.fd.flush()
6923 * os.fdatasync(self.fileno)
6924 */
6925
6926 /* Python wrapper */
6927 static PyObject *__pyx_pw_4borg_8platform_5linux_8SyncFile_5sync(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
6928 static PyMethodDef __pyx_mdef_4borg_8platform_5linux_8SyncFile_5sync = {"sync", (PyCFunction)__pyx_pw_4borg_8platform_5linux_8SyncFile_5sync, METH_O, 0};
__pyx_pw_4borg_8platform_5linux_8SyncFile_5sync(PyObject * __pyx_self,PyObject * __pyx_v_self)6929 static PyObject *__pyx_pw_4borg_8platform_5linux_8SyncFile_5sync(PyObject *__pyx_self, PyObject *__pyx_v_self) {
6930 PyObject *__pyx_r = 0;
6931 __Pyx_RefNannyDeclarations
6932 __Pyx_RefNannySetupContext("sync (wrapper)", 0);
6933 __pyx_r = __pyx_pf_4borg_8platform_5linux_8SyncFile_4sync(__pyx_self, ((PyObject *)__pyx_v_self));
6934
6935 /* function exit code */
6936 __Pyx_RefNannyFinishContext();
6937 return __pyx_r;
6938 }
6939
__pyx_pf_4borg_8platform_5linux_8SyncFile_4sync(CYTHON_UNUSED PyObject * __pyx_self,PyObject * __pyx_v_self)6940 static PyObject *__pyx_pf_4borg_8platform_5linux_8SyncFile_4sync(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
6941 PyObject *__pyx_r = NULL;
6942 __Pyx_RefNannyDeclarations
6943 PyObject *__pyx_t_1 = NULL;
6944 PyObject *__pyx_t_2 = NULL;
6945 PyObject *__pyx_t_3 = NULL;
6946 PyObject *__pyx_t_4 = NULL;
6947 int __pyx_t_5;
6948 PyObject *__pyx_t_6 = NULL;
6949 int __pyx_lineno = 0;
6950 const char *__pyx_filename = NULL;
6951 int __pyx_clineno = 0;
6952 __Pyx_RefNannySetupContext("sync", 0);
6953
6954 /* "borg/platform/linux.pyx":279
6955 *
6956 * def sync(self):
6957 * self.fd.flush() # <<<<<<<<<<<<<<
6958 * os.fdatasync(self.fileno)
6959 * # tell the OS that it does not need to cache what we just wrote,
6960 */
6961 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fd); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 279, __pyx_L1_error)
6962 __Pyx_GOTREF(__pyx_t_2);
6963 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_t_2, __pyx_n_s_flush); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 279, __pyx_L1_error)
6964 __Pyx_GOTREF(__pyx_t_3);
6965 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
6966 __pyx_t_2 = NULL;
6967 if (CYTHON_UNPACK_METHODS && likely(PyMethod_Check(__pyx_t_3))) {
6968 __pyx_t_2 = PyMethod_GET_SELF(__pyx_t_3);
6969 if (likely(__pyx_t_2)) {
6970 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
6971 __Pyx_INCREF(__pyx_t_2);
6972 __Pyx_INCREF(function);
6973 __Pyx_DECREF_SET(__pyx_t_3, function);
6974 }
6975 }
6976 __pyx_t_1 = (__pyx_t_2) ? __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_t_2) : __Pyx_PyObject_CallNoArg(__pyx_t_3);
6977 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
6978 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 279, __pyx_L1_error)
6979 __Pyx_GOTREF(__pyx_t_1);
6980 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6981 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
6982
6983 /* "borg/platform/linux.pyx":280
6984 * def sync(self):
6985 * self.fd.flush()
6986 * os.fdatasync(self.fileno) # <<<<<<<<<<<<<<
6987 * # tell the OS that it does not need to cache what we just wrote,
6988 * # avoids spoiling the cache for the OS and other processes.
6989 */
6990 __Pyx_GetModuleGlobalName(__pyx_t_3, __pyx_n_s_os); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
6991 __Pyx_GOTREF(__pyx_t_3);
6992 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_3, __pyx_n_s_fdatasync); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 280, __pyx_L1_error)
6993 __Pyx_GOTREF(__pyx_t_2);
6994 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
6995 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fileno); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 280, __pyx_L1_error)
6996 __Pyx_GOTREF(__pyx_t_3);
6997 __pyx_t_4 = NULL;
6998 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
6999 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
7000 if (likely(__pyx_t_4)) {
7001 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
7002 __Pyx_INCREF(__pyx_t_4);
7003 __Pyx_INCREF(function);
7004 __Pyx_DECREF_SET(__pyx_t_2, function);
7005 }
7006 }
7007 __pyx_t_1 = (__pyx_t_4) ? __Pyx_PyObject_Call2Args(__pyx_t_2, __pyx_t_4, __pyx_t_3) : __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3);
7008 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7009 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7010 if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 280, __pyx_L1_error)
7011 __Pyx_GOTREF(__pyx_t_1);
7012 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7013 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7014
7015 /* "borg/platform/linux.pyx":283
7016 * # tell the OS that it does not need to cache what we just wrote,
7017 * # avoids spoiling the cache for the OS and other processes.
7018 * safe_fadvise(self.fileno, 0, 0, 'DONTNEED') # <<<<<<<<<<<<<<
7019 */
7020 __Pyx_GetModuleGlobalName(__pyx_t_2, __pyx_n_s_safe_fadvise); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 283, __pyx_L1_error)
7021 __Pyx_GOTREF(__pyx_t_2);
7022 __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fileno); if (unlikely(!__pyx_t_3)) __PYX_ERR(0, 283, __pyx_L1_error)
7023 __Pyx_GOTREF(__pyx_t_3);
7024 __pyx_t_4 = NULL;
7025 __pyx_t_5 = 0;
7026 if (CYTHON_UNPACK_METHODS && unlikely(PyMethod_Check(__pyx_t_2))) {
7027 __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_2);
7028 if (likely(__pyx_t_4)) {
7029 PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
7030 __Pyx_INCREF(__pyx_t_4);
7031 __Pyx_INCREF(function);
7032 __Pyx_DECREF_SET(__pyx_t_2, function);
7033 __pyx_t_5 = 1;
7034 }
7035 }
7036 #if CYTHON_FAST_PYCALL
7037 if (PyFunction_Check(__pyx_t_2)) {
7038 PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_t_3, __pyx_int_0, __pyx_int_0, __pyx_n_u_DONTNEED};
7039 __pyx_t_1 = __Pyx_PyFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
7040 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7041 __Pyx_GOTREF(__pyx_t_1);
7042 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7043 } else
7044 #endif
7045 #if CYTHON_FAST_PYCCALL
7046 if (__Pyx_PyFastCFunction_Check(__pyx_t_2)) {
7047 PyObject *__pyx_temp[5] = {__pyx_t_4, __pyx_t_3, __pyx_int_0, __pyx_int_0, __pyx_n_u_DONTNEED};
7048 __pyx_t_1 = __Pyx_PyCFunction_FastCall(__pyx_t_2, __pyx_temp+1-__pyx_t_5, 4+__pyx_t_5); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
7049 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7050 __Pyx_GOTREF(__pyx_t_1);
7051 __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
7052 } else
7053 #endif
7054 {
7055 __pyx_t_6 = PyTuple_New(4+__pyx_t_5); if (unlikely(!__pyx_t_6)) __PYX_ERR(0, 283, __pyx_L1_error)
7056 __Pyx_GOTREF(__pyx_t_6);
7057 if (__pyx_t_4) {
7058 __Pyx_GIVEREF(__pyx_t_4); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_4); __pyx_t_4 = NULL;
7059 }
7060 __Pyx_GIVEREF(__pyx_t_3);
7061 PyTuple_SET_ITEM(__pyx_t_6, 0+__pyx_t_5, __pyx_t_3);
7062 __Pyx_INCREF(__pyx_int_0);
7063 __Pyx_GIVEREF(__pyx_int_0);
7064 PyTuple_SET_ITEM(__pyx_t_6, 1+__pyx_t_5, __pyx_int_0);
7065 __Pyx_INCREF(__pyx_int_0);
7066 __Pyx_GIVEREF(__pyx_int_0);
7067 PyTuple_SET_ITEM(__pyx_t_6, 2+__pyx_t_5, __pyx_int_0);
7068 __Pyx_INCREF(__pyx_n_u_DONTNEED);
7069 __Pyx_GIVEREF(__pyx_n_u_DONTNEED);
7070 PyTuple_SET_ITEM(__pyx_t_6, 3+__pyx_t_5, __pyx_n_u_DONTNEED);
7071 __pyx_t_3 = 0;
7072 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_6, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 283, __pyx_L1_error)
7073 __Pyx_GOTREF(__pyx_t_1);
7074 __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
7075 }
7076 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7077 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7078
7079 /* "borg/platform/linux.pyx":278
7080 * self.last_sync = offset
7081 *
7082 * def sync(self): # <<<<<<<<<<<<<<
7083 * self.fd.flush()
7084 * os.fdatasync(self.fileno)
7085 */
7086
7087 /* function exit code */
7088 __pyx_r = Py_None; __Pyx_INCREF(Py_None);
7089 goto __pyx_L0;
7090 __pyx_L1_error:;
7091 __Pyx_XDECREF(__pyx_t_1);
7092 __Pyx_XDECREF(__pyx_t_2);
7093 __Pyx_XDECREF(__pyx_t_3);
7094 __Pyx_XDECREF(__pyx_t_4);
7095 __Pyx_XDECREF(__pyx_t_6);
7096 __Pyx_AddTraceback("borg.platform.linux.SyncFile.sync", __pyx_clineno, __pyx_lineno, __pyx_filename);
7097 __pyx_r = NULL;
7098 __pyx_L0:;
7099 __Pyx_XGIVEREF(__pyx_r);
7100 __Pyx_RefNannyFinishContext();
7101 return __pyx_r;
7102 }
7103
7104 static PyMethodDef __pyx_methods[] = {
7105 {0, 0, 0, 0}
7106 };
7107
7108 #if PY_MAJOR_VERSION >= 3
7109 #if CYTHON_PEP489_MULTI_PHASE_INIT
7110 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
7111 static int __pyx_pymod_exec_linux(PyObject* module); /*proto*/
7112 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
7113 {Py_mod_create, (void*)__pyx_pymod_create},
7114 {Py_mod_exec, (void*)__pyx_pymod_exec_linux},
7115 {0, NULL}
7116 };
7117 #endif
7118
7119 static struct PyModuleDef __pyx_moduledef = {
7120 PyModuleDef_HEAD_INIT,
7121 "linux",
7122 0, /* m_doc */
7123 #if CYTHON_PEP489_MULTI_PHASE_INIT
7124 0, /* m_size */
7125 #else
7126 -1, /* m_size */
7127 #endif
7128 __pyx_methods /* m_methods */,
7129 #if CYTHON_PEP489_MULTI_PHASE_INIT
7130 __pyx_moduledef_slots, /* m_slots */
7131 #else
7132 NULL, /* m_reload */
7133 #endif
7134 NULL, /* m_traverse */
7135 NULL, /* m_clear */
7136 NULL /* m_free */
7137 };
7138 #endif
7139 #ifndef CYTHON_SMALL_CODE
7140 #if defined(__clang__)
7141 #define CYTHON_SMALL_CODE
7142 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
7143 #define CYTHON_SMALL_CODE __attribute__((cold))
7144 #else
7145 #define CYTHON_SMALL_CODE
7146 #endif
7147 #endif
7148
7149 static __Pyx_StringTabEntry __pyx_string_tab[] = {
7150 {&__pyx_kp_u_, __pyx_k_, sizeof(__pyx_k_), 0, 1, 0, 0},
7151 {&__pyx_kp_u_1_1_04, __pyx_k_1_1_04, sizeof(__pyx_k_1_1_04), 0, 1, 0, 0},
7152 {&__pyx_n_s_API_VERSION, __pyx_k_API_VERSION, sizeof(__pyx_k_API_VERSION), 0, 0, 1, 1},
7153 {&__pyx_n_s_BSD_TO_LINUX_FLAGS, __pyx_k_BSD_TO_LINUX_FLAGS, sizeof(__pyx_k_BSD_TO_LINUX_FLAGS), 0, 0, 1, 1},
7154 {&__pyx_n_s_BaseSyncFile, __pyx_k_BaseSyncFile, sizeof(__pyx_k_BaseSyncFile), 0, 0, 1, 1},
7155 {&__pyx_n_u_DONTNEED, __pyx_k_DONTNEED, sizeof(__pyx_k_DONTNEED), 0, 1, 0, 1},
7156 {&__pyx_kp_s_Implemented_using_sync_file_ran, __pyx_k_Implemented_using_sync_file_ran, sizeof(__pyx_k_Implemented_using_sync_file_ran), 0, 0, 1, 0},
7157 {&__pyx_n_s_ImportError, __pyx_k_ImportError, sizeof(__pyx_k_ImportError), 0, 0, 1, 1},
7158 {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1},
7159 {&__pyx_n_s_OSError, __pyx_k_OSError, sizeof(__pyx_k_OSError), 0, 0, 1, 1},
7160 {&__pyx_n_s_O_NOFOLLOW, __pyx_k_O_NOFOLLOW, sizeof(__pyx_k_O_NOFOLLOW), 0, 0, 1, 1},
7161 {&__pyx_n_s_O_NONBLOCK, __pyx_k_O_NONBLOCK, sizeof(__pyx_k_O_NONBLOCK), 0, 0, 1, 1},
7162 {&__pyx_n_s_O_RDONLY, __pyx_k_O_RDONLY, sizeof(__pyx_k_O_RDONLY), 0, 0, 1, 1},
7163 {&__pyx_n_s_SYNC_FILE_RANGE_LOADED, __pyx_k_SYNC_FILE_RANGE_LOADED, sizeof(__pyx_k_SYNC_FILE_RANGE_LOADED), 0, 0, 1, 1},
7164 {&__pyx_n_s_SYNC_FILE_RANGE_WAIT_AFTER, __pyx_k_SYNC_FILE_RANGE_WAIT_AFTER, sizeof(__pyx_k_SYNC_FILE_RANGE_WAIT_AFTER), 0, 0, 1, 1},
7165 {&__pyx_n_s_SYNC_FILE_RANGE_WAIT_BEFORE, __pyx_k_SYNC_FILE_RANGE_WAIT_BEFORE, sizeof(__pyx_k_SYNC_FILE_RANGE_WAIT_BEFORE), 0, 0, 1, 1},
7166 {&__pyx_n_s_SYNC_FILE_RANGE_WRITE, __pyx_k_SYNC_FILE_RANGE_WRITE, sizeof(__pyx_k_SYNC_FILE_RANGE_WRITE), 0, 0, 1, 1},
7167 {&__pyx_n_s_S_ISBLK, __pyx_k_S_ISBLK, sizeof(__pyx_k_S_ISBLK), 0, 0, 1, 1},
7168 {&__pyx_n_s_S_ISCHR, __pyx_k_S_ISCHR, sizeof(__pyx_k_S_ISCHR), 0, 0, 1, 1},
7169 {&__pyx_n_s_S_ISLNK, __pyx_k_S_ISLNK, sizeof(__pyx_k_S_ISLNK), 0, 0, 1, 1},
7170 {&__pyx_n_s_SyncFile, __pyx_k_SyncFile, sizeof(__pyx_k_SyncFile), 0, 0, 1, 1},
7171 {&__pyx_n_s_SyncFile___init, __pyx_k_SyncFile___init, sizeof(__pyx_k_SyncFile___init), 0, 0, 1, 1},
7172 {&__pyx_n_s_SyncFile_sync, __pyx_k_SyncFile_sync, sizeof(__pyx_k_SyncFile_sync), 0, 0, 1, 1},
7173 {&__pyx_n_s_SyncFile_write, __pyx_k_SyncFile_write, sizeof(__pyx_k_SyncFile_write), 0, 0, 1, 1},
7174 {&__pyx_n_s_UF_APPEND, __pyx_k_UF_APPEND, sizeof(__pyx_k_UF_APPEND), 0, 0, 1, 1},
7175 {&__pyx_n_s_UF_COMPRESSED, __pyx_k_UF_COMPRESSED, sizeof(__pyx_k_UF_COMPRESSED), 0, 0, 1, 1},
7176 {&__pyx_n_s_UF_IMMUTABLE, __pyx_k_UF_IMMUTABLE, sizeof(__pyx_k_UF_IMMUTABLE), 0, 0, 1, 1},
7177 {&__pyx_n_s_UF_NODUMP, __pyx_k_UF_NODUMP, sizeof(__pyx_k_UF_NODUMP), 0, 0, 1, 1},
7178 {&__pyx_kp_u__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 1, 0, 0},
7179 {&__pyx_kp_u__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 1, 0, 0},
7180 {&__pyx_kp_u__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 1, 0, 0},
7181 {&__pyx_n_s_access_acl, __pyx_k_access_acl, sizeof(__pyx_k_access_acl), 0, 0, 1, 1},
7182 {&__pyx_n_s_access_text, __pyx_k_access_text, sizeof(__pyx_k_access_text), 0, 0, 1, 1},
7183 {&__pyx_n_s_acl, __pyx_k_acl, sizeof(__pyx_k_acl), 0, 0, 1, 1},
7184 {&__pyx_n_u_acl_access, __pyx_k_acl_access, sizeof(__pyx_k_acl_access), 0, 1, 0, 1},
7185 {&__pyx_n_u_acl_default, __pyx_k_acl_default, sizeof(__pyx_k_acl_default), 0, 1, 0, 1},
7186 {&__pyx_n_s_acl_get, __pyx_k_acl_get, sizeof(__pyx_k_acl_get), 0, 0, 1, 1},
7187 {&__pyx_n_s_acl_set, __pyx_k_acl_set, sizeof(__pyx_k_acl_set), 0, 0, 1, 1},
7188 {&__pyx_n_s_acl_use_local_uid_gid, __pyx_k_acl_use_local_uid_gid, sizeof(__pyx_k_acl_use_local_uid_gid), 0, 0, 1, 1},
7189 {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
7190 {&__pyx_n_u_basesyncfile, __pyx_k_basesyncfile, sizeof(__pyx_k_basesyncfile), 0, 1, 0, 1},
7191 {&__pyx_n_s_binary, __pyx_k_binary, sizeof(__pyx_k_binary), 0, 0, 1, 1},
7192 {&__pyx_n_s_borg_platform_linux, __pyx_k_borg_platform_linux, sizeof(__pyx_k_borg_platform_linux), 0, 0, 1, 1},
7193 {&__pyx_n_s_bsd_flag, __pyx_k_bsd_flag, sizeof(__pyx_k_bsd_flag), 0, 0, 1, 1},
7194 {&__pyx_n_s_bsd_flags, __pyx_k_bsd_flags, sizeof(__pyx_k_bsd_flags), 0, 0, 1, 1},
7195 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
7196 {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
7197 {&__pyx_n_s_comment_re, __pyx_k_comment_re, sizeof(__pyx_k_comment_re), 0, 0, 1, 1},
7198 {&__pyx_n_s_compile, __pyx_k_compile, sizeof(__pyx_k_compile), 0, 0, 1, 1},
7199 {&__pyx_n_s_converter, __pyx_k_converter, sizeof(__pyx_k_converter), 0, 0, 1, 1},
7200 {&__pyx_n_s_data, __pyx_k_data, sizeof(__pyx_k_data), 0, 0, 1, 1},
7201 {&__pyx_n_s_default_acl, __pyx_k_default_acl, sizeof(__pyx_k_default_acl), 0, 0, 1, 1},
7202 {&__pyx_n_s_default_text, __pyx_k_default_text, sizeof(__pyx_k_default_text), 0, 0, 1, 1},
7203 {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
7204 {&__pyx_n_s_entries, __pyx_k_entries, sizeof(__pyx_k_entries), 0, 0, 1, 1},
7205 {&__pyx_n_s_entry, __pyx_k_entry, sizeof(__pyx_k_entry), 0, 0, 1, 1},
7206 {&__pyx_n_s_error_number, __pyx_k_error_number, sizeof(__pyx_k_error_number), 0, 0, 1, 1},
7207 {&__pyx_n_s_fd, __pyx_k_fd, sizeof(__pyx_k_fd), 0, 0, 1, 1},
7208 {&__pyx_n_s_fdatasync, __pyx_k_fdatasync, sizeof(__pyx_k_fdatasync), 0, 0, 1, 1},
7209 {&__pyx_n_s_fields, __pyx_k_fields, sizeof(__pyx_k_fields), 0, 0, 1, 1},
7210 {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1},
7211 {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
7212 {&__pyx_n_s_flush, __pyx_k_flush, sizeof(__pyx_k_flush), 0, 0, 1, 1},
7213 {&__pyx_n_s_follow_symlinks, __pyx_k_follow_symlinks, sizeof(__pyx_k_follow_symlinks), 0, 0, 1, 1},
7214 {&__pyx_n_s_fsencode, __pyx_k_fsencode, sizeof(__pyx_k_fsencode), 0, 0, 1, 1},
7215 {&__pyx_n_s_get, __pyx_k_get, sizeof(__pyx_k_get), 0, 0, 1, 1},
7216 {&__pyx_n_s_get_flags, __pyx_k_get_flags, sizeof(__pyx_k_get_flags), 0, 0, 1, 1},
7217 {&__pyx_n_u_group, __pyx_k_group, sizeof(__pyx_k_group), 0, 1, 0, 1},
7218 {&__pyx_n_s_group2gid, __pyx_k_group2gid, sizeof(__pyx_k_group2gid), 0, 0, 1, 1},
7219 {&__pyx_n_s_helpers, __pyx_k_helpers, sizeof(__pyx_k_helpers), 0, 0, 1, 1},
7220 {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
7221 {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
7222 {&__pyx_n_s_item, __pyx_k_item, sizeof(__pyx_k_item), 0, 0, 1, 1},
7223 {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
7224 {&__pyx_n_s_last_sync, __pyx_k_last_sync, sizeof(__pyx_k_last_sync), 0, 0, 1, 1},
7225 {&__pyx_kp_u_length_d_not_page_aligned, __pyx_k_length_d_not_page_aligned, sizeof(__pyx_k_length_d_not_page_aligned), 0, 1, 0, 0},
7226 {&__pyx_n_s_linux_flag, __pyx_k_linux_flag, sizeof(__pyx_k_linux_flag), 0, 0, 1, 1},
7227 {&__pyx_n_s_linux_flags, __pyx_k_linux_flags, sizeof(__pyx_k_linux_flags), 0, 0, 1, 1},
7228 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
7229 {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
7230 {&__pyx_n_u_mode, __pyx_k_mode, sizeof(__pyx_k_mode), 0, 1, 0, 1},
7231 {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
7232 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
7233 {&__pyx_n_s_numeric_owner, __pyx_k_numeric_owner, sizeof(__pyx_k_numeric_owner), 0, 0, 1, 1},
7234 {&__pyx_n_s_offset, __pyx_k_offset, sizeof(__pyx_k_offset), 0, 0, 1, 1},
7235 {&__pyx_kp_u_offset_d_not_page_aligned, __pyx_k_offset_d_not_page_aligned, sizeof(__pyx_k_offset_d_not_page_aligned), 0, 1, 0, 0},
7236 {&__pyx_n_s_open, __pyx_k_open, sizeof(__pyx_k_open), 0, 0, 1, 1},
7237 {&__pyx_n_s_open_fd, __pyx_k_open_fd, sizeof(__pyx_k_open_fd), 0, 0, 1, 1},
7238 {&__pyx_n_s_os, __pyx_k_os, sizeof(__pyx_k_os), 0, 0, 1, 1},
7239 {&__pyx_n_s_p, __pyx_k_p, sizeof(__pyx_k_p), 0, 0, 1, 1},
7240 {&__pyx_n_s_path, __pyx_k_path, sizeof(__pyx_k_path), 0, 0, 1, 1},
7241 {&__pyx_n_s_pending_sync, __pyx_k_pending_sync, sizeof(__pyx_k_pending_sync), 0, 0, 1, 1},
7242 {&__pyx_n_s_posix, __pyx_k_posix, sizeof(__pyx_k_posix), 0, 0, 1, 1},
7243 {&__pyx_n_s_posix_acl_use_stored_uid_gid, __pyx_k_posix_acl_use_stored_uid_gid, sizeof(__pyx_k_posix_acl_use_stored_uid_gid), 0, 0, 1, 1},
7244 {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
7245 {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
7246 {&__pyx_n_s_re, __pyx_k_re, sizeof(__pyx_k_re), 0, 0, 1, 1},
7247 {&__pyx_n_s_safe_decode, __pyx_k_safe_decode, sizeof(__pyx_k_safe_decode), 0, 0, 1, 1},
7248 {&__pyx_n_s_safe_encode, __pyx_k_safe_encode, sizeof(__pyx_k_safe_encode), 0, 0, 1, 1},
7249 {&__pyx_n_s_safe_fadvise, __pyx_k_safe_fadvise, sizeof(__pyx_k_safe_fadvise), 0, 0, 1, 1},
7250 {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
7251 {&__pyx_n_s_set_flags, __pyx_k_set_flags, sizeof(__pyx_k_set_flags), 0, 0, 1, 1},
7252 {&__pyx_n_s_split, __pyx_k_split, sizeof(__pyx_k_split), 0, 0, 1, 1},
7253 {&__pyx_kp_s_src_borg_platform_linux_pyx, __pyx_k_src_borg_platform_linux_pyx, sizeof(__pyx_k_src_borg_platform_linux_pyx), 0, 0, 1, 0},
7254 {&__pyx_n_s_st, __pyx_k_st, sizeof(__pyx_k_st), 0, 0, 1, 1},
7255 {&__pyx_n_s_st_mode, __pyx_k_st_mode, sizeof(__pyx_k_st_mode), 0, 0, 1, 1},
7256 {&__pyx_n_s_stat, __pyx_k_stat, sizeof(__pyx_k_stat), 0, 0, 1, 1},
7257 {&__pyx_n_s_strerror, __pyx_k_strerror, sizeof(__pyx_k_strerror), 0, 0, 1, 1},
7258 {&__pyx_n_s_sub, __pyx_k_sub, sizeof(__pyx_k_sub), 0, 0, 1, 1},
7259 {&__pyx_n_s_subprocess, __pyx_k_subprocess, sizeof(__pyx_k_subprocess), 0, 0, 1, 1},
7260 {&__pyx_n_s_super, __pyx_k_super, sizeof(__pyx_k_super), 0, 0, 1, 1},
7261 {&__pyx_n_s_swidth, __pyx_k_swidth, sizeof(__pyx_k_swidth), 0, 0, 1, 1},
7262 {&__pyx_n_s_sync, __pyx_k_sync, sizeof(__pyx_k_sync), 0, 0, 1, 1},
7263 {&__pyx_n_s_sync_file_range, __pyx_k_sync_file_range, sizeof(__pyx_k_sync_file_range), 0, 0, 1, 1},
7264 {&__pyx_n_s_syncfilerange, __pyx_k_syncfilerange, sizeof(__pyx_k_syncfilerange), 0, 0, 1, 1},
7265 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
7266 {&__pyx_n_u_user, __pyx_k_user, sizeof(__pyx_k_user), 0, 1, 0, 1},
7267 {&__pyx_n_s_user2uid, __pyx_k_user2uid, sizeof(__pyx_k_user2uid), 0, 0, 1, 1},
7268 {&__pyx_n_s_workarounds, __pyx_k_workarounds, sizeof(__pyx_k_workarounds), 0, 0, 1, 1},
7269 {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
7270 {&__pyx_n_s_write_window, __pyx_k_write_window, sizeof(__pyx_k_write_window), 0, 0, 1, 1},
7271 {0, 0, 0, 0, 0, 0, 0}
7272 };
__Pyx_InitCachedBuiltins(void)7273 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
7274 __pyx_builtin_ImportError = __Pyx_GetBuiltinName(__pyx_n_s_ImportError); if (!__pyx_builtin_ImportError) __PYX_ERR(0, 18, __pyx_L1_error)
7275 __pyx_builtin_OSError = __Pyx_GetBuiltinName(__pyx_n_s_OSError); if (!__pyx_builtin_OSError) __PYX_ERR(0, 93, __pyx_L1_error)
7276 __pyx_builtin_super = __Pyx_GetBuiltinName(__pyx_n_s_super); if (!__pyx_builtin_super) __PYX_ERR(0, 260, __pyx_L1_error)
7277 return 0;
7278 __pyx_L1_error:;
7279 return -1;
7280 }
7281
__Pyx_InitCachedConstants(void)7282 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
7283 __Pyx_RefNannyDeclarations
7284 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
7285
7286 /* "borg/platform/linux.pyx":132
7287 * elif fields[0] == 'group' and fields[1]:
7288 * fields[1] = str(group2gid(fields[1], fields[3]))
7289 * entries.append(':'.join(fields[:3])) # <<<<<<<<<<<<<<
7290 * return safe_encode('\n'.join(entries))
7291 *
7292 */
7293 __pyx_slice__3 = PySlice_New(Py_None, __pyx_int_3, Py_None); if (unlikely(!__pyx_slice__3)) __PYX_ERR(0, 132, __pyx_L1_error)
7294 __Pyx_GOTREF(__pyx_slice__3);
7295 __Pyx_GIVEREF(__pyx_slice__3);
7296
7297 /* "borg/platform/linux.pyx":205
7298 * cdef acl_t default_acl = NULL
7299 *
7300 * if stat.S_ISLNK(item.get('mode', 0)): # <<<<<<<<<<<<<<
7301 * # Linux does not support setting ACLs on symlinks
7302 * return
7303 */
7304 __pyx_tuple__5 = PyTuple_Pack(2, __pyx_n_u_mode, __pyx_int_0); if (unlikely(!__pyx_tuple__5)) __PYX_ERR(0, 205, __pyx_L1_error)
7305 __Pyx_GOTREF(__pyx_tuple__5);
7306 __Pyx_GIVEREF(__pyx_tuple__5);
7307
7308 /* "borg/platform/linux.pyx":76
7309 *
7310 *
7311 * def set_flags(path, bsd_flags, fd=None): # <<<<<<<<<<<<<<
7312 * if fd is None:
7313 * st = os.stat(path, follow_symlinks=False)
7314 */
7315 __pyx_tuple__7 = PyTuple_Pack(9, __pyx_n_s_path, __pyx_n_s_bsd_flags, __pyx_n_s_fd, __pyx_n_s_st, __pyx_n_s_flags, __pyx_n_s_bsd_flag, __pyx_n_s_linux_flag, __pyx_n_s_open_fd, __pyx_n_s_error_number); if (unlikely(!__pyx_tuple__7)) __PYX_ERR(0, 76, __pyx_L1_error)
7316 __Pyx_GOTREF(__pyx_tuple__7);
7317 __Pyx_GIVEREF(__pyx_tuple__7);
7318 __pyx_codeobj__8 = (PyObject*)__Pyx_PyCode_New(3, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__7, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_platform_linux_pyx, __pyx_n_s_set_flags, 76, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__8)) __PYX_ERR(0, 76, __pyx_L1_error)
7319
7320 /* "borg/platform/linux.pyx":99
7321 *
7322 *
7323 * def get_flags(path, st): # <<<<<<<<<<<<<<
7324 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode):
7325 * # avoid opening devices files - trying to open non-present devices can be rather slow.
7326 */
7327 __pyx_tuple__9 = PyTuple_Pack(7, __pyx_n_s_path, __pyx_n_s_st, __pyx_n_s_linux_flags, __pyx_n_s_fd, __pyx_n_s_bsd_flags, __pyx_n_s_bsd_flag, __pyx_n_s_linux_flag); if (unlikely(!__pyx_tuple__9)) __PYX_ERR(0, 99, __pyx_L1_error)
7328 __Pyx_GOTREF(__pyx_tuple__9);
7329 __Pyx_GIVEREF(__pyx_tuple__9);
7330 __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(2, 0, 7, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_platform_linux_pyx, __pyx_n_s_get_flags, 99, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) __PYX_ERR(0, 99, __pyx_L1_error)
7331
7332 /* "borg/platform/linux.pyx":121
7333 *
7334 *
7335 * def acl_use_local_uid_gid(acl): # <<<<<<<<<<<<<<
7336 * """Replace the user/group field with the local uid/gid if possible
7337 * """
7338 */
7339 __pyx_tuple__11 = PyTuple_Pack(4, __pyx_n_s_acl, __pyx_n_s_entries, __pyx_n_s_entry, __pyx_n_s_fields); if (unlikely(!__pyx_tuple__11)) __PYX_ERR(0, 121, __pyx_L1_error)
7340 __Pyx_GOTREF(__pyx_tuple__11);
7341 __Pyx_GIVEREF(__pyx_tuple__11);
7342 __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(1, 0, 4, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_platform_linux_pyx, __pyx_n_s_acl_use_local_uid_gid, 121, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) __PYX_ERR(0, 121, __pyx_L1_error)
7343
7344 /* "borg/platform/linux.pyx":170
7345 *
7346 *
7347 * def acl_get(path, item, st, numeric_owner=False): # <<<<<<<<<<<<<<
7348 * cdef acl_t default_acl = NULL
7349 * cdef acl_t access_acl = NULL
7350 */
7351 __pyx_tuple__13 = PyTuple_Pack(10, __pyx_n_s_path, __pyx_n_s_item, __pyx_n_s_st, __pyx_n_s_numeric_owner, __pyx_n_s_default_acl, __pyx_n_s_access_acl, __pyx_n_s_default_text, __pyx_n_s_access_text, __pyx_n_s_p, __pyx_n_s_converter); if (unlikely(!__pyx_tuple__13)) __PYX_ERR(0, 170, __pyx_L1_error)
7352 __Pyx_GOTREF(__pyx_tuple__13);
7353 __Pyx_GIVEREF(__pyx_tuple__13);
7354 __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(4, 0, 10, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_platform_linux_pyx, __pyx_n_s_acl_get, 170, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) __PYX_ERR(0, 170, __pyx_L1_error)
7355
7356 /* "borg/platform/linux.pyx":201
7357 *
7358 *
7359 * def acl_set(path, item, numeric_owner=False): # <<<<<<<<<<<<<<
7360 * cdef acl_t access_acl = NULL
7361 * cdef acl_t default_acl = NULL
7362 */
7363 __pyx_tuple__15 = PyTuple_Pack(9, __pyx_n_s_path, __pyx_n_s_item, __pyx_n_s_numeric_owner, __pyx_n_s_access_acl, __pyx_n_s_default_acl, __pyx_n_s_p, __pyx_n_s_converter, __pyx_n_s_access_text, __pyx_n_s_default_text); if (unlikely(!__pyx_tuple__15)) __PYX_ERR(0, 201, __pyx_L1_error)
7364 __Pyx_GOTREF(__pyx_tuple__15);
7365 __Pyx_GIVEREF(__pyx_tuple__15);
7366 __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(3, 0, 9, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_platform_linux_pyx, __pyx_n_s_acl_set, 201, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) __PYX_ERR(0, 201, __pyx_L1_error)
7367
7368 /* "borg/platform/linux.pyx":259
7369 * """
7370 *
7371 * def __init__(self, path, binary=False): # <<<<<<<<<<<<<<
7372 * super().__init__(path, binary)
7373 * self.offset = 0
7374 */
7375 __pyx_tuple__17 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_path, __pyx_n_s_binary); if (unlikely(!__pyx_tuple__17)) __PYX_ERR(0, 259, __pyx_L1_error)
7376 __Pyx_GOTREF(__pyx_tuple__17);
7377 __Pyx_GIVEREF(__pyx_tuple__17);
7378 __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_platform_linux_pyx, __pyx_n_s_init, 259, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) __PYX_ERR(0, 259, __pyx_L1_error)
7379 __pyx_tuple__19 = PyTuple_Pack(1, ((PyObject *)Py_False)); if (unlikely(!__pyx_tuple__19)) __PYX_ERR(0, 259, __pyx_L1_error)
7380 __Pyx_GOTREF(__pyx_tuple__19);
7381 __Pyx_GIVEREF(__pyx_tuple__19);
7382
7383 /* "borg/platform/linux.pyx":266
7384 * self.pending_sync = None
7385 *
7386 * def write(self, data): # <<<<<<<<<<<<<<
7387 * self.offset += self.fd.write(data)
7388 * offset = self.offset & ~PAGE_MASK
7389 */
7390 __pyx_tuple__20 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_data, __pyx_n_s_offset); if (unlikely(!__pyx_tuple__20)) __PYX_ERR(0, 266, __pyx_L1_error)
7391 __Pyx_GOTREF(__pyx_tuple__20);
7392 __Pyx_GIVEREF(__pyx_tuple__20);
7393 __pyx_codeobj__21 = (PyObject*)__Pyx_PyCode_New(2, 0, 3, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__20, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_platform_linux_pyx, __pyx_n_s_write, 266, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__21)) __PYX_ERR(0, 266, __pyx_L1_error)
7394
7395 /* "borg/platform/linux.pyx":278
7396 * self.last_sync = offset
7397 *
7398 * def sync(self): # <<<<<<<<<<<<<<
7399 * self.fd.flush()
7400 * os.fdatasync(self.fileno)
7401 */
7402 __pyx_tuple__22 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__22)) __PYX_ERR(0, 278, __pyx_L1_error)
7403 __Pyx_GOTREF(__pyx_tuple__22);
7404 __Pyx_GIVEREF(__pyx_tuple__22);
7405 __pyx_codeobj__23 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, CO_OPTIMIZED|CO_NEWLOCALS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__22, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_src_borg_platform_linux_pyx, __pyx_n_s_sync, 278, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__23)) __PYX_ERR(0, 278, __pyx_L1_error)
7406 __Pyx_RefNannyFinishContext();
7407 return 0;
7408 __pyx_L1_error:;
7409 __Pyx_RefNannyFinishContext();
7410 return -1;
7411 }
7412
__Pyx_InitGlobals(void)7413 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
7414 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
7415 __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) __PYX_ERR(0, 1, __pyx_L1_error)
7416 __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) __PYX_ERR(0, 1, __pyx_L1_error)
7417 return 0;
7418 __pyx_L1_error:;
7419 return -1;
7420 }
7421
7422 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
7423 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
7424 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
7425 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
7426 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
7427 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
7428 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
7429
__Pyx_modinit_global_init_code(void)7430 static int __Pyx_modinit_global_init_code(void) {
7431 __Pyx_RefNannyDeclarations
7432 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
7433 /*--- Global init code ---*/
7434 __Pyx_RefNannyFinishContext();
7435 return 0;
7436 }
7437
__Pyx_modinit_variable_export_code(void)7438 static int __Pyx_modinit_variable_export_code(void) {
7439 __Pyx_RefNannyDeclarations
7440 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
7441 /*--- Variable export code ---*/
7442 __Pyx_RefNannyFinishContext();
7443 return 0;
7444 }
7445
__Pyx_modinit_function_export_code(void)7446 static int __Pyx_modinit_function_export_code(void) {
7447 __Pyx_RefNannyDeclarations
7448 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
7449 /*--- Function export code ---*/
7450 __Pyx_RefNannyFinishContext();
7451 return 0;
7452 }
7453
__Pyx_modinit_type_init_code(void)7454 static int __Pyx_modinit_type_init_code(void) {
7455 __Pyx_RefNannyDeclarations
7456 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
7457 /*--- Type init code ---*/
7458 __Pyx_RefNannyFinishContext();
7459 return 0;
7460 }
7461
__Pyx_modinit_type_import_code(void)7462 static int __Pyx_modinit_type_import_code(void) {
7463 __Pyx_RefNannyDeclarations
7464 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
7465 /*--- Type import code ---*/
7466 __Pyx_RefNannyFinishContext();
7467 return 0;
7468 }
7469
__Pyx_modinit_variable_import_code(void)7470 static int __Pyx_modinit_variable_import_code(void) {
7471 __Pyx_RefNannyDeclarations
7472 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
7473 /*--- Variable import code ---*/
7474 __Pyx_RefNannyFinishContext();
7475 return 0;
7476 }
7477
__Pyx_modinit_function_import_code(void)7478 static int __Pyx_modinit_function_import_code(void) {
7479 __Pyx_RefNannyDeclarations
7480 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
7481 /*--- Function import code ---*/
7482 __Pyx_RefNannyFinishContext();
7483 return 0;
7484 }
7485
7486
7487 #ifndef CYTHON_NO_PYINIT_EXPORT
7488 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
7489 #elif PY_MAJOR_VERSION < 3
7490 #ifdef __cplusplus
7491 #define __Pyx_PyMODINIT_FUNC extern "C" void
7492 #else
7493 #define __Pyx_PyMODINIT_FUNC void
7494 #endif
7495 #else
7496 #ifdef __cplusplus
7497 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
7498 #else
7499 #define __Pyx_PyMODINIT_FUNC PyObject *
7500 #endif
7501 #endif
7502
7503
7504 #if PY_MAJOR_VERSION < 3
7505 __Pyx_PyMODINIT_FUNC initlinux(void) CYTHON_SMALL_CODE; /*proto*/
initlinux(void)7506 __Pyx_PyMODINIT_FUNC initlinux(void)
7507 #else
7508 __Pyx_PyMODINIT_FUNC PyInit_linux(void) CYTHON_SMALL_CODE; /*proto*/
7509 __Pyx_PyMODINIT_FUNC PyInit_linux(void)
7510 #if CYTHON_PEP489_MULTI_PHASE_INIT
7511 {
7512 return PyModuleDef_Init(&__pyx_moduledef);
7513 }
7514 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
7515 #if PY_VERSION_HEX >= 0x030700A1
7516 static PY_INT64_T main_interpreter_id = -1;
7517 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
7518 if (main_interpreter_id == -1) {
7519 main_interpreter_id = current_id;
7520 return (unlikely(current_id == -1)) ? -1 : 0;
7521 } else if (unlikely(main_interpreter_id != current_id))
7522 #else
7523 static PyInterpreterState *main_interpreter = NULL;
7524 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
7525 if (!main_interpreter) {
7526 main_interpreter = current_interpreter;
7527 } else if (unlikely(main_interpreter != current_interpreter))
7528 #endif
7529 {
7530 PyErr_SetString(
7531 PyExc_ImportError,
7532 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
7533 return -1;
7534 }
7535 return 0;
7536 }
7537 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
7538 PyObject *value = PyObject_GetAttrString(spec, from_name);
7539 int result = 0;
7540 if (likely(value)) {
7541 if (allow_none || value != Py_None) {
7542 result = PyDict_SetItemString(moddict, to_name, value);
7543 }
7544 Py_DECREF(value);
7545 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
7546 PyErr_Clear();
7547 } else {
7548 result = -1;
7549 }
7550 return result;
7551 }
7552 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
7553 PyObject *module = NULL, *moddict, *modname;
7554 if (__Pyx_check_single_interpreter())
7555 return NULL;
7556 if (__pyx_m)
7557 return __Pyx_NewRef(__pyx_m);
7558 modname = PyObject_GetAttrString(spec, "name");
7559 if (unlikely(!modname)) goto bad;
7560 module = PyModule_NewObject(modname);
7561 Py_DECREF(modname);
7562 if (unlikely(!module)) goto bad;
7563 moddict = PyModule_GetDict(module);
7564 if (unlikely(!moddict)) goto bad;
7565 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
7566 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
7567 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
7568 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
7569 return module;
7570 bad:
7571 Py_XDECREF(module);
7572 return NULL;
7573 }
7574
7575
7576 static CYTHON_SMALL_CODE int __pyx_pymod_exec_linux(PyObject *__pyx_pyinit_module)
7577 #endif
7578 #endif
7579 {
7580 PyObject *__pyx_t_1 = NULL;
7581 PyObject *__pyx_t_2 = NULL;
7582 PyObject *__pyx_t_3 = NULL;
7583 PyObject *__pyx_t_4 = NULL;
7584 PyObject *__pyx_t_5 = NULL;
7585 int __pyx_t_6;
7586 PyObject *__pyx_t_7 = NULL;
7587 int __pyx_t_8;
7588 int __pyx_t_9;
7589 int __pyx_t_10;
7590 PyObject *__pyx_t_11 = NULL;
7591 PyObject *__pyx_t_12 = NULL;
7592 int __pyx_lineno = 0;
7593 const char *__pyx_filename = NULL;
7594 int __pyx_clineno = 0;
7595 __Pyx_RefNannyDeclarations
7596 #if CYTHON_PEP489_MULTI_PHASE_INIT
7597 if (__pyx_m) {
7598 if (__pyx_m == __pyx_pyinit_module) return 0;
7599 PyErr_SetString(PyExc_RuntimeError, "Module 'linux' has already been imported. Re-initialisation is not supported.");
7600 return -1;
7601 }
7602 #elif PY_MAJOR_VERSION >= 3
7603 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
7604 #endif
7605 #if CYTHON_REFNANNY
7606 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
7607 if (!__Pyx_RefNanny) {
7608 PyErr_Clear();
7609 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
7610 if (!__Pyx_RefNanny)
7611 Py_FatalError("failed to import 'refnanny' module");
7612 }
7613 #endif
7614 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_linux(void)", 0);
7615 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7616 #ifdef __Pxy_PyFrame_Initialize_Offsets
7617 __Pxy_PyFrame_Initialize_Offsets();
7618 #endif
7619 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
7620 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
7621 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
7622 #ifdef __Pyx_CyFunction_USED
7623 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7624 #endif
7625 #ifdef __Pyx_FusedFunction_USED
7626 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7627 #endif
7628 #ifdef __Pyx_Coroutine_USED
7629 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7630 #endif
7631 #ifdef __Pyx_Generator_USED
7632 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7633 #endif
7634 #ifdef __Pyx_AsyncGen_USED
7635 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7636 #endif
7637 #ifdef __Pyx_StopAsyncIteration_USED
7638 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7639 #endif
7640 /*--- Library function declarations ---*/
7641 /*--- Threads initialization code ---*/
7642 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
7643 #ifdef WITH_THREAD /* Python build with threading support? */
7644 PyEval_InitThreads();
7645 #endif
7646 #endif
7647 /*--- Module creation code ---*/
7648 #if CYTHON_PEP489_MULTI_PHASE_INIT
7649 __pyx_m = __pyx_pyinit_module;
7650 Py_INCREF(__pyx_m);
7651 #else
7652 #if PY_MAJOR_VERSION < 3
7653 __pyx_m = Py_InitModule4("linux", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
7654 #else
7655 __pyx_m = PyModule_Create(&__pyx_moduledef);
7656 #endif
7657 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
7658 #endif
7659 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
7660 Py_INCREF(__pyx_d);
7661 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
7662 Py_INCREF(__pyx_b);
7663 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
7664 Py_INCREF(__pyx_cython_runtime);
7665 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
7666 /*--- Initialize various global constants etc. ---*/
7667 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7668 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
7669 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7670 #endif
7671 if (__pyx_module_is_main_borg__platform__linux) {
7672 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7673 }
7674 #if PY_MAJOR_VERSION >= 3
7675 {
7676 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
7677 if (!PyDict_GetItemString(modules, "borg.platform.linux")) {
7678 if (unlikely(PyDict_SetItemString(modules, "borg.platform.linux", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
7679 }
7680 }
7681 #endif
7682 /*--- Builtin init code ---*/
7683 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7684 /*--- Constants init code ---*/
7685 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7686 /*--- Global type/function init code ---*/
7687 (void)__Pyx_modinit_global_init_code();
7688 (void)__Pyx_modinit_variable_export_code();
7689 (void)__Pyx_modinit_function_export_code();
7690 (void)__Pyx_modinit_type_init_code();
7691 (void)__Pyx_modinit_type_import_code();
7692 (void)__Pyx_modinit_variable_import_code();
7693 (void)__Pyx_modinit_function_import_code();
7694 /*--- Execution code ---*/
7695 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
7696 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
7697 #endif
7698
7699 /* "borg/platform/linux.pyx":3
7700 * # cython: language_level=3
7701 *
7702 * import os # <<<<<<<<<<<<<<
7703 * import re
7704 * import stat
7705 */
7706 __pyx_t_1 = __Pyx_Import(__pyx_n_s_os, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 3, __pyx_L1_error)
7707 __Pyx_GOTREF(__pyx_t_1);
7708 if (PyDict_SetItem(__pyx_d, __pyx_n_s_os, __pyx_t_1) < 0) __PYX_ERR(0, 3, __pyx_L1_error)
7709 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7710
7711 /* "borg/platform/linux.pyx":4
7712 *
7713 * import os
7714 * import re # <<<<<<<<<<<<<<
7715 * import stat
7716 * import subprocess
7717 */
7718 __pyx_t_1 = __Pyx_Import(__pyx_n_s_re, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 4, __pyx_L1_error)
7719 __Pyx_GOTREF(__pyx_t_1);
7720 if (PyDict_SetItem(__pyx_d, __pyx_n_s_re, __pyx_t_1) < 0) __PYX_ERR(0, 4, __pyx_L1_error)
7721 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7722
7723 /* "borg/platform/linux.pyx":5
7724 * import os
7725 * import re
7726 * import stat # <<<<<<<<<<<<<<
7727 * import subprocess
7728 *
7729 */
7730 __pyx_t_1 = __Pyx_Import(__pyx_n_s_stat, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 5, __pyx_L1_error)
7731 __Pyx_GOTREF(__pyx_t_1);
7732 if (PyDict_SetItem(__pyx_d, __pyx_n_s_stat, __pyx_t_1) < 0) __PYX_ERR(0, 5, __pyx_L1_error)
7733 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7734
7735 /* "borg/platform/linux.pyx":6
7736 * import re
7737 * import stat
7738 * import subprocess # <<<<<<<<<<<<<<
7739 *
7740 * from ..helpers import workarounds
7741 */
7742 __pyx_t_1 = __Pyx_Import(__pyx_n_s_subprocess, 0, 0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 6, __pyx_L1_error)
7743 __Pyx_GOTREF(__pyx_t_1);
7744 if (PyDict_SetItem(__pyx_d, __pyx_n_s_subprocess, __pyx_t_1) < 0) __PYX_ERR(0, 6, __pyx_L1_error)
7745 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7746
7747 /* "borg/platform/linux.pyx":8
7748 * import subprocess
7749 *
7750 * from ..helpers import workarounds # <<<<<<<<<<<<<<
7751 * from ..helpers import posix_acl_use_stored_uid_gid
7752 * from ..helpers import user2uid, group2gid
7753 */
7754 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
7755 __Pyx_GOTREF(__pyx_t_1);
7756 __Pyx_INCREF(__pyx_n_s_workarounds);
7757 __Pyx_GIVEREF(__pyx_n_s_workarounds);
7758 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_workarounds);
7759 __pyx_t_2 = __Pyx_Import(__pyx_n_s_helpers, __pyx_t_1, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 8, __pyx_L1_error)
7760 __Pyx_GOTREF(__pyx_t_2);
7761 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7762 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_workarounds); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 8, __pyx_L1_error)
7763 __Pyx_GOTREF(__pyx_t_1);
7764 if (PyDict_SetItem(__pyx_d, __pyx_n_s_workarounds, __pyx_t_1) < 0) __PYX_ERR(0, 8, __pyx_L1_error)
7765 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7766 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7767
7768 /* "borg/platform/linux.pyx":9
7769 *
7770 * from ..helpers import workarounds
7771 * from ..helpers import posix_acl_use_stored_uid_gid # <<<<<<<<<<<<<<
7772 * from ..helpers import user2uid, group2gid
7773 * from ..helpers import safe_decode, safe_encode
7774 */
7775 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
7776 __Pyx_GOTREF(__pyx_t_2);
7777 __Pyx_INCREF(__pyx_n_s_posix_acl_use_stored_uid_gid);
7778 __Pyx_GIVEREF(__pyx_n_s_posix_acl_use_stored_uid_gid);
7779 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_posix_acl_use_stored_uid_gid);
7780 __pyx_t_1 = __Pyx_Import(__pyx_n_s_helpers, __pyx_t_2, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 9, __pyx_L1_error)
7781 __Pyx_GOTREF(__pyx_t_1);
7782 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7783 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_posix_acl_use_stored_uid_gid); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 9, __pyx_L1_error)
7784 __Pyx_GOTREF(__pyx_t_2);
7785 if (PyDict_SetItem(__pyx_d, __pyx_n_s_posix_acl_use_stored_uid_gid, __pyx_t_2) < 0) __PYX_ERR(0, 9, __pyx_L1_error)
7786 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7787 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7788
7789 /* "borg/platform/linux.pyx":10
7790 * from ..helpers import workarounds
7791 * from ..helpers import posix_acl_use_stored_uid_gid
7792 * from ..helpers import user2uid, group2gid # <<<<<<<<<<<<<<
7793 * from ..helpers import safe_decode, safe_encode
7794 * from .base import SyncFile as BaseSyncFile
7795 */
7796 __pyx_t_1 = PyList_New(2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
7797 __Pyx_GOTREF(__pyx_t_1);
7798 __Pyx_INCREF(__pyx_n_s_user2uid);
7799 __Pyx_GIVEREF(__pyx_n_s_user2uid);
7800 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_user2uid);
7801 __Pyx_INCREF(__pyx_n_s_group2gid);
7802 __Pyx_GIVEREF(__pyx_n_s_group2gid);
7803 PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_group2gid);
7804 __pyx_t_2 = __Pyx_Import(__pyx_n_s_helpers, __pyx_t_1, 2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 10, __pyx_L1_error)
7805 __Pyx_GOTREF(__pyx_t_2);
7806 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7807 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_user2uid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
7808 __Pyx_GOTREF(__pyx_t_1);
7809 if (PyDict_SetItem(__pyx_d, __pyx_n_s_user2uid, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
7810 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7811 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_group2gid); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 10, __pyx_L1_error)
7812 __Pyx_GOTREF(__pyx_t_1);
7813 if (PyDict_SetItem(__pyx_d, __pyx_n_s_group2gid, __pyx_t_1) < 0) __PYX_ERR(0, 10, __pyx_L1_error)
7814 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7815 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7816
7817 /* "borg/platform/linux.pyx":11
7818 * from ..helpers import posix_acl_use_stored_uid_gid
7819 * from ..helpers import user2uid, group2gid
7820 * from ..helpers import safe_decode, safe_encode # <<<<<<<<<<<<<<
7821 * from .base import SyncFile as BaseSyncFile
7822 * from .base import safe_fadvise
7823 */
7824 __pyx_t_2 = PyList_New(2); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
7825 __Pyx_GOTREF(__pyx_t_2);
7826 __Pyx_INCREF(__pyx_n_s_safe_decode);
7827 __Pyx_GIVEREF(__pyx_n_s_safe_decode);
7828 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_safe_decode);
7829 __Pyx_INCREF(__pyx_n_s_safe_encode);
7830 __Pyx_GIVEREF(__pyx_n_s_safe_encode);
7831 PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_safe_encode);
7832 __pyx_t_1 = __Pyx_Import(__pyx_n_s_helpers, __pyx_t_2, 2); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 11, __pyx_L1_error)
7833 __Pyx_GOTREF(__pyx_t_1);
7834 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7835 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_safe_decode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
7836 __Pyx_GOTREF(__pyx_t_2);
7837 if (PyDict_SetItem(__pyx_d, __pyx_n_s_safe_decode, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
7838 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7839 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_safe_encode); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 11, __pyx_L1_error)
7840 __Pyx_GOTREF(__pyx_t_2);
7841 if (PyDict_SetItem(__pyx_d, __pyx_n_s_safe_encode, __pyx_t_2) < 0) __PYX_ERR(0, 11, __pyx_L1_error)
7842 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7843 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7844
7845 /* "borg/platform/linux.pyx":12
7846 * from ..helpers import user2uid, group2gid
7847 * from ..helpers import safe_decode, safe_encode
7848 * from .base import SyncFile as BaseSyncFile # <<<<<<<<<<<<<<
7849 * from .base import safe_fadvise
7850 * from .posix import swidth
7851 */
7852 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
7853 __Pyx_GOTREF(__pyx_t_1);
7854 __Pyx_INCREF(__pyx_n_s_SyncFile);
7855 __Pyx_GIVEREF(__pyx_n_s_SyncFile);
7856 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_SyncFile);
7857 __pyx_t_2 = __Pyx_Import(__pyx_n_s_base, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 12, __pyx_L1_error)
7858 __Pyx_GOTREF(__pyx_t_2);
7859 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7860 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_SyncFile); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 12, __pyx_L1_error)
7861 __Pyx_GOTREF(__pyx_t_1);
7862 if (PyDict_SetItem(__pyx_d, __pyx_n_s_BaseSyncFile, __pyx_t_1) < 0) __PYX_ERR(0, 12, __pyx_L1_error)
7863 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7864 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7865
7866 /* "borg/platform/linux.pyx":13
7867 * from ..helpers import safe_decode, safe_encode
7868 * from .base import SyncFile as BaseSyncFile
7869 * from .base import safe_fadvise # <<<<<<<<<<<<<<
7870 * from .posix import swidth
7871 * try:
7872 */
7873 __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
7874 __Pyx_GOTREF(__pyx_t_2);
7875 __Pyx_INCREF(__pyx_n_s_safe_fadvise);
7876 __Pyx_GIVEREF(__pyx_n_s_safe_fadvise);
7877 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_safe_fadvise);
7878 __pyx_t_1 = __Pyx_Import(__pyx_n_s_base, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 13, __pyx_L1_error)
7879 __Pyx_GOTREF(__pyx_t_1);
7880 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7881 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_safe_fadvise); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 13, __pyx_L1_error)
7882 __Pyx_GOTREF(__pyx_t_2);
7883 if (PyDict_SetItem(__pyx_d, __pyx_n_s_safe_fadvise, __pyx_t_2) < 0) __PYX_ERR(0, 13, __pyx_L1_error)
7884 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7885 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7886
7887 /* "borg/platform/linux.pyx":14
7888 * from .base import SyncFile as BaseSyncFile
7889 * from .base import safe_fadvise
7890 * from .posix import swidth # <<<<<<<<<<<<<<
7891 * try:
7892 * from .syncfilerange import sync_file_range, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WAIT_AFTER
7893 */
7894 __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
7895 __Pyx_GOTREF(__pyx_t_1);
7896 __Pyx_INCREF(__pyx_n_s_swidth);
7897 __Pyx_GIVEREF(__pyx_n_s_swidth);
7898 PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_swidth);
7899 __pyx_t_2 = __Pyx_Import(__pyx_n_s_posix, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 14, __pyx_L1_error)
7900 __Pyx_GOTREF(__pyx_t_2);
7901 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7902 __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_swidth); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 14, __pyx_L1_error)
7903 __Pyx_GOTREF(__pyx_t_1);
7904 if (PyDict_SetItem(__pyx_d, __pyx_n_s_swidth, __pyx_t_1) < 0) __PYX_ERR(0, 14, __pyx_L1_error)
7905 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7906 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7907
7908 /* "borg/platform/linux.pyx":15
7909 * from .base import safe_fadvise
7910 * from .posix import swidth
7911 * try: # <<<<<<<<<<<<<<
7912 * from .syncfilerange import sync_file_range, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WAIT_AFTER
7913 * SYNC_FILE_RANGE_LOADED = True
7914 */
7915 {
7916 __Pyx_PyThreadState_declare
7917 __Pyx_PyThreadState_assign
7918 __Pyx_ExceptionSave(&__pyx_t_3, &__pyx_t_4, &__pyx_t_5);
7919 __Pyx_XGOTREF(__pyx_t_3);
7920 __Pyx_XGOTREF(__pyx_t_4);
7921 __Pyx_XGOTREF(__pyx_t_5);
7922 /*try:*/ {
7923
7924 /* "borg/platform/linux.pyx":16
7925 * from .posix import swidth
7926 * try:
7927 * from .syncfilerange import sync_file_range, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WAIT_AFTER # <<<<<<<<<<<<<<
7928 * SYNC_FILE_RANGE_LOADED = True
7929 * except ImportError:
7930 */
7931 __pyx_t_2 = PyList_New(4); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L2_error)
7932 __Pyx_GOTREF(__pyx_t_2);
7933 __Pyx_INCREF(__pyx_n_s_sync_file_range);
7934 __Pyx_GIVEREF(__pyx_n_s_sync_file_range);
7935 PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_sync_file_range);
7936 __Pyx_INCREF(__pyx_n_s_SYNC_FILE_RANGE_WRITE);
7937 __Pyx_GIVEREF(__pyx_n_s_SYNC_FILE_RANGE_WRITE);
7938 PyList_SET_ITEM(__pyx_t_2, 1, __pyx_n_s_SYNC_FILE_RANGE_WRITE);
7939 __Pyx_INCREF(__pyx_n_s_SYNC_FILE_RANGE_WAIT_BEFORE);
7940 __Pyx_GIVEREF(__pyx_n_s_SYNC_FILE_RANGE_WAIT_BEFORE);
7941 PyList_SET_ITEM(__pyx_t_2, 2, __pyx_n_s_SYNC_FILE_RANGE_WAIT_BEFORE);
7942 __Pyx_INCREF(__pyx_n_s_SYNC_FILE_RANGE_WAIT_AFTER);
7943 __Pyx_GIVEREF(__pyx_n_s_SYNC_FILE_RANGE_WAIT_AFTER);
7944 PyList_SET_ITEM(__pyx_t_2, 3, __pyx_n_s_SYNC_FILE_RANGE_WAIT_AFTER);
7945 __pyx_t_1 = __Pyx_Import(__pyx_n_s_syncfilerange, __pyx_t_2, 1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 16, __pyx_L2_error)
7946 __Pyx_GOTREF(__pyx_t_1);
7947 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7948 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_sync_file_range); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L2_error)
7949 __Pyx_GOTREF(__pyx_t_2);
7950 if (PyDict_SetItem(__pyx_d, __pyx_n_s_sync_file_range, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L2_error)
7951 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7952 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_SYNC_FILE_RANGE_WRITE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L2_error)
7953 __Pyx_GOTREF(__pyx_t_2);
7954 if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYNC_FILE_RANGE_WRITE, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L2_error)
7955 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7956 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_SYNC_FILE_RANGE_WAIT_BEFORE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L2_error)
7957 __Pyx_GOTREF(__pyx_t_2);
7958 if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYNC_FILE_RANGE_WAIT_BEFORE, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L2_error)
7959 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7960 __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_SYNC_FILE_RANGE_WAIT_AFTER); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 16, __pyx_L2_error)
7961 __Pyx_GOTREF(__pyx_t_2);
7962 if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYNC_FILE_RANGE_WAIT_AFTER, __pyx_t_2) < 0) __PYX_ERR(0, 16, __pyx_L2_error)
7963 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
7964 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
7965
7966 /* "borg/platform/linux.pyx":17
7967 * try:
7968 * from .syncfilerange import sync_file_range, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WAIT_AFTER
7969 * SYNC_FILE_RANGE_LOADED = True # <<<<<<<<<<<<<<
7970 * except ImportError:
7971 * SYNC_FILE_RANGE_LOADED = False
7972 */
7973 if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYNC_FILE_RANGE_LOADED, Py_True) < 0) __PYX_ERR(0, 17, __pyx_L2_error)
7974
7975 /* "borg/platform/linux.pyx":15
7976 * from .base import safe_fadvise
7977 * from .posix import swidth
7978 * try: # <<<<<<<<<<<<<<
7979 * from .syncfilerange import sync_file_range, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WAIT_AFTER
7980 * SYNC_FILE_RANGE_LOADED = True
7981 */
7982 }
7983 __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
7984 __Pyx_XDECREF(__pyx_t_4); __pyx_t_4 = 0;
7985 __Pyx_XDECREF(__pyx_t_5); __pyx_t_5 = 0;
7986 goto __pyx_L7_try_end;
7987 __pyx_L2_error:;
7988 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
7989 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
7990
7991 /* "borg/platform/linux.pyx":18
7992 * from .syncfilerange import sync_file_range, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WAIT_AFTER
7993 * SYNC_FILE_RANGE_LOADED = True
7994 * except ImportError: # <<<<<<<<<<<<<<
7995 * SYNC_FILE_RANGE_LOADED = False
7996 *
7997 */
7998 __pyx_t_6 = __Pyx_PyErr_ExceptionMatches(__pyx_builtin_ImportError);
7999 if (__pyx_t_6) {
8000 __Pyx_AddTraceback("borg.platform.linux", __pyx_clineno, __pyx_lineno, __pyx_filename);
8001 if (__Pyx_GetException(&__pyx_t_1, &__pyx_t_2, &__pyx_t_7) < 0) __PYX_ERR(0, 18, __pyx_L4_except_error)
8002 __Pyx_GOTREF(__pyx_t_1);
8003 __Pyx_GOTREF(__pyx_t_2);
8004 __Pyx_GOTREF(__pyx_t_7);
8005
8006 /* "borg/platform/linux.pyx":19
8007 * SYNC_FILE_RANGE_LOADED = True
8008 * except ImportError:
8009 * SYNC_FILE_RANGE_LOADED = False # <<<<<<<<<<<<<<
8010 *
8011 * from libc cimport errno
8012 */
8013 if (PyDict_SetItem(__pyx_d, __pyx_n_s_SYNC_FILE_RANGE_LOADED, Py_False) < 0) __PYX_ERR(0, 19, __pyx_L4_except_error)
8014 __Pyx_XDECREF(__pyx_t_1); __pyx_t_1 = 0;
8015 __Pyx_XDECREF(__pyx_t_2); __pyx_t_2 = 0;
8016 __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
8017 goto __pyx_L3_exception_handled;
8018 }
8019 goto __pyx_L4_except_error;
8020 __pyx_L4_except_error:;
8021
8022 /* "borg/platform/linux.pyx":15
8023 * from .base import safe_fadvise
8024 * from .posix import swidth
8025 * try: # <<<<<<<<<<<<<<
8026 * from .syncfilerange import sync_file_range, SYNC_FILE_RANGE_WRITE, SYNC_FILE_RANGE_WAIT_BEFORE, SYNC_FILE_RANGE_WAIT_AFTER
8027 * SYNC_FILE_RANGE_LOADED = True
8028 */
8029 __Pyx_XGIVEREF(__pyx_t_3);
8030 __Pyx_XGIVEREF(__pyx_t_4);
8031 __Pyx_XGIVEREF(__pyx_t_5);
8032 __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
8033 goto __pyx_L1_error;
8034 __pyx_L3_exception_handled:;
8035 __Pyx_XGIVEREF(__pyx_t_3);
8036 __Pyx_XGIVEREF(__pyx_t_4);
8037 __Pyx_XGIVEREF(__pyx_t_5);
8038 __Pyx_ExceptionReset(__pyx_t_3, __pyx_t_4, __pyx_t_5);
8039 __pyx_L7_try_end:;
8040 }
8041
8042 /* "borg/platform/linux.pyx":24
8043 * from libc.stdint cimport int64_t
8044 *
8045 * API_VERSION = '1.1_04' # <<<<<<<<<<<<<<
8046 *
8047 * cdef extern from "sys/types.h":
8048 */
8049 if (PyDict_SetItem(__pyx_d, __pyx_n_s_API_VERSION, __pyx_kp_u_1_1_04) < 0) __PYX_ERR(0, 24, __pyx_L1_error)
8050
8051 /* "borg/platform/linux.pyx":65
8052 * char *strerror(int errnum)
8053 *
8054 * _comment_re = re.compile(' *#.*', re.M) # <<<<<<<<<<<<<<
8055 *
8056 *
8057 */
8058 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_re); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 65, __pyx_L1_error)
8059 __Pyx_GOTREF(__pyx_t_7);
8060 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_compile); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 65, __pyx_L1_error)
8061 __Pyx_GOTREF(__pyx_t_2);
8062 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8063 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_re); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 65, __pyx_L1_error)
8064 __Pyx_GOTREF(__pyx_t_7);
8065 __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_M); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
8066 __Pyx_GOTREF(__pyx_t_1);
8067 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8068 __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 65, __pyx_L1_error)
8069 __Pyx_GOTREF(__pyx_t_7);
8070 __Pyx_INCREF(__pyx_kp_u__6);
8071 __Pyx_GIVEREF(__pyx_kp_u__6);
8072 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_kp_u__6);
8073 __Pyx_GIVEREF(__pyx_t_1);
8074 PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_1);
8075 __pyx_t_1 = 0;
8076 __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_7, NULL); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 65, __pyx_L1_error)
8077 __Pyx_GOTREF(__pyx_t_1);
8078 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8079 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8080 if (PyDict_SetItem(__pyx_d, __pyx_n_s_comment_re, __pyx_t_1) < 0) __PYX_ERR(0, 65, __pyx_L1_error)
8081 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8082
8083 /* "borg/platform/linux.pyx":69
8084 *
8085 * BSD_TO_LINUX_FLAGS = {
8086 * stat.UF_NODUMP: FS_NODUMP_FL, # <<<<<<<<<<<<<<
8087 * stat.UF_IMMUTABLE: FS_IMMUTABLE_FL,
8088 * stat.UF_APPEND: FS_APPEND_FL,
8089 */
8090 __pyx_t_1 = __Pyx_PyDict_NewPresized(4); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 69, __pyx_L1_error)
8091 __Pyx_GOTREF(__pyx_t_1);
8092 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_stat); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 69, __pyx_L1_error)
8093 __Pyx_GOTREF(__pyx_t_7);
8094 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_UF_NODUMP); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 69, __pyx_L1_error)
8095 __Pyx_GOTREF(__pyx_t_2);
8096 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8097 __pyx_t_7 = __Pyx_PyInt_From_int(FS_NODUMP_FL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 69, __pyx_L1_error)
8098 __Pyx_GOTREF(__pyx_t_7);
8099 if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_7) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
8100 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8101 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8102
8103 /* "borg/platform/linux.pyx":70
8104 * BSD_TO_LINUX_FLAGS = {
8105 * stat.UF_NODUMP: FS_NODUMP_FL,
8106 * stat.UF_IMMUTABLE: FS_IMMUTABLE_FL, # <<<<<<<<<<<<<<
8107 * stat.UF_APPEND: FS_APPEND_FL,
8108 * stat.UF_COMPRESSED: FS_COMPR_FL,
8109 */
8110 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_stat); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 70, __pyx_L1_error)
8111 __Pyx_GOTREF(__pyx_t_7);
8112 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_UF_IMMUTABLE); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 70, __pyx_L1_error)
8113 __Pyx_GOTREF(__pyx_t_2);
8114 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8115 __pyx_t_7 = __Pyx_PyInt_From_int(FS_IMMUTABLE_FL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 70, __pyx_L1_error)
8116 __Pyx_GOTREF(__pyx_t_7);
8117 if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_7) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
8118 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8119 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8120
8121 /* "borg/platform/linux.pyx":71
8122 * stat.UF_NODUMP: FS_NODUMP_FL,
8123 * stat.UF_IMMUTABLE: FS_IMMUTABLE_FL,
8124 * stat.UF_APPEND: FS_APPEND_FL, # <<<<<<<<<<<<<<
8125 * stat.UF_COMPRESSED: FS_COMPR_FL,
8126 * }
8127 */
8128 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_stat); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 71, __pyx_L1_error)
8129 __Pyx_GOTREF(__pyx_t_7);
8130 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_UF_APPEND); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 71, __pyx_L1_error)
8131 __Pyx_GOTREF(__pyx_t_2);
8132 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8133 __pyx_t_7 = __Pyx_PyInt_From_int(FS_APPEND_FL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 71, __pyx_L1_error)
8134 __Pyx_GOTREF(__pyx_t_7);
8135 if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_7) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
8136 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8137 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8138
8139 /* "borg/platform/linux.pyx":72
8140 * stat.UF_IMMUTABLE: FS_IMMUTABLE_FL,
8141 * stat.UF_APPEND: FS_APPEND_FL,
8142 * stat.UF_COMPRESSED: FS_COMPR_FL, # <<<<<<<<<<<<<<
8143 * }
8144 *
8145 */
8146 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_stat); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 72, __pyx_L1_error)
8147 __Pyx_GOTREF(__pyx_t_7);
8148 __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_7, __pyx_n_s_UF_COMPRESSED); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 72, __pyx_L1_error)
8149 __Pyx_GOTREF(__pyx_t_2);
8150 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8151 __pyx_t_7 = __Pyx_PyInt_From_int(FS_COMPR_FL); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 72, __pyx_L1_error)
8152 __Pyx_GOTREF(__pyx_t_7);
8153 if (PyDict_SetItem(__pyx_t_1, __pyx_t_2, __pyx_t_7) < 0) __PYX_ERR(0, 69, __pyx_L1_error)
8154 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8155 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8156 if (PyDict_SetItem(__pyx_d, __pyx_n_s_BSD_TO_LINUX_FLAGS, __pyx_t_1) < 0) __PYX_ERR(0, 68, __pyx_L1_error)
8157 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8158
8159 /* "borg/platform/linux.pyx":76
8160 *
8161 *
8162 * def set_flags(path, bsd_flags, fd=None): # <<<<<<<<<<<<<<
8163 * if fd is None:
8164 * st = os.stat(path, follow_symlinks=False)
8165 */
8166 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4borg_8platform_5linux_1set_flags, NULL, __pyx_n_s_borg_platform_linux); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 76, __pyx_L1_error)
8167 __Pyx_GOTREF(__pyx_t_1);
8168 if (PyDict_SetItem(__pyx_d, __pyx_n_s_set_flags, __pyx_t_1) < 0) __PYX_ERR(0, 76, __pyx_L1_error)
8169 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8170
8171 /* "borg/platform/linux.pyx":99
8172 *
8173 *
8174 * def get_flags(path, st): # <<<<<<<<<<<<<<
8175 * if stat.S_ISBLK(st.st_mode) or stat.S_ISCHR(st.st_mode) or stat.S_ISLNK(st.st_mode):
8176 * # avoid opening devices files - trying to open non-present devices can be rather slow.
8177 */
8178 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4borg_8platform_5linux_3get_flags, NULL, __pyx_n_s_borg_platform_linux); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 99, __pyx_L1_error)
8179 __Pyx_GOTREF(__pyx_t_1);
8180 if (PyDict_SetItem(__pyx_d, __pyx_n_s_get_flags, __pyx_t_1) < 0) __PYX_ERR(0, 99, __pyx_L1_error)
8181 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8182
8183 /* "borg/platform/linux.pyx":121
8184 *
8185 *
8186 * def acl_use_local_uid_gid(acl): # <<<<<<<<<<<<<<
8187 * """Replace the user/group field with the local uid/gid if possible
8188 * """
8189 */
8190 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4borg_8platform_5linux_5acl_use_local_uid_gid, NULL, __pyx_n_s_borg_platform_linux); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 121, __pyx_L1_error)
8191 __Pyx_GOTREF(__pyx_t_1);
8192 if (PyDict_SetItem(__pyx_d, __pyx_n_s_acl_use_local_uid_gid, __pyx_t_1) < 0) __PYX_ERR(0, 121, __pyx_L1_error)
8193 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8194
8195 /* "borg/platform/linux.pyx":170
8196 *
8197 *
8198 * def acl_get(path, item, st, numeric_owner=False): # <<<<<<<<<<<<<<
8199 * cdef acl_t default_acl = NULL
8200 * cdef acl_t access_acl = NULL
8201 */
8202 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4borg_8platform_5linux_7acl_get, NULL, __pyx_n_s_borg_platform_linux); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 170, __pyx_L1_error)
8203 __Pyx_GOTREF(__pyx_t_1);
8204 if (PyDict_SetItem(__pyx_d, __pyx_n_s_acl_get, __pyx_t_1) < 0) __PYX_ERR(0, 170, __pyx_L1_error)
8205 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8206
8207 /* "borg/platform/linux.pyx":201
8208 *
8209 *
8210 * def acl_set(path, item, numeric_owner=False): # <<<<<<<<<<<<<<
8211 * cdef acl_t access_acl = NULL
8212 * cdef acl_t default_acl = NULL
8213 */
8214 __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_4borg_8platform_5linux_9acl_set, NULL, __pyx_n_s_borg_platform_linux); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 201, __pyx_L1_error)
8215 __Pyx_GOTREF(__pyx_t_1);
8216 if (PyDict_SetItem(__pyx_d, __pyx_n_s_acl_set, __pyx_t_1) < 0) __PYX_ERR(0, 201, __pyx_L1_error)
8217 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8218
8219 /* "borg/platform/linux.pyx":240
8220 *
8221 *
8222 * cdef unsigned PAGE_MASK = sysconf(_SC_PAGESIZE) - 1 # <<<<<<<<<<<<<<
8223 *
8224 *
8225 */
8226 __pyx_v_4borg_8platform_5linux_PAGE_MASK = (sysconf(_SC_PAGESIZE) - 1);
8227
8228 /* "borg/platform/linux.pyx":243
8229 *
8230 *
8231 * if 'basesyncfile' in workarounds or not SYNC_FILE_RANGE_LOADED: # <<<<<<<<<<<<<<
8232 * class SyncFile(BaseSyncFile):
8233 * # if we are on platforms with a broken or not implemented sync_file_range,
8234 */
8235 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_workarounds); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error)
8236 __Pyx_GOTREF(__pyx_t_1);
8237 __pyx_t_9 = (__Pyx_PySequence_ContainsTF(__pyx_n_u_basesyncfile, __pyx_t_1, Py_EQ)); if (unlikely(__pyx_t_9 < 0)) __PYX_ERR(0, 243, __pyx_L1_error)
8238 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8239 __pyx_t_10 = (__pyx_t_9 != 0);
8240 if (!__pyx_t_10) {
8241 } else {
8242 __pyx_t_8 = __pyx_t_10;
8243 goto __pyx_L11_bool_binop_done;
8244 }
8245 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_SYNC_FILE_RANGE_LOADED); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 243, __pyx_L1_error)
8246 __Pyx_GOTREF(__pyx_t_1);
8247 __pyx_t_10 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_10 < 0)) __PYX_ERR(0, 243, __pyx_L1_error)
8248 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8249 __pyx_t_9 = ((!__pyx_t_10) != 0);
8250 __pyx_t_8 = __pyx_t_9;
8251 __pyx_L11_bool_binop_done:;
8252 if (__pyx_t_8) {
8253
8254 /* "borg/platform/linux.pyx":244
8255 *
8256 * if 'basesyncfile' in workarounds or not SYNC_FILE_RANGE_LOADED:
8257 * class SyncFile(BaseSyncFile): # <<<<<<<<<<<<<<
8258 * # if we are on platforms with a broken or not implemented sync_file_range,
8259 * # use the more generic BaseSyncFile to avoid issues.
8260 */
8261 __Pyx_GetModuleGlobalName(__pyx_t_1, __pyx_n_s_BaseSyncFile); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error)
8262 __Pyx_GOTREF(__pyx_t_1);
8263 __pyx_t_7 = PyTuple_New(1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 244, __pyx_L1_error)
8264 __Pyx_GOTREF(__pyx_t_7);
8265 __Pyx_GIVEREF(__pyx_t_1);
8266 PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_1);
8267 __pyx_t_1 = 0;
8268 __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_7); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 244, __pyx_L1_error)
8269 __Pyx_GOTREF(__pyx_t_1);
8270 __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_7, __pyx_n_s_SyncFile, __pyx_n_s_SyncFile, (PyObject *) NULL, __pyx_n_s_borg_platform_linux, (PyObject *) NULL); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 244, __pyx_L1_error)
8271 __Pyx_GOTREF(__pyx_t_2);
8272 __pyx_t_11 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_SyncFile, __pyx_t_7, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 244, __pyx_L1_error)
8273 __Pyx_GOTREF(__pyx_t_11);
8274 if (PyDict_SetItem(__pyx_d, __pyx_n_s_SyncFile, __pyx_t_11) < 0) __PYX_ERR(0, 244, __pyx_L1_error)
8275 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8276 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8277 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8278 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8279
8280 /* "borg/platform/linux.pyx":243
8281 *
8282 *
8283 * if 'basesyncfile' in workarounds or not SYNC_FILE_RANGE_LOADED: # <<<<<<<<<<<<<<
8284 * class SyncFile(BaseSyncFile):
8285 * # if we are on platforms with a broken or not implemented sync_file_range,
8286 */
8287 goto __pyx_L10;
8288 }
8289
8290 /* "borg/platform/linux.pyx":251
8291 * else:
8292 * # a real Linux, so we can do better. :)
8293 * class SyncFile(BaseSyncFile): # <<<<<<<<<<<<<<
8294 * """
8295 * Implemented using sync_file_range for asynchronous write-out and fdatasync for actual durability.
8296 */
8297 /*else*/ {
8298 __Pyx_GetModuleGlobalName(__pyx_t_7, __pyx_n_s_BaseSyncFile); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 251, __pyx_L1_error)
8299 __Pyx_GOTREF(__pyx_t_7);
8300 __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 251, __pyx_L1_error)
8301 __Pyx_GOTREF(__pyx_t_1);
8302 __Pyx_GIVEREF(__pyx_t_7);
8303 PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_t_7);
8304 __pyx_t_7 = 0;
8305 __pyx_t_7 = __Pyx_CalculateMetaclass(NULL, __pyx_t_1); if (unlikely(!__pyx_t_7)) __PYX_ERR(0, 251, __pyx_L1_error)
8306 __Pyx_GOTREF(__pyx_t_7);
8307 __pyx_t_2 = __Pyx_Py3MetaclassPrepare(__pyx_t_7, __pyx_t_1, __pyx_n_s_SyncFile, __pyx_n_s_SyncFile, (PyObject *) NULL, __pyx_n_s_borg_platform_linux, __pyx_kp_s_Implemented_using_sync_file_ran); if (unlikely(!__pyx_t_2)) __PYX_ERR(0, 251, __pyx_L1_error)
8308 __Pyx_GOTREF(__pyx_t_2);
8309 __pyx_t_11 = PyList_New(0); if (unlikely(!__pyx_t_11)) __PYX_ERR(0, 251, __pyx_L1_error)
8310 __Pyx_GOTREF(__pyx_t_11);
8311
8312 /* "borg/platform/linux.pyx":259
8313 * """
8314 *
8315 * def __init__(self, path, binary=False): # <<<<<<<<<<<<<<
8316 * super().__init__(path, binary)
8317 * self.offset = 0
8318 */
8319 __pyx_t_12 = __Pyx_CyFunction_New(&__pyx_mdef_4borg_8platform_5linux_8SyncFile_1__init__, 0, __pyx_n_s_SyncFile___init, NULL, __pyx_n_s_borg_platform_linux, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 259, __pyx_L1_error)
8320 __Pyx_GOTREF(__pyx_t_12);
8321 __Pyx_INCREF(__pyx_t_12);
8322 PyList_Append(__pyx_t_11, __pyx_t_12);
8323 __Pyx_GIVEREF(__pyx_t_12);
8324 __Pyx_CyFunction_SetDefaultsTuple(__pyx_t_12, __pyx_tuple__19);
8325 if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_init, __pyx_t_12) < 0) __PYX_ERR(0, 259, __pyx_L1_error)
8326 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
8327
8328 /* "borg/platform/linux.pyx":266
8329 * self.pending_sync = None
8330 *
8331 * def write(self, data): # <<<<<<<<<<<<<<
8332 * self.offset += self.fd.write(data)
8333 * offset = self.offset & ~PAGE_MASK
8334 */
8335 __pyx_t_12 = __Pyx_CyFunction_New(&__pyx_mdef_4borg_8platform_5linux_8SyncFile_3write, 0, __pyx_n_s_SyncFile_write, NULL, __pyx_n_s_borg_platform_linux, __pyx_d, ((PyObject *)__pyx_codeobj__21)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 266, __pyx_L1_error)
8336 __Pyx_GOTREF(__pyx_t_12);
8337 if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_write, __pyx_t_12) < 0) __PYX_ERR(0, 266, __pyx_L1_error)
8338 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
8339
8340 /* "borg/platform/linux.pyx":278
8341 * self.last_sync = offset
8342 *
8343 * def sync(self): # <<<<<<<<<<<<<<
8344 * self.fd.flush()
8345 * os.fdatasync(self.fileno)
8346 */
8347 __pyx_t_12 = __Pyx_CyFunction_New(&__pyx_mdef_4borg_8platform_5linux_8SyncFile_5sync, 0, __pyx_n_s_SyncFile_sync, NULL, __pyx_n_s_borg_platform_linux, __pyx_d, ((PyObject *)__pyx_codeobj__23)); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 278, __pyx_L1_error)
8348 __Pyx_GOTREF(__pyx_t_12);
8349 if (__Pyx_SetNameInClass(__pyx_t_2, __pyx_n_s_sync, __pyx_t_12) < 0) __PYX_ERR(0, 278, __pyx_L1_error)
8350 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
8351
8352 /* "borg/platform/linux.pyx":251
8353 * else:
8354 * # a real Linux, so we can do better. :)
8355 * class SyncFile(BaseSyncFile): # <<<<<<<<<<<<<<
8356 * """
8357 * Implemented using sync_file_range for asynchronous write-out and fdatasync for actual durability.
8358 */
8359 __pyx_t_12 = __Pyx_Py3ClassCreate(__pyx_t_7, __pyx_n_s_SyncFile, __pyx_t_1, __pyx_t_2, NULL, 0, 0); if (unlikely(!__pyx_t_12)) __PYX_ERR(0, 251, __pyx_L1_error)
8360 __Pyx_GOTREF(__pyx_t_12);
8361 if (__Pyx_CyFunction_InitClassCell(__pyx_t_11, __pyx_t_12) < 0) __PYX_ERR(0, 251, __pyx_L1_error)
8362 __Pyx_DECREF(__pyx_t_11); __pyx_t_11 = 0;
8363 if (PyDict_SetItem(__pyx_d, __pyx_n_s_SyncFile, __pyx_t_12) < 0) __PYX_ERR(0, 251, __pyx_L1_error)
8364 __Pyx_DECREF(__pyx_t_12); __pyx_t_12 = 0;
8365 __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
8366 __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
8367 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8368 }
8369 __pyx_L10:;
8370
8371 /* "borg/platform/linux.pyx":1
8372 * # cython: language_level=3 # <<<<<<<<<<<<<<
8373 *
8374 * import os
8375 */
8376 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
8377 __Pyx_GOTREF(__pyx_t_1);
8378 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
8379 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
8380
8381 /*--- Wrapped vars code ---*/
8382
8383 goto __pyx_L0;
8384 __pyx_L1_error:;
8385 __Pyx_XDECREF(__pyx_t_1);
8386 __Pyx_XDECREF(__pyx_t_2);
8387 __Pyx_XDECREF(__pyx_t_7);
8388 __Pyx_XDECREF(__pyx_t_11);
8389 __Pyx_XDECREF(__pyx_t_12);
8390 if (__pyx_m) {
8391 if (__pyx_d) {
8392 __Pyx_AddTraceback("init borg.platform.linux", __pyx_clineno, __pyx_lineno, __pyx_filename);
8393 }
8394 Py_CLEAR(__pyx_m);
8395 } else if (!PyErr_Occurred()) {
8396 PyErr_SetString(PyExc_ImportError, "init borg.platform.linux");
8397 }
8398 __pyx_L0:;
8399 __Pyx_RefNannyFinishContext();
8400 #if CYTHON_PEP489_MULTI_PHASE_INIT
8401 return (__pyx_m != NULL) ? 0 : -1;
8402 #elif PY_MAJOR_VERSION >= 3
8403 return __pyx_m;
8404 #else
8405 return;
8406 #endif
8407 }
8408
8409 /* --- Runtime support code --- */
8410 /* Refnanny */
8411 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)8412 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
8413 PyObject *m = NULL, *p = NULL;
8414 void *r = NULL;
8415 m = PyImport_ImportModule(modname);
8416 if (!m) goto end;
8417 p = PyObject_GetAttrString(m, "RefNannyAPI");
8418 if (!p) goto end;
8419 r = PyLong_AsVoidPtr(p);
8420 end:
8421 Py_XDECREF(p);
8422 Py_XDECREF(m);
8423 return (__Pyx_RefNannyAPIStruct *)r;
8424 }
8425 #endif
8426
8427 /* PyObjectGetAttrStr */
8428 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)8429 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
8430 PyTypeObject* tp = Py_TYPE(obj);
8431 if (likely(tp->tp_getattro))
8432 return tp->tp_getattro(obj, attr_name);
8433 #if PY_MAJOR_VERSION < 3
8434 if (likely(tp->tp_getattr))
8435 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
8436 #endif
8437 return PyObject_GetAttr(obj, attr_name);
8438 }
8439 #endif
8440
8441 /* GetBuiltinName */
__Pyx_GetBuiltinName(PyObject * name)8442 static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
8443 PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
8444 if (unlikely(!result)) {
8445 PyErr_Format(PyExc_NameError,
8446 #if PY_MAJOR_VERSION >= 3
8447 "name '%U' is not defined", name);
8448 #else
8449 "name '%.200s' is not defined", PyString_AS_STRING(name));
8450 #endif
8451 }
8452 return result;
8453 }
8454
8455 /* RaiseArgTupleInvalid */
__Pyx_RaiseArgtupleInvalid(const char * func_name,int exact,Py_ssize_t num_min,Py_ssize_t num_max,Py_ssize_t num_found)8456 static void __Pyx_RaiseArgtupleInvalid(
8457 const char* func_name,
8458 int exact,
8459 Py_ssize_t num_min,
8460 Py_ssize_t num_max,
8461 Py_ssize_t num_found)
8462 {
8463 Py_ssize_t num_expected;
8464 const char *more_or_less;
8465 if (num_found < num_min) {
8466 num_expected = num_min;
8467 more_or_less = "at least";
8468 } else {
8469 num_expected = num_max;
8470 more_or_less = "at most";
8471 }
8472 if (exact) {
8473 more_or_less = "exactly";
8474 }
8475 PyErr_Format(PyExc_TypeError,
8476 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
8477 func_name, more_or_less, num_expected,
8478 (num_expected == 1) ? "" : "s", num_found);
8479 }
8480
8481 /* RaiseDoubleKeywords */
__Pyx_RaiseDoubleKeywordsError(const char * func_name,PyObject * kw_name)8482 static void __Pyx_RaiseDoubleKeywordsError(
8483 const char* func_name,
8484 PyObject* kw_name)
8485 {
8486 PyErr_Format(PyExc_TypeError,
8487 #if PY_MAJOR_VERSION >= 3
8488 "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
8489 #else
8490 "%s() got multiple values for keyword argument '%s'", func_name,
8491 PyString_AsString(kw_name));
8492 #endif
8493 }
8494
8495 /* ParseKeywords */
__Pyx_ParseOptionalKeywords(PyObject * kwds,PyObject ** argnames[],PyObject * kwds2,PyObject * values[],Py_ssize_t num_pos_args,const char * function_name)8496 static int __Pyx_ParseOptionalKeywords(
8497 PyObject *kwds,
8498 PyObject **argnames[],
8499 PyObject *kwds2,
8500 PyObject *values[],
8501 Py_ssize_t num_pos_args,
8502 const char* function_name)
8503 {
8504 PyObject *key = 0, *value = 0;
8505 Py_ssize_t pos = 0;
8506 PyObject*** name;
8507 PyObject*** first_kw_arg = argnames + num_pos_args;
8508 while (PyDict_Next(kwds, &pos, &key, &value)) {
8509 name = first_kw_arg;
8510 while (*name && (**name != key)) name++;
8511 if (*name) {
8512 values[name-argnames] = value;
8513 continue;
8514 }
8515 name = first_kw_arg;
8516 #if PY_MAJOR_VERSION < 3
8517 if (likely(PyString_Check(key))) {
8518 while (*name) {
8519 if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
8520 && _PyString_Eq(**name, key)) {
8521 values[name-argnames] = value;
8522 break;
8523 }
8524 name++;
8525 }
8526 if (*name) continue;
8527 else {
8528 PyObject*** argname = argnames;
8529 while (argname != first_kw_arg) {
8530 if ((**argname == key) || (
8531 (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
8532 && _PyString_Eq(**argname, key))) {
8533 goto arg_passed_twice;
8534 }
8535 argname++;
8536 }
8537 }
8538 } else
8539 #endif
8540 if (likely(PyUnicode_Check(key))) {
8541 while (*name) {
8542 int cmp = (**name == key) ? 0 :
8543 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
8544 (__Pyx_PyUnicode_GET_LENGTH(**name) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
8545 #endif
8546 PyUnicode_Compare(**name, key);
8547 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
8548 if (cmp == 0) {
8549 values[name-argnames] = value;
8550 break;
8551 }
8552 name++;
8553 }
8554 if (*name) continue;
8555 else {
8556 PyObject*** argname = argnames;
8557 while (argname != first_kw_arg) {
8558 int cmp = (**argname == key) ? 0 :
8559 #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
8560 (__Pyx_PyUnicode_GET_LENGTH(**argname) != __Pyx_PyUnicode_GET_LENGTH(key)) ? 1 :
8561 #endif
8562 PyUnicode_Compare(**argname, key);
8563 if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
8564 if (cmp == 0) goto arg_passed_twice;
8565 argname++;
8566 }
8567 }
8568 } else
8569 goto invalid_keyword_type;
8570 if (kwds2) {
8571 if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
8572 } else {
8573 goto invalid_keyword;
8574 }
8575 }
8576 return 0;
8577 arg_passed_twice:
8578 __Pyx_RaiseDoubleKeywordsError(function_name, key);
8579 goto bad;
8580 invalid_keyword_type:
8581 PyErr_Format(PyExc_TypeError,
8582 "%.200s() keywords must be strings", function_name);
8583 goto bad;
8584 invalid_keyword:
8585 PyErr_Format(PyExc_TypeError,
8586 #if PY_MAJOR_VERSION < 3
8587 "%.200s() got an unexpected keyword argument '%.200s'",
8588 function_name, PyString_AsString(key));
8589 #else
8590 "%s() got an unexpected keyword argument '%U'",
8591 function_name, key);
8592 #endif
8593 bad:
8594 return -1;
8595 }
8596
8597 /* PyDictVersioning */
8598 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)8599 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
8600 PyObject *dict = Py_TYPE(obj)->tp_dict;
8601 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
8602 }
__Pyx_get_object_dict_version(PyObject * obj)8603 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
8604 PyObject **dictptr = NULL;
8605 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
8606 if (offset) {
8607 #if CYTHON_COMPILING_IN_CPYTHON
8608 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
8609 #else
8610 dictptr = _PyObject_GetDictPtr(obj);
8611 #endif
8612 }
8613 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
8614 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)8615 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
8616 PyObject *dict = Py_TYPE(obj)->tp_dict;
8617 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
8618 return 0;
8619 return obj_dict_version == __Pyx_get_object_dict_version(obj);
8620 }
8621 #endif
8622
8623 /* GetModuleGlobalName */
8624 #if CYTHON_USE_DICT_VERSIONS
__Pyx__GetModuleGlobalName(PyObject * name,PY_UINT64_T * dict_version,PyObject ** dict_cached_value)8625 static PyObject *__Pyx__GetModuleGlobalName(PyObject *name, PY_UINT64_T *dict_version, PyObject **dict_cached_value)
8626 #else
8627 static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
8628 #endif
8629 {
8630 PyObject *result;
8631 #if !CYTHON_AVOID_BORROWED_REFS
8632 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1
8633 result = _PyDict_GetItem_KnownHash(__pyx_d, name, ((PyASCIIObject *) name)->hash);
8634 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
8635 if (likely(result)) {
8636 return __Pyx_NewRef(result);
8637 } else if (unlikely(PyErr_Occurred())) {
8638 return NULL;
8639 }
8640 #else
8641 result = PyDict_GetItem(__pyx_d, name);
8642 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
8643 if (likely(result)) {
8644 return __Pyx_NewRef(result);
8645 }
8646 #endif
8647 #else
8648 result = PyObject_GetItem(__pyx_d, name);
8649 __PYX_UPDATE_DICT_CACHE(__pyx_d, result, *dict_cached_value, *dict_version)
8650 if (likely(result)) {
8651 return __Pyx_NewRef(result);
8652 }
8653 PyErr_Clear();
8654 #endif
8655 return __Pyx_GetBuiltinName(name);
8656 }
8657
8658 /* PyObjectCall */
8659 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_Call(PyObject * func,PyObject * arg,PyObject * kw)8660 static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
8661 PyObject *result;
8662 ternaryfunc call = func->ob_type->tp_call;
8663 if (unlikely(!call))
8664 return PyObject_Call(func, arg, kw);
8665 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
8666 return NULL;
8667 result = (*call)(func, arg, kw);
8668 Py_LeaveRecursiveCall();
8669 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
8670 PyErr_SetString(
8671 PyExc_SystemError,
8672 "NULL result without error in PyObject_Call");
8673 }
8674 return result;
8675 }
8676 #endif
8677
8678 /* PyCFunctionFastCall */
8679 #if CYTHON_FAST_PYCCALL
__Pyx_PyCFunction_FastCall(PyObject * func_obj,PyObject ** args,Py_ssize_t nargs)8680 static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *func_obj, PyObject **args, Py_ssize_t nargs) {
8681 PyCFunctionObject *func = (PyCFunctionObject*)func_obj;
8682 PyCFunction meth = PyCFunction_GET_FUNCTION(func);
8683 PyObject *self = PyCFunction_GET_SELF(func);
8684 int flags = PyCFunction_GET_FLAGS(func);
8685 assert(PyCFunction_Check(func));
8686 assert(METH_FASTCALL == (flags & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)));
8687 assert(nargs >= 0);
8688 assert(nargs == 0 || args != NULL);
8689 /* _PyCFunction_FastCallDict() must not be called with an exception set,
8690 because it may clear it (directly or indirectly) and so the
8691 caller loses its exception */
8692 assert(!PyErr_Occurred());
8693 if ((PY_VERSION_HEX < 0x030700A0) || unlikely(flags & METH_KEYWORDS)) {
8694 return (*((__Pyx_PyCFunctionFastWithKeywords)(void*)meth)) (self, args, nargs, NULL);
8695 } else {
8696 return (*((__Pyx_PyCFunctionFast)(void*)meth)) (self, args, nargs);
8697 }
8698 }
8699 #endif
8700
8701 /* PyFunctionFastCall */
8702 #if CYTHON_FAST_PYCALL
__Pyx_PyFunction_FastCallNoKw(PyCodeObject * co,PyObject ** args,Py_ssize_t na,PyObject * globals)8703 static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObject **args, Py_ssize_t na,
8704 PyObject *globals) {
8705 PyFrameObject *f;
8706 PyThreadState *tstate = __Pyx_PyThreadState_Current;
8707 PyObject **fastlocals;
8708 Py_ssize_t i;
8709 PyObject *result;
8710 assert(globals != NULL);
8711 /* XXX Perhaps we should create a specialized
8712 PyFrame_New() that doesn't take locals, but does
8713 take builtins without sanity checking them.
8714 */
8715 assert(tstate != NULL);
8716 f = PyFrame_New(tstate, co, globals, NULL);
8717 if (f == NULL) {
8718 return NULL;
8719 }
8720 fastlocals = __Pyx_PyFrame_GetLocalsplus(f);
8721 for (i = 0; i < na; i++) {
8722 Py_INCREF(*args);
8723 fastlocals[i] = *args++;
8724 }
8725 result = PyEval_EvalFrameEx(f,0);
8726 ++tstate->recursion_depth;
8727 Py_DECREF(f);
8728 --tstate->recursion_depth;
8729 return result;
8730 }
8731 #if 1 || PY_VERSION_HEX < 0x030600B1
__Pyx_PyFunction_FastCallDict(PyObject * func,PyObject ** args,Py_ssize_t nargs,PyObject * kwargs)8732 static PyObject *__Pyx_PyFunction_FastCallDict(PyObject *func, PyObject **args, Py_ssize_t nargs, PyObject *kwargs) {
8733 PyCodeObject *co = (PyCodeObject *)PyFunction_GET_CODE(func);
8734 PyObject *globals = PyFunction_GET_GLOBALS(func);
8735 PyObject *argdefs = PyFunction_GET_DEFAULTS(func);
8736 PyObject *closure;
8737 #if PY_MAJOR_VERSION >= 3
8738 PyObject *kwdefs;
8739 #endif
8740 PyObject *kwtuple, **k;
8741 PyObject **d;
8742 Py_ssize_t nd;
8743 Py_ssize_t nk;
8744 PyObject *result;
8745 assert(kwargs == NULL || PyDict_Check(kwargs));
8746 nk = kwargs ? PyDict_Size(kwargs) : 0;
8747 if (Py_EnterRecursiveCall((char*)" while calling a Python object")) {
8748 return NULL;
8749 }
8750 if (
8751 #if PY_MAJOR_VERSION >= 3
8752 co->co_kwonlyargcount == 0 &&
8753 #endif
8754 likely(kwargs == NULL || nk == 0) &&
8755 co->co_flags == (CO_OPTIMIZED | CO_NEWLOCALS | CO_NOFREE)) {
8756 if (argdefs == NULL && co->co_argcount == nargs) {
8757 result = __Pyx_PyFunction_FastCallNoKw(co, args, nargs, globals);
8758 goto done;
8759 }
8760 else if (nargs == 0 && argdefs != NULL
8761 && co->co_argcount == Py_SIZE(argdefs)) {
8762 /* function called with no arguments, but all parameters have
8763 a default value: use default values as arguments .*/
8764 args = &PyTuple_GET_ITEM(argdefs, 0);
8765 result =__Pyx_PyFunction_FastCallNoKw(co, args, Py_SIZE(argdefs), globals);
8766 goto done;
8767 }
8768 }
8769 if (kwargs != NULL) {
8770 Py_ssize_t pos, i;
8771 kwtuple = PyTuple_New(2 * nk);
8772 if (kwtuple == NULL) {
8773 result = NULL;
8774 goto done;
8775 }
8776 k = &PyTuple_GET_ITEM(kwtuple, 0);
8777 pos = i = 0;
8778 while (PyDict_Next(kwargs, &pos, &k[i], &k[i+1])) {
8779 Py_INCREF(k[i]);
8780 Py_INCREF(k[i+1]);
8781 i += 2;
8782 }
8783 nk = i / 2;
8784 }
8785 else {
8786 kwtuple = NULL;
8787 k = NULL;
8788 }
8789 closure = PyFunction_GET_CLOSURE(func);
8790 #if PY_MAJOR_VERSION >= 3
8791 kwdefs = PyFunction_GET_KW_DEFAULTS(func);
8792 #endif
8793 if (argdefs != NULL) {
8794 d = &PyTuple_GET_ITEM(argdefs, 0);
8795 nd = Py_SIZE(argdefs);
8796 }
8797 else {
8798 d = NULL;
8799 nd = 0;
8800 }
8801 #if PY_MAJOR_VERSION >= 3
8802 result = PyEval_EvalCodeEx((PyObject*)co, globals, (PyObject *)NULL,
8803 args, (int)nargs,
8804 k, (int)nk,
8805 d, (int)nd, kwdefs, closure);
8806 #else
8807 result = PyEval_EvalCodeEx(co, globals, (PyObject *)NULL,
8808 args, (int)nargs,
8809 k, (int)nk,
8810 d, (int)nd, closure);
8811 #endif
8812 Py_XDECREF(kwtuple);
8813 done:
8814 Py_LeaveRecursiveCall();
8815 return result;
8816 }
8817 #endif
8818 #endif
8819
8820 /* PyObjectCall2Args */
__Pyx_PyObject_Call2Args(PyObject * function,PyObject * arg1,PyObject * arg2)8821 static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* function, PyObject* arg1, PyObject* arg2) {
8822 PyObject *args, *result = NULL;
8823 #if CYTHON_FAST_PYCALL
8824 if (PyFunction_Check(function)) {
8825 PyObject *args[2] = {arg1, arg2};
8826 return __Pyx_PyFunction_FastCall(function, args, 2);
8827 }
8828 #endif
8829 #if CYTHON_FAST_PYCCALL
8830 if (__Pyx_PyFastCFunction_Check(function)) {
8831 PyObject *args[2] = {arg1, arg2};
8832 return __Pyx_PyCFunction_FastCall(function, args, 2);
8833 }
8834 #endif
8835 args = PyTuple_New(2);
8836 if (unlikely(!args)) goto done;
8837 Py_INCREF(arg1);
8838 PyTuple_SET_ITEM(args, 0, arg1);
8839 Py_INCREF(arg2);
8840 PyTuple_SET_ITEM(args, 1, arg2);
8841 Py_INCREF(function);
8842 result = __Pyx_PyObject_Call(function, args, NULL);
8843 Py_DECREF(args);
8844 Py_DECREF(function);
8845 done:
8846 return result;
8847 }
8848
8849 /* PyObjectCallMethO */
8850 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallMethO(PyObject * func,PyObject * arg)8851 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
8852 PyObject *self, *result;
8853 PyCFunction cfunc;
8854 cfunc = PyCFunction_GET_FUNCTION(func);
8855 self = PyCFunction_GET_SELF(func);
8856 if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
8857 return NULL;
8858 result = cfunc(self, arg);
8859 Py_LeaveRecursiveCall();
8860 if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
8861 PyErr_SetString(
8862 PyExc_SystemError,
8863 "NULL result without error in PyObject_Call");
8864 }
8865 return result;
8866 }
8867 #endif
8868
8869 /* PyObjectCallOneArg */
8870 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx__PyObject_CallOneArg(PyObject * func,PyObject * arg)8871 static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
8872 PyObject *result;
8873 PyObject *args = PyTuple_New(1);
8874 if (unlikely(!args)) return NULL;
8875 Py_INCREF(arg);
8876 PyTuple_SET_ITEM(args, 0, arg);
8877 result = __Pyx_PyObject_Call(func, args, NULL);
8878 Py_DECREF(args);
8879 return result;
8880 }
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)8881 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
8882 #if CYTHON_FAST_PYCALL
8883 if (PyFunction_Check(func)) {
8884 return __Pyx_PyFunction_FastCall(func, &arg, 1);
8885 }
8886 #endif
8887 if (likely(PyCFunction_Check(func))) {
8888 if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
8889 return __Pyx_PyObject_CallMethO(func, arg);
8890 #if CYTHON_FAST_PYCCALL
8891 } else if (__Pyx_PyFastCFunction_Check(func)) {
8892 return __Pyx_PyCFunction_FastCall(func, &arg, 1);
8893 #endif
8894 }
8895 }
8896 return __Pyx__PyObject_CallOneArg(func, arg);
8897 }
8898 #else
__Pyx_PyObject_CallOneArg(PyObject * func,PyObject * arg)8899 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
8900 PyObject *result;
8901 PyObject *args = PyTuple_Pack(1, arg);
8902 if (unlikely(!args)) return NULL;
8903 result = __Pyx_PyObject_Call(func, args, NULL);
8904 Py_DECREF(args);
8905 return result;
8906 }
8907 #endif
8908
8909 /* IterFinish */
__Pyx_IterFinish(void)8910 static CYTHON_INLINE int __Pyx_IterFinish(void) {
8911 #if CYTHON_FAST_THREAD_STATE
8912 PyThreadState *tstate = __Pyx_PyThreadState_Current;
8913 PyObject* exc_type = tstate->curexc_type;
8914 if (unlikely(exc_type)) {
8915 if (likely(__Pyx_PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) {
8916 PyObject *exc_value, *exc_tb;
8917 exc_value = tstate->curexc_value;
8918 exc_tb = tstate->curexc_traceback;
8919 tstate->curexc_type = 0;
8920 tstate->curexc_value = 0;
8921 tstate->curexc_traceback = 0;
8922 Py_DECREF(exc_type);
8923 Py_XDECREF(exc_value);
8924 Py_XDECREF(exc_tb);
8925 return 0;
8926 } else {
8927 return -1;
8928 }
8929 }
8930 return 0;
8931 #else
8932 if (unlikely(PyErr_Occurred())) {
8933 if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
8934 PyErr_Clear();
8935 return 0;
8936 } else {
8937 return -1;
8938 }
8939 }
8940 return 0;
8941 #endif
8942 }
8943
8944 /* PyObjectCallNoArg */
8945 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_PyObject_CallNoArg(PyObject * func)8946 static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
8947 #if CYTHON_FAST_PYCALL
8948 if (PyFunction_Check(func)) {
8949 return __Pyx_PyFunction_FastCall(func, NULL, 0);
8950 }
8951 #endif
8952 #ifdef __Pyx_CyFunction_USED
8953 if (likely(PyCFunction_Check(func) || __Pyx_CyFunction_Check(func)))
8954 #else
8955 if (likely(PyCFunction_Check(func)))
8956 #endif
8957 {
8958 if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
8959 return __Pyx_PyObject_CallMethO(func, NULL);
8960 }
8961 }
8962 return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
8963 }
8964 #endif
8965
8966 /* PyObjectGetMethod */
__Pyx_PyObject_GetMethod(PyObject * obj,PyObject * name,PyObject ** method)8967 static int __Pyx_PyObject_GetMethod(PyObject *obj, PyObject *name, PyObject **method) {
8968 PyObject *attr;
8969 #if CYTHON_UNPACK_METHODS && CYTHON_COMPILING_IN_CPYTHON && CYTHON_USE_PYTYPE_LOOKUP
8970 PyTypeObject *tp = Py_TYPE(obj);
8971 PyObject *descr;
8972 descrgetfunc f = NULL;
8973 PyObject **dictptr, *dict;
8974 int meth_found = 0;
8975 assert (*method == NULL);
8976 if (unlikely(tp->tp_getattro != PyObject_GenericGetAttr)) {
8977 attr = __Pyx_PyObject_GetAttrStr(obj, name);
8978 goto try_unpack;
8979 }
8980 if (unlikely(tp->tp_dict == NULL) && unlikely(PyType_Ready(tp) < 0)) {
8981 return 0;
8982 }
8983 descr = _PyType_Lookup(tp, name);
8984 if (likely(descr != NULL)) {
8985 Py_INCREF(descr);
8986 #if PY_MAJOR_VERSION >= 3
8987 #ifdef __Pyx_CyFunction_USED
8988 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type) || __Pyx_CyFunction_Check(descr)))
8989 #else
8990 if (likely(PyFunction_Check(descr) || (Py_TYPE(descr) == &PyMethodDescr_Type)))
8991 #endif
8992 #else
8993 #ifdef __Pyx_CyFunction_USED
8994 if (likely(PyFunction_Check(descr) || __Pyx_CyFunction_Check(descr)))
8995 #else
8996 if (likely(PyFunction_Check(descr)))
8997 #endif
8998 #endif
8999 {
9000 meth_found = 1;
9001 } else {
9002 f = Py_TYPE(descr)->tp_descr_get;
9003 if (f != NULL && PyDescr_IsData(descr)) {
9004 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
9005 Py_DECREF(descr);
9006 goto try_unpack;
9007 }
9008 }
9009 }
9010 dictptr = _PyObject_GetDictPtr(obj);
9011 if (dictptr != NULL && (dict = *dictptr) != NULL) {
9012 Py_INCREF(dict);
9013 attr = __Pyx_PyDict_GetItemStr(dict, name);
9014 if (attr != NULL) {
9015 Py_INCREF(attr);
9016 Py_DECREF(dict);
9017 Py_XDECREF(descr);
9018 goto try_unpack;
9019 }
9020 Py_DECREF(dict);
9021 }
9022 if (meth_found) {
9023 *method = descr;
9024 return 1;
9025 }
9026 if (f != NULL) {
9027 attr = f(descr, obj, (PyObject *)Py_TYPE(obj));
9028 Py_DECREF(descr);
9029 goto try_unpack;
9030 }
9031 if (descr != NULL) {
9032 *method = descr;
9033 return 0;
9034 }
9035 PyErr_Format(PyExc_AttributeError,
9036 #if PY_MAJOR_VERSION >= 3
9037 "'%.50s' object has no attribute '%U'",
9038 tp->tp_name, name);
9039 #else
9040 "'%.50s' object has no attribute '%.400s'",
9041 tp->tp_name, PyString_AS_STRING(name));
9042 #endif
9043 return 0;
9044 #else
9045 attr = __Pyx_PyObject_GetAttrStr(obj, name);
9046 goto try_unpack;
9047 #endif
9048 try_unpack:
9049 #if CYTHON_UNPACK_METHODS
9050 if (likely(attr) && PyMethod_Check(attr) && likely(PyMethod_GET_SELF(attr) == obj)) {
9051 PyObject *function = PyMethod_GET_FUNCTION(attr);
9052 Py_INCREF(function);
9053 Py_DECREF(attr);
9054 *method = function;
9055 return 1;
9056 }
9057 #endif
9058 *method = attr;
9059 return 0;
9060 }
9061
9062 /* PyObjectCallMethod0 */
__Pyx_PyObject_CallMethod0(PyObject * obj,PyObject * method_name)9063 static PyObject* __Pyx_PyObject_CallMethod0(PyObject* obj, PyObject* method_name) {
9064 PyObject *method = NULL, *result = NULL;
9065 int is_method = __Pyx_PyObject_GetMethod(obj, method_name, &method);
9066 if (likely(is_method)) {
9067 result = __Pyx_PyObject_CallOneArg(method, obj);
9068 Py_DECREF(method);
9069 return result;
9070 }
9071 if (unlikely(!method)) goto bad;
9072 result = __Pyx_PyObject_CallNoArg(method);
9073 Py_DECREF(method);
9074 bad:
9075 return result;
9076 }
9077
9078 /* RaiseNeedMoreValuesToUnpack */
__Pyx_RaiseNeedMoreValuesError(Py_ssize_t index)9079 static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
9080 PyErr_Format(PyExc_ValueError,
9081 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
9082 index, (index == 1) ? "" : "s");
9083 }
9084
9085 /* RaiseTooManyValuesToUnpack */
__Pyx_RaiseTooManyValuesError(Py_ssize_t expected)9086 static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
9087 PyErr_Format(PyExc_ValueError,
9088 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
9089 }
9090
9091 /* UnpackItemEndCheck */
__Pyx_IternextUnpackEndCheck(PyObject * retval,Py_ssize_t expected)9092 static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
9093 if (unlikely(retval)) {
9094 Py_DECREF(retval);
9095 __Pyx_RaiseTooManyValuesError(expected);
9096 return -1;
9097 } else {
9098 return __Pyx_IterFinish();
9099 }
9100 return 0;
9101 }
9102
9103 /* RaiseNoneIterError */
__Pyx_RaiseNoneNotIterableError(void)9104 static CYTHON_INLINE void __Pyx_RaiseNoneNotIterableError(void) {
9105 PyErr_SetString(PyExc_TypeError, "'NoneType' object is not iterable");
9106 }
9107
9108 /* UnpackTupleError */
__Pyx_UnpackTupleError(PyObject * t,Py_ssize_t index)9109 static void __Pyx_UnpackTupleError(PyObject *t, Py_ssize_t index) {
9110 if (t == Py_None) {
9111 __Pyx_RaiseNoneNotIterableError();
9112 } else if (PyTuple_GET_SIZE(t) < index) {
9113 __Pyx_RaiseNeedMoreValuesError(PyTuple_GET_SIZE(t));
9114 } else {
9115 __Pyx_RaiseTooManyValuesError(index);
9116 }
9117 }
9118
9119 /* UnpackTuple2 */
__Pyx_unpack_tuple2_exact(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int decref_tuple)9120 static CYTHON_INLINE int __Pyx_unpack_tuple2_exact(
9121 PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2, int decref_tuple) {
9122 PyObject *value1 = NULL, *value2 = NULL;
9123 #if CYTHON_COMPILING_IN_PYPY
9124 value1 = PySequence_ITEM(tuple, 0); if (unlikely(!value1)) goto bad;
9125 value2 = PySequence_ITEM(tuple, 1); if (unlikely(!value2)) goto bad;
9126 #else
9127 value1 = PyTuple_GET_ITEM(tuple, 0); Py_INCREF(value1);
9128 value2 = PyTuple_GET_ITEM(tuple, 1); Py_INCREF(value2);
9129 #endif
9130 if (decref_tuple) {
9131 Py_DECREF(tuple);
9132 }
9133 *pvalue1 = value1;
9134 *pvalue2 = value2;
9135 return 0;
9136 #if CYTHON_COMPILING_IN_PYPY
9137 bad:
9138 Py_XDECREF(value1);
9139 Py_XDECREF(value2);
9140 if (decref_tuple) { Py_XDECREF(tuple); }
9141 return -1;
9142 #endif
9143 }
__Pyx_unpack_tuple2_generic(PyObject * tuple,PyObject ** pvalue1,PyObject ** pvalue2,int has_known_size,int decref_tuple)9144 static int __Pyx_unpack_tuple2_generic(PyObject* tuple, PyObject** pvalue1, PyObject** pvalue2,
9145 int has_known_size, int decref_tuple) {
9146 Py_ssize_t index;
9147 PyObject *value1 = NULL, *value2 = NULL, *iter = NULL;
9148 iternextfunc iternext;
9149 iter = PyObject_GetIter(tuple);
9150 if (unlikely(!iter)) goto bad;
9151 if (decref_tuple) { Py_DECREF(tuple); tuple = NULL; }
9152 iternext = Py_TYPE(iter)->tp_iternext;
9153 value1 = iternext(iter); if (unlikely(!value1)) { index = 0; goto unpacking_failed; }
9154 value2 = iternext(iter); if (unlikely(!value2)) { index = 1; goto unpacking_failed; }
9155 if (!has_known_size && unlikely(__Pyx_IternextUnpackEndCheck(iternext(iter), 2))) goto bad;
9156 Py_DECREF(iter);
9157 *pvalue1 = value1;
9158 *pvalue2 = value2;
9159 return 0;
9160 unpacking_failed:
9161 if (!has_known_size && __Pyx_IterFinish() == 0)
9162 __Pyx_RaiseNeedMoreValuesError(index);
9163 bad:
9164 Py_XDECREF(iter);
9165 Py_XDECREF(value1);
9166 Py_XDECREF(value2);
9167 if (decref_tuple) { Py_XDECREF(tuple); }
9168 return -1;
9169 }
9170
9171 /* dict_iter */
__Pyx_dict_iterator(PyObject * iterable,int is_dict,PyObject * method_name,Py_ssize_t * p_orig_length,int * p_source_is_dict)9172 static CYTHON_INLINE PyObject* __Pyx_dict_iterator(PyObject* iterable, int is_dict, PyObject* method_name,
9173 Py_ssize_t* p_orig_length, int* p_source_is_dict) {
9174 is_dict = is_dict || likely(PyDict_CheckExact(iterable));
9175 *p_source_is_dict = is_dict;
9176 if (is_dict) {
9177 #if !CYTHON_COMPILING_IN_PYPY
9178 *p_orig_length = PyDict_Size(iterable);
9179 Py_INCREF(iterable);
9180 return iterable;
9181 #elif PY_MAJOR_VERSION >= 3
9182 static PyObject *py_items = NULL, *py_keys = NULL, *py_values = NULL;
9183 PyObject **pp = NULL;
9184 if (method_name) {
9185 const char *name = PyUnicode_AsUTF8(method_name);
9186 if (strcmp(name, "iteritems") == 0) pp = &py_items;
9187 else if (strcmp(name, "iterkeys") == 0) pp = &py_keys;
9188 else if (strcmp(name, "itervalues") == 0) pp = &py_values;
9189 if (pp) {
9190 if (!*pp) {
9191 *pp = PyUnicode_FromString(name + 4);
9192 if (!*pp)
9193 return NULL;
9194 }
9195 method_name = *pp;
9196 }
9197 }
9198 #endif
9199 }
9200 *p_orig_length = 0;
9201 if (method_name) {
9202 PyObject* iter;
9203 iterable = __Pyx_PyObject_CallMethod0(iterable, method_name);
9204 if (!iterable)
9205 return NULL;
9206 #if !CYTHON_COMPILING_IN_PYPY
9207 if (PyTuple_CheckExact(iterable) || PyList_CheckExact(iterable))
9208 return iterable;
9209 #endif
9210 iter = PyObject_GetIter(iterable);
9211 Py_DECREF(iterable);
9212 return iter;
9213 }
9214 return PyObject_GetIter(iterable);
9215 }
__Pyx_dict_iter_next(PyObject * iter_obj,CYTHON_NCP_UNUSED Py_ssize_t orig_length,CYTHON_NCP_UNUSED Py_ssize_t * ppos,PyObject ** pkey,PyObject ** pvalue,PyObject ** pitem,int source_is_dict)9216 static CYTHON_INLINE int __Pyx_dict_iter_next(
9217 PyObject* iter_obj, CYTHON_NCP_UNUSED Py_ssize_t orig_length, CYTHON_NCP_UNUSED Py_ssize_t* ppos,
9218 PyObject** pkey, PyObject** pvalue, PyObject** pitem, int source_is_dict) {
9219 PyObject* next_item;
9220 #if !CYTHON_COMPILING_IN_PYPY
9221 if (source_is_dict) {
9222 PyObject *key, *value;
9223 if (unlikely(orig_length != PyDict_Size(iter_obj))) {
9224 PyErr_SetString(PyExc_RuntimeError, "dictionary changed size during iteration");
9225 return -1;
9226 }
9227 if (unlikely(!PyDict_Next(iter_obj, ppos, &key, &value))) {
9228 return 0;
9229 }
9230 if (pitem) {
9231 PyObject* tuple = PyTuple_New(2);
9232 if (unlikely(!tuple)) {
9233 return -1;
9234 }
9235 Py_INCREF(key);
9236 Py_INCREF(value);
9237 PyTuple_SET_ITEM(tuple, 0, key);
9238 PyTuple_SET_ITEM(tuple, 1, value);
9239 *pitem = tuple;
9240 } else {
9241 if (pkey) {
9242 Py_INCREF(key);
9243 *pkey = key;
9244 }
9245 if (pvalue) {
9246 Py_INCREF(value);
9247 *pvalue = value;
9248 }
9249 }
9250 return 1;
9251 } else if (PyTuple_CheckExact(iter_obj)) {
9252 Py_ssize_t pos = *ppos;
9253 if (unlikely(pos >= PyTuple_GET_SIZE(iter_obj))) return 0;
9254 *ppos = pos + 1;
9255 next_item = PyTuple_GET_ITEM(iter_obj, pos);
9256 Py_INCREF(next_item);
9257 } else if (PyList_CheckExact(iter_obj)) {
9258 Py_ssize_t pos = *ppos;
9259 if (unlikely(pos >= PyList_GET_SIZE(iter_obj))) return 0;
9260 *ppos = pos + 1;
9261 next_item = PyList_GET_ITEM(iter_obj, pos);
9262 Py_INCREF(next_item);
9263 } else
9264 #endif
9265 {
9266 next_item = PyIter_Next(iter_obj);
9267 if (unlikely(!next_item)) {
9268 return __Pyx_IterFinish();
9269 }
9270 }
9271 if (pitem) {
9272 *pitem = next_item;
9273 } else if (pkey && pvalue) {
9274 if (__Pyx_unpack_tuple2(next_item, pkey, pvalue, source_is_dict, source_is_dict, 1))
9275 return -1;
9276 } else if (pkey) {
9277 *pkey = next_item;
9278 } else {
9279 *pvalue = next_item;
9280 }
9281 return 1;
9282 }
9283
9284 /* decode_c_string */
__Pyx_decode_c_string(const char * cstring,Py_ssize_t start,Py_ssize_t stop,const char * encoding,const char * errors,PyObject * (* decode_func)(const char * s,Py_ssize_t size,const char * errors))9285 static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
9286 const char* cstring, Py_ssize_t start, Py_ssize_t stop,
9287 const char* encoding, const char* errors,
9288 PyObject* (*decode_func)(const char *s, Py_ssize_t size, const char *errors)) {
9289 Py_ssize_t length;
9290 if (unlikely((start < 0) | (stop < 0))) {
9291 size_t slen = strlen(cstring);
9292 if (unlikely(slen > (size_t) PY_SSIZE_T_MAX)) {
9293 PyErr_SetString(PyExc_OverflowError,
9294 "c-string too long to convert to Python");
9295 return NULL;
9296 }
9297 length = (Py_ssize_t) slen;
9298 if (start < 0) {
9299 start += length;
9300 if (start < 0)
9301 start = 0;
9302 }
9303 if (stop < 0)
9304 stop += length;
9305 }
9306 if (unlikely(stop <= start))
9307 return __Pyx_NewRef(__pyx_empty_unicode);
9308 length = stop - start;
9309 cstring += start;
9310 if (decode_func) {
9311 return decode_func(cstring, length, errors);
9312 } else {
9313 return PyUnicode_Decode(cstring, length, encoding, errors);
9314 }
9315 }
9316
9317 /* PyErrFetchRestore */
9318 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)9319 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
9320 PyObject *tmp_type, *tmp_value, *tmp_tb;
9321 tmp_type = tstate->curexc_type;
9322 tmp_value = tstate->curexc_value;
9323 tmp_tb = tstate->curexc_traceback;
9324 tstate->curexc_type = type;
9325 tstate->curexc_value = value;
9326 tstate->curexc_traceback = tb;
9327 Py_XDECREF(tmp_type);
9328 Py_XDECREF(tmp_value);
9329 Py_XDECREF(tmp_tb);
9330 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)9331 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
9332 *type = tstate->curexc_type;
9333 *value = tstate->curexc_value;
9334 *tb = tstate->curexc_traceback;
9335 tstate->curexc_type = 0;
9336 tstate->curexc_value = 0;
9337 tstate->curexc_traceback = 0;
9338 }
9339 #endif
9340
9341 /* RaiseException */
9342 #if PY_MAJOR_VERSION < 3
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,CYTHON_UNUSED PyObject * cause)9343 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
9344 CYTHON_UNUSED PyObject *cause) {
9345 __Pyx_PyThreadState_declare
9346 Py_XINCREF(type);
9347 if (!value || value == Py_None)
9348 value = NULL;
9349 else
9350 Py_INCREF(value);
9351 if (!tb || tb == Py_None)
9352 tb = NULL;
9353 else {
9354 Py_INCREF(tb);
9355 if (!PyTraceBack_Check(tb)) {
9356 PyErr_SetString(PyExc_TypeError,
9357 "raise: arg 3 must be a traceback or None");
9358 goto raise_error;
9359 }
9360 }
9361 if (PyType_Check(type)) {
9362 #if CYTHON_COMPILING_IN_PYPY
9363 if (!value) {
9364 Py_INCREF(Py_None);
9365 value = Py_None;
9366 }
9367 #endif
9368 PyErr_NormalizeException(&type, &value, &tb);
9369 } else {
9370 if (value) {
9371 PyErr_SetString(PyExc_TypeError,
9372 "instance exception may not have a separate value");
9373 goto raise_error;
9374 }
9375 value = type;
9376 type = (PyObject*) Py_TYPE(type);
9377 Py_INCREF(type);
9378 if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
9379 PyErr_SetString(PyExc_TypeError,
9380 "raise: exception class must be a subclass of BaseException");
9381 goto raise_error;
9382 }
9383 }
9384 __Pyx_PyThreadState_assign
9385 __Pyx_ErrRestore(type, value, tb);
9386 return;
9387 raise_error:
9388 Py_XDECREF(value);
9389 Py_XDECREF(type);
9390 Py_XDECREF(tb);
9391 return;
9392 }
9393 #else
__Pyx_Raise(PyObject * type,PyObject * value,PyObject * tb,PyObject * cause)9394 static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
9395 PyObject* owned_instance = NULL;
9396 if (tb == Py_None) {
9397 tb = 0;
9398 } else if (tb && !PyTraceBack_Check(tb)) {
9399 PyErr_SetString(PyExc_TypeError,
9400 "raise: arg 3 must be a traceback or None");
9401 goto bad;
9402 }
9403 if (value == Py_None)
9404 value = 0;
9405 if (PyExceptionInstance_Check(type)) {
9406 if (value) {
9407 PyErr_SetString(PyExc_TypeError,
9408 "instance exception may not have a separate value");
9409 goto bad;
9410 }
9411 value = type;
9412 type = (PyObject*) Py_TYPE(value);
9413 } else if (PyExceptionClass_Check(type)) {
9414 PyObject *instance_class = NULL;
9415 if (value && PyExceptionInstance_Check(value)) {
9416 instance_class = (PyObject*) Py_TYPE(value);
9417 if (instance_class != type) {
9418 int is_subclass = PyObject_IsSubclass(instance_class, type);
9419 if (!is_subclass) {
9420 instance_class = NULL;
9421 } else if (unlikely(is_subclass == -1)) {
9422 goto bad;
9423 } else {
9424 type = instance_class;
9425 }
9426 }
9427 }
9428 if (!instance_class) {
9429 PyObject *args;
9430 if (!value)
9431 args = PyTuple_New(0);
9432 else if (PyTuple_Check(value)) {
9433 Py_INCREF(value);
9434 args = value;
9435 } else
9436 args = PyTuple_Pack(1, value);
9437 if (!args)
9438 goto bad;
9439 owned_instance = PyObject_Call(type, args, NULL);
9440 Py_DECREF(args);
9441 if (!owned_instance)
9442 goto bad;
9443 value = owned_instance;
9444 if (!PyExceptionInstance_Check(value)) {
9445 PyErr_Format(PyExc_TypeError,
9446 "calling %R should have returned an instance of "
9447 "BaseException, not %R",
9448 type, Py_TYPE(value));
9449 goto bad;
9450 }
9451 }
9452 } else {
9453 PyErr_SetString(PyExc_TypeError,
9454 "raise: exception class must be a subclass of BaseException");
9455 goto bad;
9456 }
9457 if (cause) {
9458 PyObject *fixed_cause;
9459 if (cause == Py_None) {
9460 fixed_cause = NULL;
9461 } else if (PyExceptionClass_Check(cause)) {
9462 fixed_cause = PyObject_CallObject(cause, NULL);
9463 if (fixed_cause == NULL)
9464 goto bad;
9465 } else if (PyExceptionInstance_Check(cause)) {
9466 fixed_cause = cause;
9467 Py_INCREF(fixed_cause);
9468 } else {
9469 PyErr_SetString(PyExc_TypeError,
9470 "exception causes must derive from "
9471 "BaseException");
9472 goto bad;
9473 }
9474 PyException_SetCause(value, fixed_cause);
9475 }
9476 PyErr_SetObject(type, value);
9477 if (tb) {
9478 #if CYTHON_COMPILING_IN_PYPY
9479 PyObject *tmp_type, *tmp_value, *tmp_tb;
9480 PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
9481 Py_INCREF(tb);
9482 PyErr_Restore(tmp_type, tmp_value, tb);
9483 Py_XDECREF(tmp_tb);
9484 #else
9485 PyThreadState *tstate = __Pyx_PyThreadState_Current;
9486 PyObject* tmp_tb = tstate->curexc_traceback;
9487 if (tb != tmp_tb) {
9488 Py_INCREF(tb);
9489 tstate->curexc_traceback = tb;
9490 Py_XDECREF(tmp_tb);
9491 }
9492 #endif
9493 }
9494 bad:
9495 Py_XDECREF(owned_instance);
9496 return;
9497 }
9498 #endif
9499
9500 /* GetException */
9501 #if CYTHON_FAST_THREAD_STATE
__Pyx__GetException(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)9502 static int __Pyx__GetException(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb)
9503 #else
9504 static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb)
9505 #endif
9506 {
9507 PyObject *local_type, *local_value, *local_tb;
9508 #if CYTHON_FAST_THREAD_STATE
9509 PyObject *tmp_type, *tmp_value, *tmp_tb;
9510 local_type = tstate->curexc_type;
9511 local_value = tstate->curexc_value;
9512 local_tb = tstate->curexc_traceback;
9513 tstate->curexc_type = 0;
9514 tstate->curexc_value = 0;
9515 tstate->curexc_traceback = 0;
9516 #else
9517 PyErr_Fetch(&local_type, &local_value, &local_tb);
9518 #endif
9519 PyErr_NormalizeException(&local_type, &local_value, &local_tb);
9520 #if CYTHON_FAST_THREAD_STATE
9521 if (unlikely(tstate->curexc_type))
9522 #else
9523 if (unlikely(PyErr_Occurred()))
9524 #endif
9525 goto bad;
9526 #if PY_MAJOR_VERSION >= 3
9527 if (local_tb) {
9528 if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
9529 goto bad;
9530 }
9531 #endif
9532 Py_XINCREF(local_tb);
9533 Py_XINCREF(local_type);
9534 Py_XINCREF(local_value);
9535 *type = local_type;
9536 *value = local_value;
9537 *tb = local_tb;
9538 #if CYTHON_FAST_THREAD_STATE
9539 #if CYTHON_USE_EXC_INFO_STACK
9540 {
9541 _PyErr_StackItem *exc_info = tstate->exc_info;
9542 tmp_type = exc_info->exc_type;
9543 tmp_value = exc_info->exc_value;
9544 tmp_tb = exc_info->exc_traceback;
9545 exc_info->exc_type = local_type;
9546 exc_info->exc_value = local_value;
9547 exc_info->exc_traceback = local_tb;
9548 }
9549 #else
9550 tmp_type = tstate->exc_type;
9551 tmp_value = tstate->exc_value;
9552 tmp_tb = tstate->exc_traceback;
9553 tstate->exc_type = local_type;
9554 tstate->exc_value = local_value;
9555 tstate->exc_traceback = local_tb;
9556 #endif
9557 Py_XDECREF(tmp_type);
9558 Py_XDECREF(tmp_value);
9559 Py_XDECREF(tmp_tb);
9560 #else
9561 PyErr_SetExcInfo(local_type, local_value, local_tb);
9562 #endif
9563 return 0;
9564 bad:
9565 *type = 0;
9566 *value = 0;
9567 *tb = 0;
9568 Py_XDECREF(local_type);
9569 Py_XDECREF(local_value);
9570 Py_XDECREF(local_tb);
9571 return -1;
9572 }
9573
9574 /* SwapException */
9575 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSwap(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)9576 static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
9577 PyObject *tmp_type, *tmp_value, *tmp_tb;
9578 #if CYTHON_USE_EXC_INFO_STACK
9579 _PyErr_StackItem *exc_info = tstate->exc_info;
9580 tmp_type = exc_info->exc_type;
9581 tmp_value = exc_info->exc_value;
9582 tmp_tb = exc_info->exc_traceback;
9583 exc_info->exc_type = *type;
9584 exc_info->exc_value = *value;
9585 exc_info->exc_traceback = *tb;
9586 #else
9587 tmp_type = tstate->exc_type;
9588 tmp_value = tstate->exc_value;
9589 tmp_tb = tstate->exc_traceback;
9590 tstate->exc_type = *type;
9591 tstate->exc_value = *value;
9592 tstate->exc_traceback = *tb;
9593 #endif
9594 *type = tmp_type;
9595 *value = tmp_value;
9596 *tb = tmp_tb;
9597 }
9598 #else
__Pyx_ExceptionSwap(PyObject ** type,PyObject ** value,PyObject ** tb)9599 static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
9600 PyObject *tmp_type, *tmp_value, *tmp_tb;
9601 PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
9602 PyErr_SetExcInfo(*type, *value, *tb);
9603 *type = tmp_type;
9604 *value = tmp_value;
9605 *tb = tmp_tb;
9606 }
9607 #endif
9608
9609 /* GetTopmostException */
9610 #if CYTHON_USE_EXC_INFO_STACK
9611 static _PyErr_StackItem *
__Pyx_PyErr_GetTopmostException(PyThreadState * tstate)9612 __Pyx_PyErr_GetTopmostException(PyThreadState *tstate)
9613 {
9614 _PyErr_StackItem *exc_info = tstate->exc_info;
9615 while ((exc_info->exc_type == NULL || exc_info->exc_type == Py_None) &&
9616 exc_info->previous_item != NULL)
9617 {
9618 exc_info = exc_info->previous_item;
9619 }
9620 return exc_info;
9621 }
9622 #endif
9623
9624 /* SaveResetException */
9625 #if CYTHON_FAST_THREAD_STATE
__Pyx__ExceptionSave(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)9626 static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
9627 #if CYTHON_USE_EXC_INFO_STACK
9628 _PyErr_StackItem *exc_info = __Pyx_PyErr_GetTopmostException(tstate);
9629 *type = exc_info->exc_type;
9630 *value = exc_info->exc_value;
9631 *tb = exc_info->exc_traceback;
9632 #else
9633 *type = tstate->exc_type;
9634 *value = tstate->exc_value;
9635 *tb = tstate->exc_traceback;
9636 #endif
9637 Py_XINCREF(*type);
9638 Py_XINCREF(*value);
9639 Py_XINCREF(*tb);
9640 }
__Pyx__ExceptionReset(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)9641 static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
9642 PyObject *tmp_type, *tmp_value, *tmp_tb;
9643 #if CYTHON_USE_EXC_INFO_STACK
9644 _PyErr_StackItem *exc_info = tstate->exc_info;
9645 tmp_type = exc_info->exc_type;
9646 tmp_value = exc_info->exc_value;
9647 tmp_tb = exc_info->exc_traceback;
9648 exc_info->exc_type = type;
9649 exc_info->exc_value = value;
9650 exc_info->exc_traceback = tb;
9651 #else
9652 tmp_type = tstate->exc_type;
9653 tmp_value = tstate->exc_value;
9654 tmp_tb = tstate->exc_traceback;
9655 tstate->exc_type = type;
9656 tstate->exc_value = value;
9657 tstate->exc_traceback = tb;
9658 #endif
9659 Py_XDECREF(tmp_type);
9660 Py_XDECREF(tmp_value);
9661 Py_XDECREF(tmp_tb);
9662 }
9663 #endif
9664
9665 /* PyErrExceptionMatches */
9666 #if CYTHON_FAST_THREAD_STATE
__Pyx_PyErr_ExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)9667 static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
9668 Py_ssize_t i, n;
9669 n = PyTuple_GET_SIZE(tuple);
9670 #if PY_MAJOR_VERSION >= 3
9671 for (i=0; i<n; i++) {
9672 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
9673 }
9674 #endif
9675 for (i=0; i<n; i++) {
9676 if (__Pyx_PyErr_GivenExceptionMatches(exc_type, PyTuple_GET_ITEM(tuple, i))) return 1;
9677 }
9678 return 0;
9679 }
__Pyx_PyErr_ExceptionMatchesInState(PyThreadState * tstate,PyObject * err)9680 static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadState* tstate, PyObject* err) {
9681 PyObject *exc_type = tstate->curexc_type;
9682 if (exc_type == err) return 1;
9683 if (unlikely(!exc_type)) return 0;
9684 if (unlikely(PyTuple_Check(err)))
9685 return __Pyx_PyErr_ExceptionMatchesTuple(exc_type, err);
9686 return __Pyx_PyErr_GivenExceptionMatches(exc_type, err);
9687 }
9688 #endif
9689
9690 /* GetItemInt */
__Pyx_GetItemInt_Generic(PyObject * o,PyObject * j)9691 static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
9692 PyObject *r;
9693 if (!j) return NULL;
9694 r = PyObject_GetItem(o, j);
9695 Py_DECREF(j);
9696 return r;
9697 }
__Pyx_GetItemInt_List_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)9698 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
9699 CYTHON_NCP_UNUSED int wraparound,
9700 CYTHON_NCP_UNUSED int boundscheck) {
9701 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9702 Py_ssize_t wrapped_i = i;
9703 if (wraparound & unlikely(i < 0)) {
9704 wrapped_i += PyList_GET_SIZE(o);
9705 }
9706 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyList_GET_SIZE(o)))) {
9707 PyObject *r = PyList_GET_ITEM(o, wrapped_i);
9708 Py_INCREF(r);
9709 return r;
9710 }
9711 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
9712 #else
9713 return PySequence_GetItem(o, i);
9714 #endif
9715 }
__Pyx_GetItemInt_Tuple_Fast(PyObject * o,Py_ssize_t i,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)9716 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
9717 CYTHON_NCP_UNUSED int wraparound,
9718 CYTHON_NCP_UNUSED int boundscheck) {
9719 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
9720 Py_ssize_t wrapped_i = i;
9721 if (wraparound & unlikely(i < 0)) {
9722 wrapped_i += PyTuple_GET_SIZE(o);
9723 }
9724 if ((!boundscheck) || likely(__Pyx_is_valid_index(wrapped_i, PyTuple_GET_SIZE(o)))) {
9725 PyObject *r = PyTuple_GET_ITEM(o, wrapped_i);
9726 Py_INCREF(r);
9727 return r;
9728 }
9729 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
9730 #else
9731 return PySequence_GetItem(o, i);
9732 #endif
9733 }
__Pyx_GetItemInt_Fast(PyObject * o,Py_ssize_t i,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)9734 static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
9735 CYTHON_NCP_UNUSED int wraparound,
9736 CYTHON_NCP_UNUSED int boundscheck) {
9737 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
9738 if (is_list || PyList_CheckExact(o)) {
9739 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
9740 if ((!boundscheck) || (likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o))))) {
9741 PyObject *r = PyList_GET_ITEM(o, n);
9742 Py_INCREF(r);
9743 return r;
9744 }
9745 }
9746 else if (PyTuple_CheckExact(o)) {
9747 Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
9748 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyTuple_GET_SIZE(o)))) {
9749 PyObject *r = PyTuple_GET_ITEM(o, n);
9750 Py_INCREF(r);
9751 return r;
9752 }
9753 } else {
9754 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
9755 if (likely(m && m->sq_item)) {
9756 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
9757 Py_ssize_t l = m->sq_length(o);
9758 if (likely(l >= 0)) {
9759 i += l;
9760 } else {
9761 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
9762 return NULL;
9763 PyErr_Clear();
9764 }
9765 }
9766 return m->sq_item(o, i);
9767 }
9768 }
9769 #else
9770 if (is_list || PySequence_Check(o)) {
9771 return PySequence_GetItem(o, i);
9772 }
9773 #endif
9774 return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
9775 }
9776
9777 /* BytesEquals */
__Pyx_PyBytes_Equals(PyObject * s1,PyObject * s2,int equals)9778 static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
9779 #if CYTHON_COMPILING_IN_PYPY
9780 return PyObject_RichCompareBool(s1, s2, equals);
9781 #else
9782 if (s1 == s2) {
9783 return (equals == Py_EQ);
9784 } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
9785 const char *ps1, *ps2;
9786 Py_ssize_t length = PyBytes_GET_SIZE(s1);
9787 if (length != PyBytes_GET_SIZE(s2))
9788 return (equals == Py_NE);
9789 ps1 = PyBytes_AS_STRING(s1);
9790 ps2 = PyBytes_AS_STRING(s2);
9791 if (ps1[0] != ps2[0]) {
9792 return (equals == Py_NE);
9793 } else if (length == 1) {
9794 return (equals == Py_EQ);
9795 } else {
9796 int result;
9797 #if CYTHON_USE_UNICODE_INTERNALS
9798 Py_hash_t hash1, hash2;
9799 hash1 = ((PyBytesObject*)s1)->ob_shash;
9800 hash2 = ((PyBytesObject*)s2)->ob_shash;
9801 if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
9802 return (equals == Py_NE);
9803 }
9804 #endif
9805 result = memcmp(ps1, ps2, (size_t)length);
9806 return (equals == Py_EQ) ? (result == 0) : (result != 0);
9807 }
9808 } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
9809 return (equals == Py_NE);
9810 } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
9811 return (equals == Py_NE);
9812 } else {
9813 int result;
9814 PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
9815 if (!py_result)
9816 return -1;
9817 result = __Pyx_PyObject_IsTrue(py_result);
9818 Py_DECREF(py_result);
9819 return result;
9820 }
9821 #endif
9822 }
9823
9824 /* UnicodeEquals */
__Pyx_PyUnicode_Equals(PyObject * s1,PyObject * s2,int equals)9825 static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
9826 #if CYTHON_COMPILING_IN_PYPY
9827 return PyObject_RichCompareBool(s1, s2, equals);
9828 #else
9829 #if PY_MAJOR_VERSION < 3
9830 PyObject* owned_ref = NULL;
9831 #endif
9832 int s1_is_unicode, s2_is_unicode;
9833 if (s1 == s2) {
9834 goto return_eq;
9835 }
9836 s1_is_unicode = PyUnicode_CheckExact(s1);
9837 s2_is_unicode = PyUnicode_CheckExact(s2);
9838 #if PY_MAJOR_VERSION < 3
9839 if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
9840 owned_ref = PyUnicode_FromObject(s2);
9841 if (unlikely(!owned_ref))
9842 return -1;
9843 s2 = owned_ref;
9844 s2_is_unicode = 1;
9845 } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
9846 owned_ref = PyUnicode_FromObject(s1);
9847 if (unlikely(!owned_ref))
9848 return -1;
9849 s1 = owned_ref;
9850 s1_is_unicode = 1;
9851 } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
9852 return __Pyx_PyBytes_Equals(s1, s2, equals);
9853 }
9854 #endif
9855 if (s1_is_unicode & s2_is_unicode) {
9856 Py_ssize_t length;
9857 int kind;
9858 void *data1, *data2;
9859 if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
9860 return -1;
9861 length = __Pyx_PyUnicode_GET_LENGTH(s1);
9862 if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
9863 goto return_ne;
9864 }
9865 #if CYTHON_USE_UNICODE_INTERNALS
9866 {
9867 Py_hash_t hash1, hash2;
9868 #if CYTHON_PEP393_ENABLED
9869 hash1 = ((PyASCIIObject*)s1)->hash;
9870 hash2 = ((PyASCIIObject*)s2)->hash;
9871 #else
9872 hash1 = ((PyUnicodeObject*)s1)->hash;
9873 hash2 = ((PyUnicodeObject*)s2)->hash;
9874 #endif
9875 if (hash1 != hash2 && hash1 != -1 && hash2 != -1) {
9876 goto return_ne;
9877 }
9878 }
9879 #endif
9880 kind = __Pyx_PyUnicode_KIND(s1);
9881 if (kind != __Pyx_PyUnicode_KIND(s2)) {
9882 goto return_ne;
9883 }
9884 data1 = __Pyx_PyUnicode_DATA(s1);
9885 data2 = __Pyx_PyUnicode_DATA(s2);
9886 if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
9887 goto return_ne;
9888 } else if (length == 1) {
9889 goto return_eq;
9890 } else {
9891 int result = memcmp(data1, data2, (size_t)(length * kind));
9892 #if PY_MAJOR_VERSION < 3
9893 Py_XDECREF(owned_ref);
9894 #endif
9895 return (equals == Py_EQ) ? (result == 0) : (result != 0);
9896 }
9897 } else if ((s1 == Py_None) & s2_is_unicode) {
9898 goto return_ne;
9899 } else if ((s2 == Py_None) & s1_is_unicode) {
9900 goto return_ne;
9901 } else {
9902 int result;
9903 PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
9904 #if PY_MAJOR_VERSION < 3
9905 Py_XDECREF(owned_ref);
9906 #endif
9907 if (!py_result)
9908 return -1;
9909 result = __Pyx_PyObject_IsTrue(py_result);
9910 Py_DECREF(py_result);
9911 return result;
9912 }
9913 return_eq:
9914 #if PY_MAJOR_VERSION < 3
9915 Py_XDECREF(owned_ref);
9916 #endif
9917 return (equals == Py_EQ);
9918 return_ne:
9919 #if PY_MAJOR_VERSION < 3
9920 Py_XDECREF(owned_ref);
9921 #endif
9922 return (equals == Py_NE);
9923 #endif
9924 }
9925
9926 /* SetItemInt */
__Pyx_SetItemInt_Generic(PyObject * o,PyObject * j,PyObject * v)9927 static int __Pyx_SetItemInt_Generic(PyObject *o, PyObject *j, PyObject *v) {
9928 int r;
9929 if (!j) return -1;
9930 r = PyObject_SetItem(o, j, v);
9931 Py_DECREF(j);
9932 return r;
9933 }
__Pyx_SetItemInt_Fast(PyObject * o,Py_ssize_t i,PyObject * v,int is_list,CYTHON_NCP_UNUSED int wraparound,CYTHON_NCP_UNUSED int boundscheck)9934 static CYTHON_INLINE int __Pyx_SetItemInt_Fast(PyObject *o, Py_ssize_t i, PyObject *v, int is_list,
9935 CYTHON_NCP_UNUSED int wraparound, CYTHON_NCP_UNUSED int boundscheck) {
9936 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS && CYTHON_USE_TYPE_SLOTS
9937 if (is_list || PyList_CheckExact(o)) {
9938 Py_ssize_t n = (!wraparound) ? i : ((likely(i >= 0)) ? i : i + PyList_GET_SIZE(o));
9939 if ((!boundscheck) || likely(__Pyx_is_valid_index(n, PyList_GET_SIZE(o)))) {
9940 PyObject* old = PyList_GET_ITEM(o, n);
9941 Py_INCREF(v);
9942 PyList_SET_ITEM(o, n, v);
9943 Py_DECREF(old);
9944 return 1;
9945 }
9946 } else {
9947 PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
9948 if (likely(m && m->sq_ass_item)) {
9949 if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
9950 Py_ssize_t l = m->sq_length(o);
9951 if (likely(l >= 0)) {
9952 i += l;
9953 } else {
9954 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
9955 return -1;
9956 PyErr_Clear();
9957 }
9958 }
9959 return m->sq_ass_item(o, i, v);
9960 }
9961 }
9962 #else
9963 #if CYTHON_COMPILING_IN_PYPY
9964 if (is_list || (PySequence_Check(o) && !PyDict_Check(o)))
9965 #else
9966 if (is_list || PySequence_Check(o))
9967 #endif
9968 {
9969 return PySequence_SetItem(o, i, v);
9970 }
9971 #endif
9972 return __Pyx_SetItemInt_Generic(o, PyInt_FromSsize_t(i), v);
9973 }
9974
9975 /* SliceObject */
__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)9976 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
9977 Py_ssize_t cstart, Py_ssize_t cstop,
9978 PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
9979 int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
9980 #if CYTHON_USE_TYPE_SLOTS
9981 PyMappingMethods* mp;
9982 #if PY_MAJOR_VERSION < 3
9983 PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
9984 if (likely(ms && ms->sq_slice)) {
9985 if (!has_cstart) {
9986 if (_py_start && (*_py_start != Py_None)) {
9987 cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
9988 if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
9989 } else
9990 cstart = 0;
9991 }
9992 if (!has_cstop) {
9993 if (_py_stop && (*_py_stop != Py_None)) {
9994 cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
9995 if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
9996 } else
9997 cstop = PY_SSIZE_T_MAX;
9998 }
9999 if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
10000 Py_ssize_t l = ms->sq_length(obj);
10001 if (likely(l >= 0)) {
10002 if (cstop < 0) {
10003 cstop += l;
10004 if (cstop < 0) cstop = 0;
10005 }
10006 if (cstart < 0) {
10007 cstart += l;
10008 if (cstart < 0) cstart = 0;
10009 }
10010 } else {
10011 if (!PyErr_ExceptionMatches(PyExc_OverflowError))
10012 goto bad;
10013 PyErr_Clear();
10014 }
10015 }
10016 return ms->sq_slice(obj, cstart, cstop);
10017 }
10018 #endif
10019 mp = Py_TYPE(obj)->tp_as_mapping;
10020 if (likely(mp && mp->mp_subscript))
10021 #endif
10022 {
10023 PyObject* result;
10024 PyObject *py_slice, *py_start, *py_stop;
10025 if (_py_slice) {
10026 py_slice = *_py_slice;
10027 } else {
10028 PyObject* owned_start = NULL;
10029 PyObject* owned_stop = NULL;
10030 if (_py_start) {
10031 py_start = *_py_start;
10032 } else {
10033 if (has_cstart) {
10034 owned_start = py_start = PyInt_FromSsize_t(cstart);
10035 if (unlikely(!py_start)) goto bad;
10036 } else
10037 py_start = Py_None;
10038 }
10039 if (_py_stop) {
10040 py_stop = *_py_stop;
10041 } else {
10042 if (has_cstop) {
10043 owned_stop = py_stop = PyInt_FromSsize_t(cstop);
10044 if (unlikely(!py_stop)) {
10045 Py_XDECREF(owned_start);
10046 goto bad;
10047 }
10048 } else
10049 py_stop = Py_None;
10050 }
10051 py_slice = PySlice_New(py_start, py_stop, Py_None);
10052 Py_XDECREF(owned_start);
10053 Py_XDECREF(owned_stop);
10054 if (unlikely(!py_slice)) goto bad;
10055 }
10056 #if CYTHON_USE_TYPE_SLOTS
10057 result = mp->mp_subscript(obj, py_slice);
10058 #else
10059 result = PyObject_GetItem(obj, py_slice);
10060 #endif
10061 if (!_py_slice) {
10062 Py_DECREF(py_slice);
10063 }
10064 return result;
10065 }
10066 PyErr_Format(PyExc_TypeError,
10067 "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
10068 bad:
10069 return NULL;
10070 }
10071
10072 /* PyIntCompare */
__Pyx_PyInt_EqObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,CYTHON_UNUSED long inplace)10073 static CYTHON_INLINE PyObject* __Pyx_PyInt_EqObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
10074 if (op1 == op2) {
10075 Py_RETURN_TRUE;
10076 }
10077 #if PY_MAJOR_VERSION < 3
10078 if (likely(PyInt_CheckExact(op1))) {
10079 const long b = intval;
10080 long a = PyInt_AS_LONG(op1);
10081 if (a == b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
10082 }
10083 #endif
10084 #if CYTHON_USE_PYLONG_INTERNALS
10085 if (likely(PyLong_CheckExact(op1))) {
10086 int unequal;
10087 unsigned long uintval;
10088 Py_ssize_t size = Py_SIZE(op1);
10089 const digit* digits = ((PyLongObject*)op1)->ob_digit;
10090 if (intval == 0) {
10091 if (size == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
10092 } else if (intval < 0) {
10093 if (size >= 0)
10094 Py_RETURN_FALSE;
10095 intval = -intval;
10096 size = -size;
10097 } else {
10098 if (size <= 0)
10099 Py_RETURN_FALSE;
10100 }
10101 uintval = (unsigned long) intval;
10102 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
10103 if (uintval >> (PyLong_SHIFT * 4)) {
10104 unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
10105 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
10106 } else
10107 #endif
10108 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
10109 if (uintval >> (PyLong_SHIFT * 3)) {
10110 unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
10111 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
10112 } else
10113 #endif
10114 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
10115 if (uintval >> (PyLong_SHIFT * 2)) {
10116 unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
10117 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
10118 } else
10119 #endif
10120 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
10121 if (uintval >> (PyLong_SHIFT * 1)) {
10122 unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
10123 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
10124 } else
10125 #endif
10126 unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
10127 if (unequal == 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
10128 }
10129 #endif
10130 if (PyFloat_CheckExact(op1)) {
10131 const long b = intval;
10132 double a = PyFloat_AS_DOUBLE(op1);
10133 if ((double)a == (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
10134 }
10135 return (
10136 PyObject_RichCompare(op1, op2, Py_EQ));
10137 }
10138
10139 /* PyIntCompare */
__Pyx_PyInt_NeObjC(PyObject * op1,PyObject * op2,CYTHON_UNUSED long intval,CYTHON_UNUSED long inplace)10140 static CYTHON_INLINE PyObject* __Pyx_PyInt_NeObjC(PyObject *op1, PyObject *op2, CYTHON_UNUSED long intval, CYTHON_UNUSED long inplace) {
10141 if (op1 == op2) {
10142 Py_RETURN_FALSE;
10143 }
10144 #if PY_MAJOR_VERSION < 3
10145 if (likely(PyInt_CheckExact(op1))) {
10146 const long b = intval;
10147 long a = PyInt_AS_LONG(op1);
10148 if (a != b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
10149 }
10150 #endif
10151 #if CYTHON_USE_PYLONG_INTERNALS
10152 if (likely(PyLong_CheckExact(op1))) {
10153 int unequal;
10154 unsigned long uintval;
10155 Py_ssize_t size = Py_SIZE(op1);
10156 const digit* digits = ((PyLongObject*)op1)->ob_digit;
10157 if (intval == 0) {
10158 if (size != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
10159 } else if (intval < 0) {
10160 if (size >= 0)
10161 Py_RETURN_TRUE;
10162 intval = -intval;
10163 size = -size;
10164 } else {
10165 if (size <= 0)
10166 Py_RETURN_TRUE;
10167 }
10168 uintval = (unsigned long) intval;
10169 #if PyLong_SHIFT * 4 < SIZEOF_LONG*8
10170 if (uintval >> (PyLong_SHIFT * 4)) {
10171 unequal = (size != 5) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
10172 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[4] != ((uintval >> (4 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
10173 } else
10174 #endif
10175 #if PyLong_SHIFT * 3 < SIZEOF_LONG*8
10176 if (uintval >> (PyLong_SHIFT * 3)) {
10177 unequal = (size != 4) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
10178 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[3] != ((uintval >> (3 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
10179 } else
10180 #endif
10181 #if PyLong_SHIFT * 2 < SIZEOF_LONG*8
10182 if (uintval >> (PyLong_SHIFT * 2)) {
10183 unequal = (size != 3) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
10184 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK)) | (digits[2] != ((uintval >> (2 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
10185 } else
10186 #endif
10187 #if PyLong_SHIFT * 1 < SIZEOF_LONG*8
10188 if (uintval >> (PyLong_SHIFT * 1)) {
10189 unequal = (size != 2) || (digits[0] != (uintval & (unsigned long) PyLong_MASK))
10190 | (digits[1] != ((uintval >> (1 * PyLong_SHIFT)) & (unsigned long) PyLong_MASK));
10191 } else
10192 #endif
10193 unequal = (size != 1) || (((unsigned long) digits[0]) != (uintval & (unsigned long) PyLong_MASK));
10194 if (unequal != 0) Py_RETURN_TRUE; else Py_RETURN_FALSE;
10195 }
10196 #endif
10197 if (PyFloat_CheckExact(op1)) {
10198 const long b = intval;
10199 double a = PyFloat_AS_DOUBLE(op1);
10200 if ((double)a != (double)b) Py_RETURN_TRUE; else Py_RETURN_FALSE;
10201 }
10202 return (
10203 PyObject_RichCompare(op1, op2, Py_NE));
10204 }
10205
10206 /* PyObjectSetAttrStr */
10207 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_SetAttrStr(PyObject * obj,PyObject * attr_name,PyObject * value)10208 static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
10209 PyTypeObject* tp = Py_TYPE(obj);
10210 if (likely(tp->tp_setattro))
10211 return tp->tp_setattro(obj, attr_name, value);
10212 #if PY_MAJOR_VERSION < 3
10213 if (likely(tp->tp_setattr))
10214 return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
10215 #endif
10216 return PyObject_SetAttr(obj, attr_name, value);
10217 }
10218 #endif
10219
10220 /* Import */
__Pyx_Import(PyObject * name,PyObject * from_list,int level)10221 static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
10222 PyObject *empty_list = 0;
10223 PyObject *module = 0;
10224 PyObject *global_dict = 0;
10225 PyObject *empty_dict = 0;
10226 PyObject *list;
10227 #if PY_MAJOR_VERSION < 3
10228 PyObject *py_import;
10229 py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
10230 if (!py_import)
10231 goto bad;
10232 #endif
10233 if (from_list)
10234 list = from_list;
10235 else {
10236 empty_list = PyList_New(0);
10237 if (!empty_list)
10238 goto bad;
10239 list = empty_list;
10240 }
10241 global_dict = PyModule_GetDict(__pyx_m);
10242 if (!global_dict)
10243 goto bad;
10244 empty_dict = PyDict_New();
10245 if (!empty_dict)
10246 goto bad;
10247 {
10248 #if PY_MAJOR_VERSION >= 3
10249 if (level == -1) {
10250 if ((1) && (strchr(__Pyx_MODULE_NAME, '.'))) {
10251 module = PyImport_ImportModuleLevelObject(
10252 name, global_dict, empty_dict, list, 1);
10253 if (!module) {
10254 if (!PyErr_ExceptionMatches(PyExc_ImportError))
10255 goto bad;
10256 PyErr_Clear();
10257 }
10258 }
10259 level = 0;
10260 }
10261 #endif
10262 if (!module) {
10263 #if PY_MAJOR_VERSION < 3
10264 PyObject *py_level = PyInt_FromLong(level);
10265 if (!py_level)
10266 goto bad;
10267 module = PyObject_CallFunctionObjArgs(py_import,
10268 name, global_dict, empty_dict, list, py_level, (PyObject *)NULL);
10269 Py_DECREF(py_level);
10270 #else
10271 module = PyImport_ImportModuleLevelObject(
10272 name, global_dict, empty_dict, list, level);
10273 #endif
10274 }
10275 }
10276 bad:
10277 #if PY_MAJOR_VERSION < 3
10278 Py_XDECREF(py_import);
10279 #endif
10280 Py_XDECREF(empty_list);
10281 Py_XDECREF(empty_dict);
10282 return module;
10283 }
10284
10285 /* ImportFrom */
__Pyx_ImportFrom(PyObject * module,PyObject * name)10286 static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
10287 PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
10288 if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
10289 PyErr_Format(PyExc_ImportError,
10290 #if PY_MAJOR_VERSION < 3
10291 "cannot import name %.230s", PyString_AS_STRING(name));
10292 #else
10293 "cannot import name %S", name);
10294 #endif
10295 }
10296 return value;
10297 }
10298
10299 /* CalculateMetaclass */
__Pyx_CalculateMetaclass(PyTypeObject * metaclass,PyObject * bases)10300 static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
10301 Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
10302 for (i=0; i < nbases; i++) {
10303 PyTypeObject *tmptype;
10304 PyObject *tmp = PyTuple_GET_ITEM(bases, i);
10305 tmptype = Py_TYPE(tmp);
10306 #if PY_MAJOR_VERSION < 3
10307 if (tmptype == &PyClass_Type)
10308 continue;
10309 #endif
10310 if (!metaclass) {
10311 metaclass = tmptype;
10312 continue;
10313 }
10314 if (PyType_IsSubtype(metaclass, tmptype))
10315 continue;
10316 if (PyType_IsSubtype(tmptype, metaclass)) {
10317 metaclass = tmptype;
10318 continue;
10319 }
10320 PyErr_SetString(PyExc_TypeError,
10321 "metaclass conflict: "
10322 "the metaclass of a derived class "
10323 "must be a (non-strict) subclass "
10324 "of the metaclasses of all its bases");
10325 return NULL;
10326 }
10327 if (!metaclass) {
10328 #if PY_MAJOR_VERSION < 3
10329 metaclass = &PyClass_Type;
10330 #else
10331 metaclass = &PyType_Type;
10332 #endif
10333 }
10334 Py_INCREF((PyObject*) metaclass);
10335 return (PyObject*) metaclass;
10336 }
10337
10338 /* Py3ClassCreate */
__Pyx_Py3MetaclassPrepare(PyObject * metaclass,PyObject * bases,PyObject * name,PyObject * qualname,PyObject * mkw,PyObject * modname,PyObject * doc)10339 static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
10340 PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
10341 PyObject *ns;
10342 if (metaclass) {
10343 PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
10344 if (prep) {
10345 PyObject *pargs = PyTuple_Pack(2, name, bases);
10346 if (unlikely(!pargs)) {
10347 Py_DECREF(prep);
10348 return NULL;
10349 }
10350 ns = PyObject_Call(prep, pargs, mkw);
10351 Py_DECREF(prep);
10352 Py_DECREF(pargs);
10353 } else {
10354 if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
10355 return NULL;
10356 PyErr_Clear();
10357 ns = PyDict_New();
10358 }
10359 } else {
10360 ns = PyDict_New();
10361 }
10362 if (unlikely(!ns))
10363 return NULL;
10364 if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
10365 if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
10366 if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
10367 return ns;
10368 bad:
10369 Py_DECREF(ns);
10370 return NULL;
10371 }
__Pyx_Py3ClassCreate(PyObject * metaclass,PyObject * name,PyObject * bases,PyObject * dict,PyObject * mkw,int calculate_metaclass,int allow_py2_metaclass)10372 static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
10373 PyObject *dict, PyObject *mkw,
10374 int calculate_metaclass, int allow_py2_metaclass) {
10375 PyObject *result, *margs;
10376 PyObject *owned_metaclass = NULL;
10377 if (allow_py2_metaclass) {
10378 owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
10379 if (owned_metaclass) {
10380 metaclass = owned_metaclass;
10381 } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
10382 PyErr_Clear();
10383 } else {
10384 return NULL;
10385 }
10386 }
10387 if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
10388 metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
10389 Py_XDECREF(owned_metaclass);
10390 if (unlikely(!metaclass))
10391 return NULL;
10392 owned_metaclass = metaclass;
10393 }
10394 margs = PyTuple_Pack(3, name, bases, dict);
10395 if (unlikely(!margs)) {
10396 result = NULL;
10397 } else {
10398 result = PyObject_Call(metaclass, margs, mkw);
10399 Py_DECREF(margs);
10400 }
10401 Py_XDECREF(owned_metaclass);
10402 return result;
10403 }
10404
10405 /* FetchCommonType */
__Pyx_FetchCommonType(PyTypeObject * type)10406 static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
10407 PyObject* fake_module;
10408 PyTypeObject* cached_type = NULL;
10409 fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
10410 if (!fake_module) return NULL;
10411 Py_INCREF(fake_module);
10412 cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
10413 if (cached_type) {
10414 if (!PyType_Check((PyObject*)cached_type)) {
10415 PyErr_Format(PyExc_TypeError,
10416 "Shared Cython type %.200s is not a type object",
10417 type->tp_name);
10418 goto bad;
10419 }
10420 if (cached_type->tp_basicsize != type->tp_basicsize) {
10421 PyErr_Format(PyExc_TypeError,
10422 "Shared Cython type %.200s has the wrong size, try recompiling",
10423 type->tp_name);
10424 goto bad;
10425 }
10426 } else {
10427 if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
10428 PyErr_Clear();
10429 if (PyType_Ready(type) < 0) goto bad;
10430 if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
10431 goto bad;
10432 Py_INCREF(type);
10433 cached_type = type;
10434 }
10435 done:
10436 Py_DECREF(fake_module);
10437 return cached_type;
10438 bad:
10439 Py_XDECREF(cached_type);
10440 cached_type = NULL;
10441 goto done;
10442 }
10443
10444 /* CythonFunctionShared */
10445 #include <structmember.h>
10446 static PyObject *
__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * closure)10447 __Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
10448 {
10449 if (unlikely(op->func_doc == NULL)) {
10450 if (op->func.m_ml->ml_doc) {
10451 #if PY_MAJOR_VERSION >= 3
10452 op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
10453 #else
10454 op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
10455 #endif
10456 if (unlikely(op->func_doc == NULL))
10457 return NULL;
10458 } else {
10459 Py_INCREF(Py_None);
10460 return Py_None;
10461 }
10462 }
10463 Py_INCREF(op->func_doc);
10464 return op->func_doc;
10465 }
10466 static int
__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)10467 __Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
10468 {
10469 PyObject *tmp = op->func_doc;
10470 if (value == NULL) {
10471 value = Py_None;
10472 }
10473 Py_INCREF(value);
10474 op->func_doc = value;
10475 Py_XDECREF(tmp);
10476 return 0;
10477 }
10478 static PyObject *
__Pyx_CyFunction_get_name(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)10479 __Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
10480 {
10481 if (unlikely(op->func_name == NULL)) {
10482 #if PY_MAJOR_VERSION >= 3
10483 op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
10484 #else
10485 op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
10486 #endif
10487 if (unlikely(op->func_name == NULL))
10488 return NULL;
10489 }
10490 Py_INCREF(op->func_name);
10491 return op->func_name;
10492 }
10493 static int
__Pyx_CyFunction_set_name(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)10494 __Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
10495 {
10496 PyObject *tmp;
10497 #if PY_MAJOR_VERSION >= 3
10498 if (unlikely(value == NULL || !PyUnicode_Check(value)))
10499 #else
10500 if (unlikely(value == NULL || !PyString_Check(value)))
10501 #endif
10502 {
10503 PyErr_SetString(PyExc_TypeError,
10504 "__name__ must be set to a string object");
10505 return -1;
10506 }
10507 tmp = op->func_name;
10508 Py_INCREF(value);
10509 op->func_name = value;
10510 Py_XDECREF(tmp);
10511 return 0;
10512 }
10513 static PyObject *
__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)10514 __Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
10515 {
10516 Py_INCREF(op->func_qualname);
10517 return op->func_qualname;
10518 }
10519 static int
__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)10520 __Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
10521 {
10522 PyObject *tmp;
10523 #if PY_MAJOR_VERSION >= 3
10524 if (unlikely(value == NULL || !PyUnicode_Check(value)))
10525 #else
10526 if (unlikely(value == NULL || !PyString_Check(value)))
10527 #endif
10528 {
10529 PyErr_SetString(PyExc_TypeError,
10530 "__qualname__ must be set to a string object");
10531 return -1;
10532 }
10533 tmp = op->func_qualname;
10534 Py_INCREF(value);
10535 op->func_qualname = value;
10536 Py_XDECREF(tmp);
10537 return 0;
10538 }
10539 static PyObject *
__Pyx_CyFunction_get_self(__pyx_CyFunctionObject * m,CYTHON_UNUSED void * closure)10540 __Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
10541 {
10542 PyObject *self;
10543 self = m->func_closure;
10544 if (self == NULL)
10545 self = Py_None;
10546 Py_INCREF(self);
10547 return self;
10548 }
10549 static PyObject *
__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)10550 __Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
10551 {
10552 if (unlikely(op->func_dict == NULL)) {
10553 op->func_dict = PyDict_New();
10554 if (unlikely(op->func_dict == NULL))
10555 return NULL;
10556 }
10557 Py_INCREF(op->func_dict);
10558 return op->func_dict;
10559 }
10560 static int
__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)10561 __Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value, CYTHON_UNUSED void *context)
10562 {
10563 PyObject *tmp;
10564 if (unlikely(value == NULL)) {
10565 PyErr_SetString(PyExc_TypeError,
10566 "function's dictionary may not be deleted");
10567 return -1;
10568 }
10569 if (unlikely(!PyDict_Check(value))) {
10570 PyErr_SetString(PyExc_TypeError,
10571 "setting function's dictionary to a non-dict");
10572 return -1;
10573 }
10574 tmp = op->func_dict;
10575 Py_INCREF(value);
10576 op->func_dict = value;
10577 Py_XDECREF(tmp);
10578 return 0;
10579 }
10580 static PyObject *
__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)10581 __Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
10582 {
10583 Py_INCREF(op->func_globals);
10584 return op->func_globals;
10585 }
10586 static PyObject *
__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)10587 __Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
10588 {
10589 Py_INCREF(Py_None);
10590 return Py_None;
10591 }
10592 static PyObject *
__Pyx_CyFunction_get_code(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)10593 __Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context)
10594 {
10595 PyObject* result = (op->func_code) ? op->func_code : Py_None;
10596 Py_INCREF(result);
10597 return result;
10598 }
10599 static int
__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject * op)10600 __Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
10601 int result = 0;
10602 PyObject *res = op->defaults_getter((PyObject *) op);
10603 if (unlikely(!res))
10604 return -1;
10605 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10606 op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
10607 Py_INCREF(op->defaults_tuple);
10608 op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
10609 Py_INCREF(op->defaults_kwdict);
10610 #else
10611 op->defaults_tuple = PySequence_ITEM(res, 0);
10612 if (unlikely(!op->defaults_tuple)) result = -1;
10613 else {
10614 op->defaults_kwdict = PySequence_ITEM(res, 1);
10615 if (unlikely(!op->defaults_kwdict)) result = -1;
10616 }
10617 #endif
10618 Py_DECREF(res);
10619 return result;
10620 }
10621 static int
__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)10622 __Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
10623 PyObject* tmp;
10624 if (!value) {
10625 value = Py_None;
10626 } else if (value != Py_None && !PyTuple_Check(value)) {
10627 PyErr_SetString(PyExc_TypeError,
10628 "__defaults__ must be set to a tuple object");
10629 return -1;
10630 }
10631 Py_INCREF(value);
10632 tmp = op->defaults_tuple;
10633 op->defaults_tuple = value;
10634 Py_XDECREF(tmp);
10635 return 0;
10636 }
10637 static PyObject *
__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)10638 __Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
10639 PyObject* result = op->defaults_tuple;
10640 if (unlikely(!result)) {
10641 if (op->defaults_getter) {
10642 if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
10643 result = op->defaults_tuple;
10644 } else {
10645 result = Py_None;
10646 }
10647 }
10648 Py_INCREF(result);
10649 return result;
10650 }
10651 static int
__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)10652 __Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
10653 PyObject* tmp;
10654 if (!value) {
10655 value = Py_None;
10656 } else if (value != Py_None && !PyDict_Check(value)) {
10657 PyErr_SetString(PyExc_TypeError,
10658 "__kwdefaults__ must be set to a dict object");
10659 return -1;
10660 }
10661 Py_INCREF(value);
10662 tmp = op->defaults_kwdict;
10663 op->defaults_kwdict = value;
10664 Py_XDECREF(tmp);
10665 return 0;
10666 }
10667 static PyObject *
__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)10668 __Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
10669 PyObject* result = op->defaults_kwdict;
10670 if (unlikely(!result)) {
10671 if (op->defaults_getter) {
10672 if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
10673 result = op->defaults_kwdict;
10674 } else {
10675 result = Py_None;
10676 }
10677 }
10678 Py_INCREF(result);
10679 return result;
10680 }
10681 static int
__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject * op,PyObject * value,CYTHON_UNUSED void * context)10682 __Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value, CYTHON_UNUSED void *context) {
10683 PyObject* tmp;
10684 if (!value || value == Py_None) {
10685 value = NULL;
10686 } else if (!PyDict_Check(value)) {
10687 PyErr_SetString(PyExc_TypeError,
10688 "__annotations__ must be set to a dict object");
10689 return -1;
10690 }
10691 Py_XINCREF(value);
10692 tmp = op->func_annotations;
10693 op->func_annotations = value;
10694 Py_XDECREF(tmp);
10695 return 0;
10696 }
10697 static PyObject *
__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject * op,CYTHON_UNUSED void * context)10698 __Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *context) {
10699 PyObject* result = op->func_annotations;
10700 if (unlikely(!result)) {
10701 result = PyDict_New();
10702 if (unlikely(!result)) return NULL;
10703 op->func_annotations = result;
10704 }
10705 Py_INCREF(result);
10706 return result;
10707 }
10708 static PyGetSetDef __pyx_CyFunction_getsets[] = {
10709 {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
10710 {(char *) "__doc__", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
10711 {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
10712 {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
10713 {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
10714 {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
10715 {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
10716 {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
10717 {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
10718 {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
10719 {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
10720 {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
10721 {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
10722 {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
10723 {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
10724 {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
10725 {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
10726 {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
10727 {0, 0, 0, 0, 0}
10728 };
10729 static PyMemberDef __pyx_CyFunction_members[] = {
10730 {(char *) "__module__", T_OBJECT, offsetof(PyCFunctionObject, m_module), PY_WRITE_RESTRICTED, 0},
10731 {0, 0, 0, 0, 0}
10732 };
10733 static PyObject *
__Pyx_CyFunction_reduce(__pyx_CyFunctionObject * m,CYTHON_UNUSED PyObject * args)10734 __Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
10735 {
10736 #if PY_MAJOR_VERSION >= 3
10737 return PyUnicode_FromString(m->func.m_ml->ml_name);
10738 #else
10739 return PyString_FromString(m->func.m_ml->ml_name);
10740 #endif
10741 }
10742 static PyMethodDef __pyx_CyFunction_methods[] = {
10743 {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
10744 {0, 0, 0, 0}
10745 };
10746 #if PY_VERSION_HEX < 0x030500A0
10747 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
10748 #else
10749 #define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
10750 #endif
__Pyx_CyFunction_Init(__pyx_CyFunctionObject * op,PyMethodDef * ml,int flags,PyObject * qualname,PyObject * closure,PyObject * module,PyObject * globals,PyObject * code)10751 static PyObject *__Pyx_CyFunction_Init(__pyx_CyFunctionObject *op, PyMethodDef *ml, int flags, PyObject* qualname,
10752 PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
10753 if (unlikely(op == NULL))
10754 return NULL;
10755 op->flags = flags;
10756 __Pyx_CyFunction_weakreflist(op) = NULL;
10757 op->func.m_ml = ml;
10758 op->func.m_self = (PyObject *) op;
10759 Py_XINCREF(closure);
10760 op->func_closure = closure;
10761 Py_XINCREF(module);
10762 op->func.m_module = module;
10763 op->func_dict = NULL;
10764 op->func_name = NULL;
10765 Py_INCREF(qualname);
10766 op->func_qualname = qualname;
10767 op->func_doc = NULL;
10768 op->func_classobj = NULL;
10769 op->func_globals = globals;
10770 Py_INCREF(op->func_globals);
10771 Py_XINCREF(code);
10772 op->func_code = code;
10773 op->defaults_pyobjects = 0;
10774 op->defaults_size = 0;
10775 op->defaults = NULL;
10776 op->defaults_tuple = NULL;
10777 op->defaults_kwdict = NULL;
10778 op->defaults_getter = NULL;
10779 op->func_annotations = NULL;
10780 return (PyObject *) op;
10781 }
10782 static int
__Pyx_CyFunction_clear(__pyx_CyFunctionObject * m)10783 __Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
10784 {
10785 Py_CLEAR(m->func_closure);
10786 Py_CLEAR(m->func.m_module);
10787 Py_CLEAR(m->func_dict);
10788 Py_CLEAR(m->func_name);
10789 Py_CLEAR(m->func_qualname);
10790 Py_CLEAR(m->func_doc);
10791 Py_CLEAR(m->func_globals);
10792 Py_CLEAR(m->func_code);
10793 Py_CLEAR(m->func_classobj);
10794 Py_CLEAR(m->defaults_tuple);
10795 Py_CLEAR(m->defaults_kwdict);
10796 Py_CLEAR(m->func_annotations);
10797 if (m->defaults) {
10798 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
10799 int i;
10800 for (i = 0; i < m->defaults_pyobjects; i++)
10801 Py_XDECREF(pydefaults[i]);
10802 PyObject_Free(m->defaults);
10803 m->defaults = NULL;
10804 }
10805 return 0;
10806 }
__Pyx__CyFunction_dealloc(__pyx_CyFunctionObject * m)10807 static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
10808 {
10809 if (__Pyx_CyFunction_weakreflist(m) != NULL)
10810 PyObject_ClearWeakRefs((PyObject *) m);
10811 __Pyx_CyFunction_clear(m);
10812 PyObject_GC_Del(m);
10813 }
__Pyx_CyFunction_dealloc(__pyx_CyFunctionObject * m)10814 static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
10815 {
10816 PyObject_GC_UnTrack(m);
10817 __Pyx__CyFunction_dealloc(m);
10818 }
__Pyx_CyFunction_traverse(__pyx_CyFunctionObject * m,visitproc visit,void * arg)10819 static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
10820 {
10821 Py_VISIT(m->func_closure);
10822 Py_VISIT(m->func.m_module);
10823 Py_VISIT(m->func_dict);
10824 Py_VISIT(m->func_name);
10825 Py_VISIT(m->func_qualname);
10826 Py_VISIT(m->func_doc);
10827 Py_VISIT(m->func_globals);
10828 Py_VISIT(m->func_code);
10829 Py_VISIT(m->func_classobj);
10830 Py_VISIT(m->defaults_tuple);
10831 Py_VISIT(m->defaults_kwdict);
10832 if (m->defaults) {
10833 PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
10834 int i;
10835 for (i = 0; i < m->defaults_pyobjects; i++)
10836 Py_VISIT(pydefaults[i]);
10837 }
10838 return 0;
10839 }
__Pyx_CyFunction_descr_get(PyObject * func,PyObject * obj,PyObject * type)10840 static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
10841 {
10842 #if PY_MAJOR_VERSION < 3
10843 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
10844 if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
10845 Py_INCREF(func);
10846 return func;
10847 }
10848 if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
10849 if (type == NULL)
10850 type = (PyObject *)(Py_TYPE(obj));
10851 return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
10852 }
10853 if (obj == Py_None)
10854 obj = NULL;
10855 #endif
10856 return __Pyx_PyMethod_New(func, obj, type);
10857 }
10858 static PyObject*
__Pyx_CyFunction_repr(__pyx_CyFunctionObject * op)10859 __Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
10860 {
10861 #if PY_MAJOR_VERSION >= 3
10862 return PyUnicode_FromFormat("<cyfunction %U at %p>",
10863 op->func_qualname, (void *)op);
10864 #else
10865 return PyString_FromFormat("<cyfunction %s at %p>",
10866 PyString_AsString(op->func_qualname), (void *)op);
10867 #endif
10868 }
__Pyx_CyFunction_CallMethod(PyObject * func,PyObject * self,PyObject * arg,PyObject * kw)10869 static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *self, PyObject *arg, PyObject *kw) {
10870 PyCFunctionObject* f = (PyCFunctionObject*)func;
10871 PyCFunction meth = f->m_ml->ml_meth;
10872 Py_ssize_t size;
10873 switch (f->m_ml->ml_flags & (METH_VARARGS | METH_KEYWORDS | METH_NOARGS | METH_O)) {
10874 case METH_VARARGS:
10875 if (likely(kw == NULL || PyDict_Size(kw) == 0))
10876 return (*meth)(self, arg);
10877 break;
10878 case METH_VARARGS | METH_KEYWORDS:
10879 return (*(PyCFunctionWithKeywords)(void*)meth)(self, arg, kw);
10880 case METH_NOARGS:
10881 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
10882 size = PyTuple_GET_SIZE(arg);
10883 if (likely(size == 0))
10884 return (*meth)(self, NULL);
10885 PyErr_Format(PyExc_TypeError,
10886 "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
10887 f->m_ml->ml_name, size);
10888 return NULL;
10889 }
10890 break;
10891 case METH_O:
10892 if (likely(kw == NULL || PyDict_Size(kw) == 0)) {
10893 size = PyTuple_GET_SIZE(arg);
10894 if (likely(size == 1)) {
10895 PyObject *result, *arg0;
10896 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
10897 arg0 = PyTuple_GET_ITEM(arg, 0);
10898 #else
10899 arg0 = PySequence_ITEM(arg, 0); if (unlikely(!arg0)) return NULL;
10900 #endif
10901 result = (*meth)(self, arg0);
10902 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
10903 Py_DECREF(arg0);
10904 #endif
10905 return result;
10906 }
10907 PyErr_Format(PyExc_TypeError,
10908 "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
10909 f->m_ml->ml_name, size);
10910 return NULL;
10911 }
10912 break;
10913 default:
10914 PyErr_SetString(PyExc_SystemError, "Bad call flags in "
10915 "__Pyx_CyFunction_Call. METH_OLDARGS is no "
10916 "longer supported!");
10917 return NULL;
10918 }
10919 PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
10920 f->m_ml->ml_name);
10921 return NULL;
10922 }
__Pyx_CyFunction_Call(PyObject * func,PyObject * arg,PyObject * kw)10923 static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
10924 return __Pyx_CyFunction_CallMethod(func, ((PyCFunctionObject*)func)->m_self, arg, kw);
10925 }
__Pyx_CyFunction_CallAsMethod(PyObject * func,PyObject * args,PyObject * kw)10926 static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject *args, PyObject *kw) {
10927 PyObject *result;
10928 __pyx_CyFunctionObject *cyfunc = (__pyx_CyFunctionObject *) func;
10929 if ((cyfunc->flags & __Pyx_CYFUNCTION_CCLASS) && !(cyfunc->flags & __Pyx_CYFUNCTION_STATICMETHOD)) {
10930 Py_ssize_t argc;
10931 PyObject *new_args;
10932 PyObject *self;
10933 argc = PyTuple_GET_SIZE(args);
10934 new_args = PyTuple_GetSlice(args, 1, argc);
10935 if (unlikely(!new_args))
10936 return NULL;
10937 self = PyTuple_GetItem(args, 0);
10938 if (unlikely(!self)) {
10939 Py_DECREF(new_args);
10940 return NULL;
10941 }
10942 result = __Pyx_CyFunction_CallMethod(func, self, new_args, kw);
10943 Py_DECREF(new_args);
10944 } else {
10945 result = __Pyx_CyFunction_Call(func, args, kw);
10946 }
10947 return result;
10948 }
10949 static PyTypeObject __pyx_CyFunctionType_type = {
10950 PyVarObject_HEAD_INIT(0, 0)
10951 "cython_function_or_method",
10952 sizeof(__pyx_CyFunctionObject),
10953 0,
10954 (destructor) __Pyx_CyFunction_dealloc,
10955 0,
10956 0,
10957 0,
10958 #if PY_MAJOR_VERSION < 3
10959 0,
10960 #else
10961 0,
10962 #endif
10963 (reprfunc) __Pyx_CyFunction_repr,
10964 0,
10965 0,
10966 0,
10967 0,
10968 __Pyx_CyFunction_CallAsMethod,
10969 0,
10970 0,
10971 0,
10972 0,
10973 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
10974 0,
10975 (traverseproc) __Pyx_CyFunction_traverse,
10976 (inquiry) __Pyx_CyFunction_clear,
10977 0,
10978 #if PY_VERSION_HEX < 0x030500A0
10979 offsetof(__pyx_CyFunctionObject, func_weakreflist),
10980 #else
10981 offsetof(PyCFunctionObject, m_weakreflist),
10982 #endif
10983 0,
10984 0,
10985 __pyx_CyFunction_methods,
10986 __pyx_CyFunction_members,
10987 __pyx_CyFunction_getsets,
10988 0,
10989 0,
10990 __Pyx_CyFunction_descr_get,
10991 0,
10992 offsetof(__pyx_CyFunctionObject, func_dict),
10993 0,
10994 0,
10995 0,
10996 0,
10997 0,
10998 0,
10999 0,
11000 0,
11001 0,
11002 0,
11003 0,
11004 0,
11005 #if PY_VERSION_HEX >= 0x030400a1
11006 0,
11007 #endif
11008 #if PY_VERSION_HEX >= 0x030800b1
11009 0,
11010 #endif
11011 #if PY_VERSION_HEX >= 0x030800b4 && PY_VERSION_HEX < 0x03090000
11012 0,
11013 #endif
11014 };
__pyx_CyFunction_init(void)11015 static int __pyx_CyFunction_init(void) {
11016 __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
11017 if (unlikely(__pyx_CyFunctionType == NULL)) {
11018 return -1;
11019 }
11020 return 0;
11021 }
__Pyx_CyFunction_InitDefaults(PyObject * func,size_t size,int pyobjects)11022 static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
11023 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
11024 m->defaults = PyObject_Malloc(size);
11025 if (unlikely(!m->defaults))
11026 return PyErr_NoMemory();
11027 memset(m->defaults, 0, size);
11028 m->defaults_pyobjects = pyobjects;
11029 m->defaults_size = size;
11030 return m->defaults;
11031 }
__Pyx_CyFunction_SetDefaultsTuple(PyObject * func,PyObject * tuple)11032 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
11033 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
11034 m->defaults_tuple = tuple;
11035 Py_INCREF(tuple);
11036 }
__Pyx_CyFunction_SetDefaultsKwDict(PyObject * func,PyObject * dict)11037 static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
11038 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
11039 m->defaults_kwdict = dict;
11040 Py_INCREF(dict);
11041 }
__Pyx_CyFunction_SetAnnotationsDict(PyObject * func,PyObject * dict)11042 static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
11043 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
11044 m->func_annotations = dict;
11045 Py_INCREF(dict);
11046 }
11047
11048 /* CythonFunction */
__Pyx_CyFunction_New(PyMethodDef * ml,int flags,PyObject * qualname,PyObject * closure,PyObject * module,PyObject * globals,PyObject * code)11049 static PyObject *__Pyx_CyFunction_New(PyMethodDef *ml, int flags, PyObject* qualname,
11050 PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
11051 PyObject *op = __Pyx_CyFunction_Init(
11052 PyObject_GC_New(__pyx_CyFunctionObject, __pyx_CyFunctionType),
11053 ml, flags, qualname, closure, module, globals, code
11054 );
11055 if (likely(op)) {
11056 PyObject_GC_Track(op);
11057 }
11058 return op;
11059 }
11060
11061 /* CyFunctionClassCell */
__Pyx_CyFunction_InitClassCell(PyObject * cyfunctions,PyObject * classobj)11062 static int __Pyx_CyFunction_InitClassCell(PyObject *cyfunctions, PyObject *classobj) {
11063 Py_ssize_t i, count = PyList_GET_SIZE(cyfunctions);
11064 for (i = 0; i < count; i++) {
11065 __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *)
11066 #if CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS
11067 PyList_GET_ITEM(cyfunctions, i);
11068 #else
11069 PySequence_ITEM(cyfunctions, i);
11070 if (unlikely(!m))
11071 return -1;
11072 #endif
11073 Py_INCREF(classobj);
11074 m->func_classobj = classobj;
11075 #if !(CYTHON_ASSUME_SAFE_MACROS && !CYTHON_AVOID_BORROWED_REFS)
11076 Py_DECREF((PyObject*)m);
11077 #endif
11078 }
11079 return 0;
11080 }
11081
11082 /* CLineInTraceback */
11083 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)11084 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
11085 PyObject *use_cline;
11086 PyObject *ptype, *pvalue, *ptraceback;
11087 #if CYTHON_COMPILING_IN_CPYTHON
11088 PyObject **cython_runtime_dict;
11089 #endif
11090 if (unlikely(!__pyx_cython_runtime)) {
11091 return c_line;
11092 }
11093 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
11094 #if CYTHON_COMPILING_IN_CPYTHON
11095 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
11096 if (likely(cython_runtime_dict)) {
11097 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
11098 use_cline, *cython_runtime_dict,
11099 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
11100 } else
11101 #endif
11102 {
11103 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
11104 if (use_cline_obj) {
11105 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
11106 Py_DECREF(use_cline_obj);
11107 } else {
11108 PyErr_Clear();
11109 use_cline = NULL;
11110 }
11111 }
11112 if (!use_cline) {
11113 c_line = 0;
11114 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
11115 }
11116 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
11117 c_line = 0;
11118 }
11119 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
11120 return c_line;
11121 }
11122 #endif
11123
11124 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)11125 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
11126 int start = 0, mid = 0, end = count - 1;
11127 if (end >= 0 && code_line > entries[end].code_line) {
11128 return count;
11129 }
11130 while (start < end) {
11131 mid = start + (end - start) / 2;
11132 if (code_line < entries[mid].code_line) {
11133 end = mid;
11134 } else if (code_line > entries[mid].code_line) {
11135 start = mid + 1;
11136 } else {
11137 return mid;
11138 }
11139 }
11140 if (code_line <= entries[mid].code_line) {
11141 return mid;
11142 } else {
11143 return mid + 1;
11144 }
11145 }
__pyx_find_code_object(int code_line)11146 static PyCodeObject *__pyx_find_code_object(int code_line) {
11147 PyCodeObject* code_object;
11148 int pos;
11149 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
11150 return NULL;
11151 }
11152 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
11153 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
11154 return NULL;
11155 }
11156 code_object = __pyx_code_cache.entries[pos].code_object;
11157 Py_INCREF(code_object);
11158 return code_object;
11159 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)11160 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
11161 int pos, i;
11162 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
11163 if (unlikely(!code_line)) {
11164 return;
11165 }
11166 if (unlikely(!entries)) {
11167 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
11168 if (likely(entries)) {
11169 __pyx_code_cache.entries = entries;
11170 __pyx_code_cache.max_count = 64;
11171 __pyx_code_cache.count = 1;
11172 entries[0].code_line = code_line;
11173 entries[0].code_object = code_object;
11174 Py_INCREF(code_object);
11175 }
11176 return;
11177 }
11178 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
11179 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
11180 PyCodeObject* tmp = entries[pos].code_object;
11181 entries[pos].code_object = code_object;
11182 Py_DECREF(tmp);
11183 return;
11184 }
11185 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
11186 int new_max = __pyx_code_cache.max_count + 64;
11187 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
11188 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
11189 if (unlikely(!entries)) {
11190 return;
11191 }
11192 __pyx_code_cache.entries = entries;
11193 __pyx_code_cache.max_count = new_max;
11194 }
11195 for (i=__pyx_code_cache.count; i>pos; i--) {
11196 entries[i] = entries[i-1];
11197 }
11198 entries[pos].code_line = code_line;
11199 entries[pos].code_object = code_object;
11200 __pyx_code_cache.count++;
11201 Py_INCREF(code_object);
11202 }
11203
11204 /* AddTraceback */
11205 #include "compile.h"
11206 #include "frameobject.h"
11207 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)11208 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
11209 const char *funcname, int c_line,
11210 int py_line, const char *filename) {
11211 PyCodeObject *py_code = 0;
11212 PyObject *py_srcfile = 0;
11213 PyObject *py_funcname = 0;
11214 #if PY_MAJOR_VERSION < 3
11215 py_srcfile = PyString_FromString(filename);
11216 #else
11217 py_srcfile = PyUnicode_FromString(filename);
11218 #endif
11219 if (!py_srcfile) goto bad;
11220 if (c_line) {
11221 #if PY_MAJOR_VERSION < 3
11222 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
11223 #else
11224 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
11225 #endif
11226 }
11227 else {
11228 #if PY_MAJOR_VERSION < 3
11229 py_funcname = PyString_FromString(funcname);
11230 #else
11231 py_funcname = PyUnicode_FromString(funcname);
11232 #endif
11233 }
11234 if (!py_funcname) goto bad;
11235 py_code = __Pyx_PyCode_New(
11236 0,
11237 0,
11238 0,
11239 0,
11240 0,
11241 __pyx_empty_bytes, /*PyObject *code,*/
11242 __pyx_empty_tuple, /*PyObject *consts,*/
11243 __pyx_empty_tuple, /*PyObject *names,*/
11244 __pyx_empty_tuple, /*PyObject *varnames,*/
11245 __pyx_empty_tuple, /*PyObject *freevars,*/
11246 __pyx_empty_tuple, /*PyObject *cellvars,*/
11247 py_srcfile, /*PyObject *filename,*/
11248 py_funcname, /*PyObject *name,*/
11249 py_line,
11250 __pyx_empty_bytes /*PyObject *lnotab*/
11251 );
11252 Py_DECREF(py_srcfile);
11253 Py_DECREF(py_funcname);
11254 return py_code;
11255 bad:
11256 Py_XDECREF(py_srcfile);
11257 Py_XDECREF(py_funcname);
11258 return NULL;
11259 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)11260 static void __Pyx_AddTraceback(const char *funcname, int c_line,
11261 int py_line, const char *filename) {
11262 PyCodeObject *py_code = 0;
11263 PyFrameObject *py_frame = 0;
11264 PyThreadState *tstate = __Pyx_PyThreadState_Current;
11265 if (c_line) {
11266 c_line = __Pyx_CLineForTraceback(tstate, c_line);
11267 }
11268 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
11269 if (!py_code) {
11270 py_code = __Pyx_CreateCodeObjectForTraceback(
11271 funcname, c_line, py_line, filename);
11272 if (!py_code) goto bad;
11273 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
11274 }
11275 py_frame = PyFrame_New(
11276 tstate, /*PyThreadState *tstate,*/
11277 py_code, /*PyCodeObject *code,*/
11278 __pyx_d, /*PyObject *globals,*/
11279 0 /*PyObject *locals*/
11280 );
11281 if (!py_frame) goto bad;
11282 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
11283 PyTraceBack_Here(py_frame);
11284 bad:
11285 Py_XDECREF(py_code);
11286 Py_XDECREF(py_frame);
11287 }
11288
11289 /* CIntFromPyVerify */
11290 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
11291 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
11292 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
11293 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
11294 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
11295 {\
11296 func_type value = func_value;\
11297 if (sizeof(target_type) < sizeof(func_type)) {\
11298 if (unlikely(value != (func_type) (target_type) value)) {\
11299 func_type zero = 0;\
11300 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
11301 return (target_type) -1;\
11302 if (is_unsigned && unlikely(value < zero))\
11303 goto raise_neg_overflow;\
11304 else\
11305 goto raise_overflow;\
11306 }\
11307 }\
11308 return (target_type) value;\
11309 }
11310
11311 /* CIntToPy */
__Pyx_PyInt_From_int(int value)11312 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
11313 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11314 #pragma GCC diagnostic push
11315 #pragma GCC diagnostic ignored "-Wconversion"
11316 #endif
11317 const int neg_one = (int) -1, const_zero = (int) 0;
11318 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11319 #pragma GCC diagnostic pop
11320 #endif
11321 const int is_unsigned = neg_one > const_zero;
11322 if (is_unsigned) {
11323 if (sizeof(int) < sizeof(long)) {
11324 return PyInt_FromLong((long) value);
11325 } else if (sizeof(int) <= sizeof(unsigned long)) {
11326 return PyLong_FromUnsignedLong((unsigned long) value);
11327 #ifdef HAVE_LONG_LONG
11328 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
11329 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
11330 #endif
11331 }
11332 } else {
11333 if (sizeof(int) <= sizeof(long)) {
11334 return PyInt_FromLong((long) value);
11335 #ifdef HAVE_LONG_LONG
11336 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
11337 return PyLong_FromLongLong((PY_LONG_LONG) value);
11338 #endif
11339 }
11340 }
11341 {
11342 int one = 1; int little = (int)*(unsigned char *)&one;
11343 unsigned char *bytes = (unsigned char *)&value;
11344 return _PyLong_FromByteArray(bytes, sizeof(int),
11345 little, !is_unsigned);
11346 }
11347 }
11348
11349 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)11350 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
11351 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11352 #pragma GCC diagnostic push
11353 #pragma GCC diagnostic ignored "-Wconversion"
11354 #endif
11355 const int neg_one = (int) -1, const_zero = (int) 0;
11356 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11357 #pragma GCC diagnostic pop
11358 #endif
11359 const int is_unsigned = neg_one > const_zero;
11360 #if PY_MAJOR_VERSION < 3
11361 if (likely(PyInt_Check(x))) {
11362 if (sizeof(int) < sizeof(long)) {
11363 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
11364 } else {
11365 long val = PyInt_AS_LONG(x);
11366 if (is_unsigned && unlikely(val < 0)) {
11367 goto raise_neg_overflow;
11368 }
11369 return (int) val;
11370 }
11371 } else
11372 #endif
11373 if (likely(PyLong_Check(x))) {
11374 if (is_unsigned) {
11375 #if CYTHON_USE_PYLONG_INTERNALS
11376 const digit* digits = ((PyLongObject*)x)->ob_digit;
11377 switch (Py_SIZE(x)) {
11378 case 0: return (int) 0;
11379 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
11380 case 2:
11381 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
11382 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11383 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11384 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
11385 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
11386 }
11387 }
11388 break;
11389 case 3:
11390 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
11391 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11392 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11393 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
11394 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
11395 }
11396 }
11397 break;
11398 case 4:
11399 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
11400 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11401 __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])))
11402 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
11403 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
11404 }
11405 }
11406 break;
11407 }
11408 #endif
11409 #if CYTHON_COMPILING_IN_CPYTHON
11410 if (unlikely(Py_SIZE(x) < 0)) {
11411 goto raise_neg_overflow;
11412 }
11413 #else
11414 {
11415 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
11416 if (unlikely(result < 0))
11417 return (int) -1;
11418 if (unlikely(result == 1))
11419 goto raise_neg_overflow;
11420 }
11421 #endif
11422 if (sizeof(int) <= sizeof(unsigned long)) {
11423 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
11424 #ifdef HAVE_LONG_LONG
11425 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
11426 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
11427 #endif
11428 }
11429 } else {
11430 #if CYTHON_USE_PYLONG_INTERNALS
11431 const digit* digits = ((PyLongObject*)x)->ob_digit;
11432 switch (Py_SIZE(x)) {
11433 case 0: return (int) 0;
11434 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
11435 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
11436 case -2:
11437 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
11438 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11439 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11440 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
11441 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
11442 }
11443 }
11444 break;
11445 case 2:
11446 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
11447 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11448 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11449 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
11450 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
11451 }
11452 }
11453 break;
11454 case -3:
11455 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
11456 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11457 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11458 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
11459 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
11460 }
11461 }
11462 break;
11463 case 3:
11464 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
11465 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11466 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11467 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
11468 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
11469 }
11470 }
11471 break;
11472 case -4:
11473 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
11474 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11475 __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])))
11476 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
11477 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
11478 }
11479 }
11480 break;
11481 case 4:
11482 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
11483 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11484 __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])))
11485 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
11486 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
11487 }
11488 }
11489 break;
11490 }
11491 #endif
11492 if (sizeof(int) <= sizeof(long)) {
11493 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
11494 #ifdef HAVE_LONG_LONG
11495 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
11496 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
11497 #endif
11498 }
11499 }
11500 {
11501 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
11502 PyErr_SetString(PyExc_RuntimeError,
11503 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
11504 #else
11505 int val;
11506 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
11507 #if PY_MAJOR_VERSION < 3
11508 if (likely(v) && !PyLong_Check(v)) {
11509 PyObject *tmp = v;
11510 v = PyNumber_Long(tmp);
11511 Py_DECREF(tmp);
11512 }
11513 #endif
11514 if (likely(v)) {
11515 int one = 1; int is_little = (int)*(unsigned char *)&one;
11516 unsigned char *bytes = (unsigned char *)&val;
11517 int ret = _PyLong_AsByteArray((PyLongObject *)v,
11518 bytes, sizeof(val),
11519 is_little, !is_unsigned);
11520 Py_DECREF(v);
11521 if (likely(!ret))
11522 return val;
11523 }
11524 #endif
11525 return (int) -1;
11526 }
11527 } else {
11528 int val;
11529 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
11530 if (!tmp) return (int) -1;
11531 val = __Pyx_PyInt_As_int(tmp);
11532 Py_DECREF(tmp);
11533 return val;
11534 }
11535 raise_overflow:
11536 PyErr_SetString(PyExc_OverflowError,
11537 "value too large to convert to int");
11538 return (int) -1;
11539 raise_neg_overflow:
11540 PyErr_SetString(PyExc_OverflowError,
11541 "can't convert negative value to int");
11542 return (int) -1;
11543 }
11544
11545 /* CIntToPy */
__Pyx_PyInt_From_long(long value)11546 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
11547 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11548 #pragma GCC diagnostic push
11549 #pragma GCC diagnostic ignored "-Wconversion"
11550 #endif
11551 const long neg_one = (long) -1, const_zero = (long) 0;
11552 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11553 #pragma GCC diagnostic pop
11554 #endif
11555 const int is_unsigned = neg_one > const_zero;
11556 if (is_unsigned) {
11557 if (sizeof(long) < sizeof(long)) {
11558 return PyInt_FromLong((long) value);
11559 } else if (sizeof(long) <= sizeof(unsigned long)) {
11560 return PyLong_FromUnsignedLong((unsigned long) value);
11561 #ifdef HAVE_LONG_LONG
11562 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
11563 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
11564 #endif
11565 }
11566 } else {
11567 if (sizeof(long) <= sizeof(long)) {
11568 return PyInt_FromLong((long) value);
11569 #ifdef HAVE_LONG_LONG
11570 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
11571 return PyLong_FromLongLong((PY_LONG_LONG) value);
11572 #endif
11573 }
11574 }
11575 {
11576 int one = 1; int little = (int)*(unsigned char *)&one;
11577 unsigned char *bytes = (unsigned char *)&value;
11578 return _PyLong_FromByteArray(bytes, sizeof(long),
11579 little, !is_unsigned);
11580 }
11581 }
11582
11583 /* CIntToPy */
__Pyx_PyInt_From_unsigned_int(unsigned int value)11584 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_int(unsigned int value) {
11585 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11586 #pragma GCC diagnostic push
11587 #pragma GCC diagnostic ignored "-Wconversion"
11588 #endif
11589 const unsigned int neg_one = (unsigned int) -1, const_zero = (unsigned int) 0;
11590 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11591 #pragma GCC diagnostic pop
11592 #endif
11593 const int is_unsigned = neg_one > const_zero;
11594 if (is_unsigned) {
11595 if (sizeof(unsigned int) < sizeof(long)) {
11596 return PyInt_FromLong((long) value);
11597 } else if (sizeof(unsigned int) <= sizeof(unsigned long)) {
11598 return PyLong_FromUnsignedLong((unsigned long) value);
11599 #ifdef HAVE_LONG_LONG
11600 } else if (sizeof(unsigned int) <= sizeof(unsigned PY_LONG_LONG)) {
11601 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
11602 #endif
11603 }
11604 } else {
11605 if (sizeof(unsigned int) <= sizeof(long)) {
11606 return PyInt_FromLong((long) value);
11607 #ifdef HAVE_LONG_LONG
11608 } else if (sizeof(unsigned int) <= sizeof(PY_LONG_LONG)) {
11609 return PyLong_FromLongLong((PY_LONG_LONG) value);
11610 #endif
11611 }
11612 }
11613 {
11614 int one = 1; int little = (int)*(unsigned char *)&one;
11615 unsigned char *bytes = (unsigned char *)&value;
11616 return _PyLong_FromByteArray(bytes, sizeof(unsigned int),
11617 little, !is_unsigned);
11618 }
11619 }
11620
11621 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)11622 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
11623 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11624 #pragma GCC diagnostic push
11625 #pragma GCC diagnostic ignored "-Wconversion"
11626 #endif
11627 const long neg_one = (long) -1, const_zero = (long) 0;
11628 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
11629 #pragma GCC diagnostic pop
11630 #endif
11631 const int is_unsigned = neg_one > const_zero;
11632 #if PY_MAJOR_VERSION < 3
11633 if (likely(PyInt_Check(x))) {
11634 if (sizeof(long) < sizeof(long)) {
11635 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
11636 } else {
11637 long val = PyInt_AS_LONG(x);
11638 if (is_unsigned && unlikely(val < 0)) {
11639 goto raise_neg_overflow;
11640 }
11641 return (long) val;
11642 }
11643 } else
11644 #endif
11645 if (likely(PyLong_Check(x))) {
11646 if (is_unsigned) {
11647 #if CYTHON_USE_PYLONG_INTERNALS
11648 const digit* digits = ((PyLongObject*)x)->ob_digit;
11649 switch (Py_SIZE(x)) {
11650 case 0: return (long) 0;
11651 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
11652 case 2:
11653 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
11654 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11655 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11656 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
11657 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
11658 }
11659 }
11660 break;
11661 case 3:
11662 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
11663 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11664 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11665 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
11666 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
11667 }
11668 }
11669 break;
11670 case 4:
11671 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
11672 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11673 __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])))
11674 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
11675 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
11676 }
11677 }
11678 break;
11679 }
11680 #endif
11681 #if CYTHON_COMPILING_IN_CPYTHON
11682 if (unlikely(Py_SIZE(x) < 0)) {
11683 goto raise_neg_overflow;
11684 }
11685 #else
11686 {
11687 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
11688 if (unlikely(result < 0))
11689 return (long) -1;
11690 if (unlikely(result == 1))
11691 goto raise_neg_overflow;
11692 }
11693 #endif
11694 if (sizeof(long) <= sizeof(unsigned long)) {
11695 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
11696 #ifdef HAVE_LONG_LONG
11697 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
11698 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
11699 #endif
11700 }
11701 } else {
11702 #if CYTHON_USE_PYLONG_INTERNALS
11703 const digit* digits = ((PyLongObject*)x)->ob_digit;
11704 switch (Py_SIZE(x)) {
11705 case 0: return (long) 0;
11706 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
11707 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
11708 case -2:
11709 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
11710 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11711 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11712 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
11713 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
11714 }
11715 }
11716 break;
11717 case 2:
11718 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
11719 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
11720 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11721 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
11722 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
11723 }
11724 }
11725 break;
11726 case -3:
11727 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
11728 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11729 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11730 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
11731 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
11732 }
11733 }
11734 break;
11735 case 3:
11736 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
11737 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
11738 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
11739 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
11740 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
11741 }
11742 }
11743 break;
11744 case -4:
11745 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
11746 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11747 __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])))
11748 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
11749 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
11750 }
11751 }
11752 break;
11753 case 4:
11754 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
11755 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
11756 __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])))
11757 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
11758 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
11759 }
11760 }
11761 break;
11762 }
11763 #endif
11764 if (sizeof(long) <= sizeof(long)) {
11765 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
11766 #ifdef HAVE_LONG_LONG
11767 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
11768 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
11769 #endif
11770 }
11771 }
11772 {
11773 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
11774 PyErr_SetString(PyExc_RuntimeError,
11775 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
11776 #else
11777 long val;
11778 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
11779 #if PY_MAJOR_VERSION < 3
11780 if (likely(v) && !PyLong_Check(v)) {
11781 PyObject *tmp = v;
11782 v = PyNumber_Long(tmp);
11783 Py_DECREF(tmp);
11784 }
11785 #endif
11786 if (likely(v)) {
11787 int one = 1; int is_little = (int)*(unsigned char *)&one;
11788 unsigned char *bytes = (unsigned char *)&val;
11789 int ret = _PyLong_AsByteArray((PyLongObject *)v,
11790 bytes, sizeof(val),
11791 is_little, !is_unsigned);
11792 Py_DECREF(v);
11793 if (likely(!ret))
11794 return val;
11795 }
11796 #endif
11797 return (long) -1;
11798 }
11799 } else {
11800 long val;
11801 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
11802 if (!tmp) return (long) -1;
11803 val = __Pyx_PyInt_As_long(tmp);
11804 Py_DECREF(tmp);
11805 return val;
11806 }
11807 raise_overflow:
11808 PyErr_SetString(PyExc_OverflowError,
11809 "value too large to convert to long");
11810 return (long) -1;
11811 raise_neg_overflow:
11812 PyErr_SetString(PyExc_OverflowError,
11813 "can't convert negative value to long");
11814 return (long) -1;
11815 }
11816
11817 /* FastTypeChecks */
11818 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)11819 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
11820 while (a) {
11821 a = a->tp_base;
11822 if (a == b)
11823 return 1;
11824 }
11825 return b == &PyBaseObject_Type;
11826 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)11827 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
11828 PyObject *mro;
11829 if (a == b) return 1;
11830 mro = a->tp_mro;
11831 if (likely(mro)) {
11832 Py_ssize_t i, n;
11833 n = PyTuple_GET_SIZE(mro);
11834 for (i = 0; i < n; i++) {
11835 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
11836 return 1;
11837 }
11838 return 0;
11839 }
11840 return __Pyx_InBases(a, b);
11841 }
11842 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)11843 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
11844 PyObject *exception, *value, *tb;
11845 int res;
11846 __Pyx_PyThreadState_declare
11847 __Pyx_PyThreadState_assign
11848 __Pyx_ErrFetch(&exception, &value, &tb);
11849 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
11850 if (unlikely(res == -1)) {
11851 PyErr_WriteUnraisable(err);
11852 res = 0;
11853 }
11854 if (!res) {
11855 res = PyObject_IsSubclass(err, exc_type2);
11856 if (unlikely(res == -1)) {
11857 PyErr_WriteUnraisable(err);
11858 res = 0;
11859 }
11860 }
11861 __Pyx_ErrRestore(exception, value, tb);
11862 return res;
11863 }
11864 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)11865 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
11866 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
11867 if (!res) {
11868 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
11869 }
11870 return res;
11871 }
11872 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)11873 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
11874 Py_ssize_t i, n;
11875 assert(PyExceptionClass_Check(exc_type));
11876 n = PyTuple_GET_SIZE(tuple);
11877 #if PY_MAJOR_VERSION >= 3
11878 for (i=0; i<n; i++) {
11879 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
11880 }
11881 #endif
11882 for (i=0; i<n; i++) {
11883 PyObject *t = PyTuple_GET_ITEM(tuple, i);
11884 #if PY_MAJOR_VERSION < 3
11885 if (likely(exc_type == t)) return 1;
11886 #endif
11887 if (likely(PyExceptionClass_Check(t))) {
11888 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
11889 } else {
11890 }
11891 }
11892 return 0;
11893 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)11894 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
11895 if (likely(err == exc_type)) return 1;
11896 if (likely(PyExceptionClass_Check(err))) {
11897 if (likely(PyExceptionClass_Check(exc_type))) {
11898 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
11899 } else if (likely(PyTuple_Check(exc_type))) {
11900 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
11901 } else {
11902 }
11903 }
11904 return PyErr_GivenExceptionMatches(err, exc_type);
11905 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)11906 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
11907 assert(PyExceptionClass_Check(exc_type1));
11908 assert(PyExceptionClass_Check(exc_type2));
11909 if (likely(err == exc_type1 || err == exc_type2)) return 1;
11910 if (likely(PyExceptionClass_Check(err))) {
11911 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
11912 }
11913 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
11914 }
11915 #endif
11916
11917 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)11918 static int __Pyx_check_binary_version(void) {
11919 char ctversion[4], rtversion[4];
11920 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
11921 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
11922 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
11923 char message[200];
11924 PyOS_snprintf(message, sizeof(message),
11925 "compiletime version %s of module '%.100s' "
11926 "does not match runtime version %s",
11927 ctversion, __Pyx_MODULE_NAME, rtversion);
11928 return PyErr_WarnEx(NULL, message, 1);
11929 }
11930 return 0;
11931 }
11932
11933 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)11934 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
11935 while (t->p) {
11936 #if PY_MAJOR_VERSION < 3
11937 if (t->is_unicode) {
11938 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
11939 } else if (t->intern) {
11940 *t->p = PyString_InternFromString(t->s);
11941 } else {
11942 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
11943 }
11944 #else
11945 if (t->is_unicode | t->is_str) {
11946 if (t->intern) {
11947 *t->p = PyUnicode_InternFromString(t->s);
11948 } else if (t->encoding) {
11949 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
11950 } else {
11951 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
11952 }
11953 } else {
11954 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
11955 }
11956 #endif
11957 if (!*t->p)
11958 return -1;
11959 if (PyObject_Hash(*t->p) == -1)
11960 return -1;
11961 ++t;
11962 }
11963 return 0;
11964 }
11965
__Pyx_PyUnicode_FromString(const char * c_str)11966 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
11967 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
11968 }
__Pyx_PyObject_AsString(PyObject * o)11969 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
11970 Py_ssize_t ignore;
11971 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
11972 }
11973 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
11974 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)11975 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
11976 char* defenc_c;
11977 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
11978 if (!defenc) return NULL;
11979 defenc_c = PyBytes_AS_STRING(defenc);
11980 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
11981 {
11982 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
11983 char* c;
11984 for (c = defenc_c; c < end; c++) {
11985 if ((unsigned char) (*c) >= 128) {
11986 PyUnicode_AsASCIIString(o);
11987 return NULL;
11988 }
11989 }
11990 }
11991 #endif
11992 *length = PyBytes_GET_SIZE(defenc);
11993 return defenc_c;
11994 }
11995 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)11996 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
11997 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
11998 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
11999 if (likely(PyUnicode_IS_ASCII(o))) {
12000 *length = PyUnicode_GET_LENGTH(o);
12001 return PyUnicode_AsUTF8(o);
12002 } else {
12003 PyUnicode_AsASCIIString(o);
12004 return NULL;
12005 }
12006 #else
12007 return PyUnicode_AsUTF8AndSize(o, length);
12008 #endif
12009 }
12010 #endif
12011 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)12012 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
12013 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
12014 if (
12015 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
12016 __Pyx_sys_getdefaultencoding_not_ascii &&
12017 #endif
12018 PyUnicode_Check(o)) {
12019 return __Pyx_PyUnicode_AsStringAndSize(o, length);
12020 } else
12021 #endif
12022 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
12023 if (PyByteArray_Check(o)) {
12024 *length = PyByteArray_GET_SIZE(o);
12025 return PyByteArray_AS_STRING(o);
12026 } else
12027 #endif
12028 {
12029 char* result;
12030 int r = PyBytes_AsStringAndSize(o, &result, length);
12031 if (unlikely(r < 0)) {
12032 return NULL;
12033 } else {
12034 return result;
12035 }
12036 }
12037 }
__Pyx_PyObject_IsTrue(PyObject * x)12038 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
12039 int is_true = x == Py_True;
12040 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
12041 else return PyObject_IsTrue(x);
12042 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)12043 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
12044 int retval;
12045 if (unlikely(!x)) return -1;
12046 retval = __Pyx_PyObject_IsTrue(x);
12047 Py_DECREF(x);
12048 return retval;
12049 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)12050 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
12051 #if PY_MAJOR_VERSION >= 3
12052 if (PyLong_Check(result)) {
12053 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
12054 "__int__ returned non-int (type %.200s). "
12055 "The ability to return an instance of a strict subclass of int "
12056 "is deprecated, and may be removed in a future version of Python.",
12057 Py_TYPE(result)->tp_name)) {
12058 Py_DECREF(result);
12059 return NULL;
12060 }
12061 return result;
12062 }
12063 #endif
12064 PyErr_Format(PyExc_TypeError,
12065 "__%.4s__ returned non-%.4s (type %.200s)",
12066 type_name, type_name, Py_TYPE(result)->tp_name);
12067 Py_DECREF(result);
12068 return NULL;
12069 }
__Pyx_PyNumber_IntOrLong(PyObject * x)12070 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
12071 #if CYTHON_USE_TYPE_SLOTS
12072 PyNumberMethods *m;
12073 #endif
12074 const char *name = NULL;
12075 PyObject *res = NULL;
12076 #if PY_MAJOR_VERSION < 3
12077 if (likely(PyInt_Check(x) || PyLong_Check(x)))
12078 #else
12079 if (likely(PyLong_Check(x)))
12080 #endif
12081 return __Pyx_NewRef(x);
12082 #if CYTHON_USE_TYPE_SLOTS
12083 m = Py_TYPE(x)->tp_as_number;
12084 #if PY_MAJOR_VERSION < 3
12085 if (m && m->nb_int) {
12086 name = "int";
12087 res = m->nb_int(x);
12088 }
12089 else if (m && m->nb_long) {
12090 name = "long";
12091 res = m->nb_long(x);
12092 }
12093 #else
12094 if (likely(m && m->nb_int)) {
12095 name = "int";
12096 res = m->nb_int(x);
12097 }
12098 #endif
12099 #else
12100 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
12101 res = PyNumber_Int(x);
12102 }
12103 #endif
12104 if (likely(res)) {
12105 #if PY_MAJOR_VERSION < 3
12106 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
12107 #else
12108 if (unlikely(!PyLong_CheckExact(res))) {
12109 #endif
12110 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
12111 }
12112 }
12113 else if (!PyErr_Occurred()) {
12114 PyErr_SetString(PyExc_TypeError,
12115 "an integer is required");
12116 }
12117 return res;
12118 }
12119 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
12120 Py_ssize_t ival;
12121 PyObject *x;
12122 #if PY_MAJOR_VERSION < 3
12123 if (likely(PyInt_CheckExact(b))) {
12124 if (sizeof(Py_ssize_t) >= sizeof(long))
12125 return PyInt_AS_LONG(b);
12126 else
12127 return PyInt_AsSsize_t(b);
12128 }
12129 #endif
12130 if (likely(PyLong_CheckExact(b))) {
12131 #if CYTHON_USE_PYLONG_INTERNALS
12132 const digit* digits = ((PyLongObject*)b)->ob_digit;
12133 const Py_ssize_t size = Py_SIZE(b);
12134 if (likely(__Pyx_sst_abs(size) <= 1)) {
12135 ival = likely(size) ? digits[0] : 0;
12136 if (size == -1) ival = -ival;
12137 return ival;
12138 } else {
12139 switch (size) {
12140 case 2:
12141 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
12142 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12143 }
12144 break;
12145 case -2:
12146 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
12147 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12148 }
12149 break;
12150 case 3:
12151 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
12152 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12153 }
12154 break;
12155 case -3:
12156 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
12157 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
12158 }
12159 break;
12160 case 4:
12161 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
12162 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]));
12163 }
12164 break;
12165 case -4:
12166 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
12167 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]));
12168 }
12169 break;
12170 }
12171 }
12172 #endif
12173 return PyLong_AsSsize_t(b);
12174 }
12175 x = PyNumber_Index(b);
12176 if (!x) return -1;
12177 ival = PyInt_AsSsize_t(x);
12178 Py_DECREF(x);
12179 return ival;
12180 }
12181 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
12182 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
12183 }
12184 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
12185 return PyInt_FromSize_t(ival);
12186 }
12187
12188
12189 #endif /* Py_PYTHON_H */
12190