wrapt 2.0.0rc2__cp314-cp314t-win_arm64.whl → 2.0.1__cp314-cp314t-win_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wrapt/_wrappers.c CHANGED
@@ -10,7 +10,8 @@
10
10
 
11
11
  /* ------------------------------------------------------------------------- */
12
12
 
13
- typedef struct {
13
+ typedef struct
14
+ {
14
15
  PyObject_HEAD
15
16
 
16
17
  PyObject *dict;
@@ -21,7 +22,8 @@ typedef struct {
21
22
  PyTypeObject WraptObjectProxy_Type;
22
23
  PyTypeObject WraptCallableObjectProxy_Type;
23
24
 
24
- typedef struct {
25
+ typedef struct
26
+ {
25
27
  WraptObjectProxyObject object_proxy;
26
28
 
27
29
  PyObject *args;
@@ -30,7 +32,8 @@ typedef struct {
30
32
 
31
33
  PyTypeObject WraptPartialCallableObjectProxy_Type;
32
34
 
33
- typedef struct {
35
+ typedef struct
36
+ {
34
37
  WraptObjectProxyObject object_proxy;
35
38
 
36
39
  PyObject *instance;
@@ -47,7 +50,79 @@ PyTypeObject WraptFunctionWrapper_Type;
47
50
 
48
51
  /* ------------------------------------------------------------------------- */
49
52
 
50
- static void raise_uninitialized_wrapper_error(void) {
53
+ static int raise_uninitialized_wrapper_error(WraptObjectProxyObject *object)
54
+ {
55
+ // Before raising an exception we need to first check whether this is a lazy
56
+ // proxy object and attempt to intialize the wrapped object using the supplied
57
+ // callback if so. If the callback is not present then we can proceed to raise
58
+ // the exception, but if the callback is present and returns a value, we set
59
+ // that as the wrapped object and continue and return without raising an error.
60
+
61
+ static PyObject *wrapped_str = NULL;
62
+ static PyObject *wrapped_factory_str = NULL;
63
+ static PyObject *wrapped_get_str = NULL;
64
+
65
+ PyObject *callback = NULL;
66
+ PyObject *value = NULL;
67
+
68
+ if (!wrapped_str)
69
+ {
70
+ wrapped_str = PyUnicode_InternFromString("__wrapped__");
71
+ wrapped_factory_str = PyUnicode_InternFromString("__wrapped_factory__");
72
+ wrapped_get_str = PyUnicode_InternFromString("__wrapped_get__");
73
+ }
74
+
75
+ // Note that we use existance of __wrapped_factory__ to gate whether we can
76
+ // attempt to initialize the wrapped object lazily, but it is __wrapped_get__
77
+ // that we actually call to do the initialization. This is so that we can
78
+ // handle multithreading correctly by having __wrapped_get__ use a lock to
79
+ // protect against multiple threads trying to initialize the wrapped object
80
+ // at the same time.
81
+
82
+ callback = PyObject_GenericGetAttr((PyObject *)object, wrapped_factory_str);
83
+
84
+ if (callback)
85
+ {
86
+ if (callback != Py_None)
87
+ {
88
+ Py_DECREF(callback);
89
+
90
+ callback = PyObject_GenericGetAttr((PyObject *)object, wrapped_get_str);
91
+
92
+ if (!callback)
93
+ return -1;
94
+
95
+ value = PyObject_CallObject(callback, NULL);
96
+
97
+ Py_DECREF(callback);
98
+
99
+ if (value)
100
+ {
101
+ // We use setattr so that special dunder methods will be properly set.
102
+
103
+ if (PyObject_SetAttr((PyObject *)object, wrapped_str, value) == -1)
104
+ {
105
+ Py_DECREF(value);
106
+ return -1;
107
+ }
108
+
109
+ Py_DECREF(value);
110
+
111
+ return 0;
112
+ }
113
+ else
114
+ {
115
+ return -1;
116
+ }
117
+ }
118
+ else
119
+ {
120
+ Py_DECREF(callback);
121
+ }
122
+ }
123
+ else
124
+ PyErr_Clear();
125
+
51
126
  // We need to reach into the wrapt.wrappers module to get the exception
52
127
  // class because the exception we need to raise needs to inherit from both
53
128
  // ValueError and AttributeError and we can't do that in C code using the
@@ -61,25 +136,27 @@ static void raise_uninitialized_wrapper_error(void) {
61
136
 
62
137
  wrapt_wrappers_module = PyImport_ImportModule("wrapt.wrappers");
63
138
 
64
- if (!wrapt_wrappers_module) {
139
+ if (!wrapt_wrappers_module)
140
+ {
65
141
  // Fallback to ValueError if import fails.
66
142
 
67
143
  PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
68
144
 
69
- return;
145
+ return -1;
70
146
  }
71
147
 
72
148
  wrapper_not_initialized_error = PyObject_GetAttrString(
73
149
  wrapt_wrappers_module, "WrapperNotInitializedError");
74
150
 
75
- if (!wrapper_not_initialized_error) {
151
+ if (!wrapper_not_initialized_error)
152
+ {
76
153
  // Fallback to ValueError if attribute lookup fails.
77
154
 
78
155
  Py_DECREF(wrapt_wrappers_module);
79
156
 
80
157
  PyErr_SetString(PyExc_ValueError, "wrapper has not been initialized");
81
158
 
82
- return;
159
+ return -1;
83
160
  }
84
161
 
85
162
  // Raise the custom exception.
@@ -91,12 +168,15 @@ static void raise_uninitialized_wrapper_error(void) {
91
168
 
92
169
  Py_DECREF(wrapper_not_initialized_error);
93
170
  Py_DECREF(wrapt_wrappers_module);
171
+
172
+ return -1;
94
173
  }
95
174
 
96
175
  /* ------------------------------------------------------------------------- */
97
176
 
98
177
  static PyObject *WraptObjectProxy_new(PyTypeObject *type, PyObject *args,
99
- PyObject *kwds) {
178
+ PyObject *kwds)
179
+ {
100
180
  WraptObjectProxyObject *self;
101
181
 
102
182
  self = (WraptObjectProxyObject *)type->tp_alloc(type, 0);
@@ -114,44 +194,84 @@ static PyObject *WraptObjectProxy_new(PyTypeObject *type, PyObject *args,
114
194
  /* ------------------------------------------------------------------------- */
115
195
 
116
196
  static int WraptObjectProxy_raw_init(WraptObjectProxyObject *self,
117
- PyObject *wrapped) {
197
+ PyObject *wrapped)
198
+ {
118
199
  static PyObject *module_str = NULL;
119
200
  static PyObject *doc_str = NULL;
201
+ static PyObject *wrapped_factory_str = NULL;
120
202
 
121
203
  PyObject *object = NULL;
122
204
 
205
+ // If wrapped is Py_None and we have a __wrapped_factory__ attribute
206
+ // then we defer initialization of the wrapped object until it is first needed.
207
+
208
+ if (!wrapped_factory_str)
209
+ {
210
+ wrapped_factory_str = PyUnicode_InternFromString("__wrapped_factory__");
211
+ }
212
+
213
+ if (wrapped == Py_None)
214
+ {
215
+ PyObject *callback = NULL;
216
+
217
+ callback = PyObject_GenericGetAttr((PyObject *)self, wrapped_factory_str);
218
+
219
+ if (callback)
220
+ {
221
+ if (callback != Py_None)
222
+ {
223
+ Py_DECREF(callback);
224
+ return 0;
225
+ }
226
+ else
227
+ {
228
+ Py_DECREF(callback);
229
+ }
230
+ }
231
+ else
232
+ PyErr_Clear();
233
+ }
234
+
123
235
  Py_INCREF(wrapped);
124
236
  Py_XDECREF(self->wrapped);
125
237
  self->wrapped = wrapped;
126
238
 
127
- if (!module_str) {
239
+ if (!module_str)
240
+ {
128
241
  module_str = PyUnicode_InternFromString("__module__");
129
242
  }
130
243
 
131
- if (!doc_str) {
244
+ if (!doc_str)
245
+ {
132
246
  doc_str = PyUnicode_InternFromString("__doc__");
133
247
  }
134
248
 
135
249
  object = PyObject_GetAttr(wrapped, module_str);
136
250
 
137
- if (object) {
138
- if (PyDict_SetItem(self->dict, module_str, object) == -1) {
251
+ if (object)
252
+ {
253
+ if (PyDict_SetItem(self->dict, module_str, object) == -1)
254
+ {
139
255
  Py_DECREF(object);
140
256
  return -1;
141
257
  }
142
258
  Py_DECREF(object);
143
- } else
259
+ }
260
+ else
144
261
  PyErr_Clear();
145
262
 
146
263
  object = PyObject_GetAttr(wrapped, doc_str);
147
264
 
148
- if (object) {
149
- if (PyDict_SetItem(self->dict, doc_str, object) == -1) {
265
+ if (object)
266
+ {
267
+ if (PyDict_SetItem(self->dict, doc_str, object) == -1)
268
+ {
150
269
  Py_DECREF(object);
151
270
  return -1;
152
271
  }
153
272
  Py_DECREF(object);
154
- } else
273
+ }
274
+ else
155
275
  PyErr_Clear();
156
276
 
157
277
  return 0;
@@ -160,13 +280,15 @@ static int WraptObjectProxy_raw_init(WraptObjectProxyObject *self,
160
280
  /* ------------------------------------------------------------------------- */
161
281
 
162
282
  static int WraptObjectProxy_init(WraptObjectProxyObject *self, PyObject *args,
163
- PyObject *kwds) {
283
+ PyObject *kwds)
284
+ {
164
285
  PyObject *wrapped = NULL;
165
286
 
166
287
  char *const kwlist[] = {"wrapped", NULL};
167
288
 
168
289
  if (!PyArg_ParseTupleAndKeywords(args, kwds, "O:ObjectProxy", kwlist,
169
- &wrapped)) {
290
+ &wrapped))
291
+ {
170
292
  return -1;
171
293
  }
172
294
 
@@ -176,7 +298,8 @@ static int WraptObjectProxy_init(WraptObjectProxyObject *self, PyObject *args,
176
298
  /* ------------------------------------------------------------------------- */
177
299
 
178
300
  static int WraptObjectProxy_traverse(WraptObjectProxyObject *self,
179
- visitproc visit, void *arg) {
301
+ visitproc visit, void *arg)
302
+ {
180
303
  Py_VISIT(self->dict);
181
304
  Py_VISIT(self->wrapped);
182
305
 
@@ -185,7 +308,8 @@ static int WraptObjectProxy_traverse(WraptObjectProxyObject *self,
185
308
 
186
309
  /* ------------------------------------------------------------------------- */
187
310
 
188
- static int WraptObjectProxy_clear(WraptObjectProxyObject *self) {
311
+ static int WraptObjectProxy_clear(WraptObjectProxyObject *self)
312
+ {
189
313
  Py_CLEAR(self->dict);
190
314
  Py_CLEAR(self->wrapped);
191
315
 
@@ -194,7 +318,8 @@ static int WraptObjectProxy_clear(WraptObjectProxyObject *self) {
194
318
 
195
319
  /* ------------------------------------------------------------------------- */
196
320
 
197
- static void WraptObjectProxy_dealloc(WraptObjectProxyObject *self) {
321
+ static void WraptObjectProxy_dealloc(WraptObjectProxyObject *self)
322
+ {
198
323
  PyObject_GC_UnTrack(self);
199
324
 
200
325
  if (self->weakreflist != NULL)
@@ -207,10 +332,12 @@ static void WraptObjectProxy_dealloc(WraptObjectProxyObject *self) {
207
332
 
208
333
  /* ------------------------------------------------------------------------- */
209
334
 
210
- static PyObject *WraptObjectProxy_repr(WraptObjectProxyObject *self) {
211
- if (!self->wrapped) {
212
- raise_uninitialized_wrapper_error();
213
- return NULL;
335
+ static PyObject *WraptObjectProxy_repr(WraptObjectProxyObject *self)
336
+ {
337
+ if (!self->wrapped)
338
+ {
339
+ if (raise_uninitialized_wrapper_error(self) == -1)
340
+ return NULL;
214
341
  }
215
342
 
216
343
  return PyUnicode_FromFormat("<%s at %p for %s at %p>", Py_TYPE(self)->tp_name,
@@ -220,10 +347,12 @@ static PyObject *WraptObjectProxy_repr(WraptObjectProxyObject *self) {
220
347
 
221
348
  /* ------------------------------------------------------------------------- */
222
349
 
223
- static Py_hash_t WraptObjectProxy_hash(WraptObjectProxyObject *self) {
224
- if (!self->wrapped) {
225
- raise_uninitialized_wrapper_error();
226
- return -1;
350
+ static Py_hash_t WraptObjectProxy_hash(WraptObjectProxyObject *self)
351
+ {
352
+ if (!self->wrapped)
353
+ {
354
+ if (raise_uninitialized_wrapper_error(self) == -1)
355
+ return -1;
227
356
  }
228
357
 
229
358
  return PyObject_Hash(self->wrapped);
@@ -231,10 +360,12 @@ static Py_hash_t WraptObjectProxy_hash(WraptObjectProxyObject *self) {
231
360
 
232
361
  /* ------------------------------------------------------------------------- */
233
362
 
234
- static PyObject *WraptObjectProxy_str(WraptObjectProxyObject *self) {
235
- if (!self->wrapped) {
236
- raise_uninitialized_wrapper_error();
237
- return NULL;
363
+ static PyObject *WraptObjectProxy_str(WraptObjectProxyObject *self)
364
+ {
365
+ if (!self->wrapped)
366
+ {
367
+ if (raise_uninitialized_wrapper_error(self) == -1)
368
+ return NULL;
238
369
  }
239
370
 
240
371
  return PyObject_Str(self->wrapped);
@@ -242,20 +373,25 @@ static PyObject *WraptObjectProxy_str(WraptObjectProxyObject *self) {
242
373
 
243
374
  /* ------------------------------------------------------------------------- */
244
375
 
245
- static PyObject *WraptObjectProxy_add(PyObject *o1, PyObject *o2) {
246
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
247
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
248
- raise_uninitialized_wrapper_error();
249
- return NULL;
376
+ static PyObject *WraptObjectProxy_add(PyObject *o1, PyObject *o2)
377
+ {
378
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
379
+ {
380
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
381
+ {
382
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
383
+ return NULL;
250
384
  }
251
385
 
252
386
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
253
387
  }
254
388
 
255
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
256
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
257
- raise_uninitialized_wrapper_error();
258
- return NULL;
389
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
390
+ {
391
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
392
+ {
393
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
394
+ return NULL;
259
395
  }
260
396
 
261
397
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -266,20 +402,25 @@ static PyObject *WraptObjectProxy_add(PyObject *o1, PyObject *o2) {
266
402
 
267
403
  /* ------------------------------------------------------------------------- */
268
404
 
269
- static PyObject *WraptObjectProxy_subtract(PyObject *o1, PyObject *o2) {
270
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
271
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
272
- raise_uninitialized_wrapper_error();
273
- return NULL;
405
+ static PyObject *WraptObjectProxy_subtract(PyObject *o1, PyObject *o2)
406
+ {
407
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
408
+ {
409
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
410
+ {
411
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
412
+ return NULL;
274
413
  }
275
414
 
276
415
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
277
416
  }
278
417
 
279
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
280
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
281
- raise_uninitialized_wrapper_error();
282
- return NULL;
418
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
419
+ {
420
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
421
+ {
422
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
423
+ return NULL;
283
424
  }
284
425
 
285
426
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -290,20 +431,25 @@ static PyObject *WraptObjectProxy_subtract(PyObject *o1, PyObject *o2) {
290
431
 
291
432
  /* ------------------------------------------------------------------------- */
292
433
 
293
- static PyObject *WraptObjectProxy_multiply(PyObject *o1, PyObject *o2) {
294
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
295
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
296
- raise_uninitialized_wrapper_error();
297
- return NULL;
434
+ static PyObject *WraptObjectProxy_multiply(PyObject *o1, PyObject *o2)
435
+ {
436
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
437
+ {
438
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
439
+ {
440
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
441
+ return NULL;
298
442
  }
299
443
 
300
444
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
301
445
  }
302
446
 
303
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
304
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
305
- raise_uninitialized_wrapper_error();
306
- return NULL;
447
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
448
+ {
449
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
450
+ {
451
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
452
+ return NULL;
307
453
  }
308
454
 
309
455
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -314,20 +460,25 @@ static PyObject *WraptObjectProxy_multiply(PyObject *o1, PyObject *o2) {
314
460
 
315
461
  /* ------------------------------------------------------------------------- */
316
462
 
317
- static PyObject *WraptObjectProxy_remainder(PyObject *o1, PyObject *o2) {
318
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
319
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
320
- raise_uninitialized_wrapper_error();
321
- return NULL;
463
+ static PyObject *WraptObjectProxy_remainder(PyObject *o1, PyObject *o2)
464
+ {
465
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
466
+ {
467
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
468
+ {
469
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
470
+ return NULL;
322
471
  }
323
472
 
324
473
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
325
474
  }
326
475
 
327
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
328
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
329
- raise_uninitialized_wrapper_error();
330
- return NULL;
476
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
477
+ {
478
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
479
+ {
480
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
481
+ return NULL;
331
482
  }
332
483
 
333
484
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -338,20 +489,25 @@ static PyObject *WraptObjectProxy_remainder(PyObject *o1, PyObject *o2) {
338
489
 
339
490
  /* ------------------------------------------------------------------------- */
340
491
 
341
- static PyObject *WraptObjectProxy_divmod(PyObject *o1, PyObject *o2) {
342
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
343
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
344
- raise_uninitialized_wrapper_error();
345
- return NULL;
492
+ static PyObject *WraptObjectProxy_divmod(PyObject *o1, PyObject *o2)
493
+ {
494
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
495
+ {
496
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
497
+ {
498
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
499
+ return NULL;
346
500
  }
347
501
 
348
502
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
349
503
  }
350
504
 
351
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
352
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
353
- raise_uninitialized_wrapper_error();
354
- return NULL;
505
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
506
+ {
507
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
508
+ {
509
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
510
+ return NULL;
355
511
  }
356
512
 
357
513
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -363,20 +519,25 @@ static PyObject *WraptObjectProxy_divmod(PyObject *o1, PyObject *o2) {
363
519
  /* ------------------------------------------------------------------------- */
364
520
 
365
521
  static PyObject *WraptObjectProxy_power(PyObject *o1, PyObject *o2,
366
- PyObject *modulo) {
367
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
368
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
369
- raise_uninitialized_wrapper_error();
370
- return NULL;
522
+ PyObject *modulo)
523
+ {
524
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
525
+ {
526
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
527
+ {
528
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
529
+ return NULL;
371
530
  }
372
531
 
373
532
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
374
533
  }
375
534
 
376
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
377
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
378
- raise_uninitialized_wrapper_error();
379
- return NULL;
535
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
536
+ {
537
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
538
+ {
539
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
540
+ return NULL;
380
541
  }
381
542
 
382
543
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -387,10 +548,12 @@ static PyObject *WraptObjectProxy_power(PyObject *o1, PyObject *o2,
387
548
 
388
549
  /* ------------------------------------------------------------------------- */
389
550
 
390
- static PyObject *WraptObjectProxy_negative(WraptObjectProxyObject *self) {
391
- if (!self->wrapped) {
392
- raise_uninitialized_wrapper_error();
393
- return NULL;
551
+ static PyObject *WraptObjectProxy_negative(WraptObjectProxyObject *self)
552
+ {
553
+ if (!self->wrapped)
554
+ {
555
+ if (raise_uninitialized_wrapper_error(self) == -1)
556
+ return NULL;
394
557
  }
395
558
 
396
559
  return PyNumber_Negative(self->wrapped);
@@ -398,10 +561,12 @@ static PyObject *WraptObjectProxy_negative(WraptObjectProxyObject *self) {
398
561
 
399
562
  /* ------------------------------------------------------------------------- */
400
563
 
401
- static PyObject *WraptObjectProxy_positive(WraptObjectProxyObject *self) {
402
- if (!self->wrapped) {
403
- raise_uninitialized_wrapper_error();
404
- return NULL;
564
+ static PyObject *WraptObjectProxy_positive(WraptObjectProxyObject *self)
565
+ {
566
+ if (!self->wrapped)
567
+ {
568
+ if (raise_uninitialized_wrapper_error(self) == -1)
569
+ return NULL;
405
570
  }
406
571
 
407
572
  return PyNumber_Positive(self->wrapped);
@@ -409,10 +574,12 @@ static PyObject *WraptObjectProxy_positive(WraptObjectProxyObject *self) {
409
574
 
410
575
  /* ------------------------------------------------------------------------- */
411
576
 
412
- static PyObject *WraptObjectProxy_absolute(WraptObjectProxyObject *self) {
413
- if (!self->wrapped) {
414
- raise_uninitialized_wrapper_error();
415
- return NULL;
577
+ static PyObject *WraptObjectProxy_absolute(WraptObjectProxyObject *self)
578
+ {
579
+ if (!self->wrapped)
580
+ {
581
+ if (raise_uninitialized_wrapper_error(self) == -1)
582
+ return NULL;
416
583
  }
417
584
 
418
585
  return PyNumber_Absolute(self->wrapped);
@@ -420,10 +587,12 @@ static PyObject *WraptObjectProxy_absolute(WraptObjectProxyObject *self) {
420
587
 
421
588
  /* ------------------------------------------------------------------------- */
422
589
 
423
- static int WraptObjectProxy_bool(WraptObjectProxyObject *self) {
424
- if (!self->wrapped) {
425
- raise_uninitialized_wrapper_error();
426
- return -1;
590
+ static int WraptObjectProxy_bool(WraptObjectProxyObject *self)
591
+ {
592
+ if (!self->wrapped)
593
+ {
594
+ if (raise_uninitialized_wrapper_error(self) == -1)
595
+ return -1;
427
596
  }
428
597
 
429
598
  return PyObject_IsTrue(self->wrapped);
@@ -431,10 +600,12 @@ static int WraptObjectProxy_bool(WraptObjectProxyObject *self) {
431
600
 
432
601
  /* ------------------------------------------------------------------------- */
433
602
 
434
- static PyObject *WraptObjectProxy_invert(WraptObjectProxyObject *self) {
435
- if (!self->wrapped) {
436
- raise_uninitialized_wrapper_error();
437
- return NULL;
603
+ static PyObject *WraptObjectProxy_invert(WraptObjectProxyObject *self)
604
+ {
605
+ if (!self->wrapped)
606
+ {
607
+ if (raise_uninitialized_wrapper_error(self) == -1)
608
+ return NULL;
438
609
  }
439
610
 
440
611
  return PyNumber_Invert(self->wrapped);
@@ -442,20 +613,25 @@ static PyObject *WraptObjectProxy_invert(WraptObjectProxyObject *self) {
442
613
 
443
614
  /* ------------------------------------------------------------------------- */
444
615
 
445
- static PyObject *WraptObjectProxy_lshift(PyObject *o1, PyObject *o2) {
446
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
447
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
448
- raise_uninitialized_wrapper_error();
449
- return NULL;
616
+ static PyObject *WraptObjectProxy_lshift(PyObject *o1, PyObject *o2)
617
+ {
618
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
619
+ {
620
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
621
+ {
622
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
623
+ return NULL;
450
624
  }
451
625
 
452
626
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
453
627
  }
454
628
 
455
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
456
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
457
- raise_uninitialized_wrapper_error();
458
- return NULL;
629
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
630
+ {
631
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
632
+ {
633
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
634
+ return NULL;
459
635
  }
460
636
 
461
637
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -466,20 +642,25 @@ static PyObject *WraptObjectProxy_lshift(PyObject *o1, PyObject *o2) {
466
642
 
467
643
  /* ------------------------------------------------------------------------- */
468
644
 
469
- static PyObject *WraptObjectProxy_rshift(PyObject *o1, PyObject *o2) {
470
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
471
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
472
- raise_uninitialized_wrapper_error();
473
- return NULL;
645
+ static PyObject *WraptObjectProxy_rshift(PyObject *o1, PyObject *o2)
646
+ {
647
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
648
+ {
649
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
650
+ {
651
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
652
+ return NULL;
474
653
  }
475
654
 
476
655
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
477
656
  }
478
657
 
479
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
480
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
481
- raise_uninitialized_wrapper_error();
482
- return NULL;
658
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
659
+ {
660
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
661
+ {
662
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
663
+ return NULL;
483
664
  }
484
665
 
485
666
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -490,20 +671,25 @@ static PyObject *WraptObjectProxy_rshift(PyObject *o1, PyObject *o2) {
490
671
 
491
672
  /* ------------------------------------------------------------------------- */
492
673
 
493
- static PyObject *WraptObjectProxy_and(PyObject *o1, PyObject *o2) {
494
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
495
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
496
- raise_uninitialized_wrapper_error();
497
- return NULL;
674
+ static PyObject *WraptObjectProxy_and(PyObject *o1, PyObject *o2)
675
+ {
676
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
677
+ {
678
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
679
+ {
680
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
681
+ return NULL;
498
682
  }
499
683
 
500
684
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
501
685
  }
502
686
 
503
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
504
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
505
- raise_uninitialized_wrapper_error();
506
- return NULL;
687
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
688
+ {
689
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
690
+ {
691
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
692
+ return NULL;
507
693
  }
508
694
 
509
695
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -514,20 +700,25 @@ static PyObject *WraptObjectProxy_and(PyObject *o1, PyObject *o2) {
514
700
 
515
701
  /* ------------------------------------------------------------------------- */
516
702
 
517
- static PyObject *WraptObjectProxy_xor(PyObject *o1, PyObject *o2) {
518
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
519
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
520
- raise_uninitialized_wrapper_error();
521
- return NULL;
703
+ static PyObject *WraptObjectProxy_xor(PyObject *o1, PyObject *o2)
704
+ {
705
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
706
+ {
707
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
708
+ {
709
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
710
+ return NULL;
522
711
  }
523
712
 
524
713
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
525
714
  }
526
715
 
527
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
528
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
529
- raise_uninitialized_wrapper_error();
530
- return NULL;
716
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
717
+ {
718
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
719
+ {
720
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
721
+ return NULL;
531
722
  }
532
723
 
533
724
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -538,20 +729,25 @@ static PyObject *WraptObjectProxy_xor(PyObject *o1, PyObject *o2) {
538
729
 
539
730
  /* ------------------------------------------------------------------------- */
540
731
 
541
- static PyObject *WraptObjectProxy_or(PyObject *o1, PyObject *o2) {
542
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
543
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
544
- raise_uninitialized_wrapper_error();
545
- return NULL;
732
+ static PyObject *WraptObjectProxy_or(PyObject *o1, PyObject *o2)
733
+ {
734
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
735
+ {
736
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
737
+ {
738
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
739
+ return NULL;
546
740
  }
547
741
 
548
742
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
549
743
  }
550
744
 
551
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
552
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
553
- raise_uninitialized_wrapper_error();
554
- return NULL;
745
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
746
+ {
747
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
748
+ {
749
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
750
+ return NULL;
555
751
  }
556
752
 
557
753
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
@@ -562,10 +758,12 @@ static PyObject *WraptObjectProxy_or(PyObject *o1, PyObject *o2) {
562
758
 
563
759
  /* ------------------------------------------------------------------------- */
564
760
 
565
- static PyObject *WraptObjectProxy_long(WraptObjectProxyObject *self) {
566
- if (!self->wrapped) {
567
- raise_uninitialized_wrapper_error();
568
- return NULL;
761
+ static PyObject *WraptObjectProxy_long(WraptObjectProxyObject *self)
762
+ {
763
+ if (!self->wrapped)
764
+ {
765
+ if (raise_uninitialized_wrapper_error(self) == -1)
766
+ return NULL;
569
767
  }
570
768
 
571
769
  return PyNumber_Long(self->wrapped);
@@ -573,10 +771,12 @@ static PyObject *WraptObjectProxy_long(WraptObjectProxyObject *self) {
573
771
 
574
772
  /* ------------------------------------------------------------------------- */
575
773
 
576
- static PyObject *WraptObjectProxy_float(WraptObjectProxyObject *self) {
577
- if (!self->wrapped) {
578
- raise_uninitialized_wrapper_error();
579
- return NULL;
774
+ static PyObject *WraptObjectProxy_float(WraptObjectProxyObject *self)
775
+ {
776
+ if (!self->wrapped)
777
+ {
778
+ if (raise_uninitialized_wrapper_error(self) == -1)
779
+ return NULL;
580
780
  }
581
781
 
582
782
  return PyNumber_Float(self->wrapped);
@@ -585,384 +785,934 @@ static PyObject *WraptObjectProxy_float(WraptObjectProxyObject *self) {
585
785
  /* ------------------------------------------------------------------------- */
586
786
 
587
787
  static PyObject *WraptObjectProxy_inplace_add(WraptObjectProxyObject *self,
588
- PyObject *other) {
788
+ PyObject *other)
789
+ {
589
790
  PyObject *object = NULL;
590
791
 
591
- if (!self->wrapped) {
592
- raise_uninitialized_wrapper_error();
593
- return NULL;
792
+ if (!self->wrapped)
793
+ {
794
+ if (raise_uninitialized_wrapper_error(self) == -1)
795
+ return NULL;
594
796
  }
595
797
 
596
798
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
597
799
  other = ((WraptObjectProxyObject *)other)->wrapped;
598
800
 
599
- object = PyNumber_InPlaceAdd(self->wrapped, other);
801
+ if (PyObject_HasAttrString(self->wrapped, "__iadd__"))
802
+ {
803
+ object = PyNumber_InPlaceAdd(self->wrapped, other);
600
804
 
601
- if (!object)
602
- return NULL;
805
+ if (!object)
806
+ return NULL;
603
807
 
604
- Py_DECREF(self->wrapped);
605
- self->wrapped = object;
808
+ Py_DECREF(self->wrapped);
809
+ self->wrapped = object;
606
810
 
607
- Py_INCREF(self);
608
- return (PyObject *)self;
811
+ Py_INCREF(self);
812
+ return (PyObject *)self;
813
+ }
814
+ else
815
+ {
816
+ PyObject *result = PyNumber_Add(self->wrapped, other);
817
+
818
+ if (!result)
819
+ return NULL;
820
+
821
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
822
+
823
+ if (!proxy_type)
824
+ {
825
+ Py_DECREF(proxy_type);
826
+ return NULL;
827
+ }
828
+
829
+ PyObject *proxy_args = PyTuple_Pack(1, result);
830
+
831
+ Py_DECREF(result);
832
+
833
+ if (!proxy_args)
834
+ {
835
+ Py_DECREF(proxy_type);
836
+ return NULL;
837
+ }
838
+
839
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
840
+
841
+ Py_DECREF(proxy_type);
842
+ Py_DECREF(proxy_args);
843
+
844
+ return proxy_instance;
845
+ }
609
846
  }
610
847
 
611
848
  /* ------------------------------------------------------------------------- */
612
849
 
613
850
  static PyObject *WraptObjectProxy_inplace_subtract(WraptObjectProxyObject *self,
614
- PyObject *other) {
851
+ PyObject *other)
852
+ {
615
853
  PyObject *object = NULL;
616
854
 
617
- if (!self->wrapped) {
618
- raise_uninitialized_wrapper_error();
619
- return NULL;
855
+ if (!self->wrapped)
856
+ {
857
+ if (raise_uninitialized_wrapper_error(self) == -1)
858
+ return NULL;
620
859
  }
621
860
 
622
861
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
623
862
  other = ((WraptObjectProxyObject *)other)->wrapped;
624
863
 
625
- object = PyNumber_InPlaceSubtract(self->wrapped, other);
864
+ if (PyObject_HasAttrString(self->wrapped, "__isub__"))
865
+ {
866
+ object = PyNumber_InPlaceSubtract(self->wrapped, other);
626
867
 
627
- if (!object)
628
- return NULL;
868
+ if (!object)
869
+ return NULL;
629
870
 
630
- Py_DECREF(self->wrapped);
631
- self->wrapped = object;
871
+ Py_DECREF(self->wrapped);
872
+ self->wrapped = object;
632
873
 
633
- Py_INCREF(self);
634
- return (PyObject *)self;
874
+ Py_INCREF(self);
875
+ return (PyObject *)self;
876
+ }
877
+ else
878
+ {
879
+ PyObject *result = PyNumber_Subtract(self->wrapped, other);
880
+
881
+ if (!result)
882
+ return NULL;
883
+
884
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
885
+
886
+ if (!proxy_type)
887
+ {
888
+ Py_DECREF(proxy_type);
889
+ return NULL;
890
+ }
891
+
892
+ PyObject *proxy_args = PyTuple_Pack(1, result);
893
+
894
+ Py_DECREF(result);
895
+
896
+ if (!proxy_args)
897
+ {
898
+ Py_DECREF(proxy_type);
899
+ return NULL;
900
+ }
901
+
902
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
903
+
904
+ Py_DECREF(proxy_type);
905
+ Py_DECREF(proxy_args);
906
+
907
+ return proxy_instance;
908
+ }
635
909
  }
636
910
 
637
911
  /* ------------------------------------------------------------------------- */
638
912
 
639
913
  static PyObject *WraptObjectProxy_inplace_multiply(WraptObjectProxyObject *self,
640
- PyObject *other) {
914
+ PyObject *other)
915
+ {
641
916
  PyObject *object = NULL;
642
917
 
643
- if (!self->wrapped) {
644
- raise_uninitialized_wrapper_error();
645
- return NULL;
918
+ if (!self->wrapped)
919
+ {
920
+ if (raise_uninitialized_wrapper_error(self) == -1)
921
+ return NULL;
646
922
  }
647
923
 
648
924
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
649
925
  other = ((WraptObjectProxyObject *)other)->wrapped;
650
926
 
651
- object = PyNumber_InPlaceMultiply(self->wrapped, other);
927
+ if (PyObject_HasAttrString(self->wrapped, "__imul__"))
928
+ {
929
+ object = PyNumber_InPlaceMultiply(self->wrapped, other);
652
930
 
653
- if (!object)
654
- return NULL;
931
+ if (!object)
932
+ return NULL;
655
933
 
656
- Py_DECREF(self->wrapped);
657
- self->wrapped = object;
934
+ Py_DECREF(self->wrapped);
935
+ self->wrapped = object;
658
936
 
659
- Py_INCREF(self);
660
- return (PyObject *)self;
937
+ Py_INCREF(self);
938
+ return (PyObject *)self;
939
+ }
940
+ else
941
+ {
942
+ PyObject *result = PyNumber_Multiply(self->wrapped, other);
943
+
944
+ if (!result)
945
+ return NULL;
946
+
947
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
948
+
949
+ if (!proxy_type)
950
+ {
951
+ Py_DECREF(proxy_type);
952
+ return NULL;
953
+ }
954
+
955
+ PyObject *proxy_args = PyTuple_Pack(1, result);
956
+
957
+ Py_DECREF(result);
958
+
959
+ if (!proxy_args)
960
+ {
961
+ Py_DECREF(proxy_type);
962
+ return NULL;
963
+ }
964
+
965
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
966
+
967
+ Py_DECREF(proxy_type);
968
+ Py_DECREF(proxy_args);
969
+
970
+ return proxy_instance;
971
+ }
661
972
  }
662
973
 
663
974
  /* ------------------------------------------------------------------------- */
664
975
 
665
976
  static PyObject *
666
977
  WraptObjectProxy_inplace_remainder(WraptObjectProxyObject *self,
667
- PyObject *other) {
978
+ PyObject *other)
979
+ {
668
980
  PyObject *object = NULL;
669
981
 
670
- if (!self->wrapped) {
671
- raise_uninitialized_wrapper_error();
672
- return NULL;
982
+ if (!self->wrapped)
983
+ {
984
+ if (raise_uninitialized_wrapper_error(self) == -1)
985
+ return NULL;
673
986
  }
674
987
 
675
988
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
676
989
  other = ((WraptObjectProxyObject *)other)->wrapped;
677
990
 
678
- object = PyNumber_InPlaceRemainder(self->wrapped, other);
991
+ if (PyObject_HasAttrString(self->wrapped, "__imod__"))
992
+ {
993
+ object = PyNumber_InPlaceRemainder(self->wrapped, other);
679
994
 
680
- if (!object)
681
- return NULL;
995
+ if (!object)
996
+ return NULL;
682
997
 
683
- Py_DECREF(self->wrapped);
684
- self->wrapped = object;
998
+ Py_DECREF(self->wrapped);
999
+ self->wrapped = object;
685
1000
 
686
- Py_INCREF(self);
687
- return (PyObject *)self;
1001
+ Py_INCREF(self);
1002
+ return (PyObject *)self;
1003
+ }
1004
+ else
1005
+ {
1006
+ PyObject *result = PyNumber_Remainder(self->wrapped, other);
1007
+
1008
+ if (!result)
1009
+ return NULL;
1010
+
1011
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
1012
+
1013
+ if (!proxy_type)
1014
+ {
1015
+ Py_DECREF(proxy_type);
1016
+ return NULL;
1017
+ }
1018
+
1019
+ PyObject *proxy_args = PyTuple_Pack(1, result);
1020
+
1021
+ Py_DECREF(result);
1022
+
1023
+ if (!proxy_args)
1024
+ {
1025
+ Py_DECREF(proxy_type);
1026
+ return NULL;
1027
+ }
1028
+
1029
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
1030
+
1031
+ Py_DECREF(proxy_type);
1032
+ Py_DECREF(proxy_args);
1033
+
1034
+ return proxy_instance;
1035
+ }
688
1036
  }
689
1037
 
690
1038
  /* ------------------------------------------------------------------------- */
691
1039
 
692
1040
  static PyObject *WraptObjectProxy_inplace_power(WraptObjectProxyObject *self,
693
1041
  PyObject *other,
694
- PyObject *modulo) {
1042
+ PyObject *modulo)
1043
+ {
695
1044
  PyObject *object = NULL;
696
1045
 
697
- if (!self->wrapped) {
698
- raise_uninitialized_wrapper_error();
699
- return NULL;
1046
+ if (!self->wrapped)
1047
+ {
1048
+ if (raise_uninitialized_wrapper_error(self) == -1)
1049
+ return NULL;
700
1050
  }
701
1051
 
702
1052
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
703
1053
  other = ((WraptObjectProxyObject *)other)->wrapped;
704
1054
 
705
- object = PyNumber_InPlacePower(self->wrapped, other, modulo);
1055
+ if (PyObject_HasAttrString(self->wrapped, "__ipow__"))
1056
+ {
1057
+ object = PyNumber_InPlacePower(self->wrapped, other, modulo);
706
1058
 
707
- if (!object)
708
- return NULL;
1059
+ if (!object)
1060
+ return NULL;
709
1061
 
710
- Py_DECREF(self->wrapped);
711
- self->wrapped = object;
1062
+ Py_DECREF(self->wrapped);
1063
+ self->wrapped = object;
712
1064
 
713
- Py_INCREF(self);
714
- return (PyObject *)self;
1065
+ Py_INCREF(self);
1066
+ return (PyObject *)self;
1067
+ }
1068
+ else
1069
+ {
1070
+ PyObject *result = PyNumber_Power(self->wrapped, other, modulo);
1071
+
1072
+ if (!result)
1073
+ return NULL;
1074
+
1075
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
1076
+
1077
+ if (!proxy_type)
1078
+ {
1079
+ Py_DECREF(proxy_type);
1080
+ return NULL;
1081
+ }
1082
+
1083
+ PyObject *proxy_args = PyTuple_Pack(1, result);
1084
+
1085
+ Py_DECREF(result);
1086
+
1087
+ if (!proxy_args)
1088
+ {
1089
+ Py_DECREF(proxy_type);
1090
+ return NULL;
1091
+ }
1092
+
1093
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
1094
+
1095
+ Py_DECREF(proxy_type);
1096
+ Py_DECREF(proxy_args);
1097
+
1098
+ return proxy_instance;
1099
+ }
715
1100
  }
716
1101
 
717
1102
  /* ------------------------------------------------------------------------- */
718
1103
 
719
1104
  static PyObject *WraptObjectProxy_inplace_lshift(WraptObjectProxyObject *self,
720
- PyObject *other) {
1105
+ PyObject *other)
1106
+ {
721
1107
  PyObject *object = NULL;
722
1108
 
723
- if (!self->wrapped) {
724
- raise_uninitialized_wrapper_error();
725
- return NULL;
1109
+ if (!self->wrapped)
1110
+ {
1111
+ if (raise_uninitialized_wrapper_error(self) == -1)
1112
+ return NULL;
726
1113
  }
727
1114
 
728
1115
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
729
1116
  other = ((WraptObjectProxyObject *)other)->wrapped;
730
1117
 
731
- object = PyNumber_InPlaceLshift(self->wrapped, other);
1118
+ if (PyObject_HasAttrString(self->wrapped, "__ilshift__"))
1119
+ {
1120
+ object = PyNumber_InPlaceLshift(self->wrapped, other);
732
1121
 
733
- if (!object)
734
- return NULL;
1122
+ if (!object)
1123
+ return NULL;
735
1124
 
736
- Py_DECREF(self->wrapped);
737
- self->wrapped = object;
1125
+ Py_DECREF(self->wrapped);
1126
+ self->wrapped = object;
738
1127
 
739
- Py_INCREF(self);
740
- return (PyObject *)self;
1128
+ Py_INCREF(self);
1129
+ return (PyObject *)self;
1130
+ }
1131
+ else
1132
+ {
1133
+ PyObject *result = PyNumber_Lshift(self->wrapped, other);
1134
+
1135
+ if (!result)
1136
+ return NULL;
1137
+
1138
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
1139
+
1140
+ if (!proxy_type)
1141
+ {
1142
+ Py_DECREF(proxy_type);
1143
+ return NULL;
1144
+ }
1145
+
1146
+ PyObject *proxy_args = PyTuple_Pack(1, result);
1147
+
1148
+ Py_DECREF(result);
1149
+
1150
+ if (!proxy_args)
1151
+ {
1152
+ Py_DECREF(proxy_type);
1153
+ return NULL;
1154
+ }
1155
+
1156
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
1157
+
1158
+ Py_DECREF(proxy_type);
1159
+ Py_DECREF(proxy_args);
1160
+
1161
+ return proxy_instance;
1162
+ }
741
1163
  }
742
1164
 
743
1165
  /* ------------------------------------------------------------------------- */
744
1166
 
745
1167
  static PyObject *WraptObjectProxy_inplace_rshift(WraptObjectProxyObject *self,
746
- PyObject *other) {
1168
+ PyObject *other)
1169
+ {
747
1170
  PyObject *object = NULL;
748
1171
 
749
- if (!self->wrapped) {
750
- raise_uninitialized_wrapper_error();
751
- return NULL;
1172
+ if (!self->wrapped)
1173
+ {
1174
+ if (raise_uninitialized_wrapper_error(self) == -1)
1175
+ return NULL;
752
1176
  }
753
1177
 
754
1178
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
755
1179
  other = ((WraptObjectProxyObject *)other)->wrapped;
756
1180
 
757
- object = PyNumber_InPlaceRshift(self->wrapped, other);
1181
+ if (PyObject_HasAttrString(self->wrapped, "__irshift__"))
1182
+ {
1183
+ object = PyNumber_InPlaceRshift(self->wrapped, other);
758
1184
 
759
- if (!object)
760
- return NULL;
1185
+ if (!object)
1186
+ return NULL;
761
1187
 
762
- Py_DECREF(self->wrapped);
763
- self->wrapped = object;
1188
+ Py_DECREF(self->wrapped);
1189
+ self->wrapped = object;
764
1190
 
765
- Py_INCREF(self);
766
- return (PyObject *)self;
1191
+ Py_INCREF(self);
1192
+ return (PyObject *)self;
1193
+ }
1194
+ else
1195
+ {
1196
+ PyObject *result = PyNumber_Rshift(self->wrapped, other);
1197
+
1198
+ if (!result)
1199
+ return NULL;
1200
+
1201
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
1202
+
1203
+ if (!proxy_type)
1204
+ {
1205
+ Py_DECREF(proxy_type);
1206
+ return NULL;
1207
+ }
1208
+
1209
+ PyObject *proxy_args = PyTuple_Pack(1, result);
1210
+
1211
+ Py_DECREF(result);
1212
+
1213
+ if (!proxy_args)
1214
+ {
1215
+ Py_DECREF(proxy_type);
1216
+ return NULL;
1217
+ }
1218
+
1219
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
1220
+
1221
+ Py_DECREF(proxy_type);
1222
+ Py_DECREF(proxy_args);
1223
+
1224
+ return proxy_instance;
1225
+ }
767
1226
  }
768
1227
 
769
1228
  /* ------------------------------------------------------------------------- */
770
1229
 
771
1230
  static PyObject *WraptObjectProxy_inplace_and(WraptObjectProxyObject *self,
772
- PyObject *other) {
1231
+ PyObject *other)
1232
+ {
773
1233
  PyObject *object = NULL;
774
1234
 
775
- if (!self->wrapped) {
776
- raise_uninitialized_wrapper_error();
777
- return NULL;
1235
+ if (!self->wrapped)
1236
+ {
1237
+ if (raise_uninitialized_wrapper_error(self) == -1)
1238
+ return NULL;
778
1239
  }
779
1240
 
780
1241
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
781
1242
  other = ((WraptObjectProxyObject *)other)->wrapped;
782
1243
 
783
- object = PyNumber_InPlaceAnd(self->wrapped, other);
1244
+ if (PyObject_HasAttrString(self->wrapped, "__iand__"))
1245
+ {
1246
+ object = PyNumber_InPlaceAnd(self->wrapped, other);
784
1247
 
785
- if (!object)
786
- return NULL;
1248
+ if (!object)
1249
+ return NULL;
787
1250
 
788
- Py_DECREF(self->wrapped);
789
- self->wrapped = object;
1251
+ Py_DECREF(self->wrapped);
1252
+ self->wrapped = object;
790
1253
 
791
- Py_INCREF(self);
792
- return (PyObject *)self;
1254
+ Py_INCREF(self);
1255
+ return (PyObject *)self;
1256
+ }
1257
+ else
1258
+ {
1259
+ PyObject *result = PyNumber_And(self->wrapped, other);
1260
+
1261
+ if (!result)
1262
+ return NULL;
1263
+
1264
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
1265
+
1266
+ if (!proxy_type)
1267
+ {
1268
+ Py_DECREF(proxy_type);
1269
+ return NULL;
1270
+ }
1271
+
1272
+ PyObject *proxy_args = PyTuple_Pack(1, result);
1273
+
1274
+ Py_DECREF(result);
1275
+
1276
+ if (!proxy_args)
1277
+ {
1278
+ Py_DECREF(proxy_type);
1279
+ return NULL;
1280
+ }
1281
+
1282
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
1283
+
1284
+ Py_DECREF(proxy_type);
1285
+ Py_DECREF(proxy_args);
1286
+
1287
+ return proxy_instance;
1288
+ }
793
1289
  }
794
1290
 
795
1291
  /* ------------------------------------------------------------------------- */
796
1292
 
797
1293
  static PyObject *WraptObjectProxy_inplace_xor(WraptObjectProxyObject *self,
798
- PyObject *other) {
1294
+ PyObject *other)
1295
+ {
799
1296
  PyObject *object = NULL;
800
1297
 
801
- if (!self->wrapped) {
802
- raise_uninitialized_wrapper_error();
803
- return NULL;
1298
+ if (!self->wrapped)
1299
+ {
1300
+ if (raise_uninitialized_wrapper_error(self) == -1)
1301
+ return NULL;
804
1302
  }
805
1303
 
806
1304
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
807
1305
  other = ((WraptObjectProxyObject *)other)->wrapped;
808
1306
 
809
- object = PyNumber_InPlaceXor(self->wrapped, other);
1307
+ if (PyObject_HasAttrString(self->wrapped, "__ixor__"))
1308
+ {
1309
+ object = PyNumber_InPlaceXor(self->wrapped, other);
810
1310
 
811
- if (!object)
812
- return NULL;
1311
+ if (!object)
1312
+ return NULL;
813
1313
 
814
- Py_DECREF(self->wrapped);
815
- self->wrapped = object;
1314
+ Py_DECREF(self->wrapped);
1315
+ self->wrapped = object;
816
1316
 
817
- Py_INCREF(self);
818
- return (PyObject *)self;
1317
+ Py_INCREF(self);
1318
+ return (PyObject *)self;
1319
+ }
1320
+ else
1321
+ {
1322
+ PyObject *result = PyNumber_Xor(self->wrapped, other);
1323
+
1324
+ if (!result)
1325
+ return NULL;
1326
+
1327
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
1328
+
1329
+ if (!proxy_type)
1330
+ {
1331
+ Py_DECREF(proxy_type);
1332
+ return NULL;
1333
+ }
1334
+
1335
+ PyObject *proxy_args = PyTuple_Pack(1, result);
1336
+
1337
+ Py_DECREF(result);
1338
+
1339
+ if (!proxy_args)
1340
+ {
1341
+ Py_DECREF(proxy_type);
1342
+ return NULL;
1343
+ }
1344
+
1345
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
1346
+
1347
+ Py_DECREF(proxy_type);
1348
+ Py_DECREF(proxy_args);
1349
+
1350
+ return proxy_instance;
1351
+ }
819
1352
  }
820
1353
 
821
1354
  /* ------------------------------------------------------------------------- */
822
1355
 
823
1356
  static PyObject *WraptObjectProxy_inplace_or(WraptObjectProxyObject *self,
824
- PyObject *other) {
1357
+ PyObject *other)
1358
+ {
1359
+ PyObject *object = NULL;
1360
+
1361
+ if (!self->wrapped)
1362
+ {
1363
+ if (raise_uninitialized_wrapper_error(self) == -1)
1364
+ return NULL;
1365
+ }
1366
+
1367
+ if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
1368
+ other = ((WraptObjectProxyObject *)other)->wrapped;
1369
+
1370
+ if (PyObject_HasAttrString(self->wrapped, "__ior__"))
1371
+ {
1372
+ object = PyNumber_InPlaceOr(self->wrapped, other);
1373
+
1374
+ if (!object)
1375
+ return NULL;
1376
+
1377
+ Py_DECREF(self->wrapped);
1378
+ self->wrapped = object;
1379
+
1380
+ Py_INCREF(self);
1381
+ return (PyObject *)self;
1382
+ }
1383
+ else
1384
+ {
1385
+ PyObject *result = PyNumber_Or(self->wrapped, other);
1386
+
1387
+ if (!result)
1388
+ return NULL;
1389
+
1390
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
1391
+
1392
+ if (!proxy_type)
1393
+ {
1394
+ Py_DECREF(proxy_type);
1395
+ return NULL;
1396
+ }
1397
+
1398
+ PyObject *proxy_args = PyTuple_Pack(1, result);
1399
+
1400
+ Py_DECREF(result);
1401
+
1402
+ if (!proxy_args)
1403
+ {
1404
+ Py_DECREF(proxy_type);
1405
+ return NULL;
1406
+ }
1407
+
1408
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
1409
+
1410
+ Py_DECREF(proxy_type);
1411
+ Py_DECREF(proxy_args);
1412
+
1413
+ return proxy_instance;
1414
+ }
1415
+ }
1416
+
1417
+ /* ------------------------------------------------------------------------- */
1418
+
1419
+ static PyObject *WraptObjectProxy_floor_divide(PyObject *o1, PyObject *o2)
1420
+ {
1421
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
1422
+ {
1423
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
1424
+ {
1425
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
1426
+ return NULL;
1427
+ }
1428
+
1429
+ o1 = ((WraptObjectProxyObject *)o1)->wrapped;
1430
+ }
1431
+
1432
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
1433
+ {
1434
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
1435
+ {
1436
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
1437
+ return NULL;
1438
+ }
1439
+
1440
+ o2 = ((WraptObjectProxyObject *)o2)->wrapped;
1441
+ }
1442
+
1443
+ return PyNumber_FloorDivide(o1, o2);
1444
+ }
1445
+
1446
+ /* ------------------------------------------------------------------------- */
1447
+
1448
+ static PyObject *WraptObjectProxy_true_divide(PyObject *o1, PyObject *o2)
1449
+ {
1450
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
1451
+ {
1452
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
1453
+ {
1454
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
1455
+ return NULL;
1456
+ }
1457
+
1458
+ o1 = ((WraptObjectProxyObject *)o1)->wrapped;
1459
+ }
1460
+
1461
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
1462
+ {
1463
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
1464
+ {
1465
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
1466
+ return NULL;
1467
+ }
1468
+
1469
+ o2 = ((WraptObjectProxyObject *)o2)->wrapped;
1470
+ }
1471
+
1472
+ return PyNumber_TrueDivide(o1, o2);
1473
+ }
1474
+
1475
+ /* ------------------------------------------------------------------------- */
1476
+
1477
+ static PyObject *
1478
+ WraptObjectProxy_inplace_floor_divide(WraptObjectProxyObject *self,
1479
+ PyObject *other)
1480
+ {
1481
+ PyObject *object = NULL;
1482
+
1483
+ if (!self->wrapped)
1484
+ {
1485
+ if (raise_uninitialized_wrapper_error(self) == -1)
1486
+ return NULL;
1487
+ }
1488
+
1489
+ if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
1490
+ other = ((WraptObjectProxyObject *)other)->wrapped;
1491
+
1492
+ if (PyObject_HasAttrString(self->wrapped, "__ifloordiv__"))
1493
+ {
1494
+ object = PyNumber_InPlaceFloorDivide(self->wrapped, other);
1495
+
1496
+ if (!object)
1497
+ return NULL;
1498
+
1499
+ Py_DECREF(self->wrapped);
1500
+ self->wrapped = object;
1501
+
1502
+ Py_INCREF(self);
1503
+ return (PyObject *)self;
1504
+ }
1505
+ else
1506
+ {
1507
+ PyObject *result = PyNumber_FloorDivide(self->wrapped, other);
1508
+
1509
+ if (!result)
1510
+ return NULL;
1511
+
1512
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
1513
+
1514
+ if (!proxy_type)
1515
+ {
1516
+ Py_DECREF(proxy_type);
1517
+ return NULL;
1518
+ }
1519
+
1520
+ PyObject *proxy_args = PyTuple_Pack(1, result);
1521
+
1522
+ Py_DECREF(result);
1523
+
1524
+ if (!proxy_args)
1525
+ {
1526
+ Py_DECREF(proxy_type);
1527
+ return NULL;
1528
+ }
1529
+
1530
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
1531
+
1532
+ Py_DECREF(proxy_type);
1533
+ Py_DECREF(proxy_args);
1534
+
1535
+ return proxy_instance;
1536
+ }
1537
+ }
1538
+
1539
+ /* ------------------------------------------------------------------------- */
1540
+
1541
+ static PyObject *
1542
+ WraptObjectProxy_inplace_true_divide(WraptObjectProxyObject *self,
1543
+ PyObject *other)
1544
+ {
825
1545
  PyObject *object = NULL;
826
1546
 
827
- if (!self->wrapped) {
828
- raise_uninitialized_wrapper_error();
829
- return NULL;
1547
+ if (!self->wrapped)
1548
+ {
1549
+ if (raise_uninitialized_wrapper_error(self) == -1)
1550
+ return NULL;
830
1551
  }
831
1552
 
832
1553
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
833
1554
  other = ((WraptObjectProxyObject *)other)->wrapped;
834
1555
 
835
- object = PyNumber_InPlaceOr(self->wrapped, other);
1556
+ if (PyObject_HasAttrString(self->wrapped, "__itruediv__"))
1557
+ {
1558
+ object = PyNumber_InPlaceTrueDivide(self->wrapped, other);
836
1559
 
837
- if (!object)
838
- return NULL;
1560
+ if (!object)
1561
+ return NULL;
839
1562
 
840
- Py_DECREF(self->wrapped);
841
- self->wrapped = object;
1563
+ Py_DECREF(self->wrapped);
1564
+ self->wrapped = object;
842
1565
 
843
- Py_INCREF(self);
844
- return (PyObject *)self;
845
- }
1566
+ Py_INCREF(self);
1567
+ return (PyObject *)self;
1568
+ }
1569
+ else
1570
+ {
1571
+ PyObject *result = PyNumber_TrueDivide(self->wrapped, other);
846
1572
 
847
- /* ------------------------------------------------------------------------- */
1573
+ if (!result)
1574
+ return NULL;
848
1575
 
849
- static PyObject *WraptObjectProxy_floor_divide(PyObject *o1, PyObject *o2) {
850
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
851
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
852
- raise_uninitialized_wrapper_error();
1576
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
1577
+
1578
+ if (!proxy_type)
1579
+ {
1580
+ Py_DECREF(proxy_type);
853
1581
  return NULL;
854
1582
  }
855
1583
 
856
- o1 = ((WraptObjectProxyObject *)o1)->wrapped;
857
- }
1584
+ PyObject *proxy_args = PyTuple_Pack(1, result);
1585
+
1586
+ Py_DECREF(result);
858
1587
 
859
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
860
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
861
- raise_uninitialized_wrapper_error();
1588
+ if (!proxy_args)
1589
+ {
1590
+ Py_DECREF(proxy_type);
862
1591
  return NULL;
863
1592
  }
864
1593
 
865
- o2 = ((WraptObjectProxyObject *)o2)->wrapped;
866
- }
1594
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
867
1595
 
868
- return PyNumber_FloorDivide(o1, o2);
1596
+ Py_DECREF(proxy_type);
1597
+ Py_DECREF(proxy_args);
1598
+
1599
+ return proxy_instance;
1600
+ }
869
1601
  }
870
1602
 
871
1603
  /* ------------------------------------------------------------------------- */
872
1604
 
873
- static PyObject *WraptObjectProxy_true_divide(PyObject *o1, PyObject *o2) {
874
- if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type)) {
875
- if (!((WraptObjectProxyObject *)o1)->wrapped) {
876
- raise_uninitialized_wrapper_error();
1605
+ static PyObject *WraptObjectProxy_index(WraptObjectProxyObject *self)
1606
+ {
1607
+ if (!self->wrapped)
1608
+ {
1609
+ if (raise_uninitialized_wrapper_error(self) == -1)
877
1610
  return NULL;
1611
+ }
1612
+
1613
+ return PyNumber_Index(self->wrapped);
1614
+ }
1615
+
1616
+ /* ------------------------------------------------------------------------- */
1617
+
1618
+ static PyObject *WraptObjectProxy_matrix_multiply(PyObject *o1, PyObject *o2)
1619
+ {
1620
+ if (PyObject_IsInstance(o1, (PyObject *)&WraptObjectProxy_Type))
1621
+ {
1622
+ if (!((WraptObjectProxyObject *)o1)->wrapped)
1623
+ {
1624
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
1625
+ return NULL;
878
1626
  }
879
1627
 
880
1628
  o1 = ((WraptObjectProxyObject *)o1)->wrapped;
881
1629
  }
882
1630
 
883
- if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type)) {
884
- if (!((WraptObjectProxyObject *)o2)->wrapped) {
885
- raise_uninitialized_wrapper_error();
886
- return NULL;
1631
+ if (PyObject_IsInstance(o2, (PyObject *)&WraptObjectProxy_Type))
1632
+ {
1633
+ if (!((WraptObjectProxyObject *)o2)->wrapped)
1634
+ {
1635
+ if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
1636
+ return NULL;
887
1637
  }
888
1638
 
889
1639
  o2 = ((WraptObjectProxyObject *)o2)->wrapped;
890
1640
  }
891
1641
 
892
- return PyNumber_TrueDivide(o1, o2);
1642
+ return PyNumber_MatrixMultiply(o1, o2);
893
1643
  }
894
1644
 
895
1645
  /* ------------------------------------------------------------------------- */
896
1646
 
897
- static PyObject *
898
- WraptObjectProxy_inplace_floor_divide(WraptObjectProxyObject *self,
899
- PyObject *other) {
1647
+ static PyObject *WraptObjectProxy_inplace_matrix_multiply(
1648
+ WraptObjectProxyObject *self, PyObject *other)
1649
+ {
900
1650
  PyObject *object = NULL;
901
1651
 
902
- if (!self->wrapped) {
903
- raise_uninitialized_wrapper_error();
904
- return NULL;
1652
+ if (!self->wrapped)
1653
+ {
1654
+ if (raise_uninitialized_wrapper_error(self) == -1)
1655
+ return NULL;
905
1656
  }
906
1657
 
907
1658
  if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
908
1659
  other = ((WraptObjectProxyObject *)other)->wrapped;
909
1660
 
910
- object = PyNumber_InPlaceFloorDivide(self->wrapped, other);
911
-
912
- if (!object)
913
- return NULL;
1661
+ if (PyObject_HasAttrString(self->wrapped, "__imatmul__"))
1662
+ {
1663
+ object = PyNumber_InPlaceMatrixMultiply(self->wrapped, other);
914
1664
 
915
- Py_DECREF(self->wrapped);
916
- self->wrapped = object;
1665
+ if (!object)
1666
+ return NULL;
917
1667
 
918
- Py_INCREF(self);
919
- return (PyObject *)self;
920
- }
1668
+ Py_DECREF(self->wrapped);
1669
+ self->wrapped = object;
921
1670
 
922
- /* ------------------------------------------------------------------------- */
1671
+ Py_INCREF(self);
1672
+ return (PyObject *)self;
1673
+ }
1674
+ else
1675
+ {
1676
+ PyObject *result = PyNumber_MatrixMultiply(self->wrapped, other);
923
1677
 
924
- static PyObject *
925
- WraptObjectProxy_inplace_true_divide(WraptObjectProxyObject *self,
926
- PyObject *other) {
927
- PyObject *object = NULL;
1678
+ if (!result)
1679
+ return NULL;
928
1680
 
929
- if (!self->wrapped) {
930
- raise_uninitialized_wrapper_error();
931
- return NULL;
932
- }
1681
+ PyObject *proxy_type = PyObject_GetAttrString((PyObject *)self, "__object_proxy__");
933
1682
 
934
- if (PyObject_IsInstance(other, (PyObject *)&WraptObjectProxy_Type))
935
- other = ((WraptObjectProxyObject *)other)->wrapped;
1683
+ if (!proxy_type)
1684
+ {
1685
+ Py_DECREF(proxy_type);
1686
+ return NULL;
1687
+ }
936
1688
 
937
- object = PyNumber_InPlaceTrueDivide(self->wrapped, other);
1689
+ PyObject *proxy_args = PyTuple_Pack(1, result);
938
1690
 
939
- if (!object)
940
- return NULL;
1691
+ Py_DECREF(result);
941
1692
 
942
- Py_DECREF(self->wrapped);
943
- self->wrapped = object;
1693
+ if (!proxy_args)
1694
+ {
1695
+ Py_DECREF(proxy_type);
1696
+ return NULL;
1697
+ }
944
1698
 
945
- Py_INCREF(self);
946
- return (PyObject *)self;
947
- }
1699
+ PyObject *proxy_instance = PyObject_Call(proxy_type, proxy_args, NULL);
948
1700
 
949
- /* ------------------------------------------------------------------------- */
1701
+ Py_DECREF(proxy_type);
1702
+ Py_DECREF(proxy_args);
950
1703
 
951
- static PyObject *WraptObjectProxy_index(WraptObjectProxyObject *self) {
952
- if (!self->wrapped) {
953
- raise_uninitialized_wrapper_error();
954
- return NULL;
1704
+ return proxy_instance;
955
1705
  }
956
-
957
- return PyNumber_Index(self->wrapped);
958
1706
  }
959
1707
 
960
1708
  /* ------------------------------------------------------------------------- */
961
1709
 
962
- static Py_ssize_t WraptObjectProxy_length(WraptObjectProxyObject *self) {
963
- if (!self->wrapped) {
964
- raise_uninitialized_wrapper_error();
965
- return -1;
1710
+ static Py_ssize_t WraptObjectProxy_length(WraptObjectProxyObject *self)
1711
+ {
1712
+ if (!self->wrapped)
1713
+ {
1714
+ if (raise_uninitialized_wrapper_error(self) == -1)
1715
+ return -1;
966
1716
  }
967
1717
 
968
1718
  return PyObject_Length(self->wrapped);
@@ -971,10 +1721,12 @@ static Py_ssize_t WraptObjectProxy_length(WraptObjectProxyObject *self) {
971
1721
  /* ------------------------------------------------------------------------- */
972
1722
 
973
1723
  static int WraptObjectProxy_contains(WraptObjectProxyObject *self,
974
- PyObject *value) {
975
- if (!self->wrapped) {
976
- raise_uninitialized_wrapper_error();
977
- return -1;
1724
+ PyObject *value)
1725
+ {
1726
+ if (!self->wrapped)
1727
+ {
1728
+ if (raise_uninitialized_wrapper_error(self) == -1)
1729
+ return -1;
978
1730
  }
979
1731
 
980
1732
  return PySequence_Contains(self->wrapped, value);
@@ -983,10 +1735,12 @@ static int WraptObjectProxy_contains(WraptObjectProxyObject *self,
983
1735
  /* ------------------------------------------------------------------------- */
984
1736
 
985
1737
  static PyObject *WraptObjectProxy_getitem(WraptObjectProxyObject *self,
986
- PyObject *key) {
987
- if (!self->wrapped) {
988
- raise_uninitialized_wrapper_error();
989
- return NULL;
1738
+ PyObject *key)
1739
+ {
1740
+ if (!self->wrapped)
1741
+ {
1742
+ if (raise_uninitialized_wrapper_error(self) == -1)
1743
+ return NULL;
990
1744
  }
991
1745
 
992
1746
  return PyObject_GetItem(self->wrapped, key);
@@ -995,10 +1749,12 @@ static PyObject *WraptObjectProxy_getitem(WraptObjectProxyObject *self,
995
1749
  /* ------------------------------------------------------------------------- */
996
1750
 
997
1751
  static int WraptObjectProxy_setitem(WraptObjectProxyObject *self, PyObject *key,
998
- PyObject *value) {
999
- if (!self->wrapped) {
1000
- raise_uninitialized_wrapper_error();
1001
- return -1;
1752
+ PyObject *value)
1753
+ {
1754
+ if (!self->wrapped)
1755
+ {
1756
+ if (raise_uninitialized_wrapper_error(self) == -1)
1757
+ return -1;
1002
1758
  }
1003
1759
 
1004
1760
  if (value == NULL)
@@ -1010,14 +1766,16 @@ static int WraptObjectProxy_setitem(WraptObjectProxyObject *self, PyObject *key,
1010
1766
  /* ------------------------------------------------------------------------- */
1011
1767
 
1012
1768
  static PyObject *WraptObjectProxy_self_setattr(WraptObjectProxyObject *self,
1013
- PyObject *args) {
1769
+ PyObject *args)
1770
+ {
1014
1771
  PyObject *name = NULL;
1015
1772
  PyObject *value = NULL;
1016
1773
 
1017
1774
  if (!PyArg_ParseTuple(args, "UO:__self_setattr__", &name, &value))
1018
1775
  return NULL;
1019
1776
 
1020
- if (PyObject_GenericSetAttr((PyObject *)self, name, value) != 0) {
1777
+ if (PyObject_GenericSetAttr((PyObject *)self, name, value) != 0)
1778
+ {
1021
1779
  return NULL;
1022
1780
  }
1023
1781
 
@@ -1028,10 +1786,12 @@ static PyObject *WraptObjectProxy_self_setattr(WraptObjectProxyObject *self,
1028
1786
  /* ------------------------------------------------------------------------- */
1029
1787
 
1030
1788
  static PyObject *WraptObjectProxy_dir(WraptObjectProxyObject *self,
1031
- PyObject *args) {
1032
- if (!self->wrapped) {
1033
- raise_uninitialized_wrapper_error();
1034
- return NULL;
1789
+ PyObject *args)
1790
+ {
1791
+ if (!self->wrapped)
1792
+ {
1793
+ if (raise_uninitialized_wrapper_error(self) == -1)
1794
+ return NULL;
1035
1795
  }
1036
1796
 
1037
1797
  return PyObject_Dir(self->wrapped);
@@ -1040,13 +1800,15 @@ static PyObject *WraptObjectProxy_dir(WraptObjectProxyObject *self,
1040
1800
  /* ------------------------------------------------------------------------- */
1041
1801
 
1042
1802
  static PyObject *WraptObjectProxy_enter(WraptObjectProxyObject *self,
1043
- PyObject *args, PyObject *kwds) {
1803
+ PyObject *args, PyObject *kwds)
1804
+ {
1044
1805
  PyObject *method = NULL;
1045
1806
  PyObject *result = NULL;
1046
1807
 
1047
- if (!self->wrapped) {
1048
- raise_uninitialized_wrapper_error();
1049
- return NULL;
1808
+ if (!self->wrapped)
1809
+ {
1810
+ if (raise_uninitialized_wrapper_error(self) == -1)
1811
+ return NULL;
1050
1812
  }
1051
1813
 
1052
1814
  method = PyObject_GetAttrString(self->wrapped, "__enter__");
@@ -1064,13 +1826,15 @@ static PyObject *WraptObjectProxy_enter(WraptObjectProxyObject *self,
1064
1826
  /* ------------------------------------------------------------------------- */
1065
1827
 
1066
1828
  static PyObject *WraptObjectProxy_exit(WraptObjectProxyObject *self,
1067
- PyObject *args, PyObject *kwds) {
1829
+ PyObject *args, PyObject *kwds)
1830
+ {
1068
1831
  PyObject *method = NULL;
1069
1832
  PyObject *result = NULL;
1070
1833
 
1071
- if (!self->wrapped) {
1072
- raise_uninitialized_wrapper_error();
1073
- return NULL;
1834
+ if (!self->wrapped)
1835
+ {
1836
+ if (raise_uninitialized_wrapper_error(self) == -1)
1837
+ return NULL;
1074
1838
  }
1075
1839
 
1076
1840
  method = PyObject_GetAttrString(self->wrapped, "__exit__");
@@ -1087,8 +1851,61 @@ static PyObject *WraptObjectProxy_exit(WraptObjectProxyObject *self,
1087
1851
 
1088
1852
  /* ------------------------------------------------------------------------- */
1089
1853
 
1854
+ static PyObject *WraptObjectProxy_aenter(WraptObjectProxyObject *self,
1855
+ PyObject *args, PyObject *kwds)
1856
+ {
1857
+ PyObject *method = NULL;
1858
+ PyObject *result = NULL;
1859
+
1860
+ if (!self->wrapped)
1861
+ {
1862
+ if (raise_uninitialized_wrapper_error(self) == -1)
1863
+ return NULL;
1864
+ }
1865
+
1866
+ method = PyObject_GetAttrString(self->wrapped, "__aenter__");
1867
+
1868
+ if (!method)
1869
+ return NULL;
1870
+
1871
+ result = PyObject_Call(method, args, kwds);
1872
+
1873
+ Py_DECREF(method);
1874
+
1875
+ return result;
1876
+ }
1877
+
1878
+ /* ------------------------------------------------------------------------- */
1879
+
1880
+ static PyObject *WraptObjectProxy_aexit(WraptObjectProxyObject *self,
1881
+ PyObject *args, PyObject *kwds)
1882
+ {
1883
+ PyObject *method = NULL;
1884
+ PyObject *result = NULL;
1885
+
1886
+ if (!self->wrapped)
1887
+ {
1888
+ if (raise_uninitialized_wrapper_error(self) == -1)
1889
+ return NULL;
1890
+ }
1891
+
1892
+ method = PyObject_GetAttrString(self->wrapped, "__aexit__");
1893
+
1894
+ if (!method)
1895
+ return NULL;
1896
+
1897
+ result = PyObject_Call(method, args, kwds);
1898
+
1899
+ Py_DECREF(method);
1900
+
1901
+ return result;
1902
+ }
1903
+
1904
+ /* ------------------------------------------------------------------------- */
1905
+
1090
1906
  static PyObject *WraptObjectProxy_copy(WraptObjectProxyObject *self,
1091
- PyObject *args, PyObject *kwds) {
1907
+ PyObject *args, PyObject *kwds)
1908
+ {
1092
1909
  PyErr_SetString(PyExc_NotImplementedError,
1093
1910
  "object proxy must define __copy__()");
1094
1911
 
@@ -1098,7 +1915,8 @@ static PyObject *WraptObjectProxy_copy(WraptObjectProxyObject *self,
1098
1915
  /* ------------------------------------------------------------------------- */
1099
1916
 
1100
1917
  static PyObject *WraptObjectProxy_deepcopy(WraptObjectProxyObject *self,
1101
- PyObject *args, PyObject *kwds) {
1918
+ PyObject *args, PyObject *kwds)
1919
+ {
1102
1920
  PyErr_SetString(PyExc_NotImplementedError,
1103
1921
  "object proxy must define __deepcopy__()");
1104
1922
 
@@ -1108,7 +1926,8 @@ static PyObject *WraptObjectProxy_deepcopy(WraptObjectProxyObject *self,
1108
1926
  /* ------------------------------------------------------------------------- */
1109
1927
 
1110
1928
  static PyObject *WraptObjectProxy_reduce(WraptObjectProxyObject *self,
1111
- PyObject *args, PyObject *kwds) {
1929
+ PyObject *args, PyObject *kwds)
1930
+ {
1112
1931
  PyErr_SetString(PyExc_NotImplementedError,
1113
1932
  "object proxy must define __reduce__()");
1114
1933
 
@@ -1118,7 +1937,8 @@ static PyObject *WraptObjectProxy_reduce(WraptObjectProxyObject *self,
1118
1937
  /* ------------------------------------------------------------------------- */
1119
1938
 
1120
1939
  static PyObject *WraptObjectProxy_reduce_ex(WraptObjectProxyObject *self,
1121
- PyObject *args, PyObject *kwds) {
1940
+ PyObject *args, PyObject *kwds)
1941
+ {
1122
1942
  PyErr_SetString(PyExc_NotImplementedError,
1123
1943
  "object proxy must define __reduce_ex__()");
1124
1944
 
@@ -1128,10 +1948,12 @@ static PyObject *WraptObjectProxy_reduce_ex(WraptObjectProxyObject *self,
1128
1948
  /* ------------------------------------------------------------------------- */
1129
1949
 
1130
1950
  static PyObject *WraptObjectProxy_bytes(WraptObjectProxyObject *self,
1131
- PyObject *args) {
1132
- if (!self->wrapped) {
1133
- raise_uninitialized_wrapper_error();
1134
- return NULL;
1951
+ PyObject *args)
1952
+ {
1953
+ if (!self->wrapped)
1954
+ {
1955
+ if (raise_uninitialized_wrapper_error(self) == -1)
1956
+ return NULL;
1135
1957
  }
1136
1958
 
1137
1959
  return PyObject_Bytes(self->wrapped);
@@ -1140,12 +1962,14 @@ static PyObject *WraptObjectProxy_bytes(WraptObjectProxyObject *self,
1140
1962
  /* ------------------------------------------------------------------------- */
1141
1963
 
1142
1964
  static PyObject *WraptObjectProxy_format(WraptObjectProxyObject *self,
1143
- PyObject *args) {
1965
+ PyObject *args)
1966
+ {
1144
1967
  PyObject *format_spec = NULL;
1145
1968
 
1146
- if (!self->wrapped) {
1147
- raise_uninitialized_wrapper_error();
1148
- return NULL;
1969
+ if (!self->wrapped)
1970
+ {
1971
+ if (raise_uninitialized_wrapper_error(self) == -1)
1972
+ return NULL;
1149
1973
  }
1150
1974
 
1151
1975
  if (!PyArg_ParseTuple(args, "|O:format", &format_spec))
@@ -1157,10 +1981,12 @@ static PyObject *WraptObjectProxy_format(WraptObjectProxyObject *self,
1157
1981
  /* ------------------------------------------------------------------------- */
1158
1982
 
1159
1983
  static PyObject *WraptObjectProxy_reversed(WraptObjectProxyObject *self,
1160
- PyObject *args) {
1161
- if (!self->wrapped) {
1162
- raise_uninitialized_wrapper_error();
1163
- return NULL;
1984
+ PyObject *args)
1985
+ {
1986
+ if (!self->wrapped)
1987
+ {
1988
+ if (raise_uninitialized_wrapper_error(self) == -1)
1989
+ return NULL;
1164
1990
  }
1165
1991
 
1166
1992
  return PyObject_CallFunctionObjArgs((PyObject *)&PyReversed_Type,
@@ -1170,24 +1996,26 @@ static PyObject *WraptObjectProxy_reversed(WraptObjectProxyObject *self,
1170
1996
  /* ------------------------------------------------------------------------- */
1171
1997
 
1172
1998
  static PyObject *WraptObjectProxy_round(WraptObjectProxyObject *self,
1173
- PyObject *args, PyObject *kwds) {
1999
+ PyObject *args, PyObject *kwds)
2000
+ {
1174
2001
  PyObject *ndigits = NULL;
1175
2002
 
1176
2003
  PyObject *module = NULL;
1177
- PyObject *dict = NULL;
1178
2004
  PyObject *round = NULL;
1179
2005
 
1180
2006
  PyObject *result = NULL;
1181
2007
 
1182
2008
  char *const kwlist[] = {"ndigits", NULL};
1183
2009
 
1184
- if (!self->wrapped) {
1185
- raise_uninitialized_wrapper_error();
1186
- return NULL;
2010
+ if (!self->wrapped)
2011
+ {
2012
+ if (raise_uninitialized_wrapper_error(self) == -1)
2013
+ return NULL;
1187
2014
  }
1188
2015
 
1189
2016
  if (!PyArg_ParseTupleAndKeywords(args, kwds, "|O:ObjectProxy", kwlist,
1190
- &ndigits)) {
2017
+ &ndigits))
2018
+ {
1191
2019
  return NULL;
1192
2020
  }
1193
2021
 
@@ -1198,7 +2026,8 @@ static PyObject *WraptObjectProxy_round(WraptObjectProxyObject *self,
1198
2026
 
1199
2027
  round = PyObject_GetAttrString(module, "round");
1200
2028
 
1201
- if (!round) {
2029
+ if (!round)
2030
+ {
1202
2031
  Py_DECREF(module);
1203
2032
  return NULL;
1204
2033
  }
@@ -1216,10 +2045,12 @@ static PyObject *WraptObjectProxy_round(WraptObjectProxyObject *self,
1216
2045
  /* ------------------------------------------------------------------------- */
1217
2046
 
1218
2047
  static PyObject *WraptObjectProxy_complex(WraptObjectProxyObject *self,
1219
- PyObject *args) {
1220
- if (!self->wrapped) {
1221
- raise_uninitialized_wrapper_error();
1222
- return NULL;
2048
+ PyObject *args)
2049
+ {
2050
+ if (!self->wrapped)
2051
+ {
2052
+ if (raise_uninitialized_wrapper_error(self) == -1)
2053
+ return NULL;
1223
2054
  }
1224
2055
 
1225
2056
  return PyObject_CallFunctionObjArgs((PyObject *)&PyComplex_Type,
@@ -1229,21 +2060,58 @@ static PyObject *WraptObjectProxy_complex(WraptObjectProxyObject *self,
1229
2060
  /* ------------------------------------------------------------------------- */
1230
2061
 
1231
2062
  static PyObject *WraptObjectProxy_mro_entries(WraptObjectProxyObject *self,
1232
- PyObject *args, PyObject *kwds) {
1233
- if (!self->wrapped) {
1234
- raise_uninitialized_wrapper_error();
1235
- return NULL;
2063
+ PyObject *args, PyObject *kwds)
2064
+ {
2065
+ PyObject *wrapped = NULL;
2066
+ PyObject *mro_entries_method = NULL;
2067
+ PyObject *result = NULL;
2068
+ int is_type = 0;
2069
+
2070
+ if (!self->wrapped)
2071
+ {
2072
+ if (raise_uninitialized_wrapper_error(self) == -1)
2073
+ return NULL;
2074
+ }
2075
+
2076
+ wrapped = self->wrapped;
2077
+
2078
+ // Check if wrapped is a type (class).
2079
+
2080
+ is_type = PyType_Check(wrapped);
2081
+
2082
+ // If wrapped is not a type and has __mro_entries__, forward to it.
2083
+
2084
+ if (!is_type)
2085
+ {
2086
+ mro_entries_method = PyObject_GetAttrString(wrapped, "__mro_entries__");
2087
+
2088
+ if (mro_entries_method)
2089
+ {
2090
+ // Call wrapped.__mro_entries__(bases).
2091
+
2092
+ result = PyObject_Call(mro_entries_method, args, kwds);
2093
+
2094
+ Py_DECREF(mro_entries_method);
2095
+
2096
+ return result;
2097
+ }
2098
+ else
2099
+ {
2100
+ PyErr_Clear();
2101
+ }
1236
2102
  }
1237
2103
 
1238
- return Py_BuildValue("(O)", self->wrapped);
2104
+ return Py_BuildValue("(O)", wrapped);
1239
2105
  }
1240
2106
 
1241
2107
  /* ------------------------------------------------------------------------- */
1242
2108
 
1243
- static PyObject *WraptObjectProxy_get_name(WraptObjectProxyObject *self) {
1244
- if (!self->wrapped) {
1245
- raise_uninitialized_wrapper_error();
1246
- return NULL;
2109
+ static PyObject *WraptObjectProxy_get_name(WraptObjectProxyObject *self)
2110
+ {
2111
+ if (!self->wrapped)
2112
+ {
2113
+ if (raise_uninitialized_wrapper_error(self) == -1)
2114
+ return NULL;
1247
2115
  }
1248
2116
 
1249
2117
  return PyObject_GetAttrString(self->wrapped, "__name__");
@@ -1252,10 +2120,12 @@ static PyObject *WraptObjectProxy_get_name(WraptObjectProxyObject *self) {
1252
2120
  /* ------------------------------------------------------------------------- */
1253
2121
 
1254
2122
  static int WraptObjectProxy_set_name(WraptObjectProxyObject *self,
1255
- PyObject *value) {
1256
- if (!self->wrapped) {
1257
- raise_uninitialized_wrapper_error();
1258
- return -1;
2123
+ PyObject *value)
2124
+ {
2125
+ if (!self->wrapped)
2126
+ {
2127
+ if (raise_uninitialized_wrapper_error(self) == -1)
2128
+ return -1;
1259
2129
  }
1260
2130
 
1261
2131
  return PyObject_SetAttrString(self->wrapped, "__name__", value);
@@ -1263,10 +2133,12 @@ static int WraptObjectProxy_set_name(WraptObjectProxyObject *self,
1263
2133
 
1264
2134
  /* ------------------------------------------------------------------------- */
1265
2135
 
1266
- static PyObject *WraptObjectProxy_get_qualname(WraptObjectProxyObject *self) {
1267
- if (!self->wrapped) {
1268
- raise_uninitialized_wrapper_error();
1269
- return NULL;
2136
+ static PyObject *WraptObjectProxy_get_qualname(WraptObjectProxyObject *self)
2137
+ {
2138
+ if (!self->wrapped)
2139
+ {
2140
+ if (raise_uninitialized_wrapper_error(self) == -1)
2141
+ return NULL;
1270
2142
  }
1271
2143
 
1272
2144
  return PyObject_GetAttrString(self->wrapped, "__qualname__");
@@ -1275,10 +2147,12 @@ static PyObject *WraptObjectProxy_get_qualname(WraptObjectProxyObject *self) {
1275
2147
  /* ------------------------------------------------------------------------- */
1276
2148
 
1277
2149
  static int WraptObjectProxy_set_qualname(WraptObjectProxyObject *self,
1278
- PyObject *value) {
1279
- if (!self->wrapped) {
1280
- raise_uninitialized_wrapper_error();
1281
- return -1;
2150
+ PyObject *value)
2151
+ {
2152
+ if (!self->wrapped)
2153
+ {
2154
+ if (raise_uninitialized_wrapper_error(self) == -1)
2155
+ return -1;
1282
2156
  }
1283
2157
 
1284
2158
  return PyObject_SetAttrString(self->wrapped, "__qualname__", value);
@@ -1286,10 +2160,12 @@ static int WraptObjectProxy_set_qualname(WraptObjectProxyObject *self,
1286
2160
 
1287
2161
  /* ------------------------------------------------------------------------- */
1288
2162
 
1289
- static PyObject *WraptObjectProxy_get_module(WraptObjectProxyObject *self) {
1290
- if (!self->wrapped) {
1291
- raise_uninitialized_wrapper_error();
1292
- return NULL;
2163
+ static PyObject *WraptObjectProxy_get_module(WraptObjectProxyObject *self)
2164
+ {
2165
+ if (!self->wrapped)
2166
+ {
2167
+ if (raise_uninitialized_wrapper_error(self) == -1)
2168
+ return NULL;
1293
2169
  }
1294
2170
 
1295
2171
  return PyObject_GetAttrString(self->wrapped, "__module__");
@@ -1298,10 +2174,12 @@ static PyObject *WraptObjectProxy_get_module(WraptObjectProxyObject *self) {
1298
2174
  /* ------------------------------------------------------------------------- */
1299
2175
 
1300
2176
  static int WraptObjectProxy_set_module(WraptObjectProxyObject *self,
1301
- PyObject *value) {
1302
- if (!self->wrapped) {
1303
- raise_uninitialized_wrapper_error();
1304
- return -1;
2177
+ PyObject *value)
2178
+ {
2179
+ if (!self->wrapped)
2180
+ {
2181
+ if (raise_uninitialized_wrapper_error(self) == -1)
2182
+ return -1;
1305
2183
  }
1306
2184
 
1307
2185
  if (PyObject_SetAttrString(self->wrapped, "__module__", value) == -1)
@@ -1312,10 +2190,12 @@ static int WraptObjectProxy_set_module(WraptObjectProxyObject *self,
1312
2190
 
1313
2191
  /* ------------------------------------------------------------------------- */
1314
2192
 
1315
- static PyObject *WraptObjectProxy_get_doc(WraptObjectProxyObject *self) {
1316
- if (!self->wrapped) {
1317
- raise_uninitialized_wrapper_error();
1318
- return NULL;
2193
+ static PyObject *WraptObjectProxy_get_doc(WraptObjectProxyObject *self)
2194
+ {
2195
+ if (!self->wrapped)
2196
+ {
2197
+ if (raise_uninitialized_wrapper_error(self) == -1)
2198
+ return NULL;
1319
2199
  }
1320
2200
 
1321
2201
  return PyObject_GetAttrString(self->wrapped, "__doc__");
@@ -1324,10 +2204,12 @@ static PyObject *WraptObjectProxy_get_doc(WraptObjectProxyObject *self) {
1324
2204
  /* ------------------------------------------------------------------------- */
1325
2205
 
1326
2206
  static int WraptObjectProxy_set_doc(WraptObjectProxyObject *self,
1327
- PyObject *value) {
1328
- if (!self->wrapped) {
1329
- raise_uninitialized_wrapper_error();
1330
- return -1;
2207
+ PyObject *value)
2208
+ {
2209
+ if (!self->wrapped)
2210
+ {
2211
+ if (raise_uninitialized_wrapper_error(self) == -1)
2212
+ return -1;
1331
2213
  }
1332
2214
 
1333
2215
  if (PyObject_SetAttrString(self->wrapped, "__doc__", value) == -1)
@@ -1338,10 +2220,12 @@ static int WraptObjectProxy_set_doc(WraptObjectProxyObject *self,
1338
2220
 
1339
2221
  /* ------------------------------------------------------------------------- */
1340
2222
 
1341
- static PyObject *WraptObjectProxy_get_class(WraptObjectProxyObject *self) {
1342
- if (!self->wrapped) {
1343
- raise_uninitialized_wrapper_error();
1344
- return NULL;
2223
+ static PyObject *WraptObjectProxy_get_class(WraptObjectProxyObject *self)
2224
+ {
2225
+ if (!self->wrapped)
2226
+ {
2227
+ if (raise_uninitialized_wrapper_error(self) == -1)
2228
+ return NULL;
1345
2229
  }
1346
2230
 
1347
2231
  return PyObject_GetAttrString(self->wrapped, "__class__");
@@ -1350,10 +2234,12 @@ static PyObject *WraptObjectProxy_get_class(WraptObjectProxyObject *self) {
1350
2234
  /* ------------------------------------------------------------------------- */
1351
2235
 
1352
2236
  static int WraptObjectProxy_set_class(WraptObjectProxyObject *self,
1353
- PyObject *value) {
1354
- if (!self->wrapped) {
1355
- raise_uninitialized_wrapper_error();
1356
- return -1;
2237
+ PyObject *value)
2238
+ {
2239
+ if (!self->wrapped)
2240
+ {
2241
+ if (raise_uninitialized_wrapper_error(self) == -1)
2242
+ return -1;
1357
2243
  }
1358
2244
 
1359
2245
  return PyObject_SetAttrString(self->wrapped, "__class__", value);
@@ -1362,10 +2248,12 @@ static int WraptObjectProxy_set_class(WraptObjectProxyObject *self,
1362
2248
  /* ------------------------------------------------------------------------- */
1363
2249
 
1364
2250
  static PyObject *
1365
- WraptObjectProxy_get_annotations(WraptObjectProxyObject *self) {
1366
- if (!self->wrapped) {
1367
- raise_uninitialized_wrapper_error();
1368
- return NULL;
2251
+ WraptObjectProxy_get_annotations(WraptObjectProxyObject *self)
2252
+ {
2253
+ if (!self->wrapped)
2254
+ {
2255
+ if (raise_uninitialized_wrapper_error(self) == -1)
2256
+ return NULL;
1369
2257
  }
1370
2258
 
1371
2259
  return PyObject_GetAttrString(self->wrapped, "__annotations__");
@@ -1374,10 +2262,12 @@ WraptObjectProxy_get_annotations(WraptObjectProxyObject *self) {
1374
2262
  /* ------------------------------------------------------------------------- */
1375
2263
 
1376
2264
  static int WraptObjectProxy_set_annotations(WraptObjectProxyObject *self,
1377
- PyObject *value) {
1378
- if (!self->wrapped) {
1379
- raise_uninitialized_wrapper_error();
1380
- return -1;
2265
+ PyObject *value)
2266
+ {
2267
+ if (!self->wrapped)
2268
+ {
2269
+ if (raise_uninitialized_wrapper_error(self) == -1)
2270
+ return -1;
1381
2271
  }
1382
2272
 
1383
2273
  return PyObject_SetAttrString(self->wrapped, "__annotations__", value);
@@ -1385,10 +2275,12 @@ static int WraptObjectProxy_set_annotations(WraptObjectProxyObject *self,
1385
2275
 
1386
2276
  /* ------------------------------------------------------------------------- */
1387
2277
 
1388
- static PyObject *WraptObjectProxy_get_wrapped(WraptObjectProxyObject *self) {
1389
- if (!self->wrapped) {
1390
- raise_uninitialized_wrapper_error();
1391
- return NULL;
2278
+ static PyObject *WraptObjectProxy_get_wrapped(WraptObjectProxyObject *self)
2279
+ {
2280
+ if (!self->wrapped)
2281
+ {
2282
+ if (raise_uninitialized_wrapper_error(self) == -1)
2283
+ return NULL;
1392
2284
  }
1393
2285
 
1394
2286
  Py_INCREF(self->wrapped);
@@ -1397,9 +2289,23 @@ static PyObject *WraptObjectProxy_get_wrapped(WraptObjectProxyObject *self) {
1397
2289
 
1398
2290
  /* ------------------------------------------------------------------------- */
1399
2291
 
2292
+ static PyObject *WraptObjectProxy_get_object_proxy(WraptObjectProxyObject *self)
2293
+ {
2294
+ Py_INCREF(&WraptObjectProxy_Type);
2295
+ return (PyObject *)&WraptObjectProxy_Type;
2296
+ }
2297
+
2298
+ /* ------------------------------------------------------------------------- */
2299
+
1400
2300
  static int WraptObjectProxy_set_wrapped(WraptObjectProxyObject *self,
1401
- PyObject *value) {
1402
- if (!value) {
2301
+ PyObject *value)
2302
+ {
2303
+ static PyObject *fixups_str = NULL;
2304
+
2305
+ PyObject *fixups = NULL;
2306
+
2307
+ if (!value)
2308
+ {
1403
2309
  PyErr_SetString(PyExc_TypeError, "__wrapped__ must be an object");
1404
2310
  return -1;
1405
2311
  }
@@ -1409,13 +2315,36 @@ static int WraptObjectProxy_set_wrapped(WraptObjectProxyObject *self,
1409
2315
 
1410
2316
  self->wrapped = value;
1411
2317
 
2318
+ if (!fixups_str)
2319
+ {
2320
+ fixups_str = PyUnicode_InternFromString("__wrapped_setattr_fixups__");
2321
+ }
2322
+
2323
+ fixups = PyObject_GetAttr((PyObject *)self, fixups_str);
2324
+
2325
+ if (fixups)
2326
+ {
2327
+ PyObject *result = NULL;
2328
+
2329
+ result = PyObject_CallObject(fixups, NULL);
2330
+ Py_DECREF(fixups);
2331
+
2332
+ if (!result)
2333
+ return -1;
2334
+
2335
+ Py_DECREF(result);
2336
+ }
2337
+ else
2338
+ PyErr_Clear();
2339
+
1412
2340
  return 0;
1413
2341
  }
1414
2342
 
1415
2343
  /* ------------------------------------------------------------------------- */
1416
2344
 
1417
2345
  static PyObject *WraptObjectProxy_getattro(WraptObjectProxyObject *self,
1418
- PyObject *name) {
2346
+ PyObject *name)
2347
+ {
1419
2348
  PyObject *object = NULL;
1420
2349
  PyObject *result = NULL;
1421
2350
 
@@ -1431,7 +2360,8 @@ static PyObject *WraptObjectProxy_getattro(WraptObjectProxyObject *self,
1431
2360
 
1432
2361
  PyErr_Clear();
1433
2362
 
1434
- if (!getattr_str) {
2363
+ if (!getattr_str)
2364
+ {
1435
2365
  getattr_str = PyUnicode_InternFromString("__getattr__");
1436
2366
  }
1437
2367
 
@@ -1450,15 +2380,17 @@ static PyObject *WraptObjectProxy_getattro(WraptObjectProxyObject *self,
1450
2380
  /* ------------------------------------------------------------------------- */
1451
2381
 
1452
2382
  static PyObject *WraptObjectProxy_getattr(WraptObjectProxyObject *self,
1453
- PyObject *args) {
2383
+ PyObject *args)
2384
+ {
1454
2385
  PyObject *name = NULL;
1455
2386
 
1456
2387
  if (!PyArg_ParseTuple(args, "U:__getattr__", &name))
1457
2388
  return NULL;
1458
2389
 
1459
- if (!self->wrapped) {
1460
- raise_uninitialized_wrapper_error();
1461
- return NULL;
2390
+ if (!self->wrapped)
2391
+ {
2392
+ if (raise_uninitialized_wrapper_error(self) == -1)
2393
+ return NULL;
1462
2394
  }
1463
2395
 
1464
2396
  return PyObject_GetAttr(self->wrapped, name);
@@ -1467,42 +2399,43 @@ static PyObject *WraptObjectProxy_getattr(WraptObjectProxyObject *self,
1467
2399
  /* ------------------------------------------------------------------------- */
1468
2400
 
1469
2401
  static int WraptObjectProxy_setattro(WraptObjectProxyObject *self,
1470
- PyObject *name, PyObject *value) {
2402
+ PyObject *name, PyObject *value)
2403
+ {
1471
2404
  static PyObject *self_str = NULL;
1472
- static PyObject *wrapped_str = NULL;
1473
2405
  static PyObject *startswith_str = NULL;
1474
2406
 
1475
2407
  PyObject *match = NULL;
1476
2408
 
1477
- if (!startswith_str) {
2409
+ if (!startswith_str)
2410
+ {
1478
2411
  startswith_str = PyUnicode_InternFromString("startswith");
1479
2412
  }
1480
2413
 
1481
- if (!self_str) {
2414
+ if (!self_str)
2415
+ {
1482
2416
  self_str = PyUnicode_InternFromString("_self_");
1483
2417
  }
1484
2418
 
1485
2419
  match = PyObject_CallMethodObjArgs(name, startswith_str, self_str, NULL);
1486
2420
 
1487
- if (match == Py_True) {
2421
+ if (match == Py_True)
2422
+ {
1488
2423
  Py_DECREF(match);
1489
2424
 
1490
2425
  return PyObject_GenericSetAttr((PyObject *)self, name, value);
1491
- } else if (!match)
2426
+ }
2427
+ else if (!match)
1492
2428
  PyErr_Clear();
1493
2429
 
1494
2430
  Py_XDECREF(match);
1495
2431
 
1496
- if (!wrapped_str) {
1497
- wrapped_str = PyUnicode_InternFromString("__wrapped__");
1498
- }
1499
-
1500
2432
  if (PyObject_HasAttr((PyObject *)Py_TYPE(self), name))
1501
2433
  return PyObject_GenericSetAttr((PyObject *)self, name, value);
1502
2434
 
1503
- if (!self->wrapped) {
1504
- raise_uninitialized_wrapper_error();
1505
- return -1;
2435
+ if (!self->wrapped)
2436
+ {
2437
+ if (raise_uninitialized_wrapper_error(self) == -1)
2438
+ return -1;
1506
2439
  }
1507
2440
 
1508
2441
  return PyObject_SetAttr(self->wrapped, name, value);
@@ -1511,10 +2444,12 @@ static int WraptObjectProxy_setattro(WraptObjectProxyObject *self,
1511
2444
  /* ------------------------------------------------------------------------- */
1512
2445
 
1513
2446
  static PyObject *WraptObjectProxy_richcompare(WraptObjectProxyObject *self,
1514
- PyObject *other, int opcode) {
1515
- if (!self->wrapped) {
1516
- raise_uninitialized_wrapper_error();
1517
- return NULL;
2447
+ PyObject *other, int opcode)
2448
+ {
2449
+ if (!self->wrapped)
2450
+ {
2451
+ if (raise_uninitialized_wrapper_error(self) == -1)
2452
+ return NULL;
1518
2453
  }
1519
2454
 
1520
2455
  return PyObject_RichCompare(self->wrapped, other, opcode);
@@ -1522,10 +2457,12 @@ static PyObject *WraptObjectProxy_richcompare(WraptObjectProxyObject *self,
1522
2457
 
1523
2458
  /* ------------------------------------------------------------------------- */
1524
2459
 
1525
- static PyObject *WraptObjectProxy_iter(WraptObjectProxyObject *self) {
1526
- if (!self->wrapped) {
1527
- raise_uninitialized_wrapper_error();
1528
- return NULL;
2460
+ static PyObject *WraptObjectProxy_iter(WraptObjectProxyObject *self)
2461
+ {
2462
+ if (!self->wrapped)
2463
+ {
2464
+ if (raise_uninitialized_wrapper_error(self) == -1)
2465
+ return NULL;
1529
2466
  }
1530
2467
 
1531
2468
  return PyObject_GetIter(self->wrapped);
@@ -1566,9 +2503,11 @@ static PyNumberMethods WraptObjectProxy_as_number = {
1566
2503
  (binaryfunc)WraptObjectProxy_floor_divide, /*nb_floor_divide*/
1567
2504
  (binaryfunc)WraptObjectProxy_true_divide, /*nb_true_divide*/
1568
2505
  (binaryfunc)
1569
- WraptObjectProxy_inplace_floor_divide, /*nb_inplace_floor_divide*/
1570
- (binaryfunc)WraptObjectProxy_inplace_true_divide, /*nb_inplace_true_divide*/
1571
- (unaryfunc)WraptObjectProxy_index, /*nb_index*/
2506
+ WraptObjectProxy_inplace_floor_divide, /*nb_inplace_floor_divide*/
2507
+ (binaryfunc)WraptObjectProxy_inplace_true_divide, /*nb_inplace_true_divide*/
2508
+ (unaryfunc)WraptObjectProxy_index, /*nb_index*/
2509
+ (binaryfunc)WraptObjectProxy_matrix_multiply, /*nb_matrix_multiply*/
2510
+ (binaryfunc)WraptObjectProxy_inplace_matrix_multiply, /*nb_inplace_matrix_multiply*/
1572
2511
  };
1573
2512
 
1574
2513
  static PySequenceMethods WraptObjectProxy_as_sequence = {
@@ -1596,6 +2535,10 @@ static PyMethodDef WraptObjectProxy_methods[] = {
1596
2535
  METH_VARARGS | METH_KEYWORDS, 0},
1597
2536
  {"__exit__", (PyCFunction)WraptObjectProxy_exit,
1598
2537
  METH_VARARGS | METH_KEYWORDS, 0},
2538
+ {"__aenter__", (PyCFunction)WraptObjectProxy_aenter,
2539
+ METH_VARARGS | METH_KEYWORDS, 0},
2540
+ {"__aexit__", (PyCFunction)WraptObjectProxy_aexit,
2541
+ METH_VARARGS | METH_KEYWORDS, 0},
1599
2542
  {"__copy__", (PyCFunction)WraptObjectProxy_copy, METH_NOARGS, 0},
1600
2543
  {"__deepcopy__", (PyCFunction)WraptObjectProxy_deepcopy,
1601
2544
  METH_VARARGS | METH_KEYWORDS, 0},
@@ -1629,6 +2572,7 @@ static PyGetSetDef WraptObjectProxy_getset[] = {
1629
2572
  (setter)WraptObjectProxy_set_annotations, 0},
1630
2573
  {"__wrapped__", (getter)WraptObjectProxy_get_wrapped,
1631
2574
  (setter)WraptObjectProxy_set_wrapped, 0},
2575
+ {"__object_proxy__", (getter)WraptObjectProxy_get_object_proxy, 0, 0},
1632
2576
  {NULL},
1633
2577
  };
1634
2578
 
@@ -1637,51 +2581,53 @@ PyTypeObject WraptObjectProxy_Type = {
1637
2581
  sizeof(WraptObjectProxyObject), /*tp_basicsize*/
1638
2582
  0, /*tp_itemsize*/
1639
2583
  /* methods */
1640
- (destructor)WraptObjectProxy_dealloc, /*tp_dealloc*/
1641
- 0, /*tp_print*/
1642
- 0, /*tp_getattr*/
1643
- 0, /*tp_setattr*/
1644
- 0, /*tp_compare*/
1645
- (unaryfunc)WraptObjectProxy_repr, /*tp_repr*/
1646
- &WraptObjectProxy_as_number, /*tp_as_number*/
1647
- &WraptObjectProxy_as_sequence, /*tp_as_sequence*/
1648
- &WraptObjectProxy_as_mapping, /*tp_as_mapping*/
1649
- (hashfunc)WraptObjectProxy_hash, /*tp_hash*/
1650
- 0, /*tp_call*/
1651
- (unaryfunc)WraptObjectProxy_str, /*tp_str*/
1652
- (getattrofunc)WraptObjectProxy_getattro, /*tp_getattro*/
1653
- (setattrofunc)WraptObjectProxy_setattro, /*tp_setattro*/
1654
- 0, /*tp_as_buffer*/
2584
+ (destructor)WraptObjectProxy_dealloc, /*tp_dealloc*/
2585
+ 0, /*tp_print*/
2586
+ 0, /*tp_getattr*/
2587
+ 0, /*tp_setattr*/
2588
+ 0, /*tp_as_async*/
2589
+ (unaryfunc)WraptObjectProxy_repr, /*tp_repr*/
2590
+ &WraptObjectProxy_as_number, /*tp_as_number*/
2591
+ &WraptObjectProxy_as_sequence, /*tp_as_sequence*/
2592
+ &WraptObjectProxy_as_mapping, /*tp_as_mapping*/
2593
+ (hashfunc)WraptObjectProxy_hash, /*tp_hash*/
2594
+ 0, /*tp_call*/
2595
+ (unaryfunc)WraptObjectProxy_str, /*tp_str*/
2596
+ (getattrofunc)WraptObjectProxy_getattro, /*tp_getattro*/
2597
+ (setattrofunc)WraptObjectProxy_setattro, /*tp_setattro*/
2598
+ 0, /*tp_as_buffer*/
1655
2599
  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1656
2600
  0, /*tp_doc*/
1657
- (traverseproc)WraptObjectProxy_traverse, /*tp_traverse*/
1658
- (inquiry)WraptObjectProxy_clear, /*tp_clear*/
1659
- (richcmpfunc)WraptObjectProxy_richcompare, /*tp_richcompare*/
1660
- offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
1661
- (getiterfunc)WraptObjectProxy_iter, /*tp_iter*/
1662
- 0, /*tp_iternext*/
1663
- WraptObjectProxy_methods, /*tp_methods*/
1664
- 0, /*tp_members*/
1665
- WraptObjectProxy_getset, /*tp_getset*/
1666
- 0, /*tp_base*/
1667
- 0, /*tp_dict*/
1668
- 0, /*tp_descr_get*/
1669
- 0, /*tp_descr_set*/
1670
- offsetof(WraptObjectProxyObject, dict), /*tp_dictoffset*/
1671
- (initproc)WraptObjectProxy_init, /*tp_init*/
1672
- PyType_GenericAlloc, /*tp_alloc*/
1673
- WraptObjectProxy_new, /*tp_new*/
1674
- PyObject_GC_Del, /*tp_free*/
1675
- 0, /*tp_is_gc*/
2601
+ (traverseproc)WraptObjectProxy_traverse, /*tp_traverse*/
2602
+ (inquiry)WraptObjectProxy_clear, /*tp_clear*/
2603
+ (richcmpfunc)WraptObjectProxy_richcompare, /*tp_richcompare*/
2604
+ offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
2605
+ 0, /* (getiterfunc)WraptObjectProxy_iter, */ /*tp_iter*/
2606
+ 0, /*tp_iternext*/
2607
+ WraptObjectProxy_methods, /*tp_methods*/
2608
+ 0, /*tp_members*/
2609
+ WraptObjectProxy_getset, /*tp_getset*/
2610
+ 0, /*tp_base*/
2611
+ 0, /*tp_dict*/
2612
+ 0, /*tp_descr_get*/
2613
+ 0, /*tp_descr_set*/
2614
+ offsetof(WraptObjectProxyObject, dict), /*tp_dictoffset*/
2615
+ (initproc)WraptObjectProxy_init, /*tp_init*/
2616
+ PyType_GenericAlloc, /*tp_alloc*/
2617
+ WraptObjectProxy_new, /*tp_new*/
2618
+ PyObject_GC_Del, /*tp_free*/
2619
+ 0, /*tp_is_gc*/
1676
2620
  };
1677
2621
 
1678
2622
  /* ------------------------------------------------------------------------- */
1679
2623
 
1680
2624
  static PyObject *WraptCallableObjectProxy_call(WraptObjectProxyObject *self,
1681
- PyObject *args, PyObject *kwds) {
1682
- if (!self->wrapped) {
1683
- raise_uninitialized_wrapper_error();
1684
- return NULL;
2625
+ PyObject *args, PyObject *kwds)
2626
+ {
2627
+ if (!self->wrapped)
2628
+ {
2629
+ if (raise_uninitialized_wrapper_error(self) == -1)
2630
+ return NULL;
1685
2631
  }
1686
2632
 
1687
2633
  return PyObject_Call(self->wrapped, args, kwds);
@@ -1744,7 +2690,8 @@ PyTypeObject WraptCallableObjectProxy_Type = {
1744
2690
 
1745
2691
  static PyObject *WraptPartialCallableObjectProxy_new(PyTypeObject *type,
1746
2692
  PyObject *args,
1747
- PyObject *kwds) {
2693
+ PyObject *kwds)
2694
+ {
1748
2695
  WraptPartialCallableObjectProxyObject *self;
1749
2696
 
1750
2697
  self = (WraptPartialCallableObjectProxyObject *)WraptObjectProxy_new(
@@ -1763,12 +2710,14 @@ static PyObject *WraptPartialCallableObjectProxy_new(PyTypeObject *type,
1763
2710
 
1764
2711
  static int WraptPartialCallableObjectProxy_raw_init(
1765
2712
  WraptPartialCallableObjectProxyObject *self, PyObject *wrapped,
1766
- PyObject *args, PyObject *kwargs) {
2713
+ PyObject *args, PyObject *kwargs)
2714
+ {
1767
2715
  int result = 0;
1768
2716
 
1769
2717
  result = WraptObjectProxy_raw_init((WraptObjectProxyObject *)self, wrapped);
1770
2718
 
1771
- if (result == 0) {
2719
+ if (result == 0)
2720
+ {
1772
2721
  Py_INCREF(args);
1773
2722
  Py_XDECREF(self->args);
1774
2723
  self->args = args;
@@ -1785,18 +2734,21 @@ static int WraptPartialCallableObjectProxy_raw_init(
1785
2734
 
1786
2735
  static int WraptPartialCallableObjectProxy_init(
1787
2736
  WraptPartialCallableObjectProxyObject *self, PyObject *args,
1788
- PyObject *kwds) {
2737
+ PyObject *kwds)
2738
+ {
1789
2739
  PyObject *wrapped = NULL;
1790
2740
  PyObject *fnargs = NULL;
1791
2741
 
1792
2742
  int result = 0;
1793
2743
 
1794
- if (!PyObject_Length(args)) {
2744
+ if (!PyObject_Length(args))
2745
+ {
1795
2746
  PyErr_SetString(PyExc_TypeError, "__init__ of partial needs an argument");
1796
2747
  return -1;
1797
2748
  }
1798
2749
 
1799
- if (PyObject_Length(args) < 1) {
2750
+ if (PyObject_Length(args) < 1)
2751
+ {
1800
2752
  PyErr_SetString(PyExc_TypeError,
1801
2753
  "partial type takes at least one argument");
1802
2754
  return -1;
@@ -1804,7 +2756,8 @@ static int WraptPartialCallableObjectProxy_init(
1804
2756
 
1805
2757
  wrapped = PyTuple_GetItem(args, 0);
1806
2758
 
1807
- if (!PyCallable_Check(wrapped)) {
2759
+ if (!PyCallable_Check(wrapped))
2760
+ {
1808
2761
  PyErr_SetString(PyExc_TypeError, "the first argument must be callable");
1809
2762
  return -1;
1810
2763
  }
@@ -1825,7 +2778,8 @@ static int WraptPartialCallableObjectProxy_init(
1825
2778
  /* ------------------------------------------------------------------------- */
1826
2779
 
1827
2780
  static int WraptPartialCallableObjectProxy_traverse(
1828
- WraptPartialCallableObjectProxyObject *self, visitproc visit, void *arg) {
2781
+ WraptPartialCallableObjectProxyObject *self, visitproc visit, void *arg)
2782
+ {
1829
2783
  WraptObjectProxy_traverse((WraptObjectProxyObject *)self, visit, arg);
1830
2784
 
1831
2785
  Py_VISIT(self->args);
@@ -1837,7 +2791,8 @@ static int WraptPartialCallableObjectProxy_traverse(
1837
2791
  /* ------------------------------------------------------------------------- */
1838
2792
 
1839
2793
  static int WraptPartialCallableObjectProxy_clear(
1840
- WraptPartialCallableObjectProxyObject *self) {
2794
+ WraptPartialCallableObjectProxyObject *self)
2795
+ {
1841
2796
  WraptObjectProxy_clear((WraptObjectProxyObject *)self);
1842
2797
 
1843
2798
  Py_CLEAR(self->args);
@@ -1849,7 +2804,8 @@ static int WraptPartialCallableObjectProxy_clear(
1849
2804
  /* ------------------------------------------------------------------------- */
1850
2805
 
1851
2806
  static void WraptPartialCallableObjectProxy_dealloc(
1852
- WraptPartialCallableObjectProxyObject *self) {
2807
+ WraptPartialCallableObjectProxyObject *self)
2808
+ {
1853
2809
  PyObject_GC_UnTrack(self);
1854
2810
 
1855
2811
  WraptPartialCallableObjectProxy_clear(self);
@@ -1861,7 +2817,8 @@ static void WraptPartialCallableObjectProxy_dealloc(
1861
2817
 
1862
2818
  static PyObject *WraptPartialCallableObjectProxy_call(
1863
2819
  WraptPartialCallableObjectProxyObject *self, PyObject *args,
1864
- PyObject *kwds) {
2820
+ PyObject *kwds)
2821
+ {
1865
2822
  PyObject *fnargs = NULL;
1866
2823
  PyObject *fnkwargs = NULL;
1867
2824
 
@@ -1870,14 +2827,16 @@ static PyObject *WraptPartialCallableObjectProxy_call(
1870
2827
  long i;
1871
2828
  long offset;
1872
2829
 
1873
- if (!self->object_proxy.wrapped) {
1874
- raise_uninitialized_wrapper_error();
1875
- return NULL;
2830
+ if (!self->object_proxy.wrapped)
2831
+ {
2832
+ if (raise_uninitialized_wrapper_error(&self->object_proxy) == -1)
2833
+ return NULL;
1876
2834
  }
1877
2835
 
1878
2836
  fnargs = PyTuple_New(PyTuple_Size(self->args) + PyTuple_Size(args));
1879
2837
 
1880
- for (i = 0; i < PyTuple_Size(self->args); i++) {
2838
+ for (i = 0; i < PyTuple_Size(self->args); i++)
2839
+ {
1881
2840
  PyObject *item;
1882
2841
  item = PyTuple_GetItem(self->args, i);
1883
2842
  Py_INCREF(item);
@@ -1886,7 +2845,8 @@ static PyObject *WraptPartialCallableObjectProxy_call(
1886
2845
 
1887
2846
  offset = PyTuple_Size(self->args);
1888
2847
 
1889
- for (i = 0; i < PyTuple_Size(args); i++) {
2848
+ for (i = 0; i < PyTuple_Size(args); i++)
2849
+ {
1890
2850
  PyObject *item;
1891
2851
  item = PyTuple_GetItem(args, i);
1892
2852
  Py_INCREF(item);
@@ -1895,13 +2855,15 @@ static PyObject *WraptPartialCallableObjectProxy_call(
1895
2855
 
1896
2856
  fnkwargs = PyDict_New();
1897
2857
 
1898
- if (self->kwargs && PyDict_Update(fnkwargs, self->kwargs) == -1) {
2858
+ if (self->kwargs && PyDict_Update(fnkwargs, self->kwargs) == -1)
2859
+ {
1899
2860
  Py_DECREF(fnargs);
1900
2861
  Py_DECREF(fnkwargs);
1901
2862
  return NULL;
1902
2863
  }
1903
2864
 
1904
- if (kwds && PyDict_Update(fnkwargs, kwds) == -1) {
2865
+ if (kwds && PyDict_Update(fnkwargs, kwds) == -1)
2866
+ {
1905
2867
  Py_DECREF(fnargs);
1906
2868
  Py_DECREF(fnkwargs);
1907
2869
  return NULL;
@@ -1927,56 +2889,52 @@ static PyGetSetDef WraptPartialCallableObjectProxy_getset[] = {
1927
2889
 
1928
2890
  PyTypeObject WraptPartialCallableObjectProxy_Type = {
1929
2891
  PyVarObject_HEAD_INIT(NULL, 0) "PartialCallableObjectProxy", /*tp_name*/
1930
- sizeof(WraptPartialCallableObjectProxyObject), /*tp_basicsize*/
1931
- 0, /*tp_itemsize*/
2892
+ sizeof(WraptPartialCallableObjectProxyObject), /*tp_basicsize*/
2893
+ 0, /*tp_itemsize*/
1932
2894
  /* methods */
1933
- (destructor)WraptPartialCallableObjectProxy_dealloc, /*tp_dealloc*/
1934
- 0, /*tp_print*/
1935
- 0, /*tp_getattr*/
1936
- 0, /*tp_setattr*/
1937
- 0, /*tp_compare*/
1938
- 0, /*tp_repr*/
1939
- 0, /*tp_as_number*/
1940
- 0, /*tp_as_sequence*/
1941
- 0, /*tp_as_mapping*/
1942
- 0, /*tp_hash*/
1943
- (ternaryfunc)WraptPartialCallableObjectProxy_call, /*tp_call*/
1944
- 0, /*tp_str*/
1945
- 0, /*tp_getattro*/
1946
- 0, /*tp_setattro*/
1947
- 0, /*tp_as_buffer*/
1948
- #if PY_MAJOR_VERSION < 3
1949
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
1950
- Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
1951
- #else
2895
+ (destructor)WraptPartialCallableObjectProxy_dealloc, /*tp_dealloc*/
2896
+ 0, /*tp_print*/
2897
+ 0, /*tp_getattr*/
2898
+ 0, /*tp_setattr*/
2899
+ 0, /*tp_compare*/
2900
+ 0, /*tp_repr*/
2901
+ 0, /*tp_as_number*/
2902
+ 0, /*tp_as_sequence*/
2903
+ 0, /*tp_as_mapping*/
2904
+ 0, /*tp_hash*/
2905
+ (ternaryfunc)WraptPartialCallableObjectProxy_call, /*tp_call*/
2906
+ 0, /*tp_str*/
2907
+ 0, /*tp_getattro*/
2908
+ 0, /*tp_setattro*/
2909
+ 0, /*tp_as_buffer*/
1952
2910
  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1953
- #endif
1954
- 0, /*tp_doc*/
1955
- (traverseproc)WraptPartialCallableObjectProxy_traverse, /*tp_traverse*/
1956
- (inquiry)WraptPartialCallableObjectProxy_clear, /*tp_clear*/
1957
- 0, /*tp_richcompare*/
1958
- offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
1959
- 0, /*tp_iter*/
1960
- 0, /*tp_iternext*/
1961
- 0, /*tp_methods*/
1962
- 0, /*tp_members*/
1963
- WraptPartialCallableObjectProxy_getset, /*tp_getset*/
1964
- 0, /*tp_base*/
1965
- 0, /*tp_dict*/
1966
- 0, /*tp_descr_get*/
1967
- 0, /*tp_descr_set*/
1968
- 0, /*tp_dictoffset*/
1969
- (initproc)WraptPartialCallableObjectProxy_init, /*tp_init*/
1970
- 0, /*tp_alloc*/
1971
- WraptPartialCallableObjectProxy_new, /*tp_new*/
1972
- 0, /*tp_free*/
1973
- 0, /*tp_is_gc*/
2911
+ 0, /*tp_doc*/
2912
+ (traverseproc)WraptPartialCallableObjectProxy_traverse, /*tp_traverse*/
2913
+ (inquiry)WraptPartialCallableObjectProxy_clear, /*tp_clear*/
2914
+ 0, /*tp_richcompare*/
2915
+ offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
2916
+ 0, /*tp_iter*/
2917
+ 0, /*tp_iternext*/
2918
+ 0, /*tp_methods*/
2919
+ 0, /*tp_members*/
2920
+ WraptPartialCallableObjectProxy_getset, /*tp_getset*/
2921
+ 0, /*tp_base*/
2922
+ 0, /*tp_dict*/
2923
+ 0, /*tp_descr_get*/
2924
+ 0, /*tp_descr_set*/
2925
+ 0, /*tp_dictoffset*/
2926
+ (initproc)WraptPartialCallableObjectProxy_init, /*tp_init*/
2927
+ 0, /*tp_alloc*/
2928
+ WraptPartialCallableObjectProxy_new, /*tp_new*/
2929
+ 0, /*tp_free*/
2930
+ 0, /*tp_is_gc*/
1974
2931
  };
1975
2932
 
1976
2933
  /* ------------------------------------------------------------------------- */
1977
2934
 
1978
2935
  static PyObject *WraptFunctionWrapperBase_new(PyTypeObject *type,
1979
- PyObject *args, PyObject *kwds) {
2936
+ PyObject *args, PyObject *kwds)
2937
+ {
1980
2938
  WraptFunctionWrapperObject *self;
1981
2939
 
1982
2940
  self = (WraptFunctionWrapperObject *)WraptObjectProxy_new(type, args, kwds);
@@ -1999,12 +2957,14 @@ static PyObject *WraptFunctionWrapperBase_new(PyTypeObject *type,
1999
2957
  static int WraptFunctionWrapperBase_raw_init(
2000
2958
  WraptFunctionWrapperObject *self, PyObject *wrapped, PyObject *instance,
2001
2959
  PyObject *wrapper, PyObject *enabled, PyObject *binding, PyObject *parent,
2002
- PyObject *owner) {
2960
+ PyObject *owner)
2961
+ {
2003
2962
  int result = 0;
2004
2963
 
2005
2964
  result = WraptObjectProxy_raw_init((WraptObjectProxyObject *)self, wrapped);
2006
2965
 
2007
- if (result == 0) {
2966
+ if (result == 0)
2967
+ {
2008
2968
  Py_INCREF(instance);
2009
2969
  Py_XDECREF(self->instance);
2010
2970
  self->instance = instance;
@@ -2036,7 +2996,8 @@ static int WraptFunctionWrapperBase_raw_init(
2036
2996
  /* ------------------------------------------------------------------------- */
2037
2997
 
2038
2998
  static int WraptFunctionWrapperBase_init(WraptFunctionWrapperObject *self,
2039
- PyObject *args, PyObject *kwds) {
2999
+ PyObject *args, PyObject *kwds)
3000
+ {
2040
3001
  PyObject *wrapped = NULL;
2041
3002
  PyObject *instance = NULL;
2042
3003
  PyObject *wrapper = NULL;
@@ -2048,19 +3009,17 @@ static int WraptFunctionWrapperBase_init(WraptFunctionWrapperObject *self,
2048
3009
  static PyObject *callable_str = NULL;
2049
3010
 
2050
3011
  char *const kwlist[] = {"wrapped", "instance", "wrapper", "enabled",
2051
- "binding", "parent", "owner", NULL};
3012
+ "binding", "parent", "owner", NULL};
2052
3013
 
2053
- if (!callable_str) {
2054
- #if PY_MAJOR_VERSION >= 3
3014
+ if (!callable_str)
3015
+ {
2055
3016
  callable_str = PyUnicode_InternFromString("callable");
2056
- #else
2057
- callable_str = PyString_InternFromString("callable");
2058
- #endif
2059
3017
  }
2060
3018
 
2061
3019
  if (!PyArg_ParseTupleAndKeywords(args, kwds, "OOO|OOOO:FunctionWrapperBase",
2062
3020
  kwlist, &wrapped, &instance, &wrapper,
2063
- &enabled, &binding, &parent, &owner)) {
3021
+ &enabled, &binding, &parent, &owner))
3022
+ {
2064
3023
  return -1;
2065
3024
  }
2066
3025
 
@@ -2074,7 +3033,8 @@ static int WraptFunctionWrapperBase_init(WraptFunctionWrapperObject *self,
2074
3033
  /* ------------------------------------------------------------------------- */
2075
3034
 
2076
3035
  static int WraptFunctionWrapperBase_traverse(WraptFunctionWrapperObject *self,
2077
- visitproc visit, void *arg) {
3036
+ visitproc visit, void *arg)
3037
+ {
2078
3038
  WraptObjectProxy_traverse((WraptObjectProxyObject *)self, visit, arg);
2079
3039
 
2080
3040
  Py_VISIT(self->instance);
@@ -2089,7 +3049,8 @@ static int WraptFunctionWrapperBase_traverse(WraptFunctionWrapperObject *self,
2089
3049
 
2090
3050
  /* ------------------------------------------------------------------------- */
2091
3051
 
2092
- static int WraptFunctionWrapperBase_clear(WraptFunctionWrapperObject *self) {
3052
+ static int WraptFunctionWrapperBase_clear(WraptFunctionWrapperObject *self)
3053
+ {
2093
3054
  WraptObjectProxy_clear((WraptObjectProxyObject *)self);
2094
3055
 
2095
3056
  Py_CLEAR(self->instance);
@@ -2104,7 +3065,8 @@ static int WraptFunctionWrapperBase_clear(WraptFunctionWrapperObject *self) {
2104
3065
 
2105
3066
  /* ------------------------------------------------------------------------- */
2106
3067
 
2107
- static void WraptFunctionWrapperBase_dealloc(WraptFunctionWrapperObject *self) {
3068
+ static void WraptFunctionWrapperBase_dealloc(WraptFunctionWrapperObject *self)
3069
+ {
2108
3070
  PyObject_GC_UnTrack(self);
2109
3071
 
2110
3072
  WraptFunctionWrapperBase_clear(self);
@@ -2115,7 +3077,8 @@ static void WraptFunctionWrapperBase_dealloc(WraptFunctionWrapperObject *self) {
2115
3077
  /* ------------------------------------------------------------------------- */
2116
3078
 
2117
3079
  static PyObject *WraptFunctionWrapperBase_call(WraptFunctionWrapperObject *self,
2118
- PyObject *args, PyObject *kwds) {
3080
+ PyObject *args, PyObject *kwds)
3081
+ {
2119
3082
  PyObject *param_kwds = NULL;
2120
3083
 
2121
3084
  PyObject *result = NULL;
@@ -2125,22 +3088,18 @@ static PyObject *WraptFunctionWrapperBase_call(WraptFunctionWrapperObject *self,
2125
3088
  static PyObject *classmethod_str = NULL;
2126
3089
  static PyObject *instancemethod_str = NULL;
2127
3090
 
2128
- if (!function_str) {
2129
- #if PY_MAJOR_VERSION >= 3
3091
+ if (!function_str)
3092
+ {
2130
3093
  function_str = PyUnicode_InternFromString("function");
2131
3094
  callable_str = PyUnicode_InternFromString("callable");
2132
3095
  classmethod_str = PyUnicode_InternFromString("classmethod");
2133
3096
  instancemethod_str = PyUnicode_InternFromString("instancemethod");
2134
- #else
2135
- function_str = PyString_InternFromString("function");
2136
- callable_str = PyString_InternFromString("callable");
2137
- classmethod_str = PyString_InternFromString("classmethod");
2138
- instancemethod_str = PyString_InternFromString("instancemethod");
2139
- #endif
2140
3097
  }
2141
3098
 
2142
- if (self->enabled != Py_None) {
2143
- if (PyCallable_Check(self->enabled)) {
3099
+ if (self->enabled != Py_None)
3100
+ {
3101
+ if (PyCallable_Check(self->enabled))
3102
+ {
2144
3103
  PyObject *object = NULL;
2145
3104
 
2146
3105
  object = PyObject_CallFunctionObjArgs(self->enabled, NULL);
@@ -2148,18 +3107,22 @@ static PyObject *WraptFunctionWrapperBase_call(WraptFunctionWrapperObject *self,
2148
3107
  if (!object)
2149
3108
  return NULL;
2150
3109
 
2151
- if (PyObject_Not(object)) {
3110
+ if (PyObject_Not(object))
3111
+ {
2152
3112
  Py_DECREF(object);
2153
3113
  return PyObject_Call(self->object_proxy.wrapped, args, kwds);
2154
3114
  }
2155
3115
 
2156
3116
  Py_DECREF(object);
2157
- } else if (PyObject_Not(self->enabled)) {
3117
+ }
3118
+ else if (PyObject_Not(self->enabled))
3119
+ {
2158
3120
  return PyObject_Call(self->object_proxy.wrapped, args, kwds);
2159
3121
  }
2160
3122
  }
2161
3123
 
2162
- if (!kwds) {
3124
+ if (!kwds)
3125
+ {
2163
3126
  param_kwds = PyDict_New();
2164
3127
  kwds = param_kwds;
2165
3128
  }
@@ -2173,13 +3136,15 @@ static PyObject *WraptFunctionWrapperBase_call(WraptFunctionWrapperObject *self,
2173
3136
  self->binding == callable_str ||
2174
3137
  PyObject_RichCompareBool(self->binding, callable_str, Py_EQ) == 1 ||
2175
3138
  self->binding == classmethod_str ||
2176
- PyObject_RichCompareBool(self->binding, classmethod_str, Py_EQ) == 1)) {
3139
+ PyObject_RichCompareBool(self->binding, classmethod_str, Py_EQ) == 1))
3140
+ {
2177
3141
 
2178
3142
  PyObject *instance = NULL;
2179
3143
 
2180
3144
  instance = PyObject_GetAttrString(self->object_proxy.wrapped, "__self__");
2181
3145
 
2182
- if (instance) {
3146
+ if (instance)
3147
+ {
2183
3148
  result = PyObject_CallFunctionObjArgs(self->wrapper,
2184
3149
  self->object_proxy.wrapped,
2185
3150
  instance, args, kwds, NULL);
@@ -2189,7 +3154,8 @@ static PyObject *WraptFunctionWrapperBase_call(WraptFunctionWrapperObject *self,
2189
3154
  Py_DECREF(instance);
2190
3155
 
2191
3156
  return result;
2192
- } else
3157
+ }
3158
+ else
2193
3159
  PyErr_Clear();
2194
3160
  }
2195
3161
 
@@ -2206,7 +3172,8 @@ static PyObject *WraptFunctionWrapperBase_call(WraptFunctionWrapperObject *self,
2206
3172
 
2207
3173
  static PyObject *
2208
3174
  WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
2209
- PyObject *obj, PyObject *type) {
3175
+ PyObject *obj, PyObject *type)
3176
+ {
2210
3177
  PyObject *bound_type = NULL;
2211
3178
  PyObject *descriptor = NULL;
2212
3179
  PyObject *result = NULL;
@@ -2218,44 +3185,38 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
2218
3185
  static PyObject *class_str = NULL;
2219
3186
  static PyObject *instancemethod_str = NULL;
2220
3187
 
2221
- if (!bound_type_str) {
2222
- #if PY_MAJOR_VERSION >= 3
3188
+ if (!bound_type_str)
3189
+ {
2223
3190
  bound_type_str = PyUnicode_InternFromString("__bound_function_wrapper__");
2224
- #else
2225
- bound_type_str = PyString_InternFromString("__bound_function_wrapper__");
2226
- #endif
2227
3191
  }
2228
3192
 
2229
- if (!function_str) {
2230
- #if PY_MAJOR_VERSION >= 3
3193
+ if (!function_str)
3194
+ {
2231
3195
  function_str = PyUnicode_InternFromString("function");
2232
3196
  callable_str = PyUnicode_InternFromString("callable");
2233
3197
  builtin_str = PyUnicode_InternFromString("builtin");
2234
3198
  class_str = PyUnicode_InternFromString("class");
2235
3199
  instancemethod_str = PyUnicode_InternFromString("instancemethod");
2236
- #else
2237
- function_str = PyString_InternFromString("function");
2238
- callable_str = PyString_InternFromString("callable");
2239
- builtin_str = PyString_InternFromString("builtin");
2240
- class_str = PyString_InternFromString("class");
2241
- instancemethod_str = PyString_InternFromString("instancemethod");
2242
- #endif
2243
3200
  }
2244
3201
 
2245
- if (self->parent == Py_None) {
3202
+ if (self->parent == Py_None)
3203
+ {
2246
3204
  if (self->binding == builtin_str ||
2247
- PyObject_RichCompareBool(self->binding, builtin_str, Py_EQ) == 1) {
3205
+ PyObject_RichCompareBool(self->binding, builtin_str, Py_EQ) == 1)
3206
+ {
2248
3207
  Py_INCREF(self);
2249
3208
  return (PyObject *)self;
2250
3209
  }
2251
3210
 
2252
3211
  if (self->binding == class_str ||
2253
- PyObject_RichCompareBool(self->binding, class_str, Py_EQ) == 1) {
3212
+ PyObject_RichCompareBool(self->binding, class_str, Py_EQ) == 1)
3213
+ {
2254
3214
  Py_INCREF(self);
2255
3215
  return (PyObject *)self;
2256
3216
  }
2257
3217
 
2258
- if (Py_TYPE(self->object_proxy.wrapped)->tp_descr_get == NULL) {
3218
+ if (Py_TYPE(self->object_proxy.wrapped)->tp_descr_get == NULL)
3219
+ {
2259
3220
  Py_INCREF(self);
2260
3221
  return (PyObject *)self;
2261
3222
  }
@@ -2266,7 +3227,8 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
2266
3227
  if (!descriptor)
2267
3228
  return NULL;
2268
3229
 
2269
- if (Py_TYPE(self) != &WraptFunctionWrapper_Type) {
3230
+ if (Py_TYPE(self) != &WraptFunctionWrapper_Type)
3231
+ {
2270
3232
  bound_type = PyObject_GenericGetAttr((PyObject *)self, bound_type_str);
2271
3233
 
2272
3234
  if (!bound_type)
@@ -2294,18 +3256,16 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
2294
3256
  PyObject_RichCompareBool(self->binding, instancemethod_str, Py_EQ) ==
2295
3257
  1 ||
2296
3258
  self->binding == callable_str ||
2297
- PyObject_RichCompareBool(self->binding, callable_str, Py_EQ) == 1)) {
3259
+ PyObject_RichCompareBool(self->binding, callable_str, Py_EQ) == 1))
3260
+ {
2298
3261
 
2299
3262
  PyObject *wrapped = NULL;
2300
3263
 
2301
3264
  static PyObject *wrapped_str = NULL;
2302
3265
 
2303
- if (!wrapped_str) {
2304
- #if PY_MAJOR_VERSION >= 3
3266
+ if (!wrapped_str)
3267
+ {
2305
3268
  wrapped_str = PyUnicode_InternFromString("__wrapped__");
2306
- #else
2307
- wrapped_str = PyString_InternFromString("__wrapped__");
2308
- #endif
2309
3269
  }
2310
3270
 
2311
3271
  wrapped = PyObject_GetAttr(self->parent, wrapped_str);
@@ -2313,7 +3273,8 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
2313
3273
  if (!wrapped)
2314
3274
  return NULL;
2315
3275
 
2316
- if (Py_TYPE(wrapped)->tp_descr_get == NULL) {
3276
+ if (Py_TYPE(wrapped)->tp_descr_get == NULL)
3277
+ {
2317
3278
  PyErr_Format(PyExc_AttributeError,
2318
3279
  "'%s' object has no attribute '__get__'",
2319
3280
  Py_TYPE(wrapped)->tp_name);
@@ -2328,7 +3289,8 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
2328
3289
  if (!descriptor)
2329
3290
  return NULL;
2330
3291
 
2331
- if (Py_TYPE(self->parent) != &WraptFunctionWrapper_Type) {
3292
+ if (Py_TYPE(self->parent) != &WraptFunctionWrapper_Type)
3293
+ {
2332
3294
  bound_type =
2333
3295
  PyObject_GenericGetAttr((PyObject *)self->parent, bound_type_str);
2334
3296
 
@@ -2358,18 +3320,21 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
2358
3320
 
2359
3321
  static PyObject *
2360
3322
  WraptFunctionWrapperBase_set_name(WraptFunctionWrapperObject *self,
2361
- PyObject *args, PyObject *kwds) {
3323
+ PyObject *args, PyObject *kwds)
3324
+ {
2362
3325
  PyObject *method = NULL;
2363
3326
  PyObject *result = NULL;
2364
3327
 
2365
- if (!self->object_proxy.wrapped) {
2366
- raise_uninitialized_wrapper_error();
2367
- return NULL;
3328
+ if (!self->object_proxy.wrapped)
3329
+ {
3330
+ if (raise_uninitialized_wrapper_error(&self->object_proxy) == -1)
3331
+ return NULL;
2368
3332
  }
2369
3333
 
2370
3334
  method = PyObject_GetAttrString(self->object_proxy.wrapped, "__set_name__");
2371
3335
 
2372
- if (!method) {
3336
+ if (!method)
3337
+ {
2373
3338
  PyErr_Clear();
2374
3339
  Py_INCREF(Py_None);
2375
3340
  return Py_None;
@@ -2386,19 +3351,22 @@ WraptFunctionWrapperBase_set_name(WraptFunctionWrapperObject *self,
2386
3351
 
2387
3352
  static PyObject *
2388
3353
  WraptFunctionWrapperBase_instancecheck(WraptFunctionWrapperObject *self,
2389
- PyObject *instance) {
3354
+ PyObject *instance)
3355
+ {
2390
3356
  PyObject *result = NULL;
2391
3357
 
2392
3358
  int check = 0;
2393
3359
 
2394
- if (!self->object_proxy.wrapped) {
2395
- raise_uninitialized_wrapper_error();
2396
- return NULL;
3360
+ if (!self->object_proxy.wrapped)
3361
+ {
3362
+ if (raise_uninitialized_wrapper_error(&self->object_proxy) == -1)
3363
+ return NULL;
2397
3364
  }
2398
3365
 
2399
3366
  check = PyObject_IsInstance(instance, self->object_proxy.wrapped);
2400
3367
 
2401
- if (check < 0) {
3368
+ if (check < 0)
3369
+ {
2402
3370
  return NULL;
2403
3371
  }
2404
3372
 
@@ -2412,16 +3380,18 @@ WraptFunctionWrapperBase_instancecheck(WraptFunctionWrapperObject *self,
2412
3380
 
2413
3381
  static PyObject *
2414
3382
  WraptFunctionWrapperBase_subclasscheck(WraptFunctionWrapperObject *self,
2415
- PyObject *args) {
3383
+ PyObject *args)
3384
+ {
2416
3385
  PyObject *subclass = NULL;
2417
3386
  PyObject *object = NULL;
2418
3387
  PyObject *result = NULL;
2419
3388
 
2420
3389
  int check = 0;
2421
3390
 
2422
- if (!self->object_proxy.wrapped) {
2423
- raise_uninitialized_wrapper_error();
2424
- return NULL;
3391
+ if (!self->object_proxy.wrapped)
3392
+ {
3393
+ if (raise_uninitialized_wrapper_error(&self->object_proxy) == -1)
3394
+ return NULL;
2425
3395
  }
2426
3396
 
2427
3397
  if (!PyArg_ParseTuple(args, "O", &subclass))
@@ -2451,8 +3421,10 @@ WraptFunctionWrapperBase_subclasscheck(WraptFunctionWrapperObject *self,
2451
3421
 
2452
3422
  static PyObject *
2453
3423
  WraptFunctionWrapperBase_get_self_instance(WraptFunctionWrapperObject *self,
2454
- void *closure) {
2455
- if (!self->instance) {
3424
+ void *closure)
3425
+ {
3426
+ if (!self->instance)
3427
+ {
2456
3428
  Py_INCREF(Py_None);
2457
3429
  return Py_None;
2458
3430
  }
@@ -2465,8 +3437,10 @@ WraptFunctionWrapperBase_get_self_instance(WraptFunctionWrapperObject *self,
2465
3437
 
2466
3438
  static PyObject *
2467
3439
  WraptFunctionWrapperBase_get_self_wrapper(WraptFunctionWrapperObject *self,
2468
- void *closure) {
2469
- if (!self->wrapper) {
3440
+ void *closure)
3441
+ {
3442
+ if (!self->wrapper)
3443
+ {
2470
3444
  Py_INCREF(Py_None);
2471
3445
  return Py_None;
2472
3446
  }
@@ -2479,8 +3453,10 @@ WraptFunctionWrapperBase_get_self_wrapper(WraptFunctionWrapperObject *self,
2479
3453
 
2480
3454
  static PyObject *
2481
3455
  WraptFunctionWrapperBase_get_self_enabled(WraptFunctionWrapperObject *self,
2482
- void *closure) {
2483
- if (!self->enabled) {
3456
+ void *closure)
3457
+ {
3458
+ if (!self->enabled)
3459
+ {
2484
3460
  Py_INCREF(Py_None);
2485
3461
  return Py_None;
2486
3462
  }
@@ -2493,8 +3469,10 @@ WraptFunctionWrapperBase_get_self_enabled(WraptFunctionWrapperObject *self,
2493
3469
 
2494
3470
  static PyObject *
2495
3471
  WraptFunctionWrapperBase_get_self_binding(WraptFunctionWrapperObject *self,
2496
- void *closure) {
2497
- if (!self->binding) {
3472
+ void *closure)
3473
+ {
3474
+ if (!self->binding)
3475
+ {
2498
3476
  Py_INCREF(Py_None);
2499
3477
  return Py_None;
2500
3478
  }
@@ -2507,8 +3485,10 @@ WraptFunctionWrapperBase_get_self_binding(WraptFunctionWrapperObject *self,
2507
3485
 
2508
3486
  static PyObject *
2509
3487
  WraptFunctionWrapperBase_get_self_parent(WraptFunctionWrapperObject *self,
2510
- void *closure) {
2511
- if (!self->parent) {
3488
+ void *closure)
3489
+ {
3490
+ if (!self->parent)
3491
+ {
2512
3492
  Py_INCREF(Py_None);
2513
3493
  return Py_None;
2514
3494
  }
@@ -2521,8 +3501,10 @@ WraptFunctionWrapperBase_get_self_parent(WraptFunctionWrapperObject *self,
2521
3501
 
2522
3502
  static PyObject *
2523
3503
  WraptFunctionWrapperBase_get_self_owner(WraptFunctionWrapperObject *self,
2524
- void *closure) {
2525
- if (!self->owner) {
3504
+ void *closure)
3505
+ {
3506
+ if (!self->owner)
3507
+ {
2526
3508
  Py_INCREF(Py_None);
2527
3509
  return Py_None;
2528
3510
  }
@@ -2568,54 +3550,50 @@ PyTypeObject WraptFunctionWrapperBase_Type = {
2568
3550
  sizeof(WraptFunctionWrapperObject), /*tp_basicsize*/
2569
3551
  0, /*tp_itemsize*/
2570
3552
  /* methods */
2571
- (destructor)WraptFunctionWrapperBase_dealloc, /*tp_dealloc*/
2572
- 0, /*tp_print*/
2573
- 0, /*tp_getattr*/
2574
- 0, /*tp_setattr*/
2575
- 0, /*tp_compare*/
2576
- 0, /*tp_repr*/
2577
- 0, /*tp_as_number*/
2578
- 0, /*tp_as_sequence*/
2579
- 0, /*tp_as_mapping*/
2580
- 0, /*tp_hash*/
2581
- (ternaryfunc)WraptFunctionWrapperBase_call, /*tp_call*/
2582
- 0, /*tp_str*/
2583
- 0, /*tp_getattro*/
2584
- 0, /*tp_setattro*/
2585
- 0, /*tp_as_buffer*/
2586
- #if PY_MAJOR_VERSION < 3
2587
- Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC |
2588
- Py_TPFLAGS_CHECKTYPES, /*tp_flags*/
2589
- #else
3553
+ (destructor)WraptFunctionWrapperBase_dealloc, /*tp_dealloc*/
3554
+ 0, /*tp_print*/
3555
+ 0, /*tp_getattr*/
3556
+ 0, /*tp_setattr*/
3557
+ 0, /*tp_compare*/
3558
+ 0, /*tp_repr*/
3559
+ 0, /*tp_as_number*/
3560
+ 0, /*tp_as_sequence*/
3561
+ 0, /*tp_as_mapping*/
3562
+ 0, /*tp_hash*/
3563
+ (ternaryfunc)WraptFunctionWrapperBase_call, /*tp_call*/
3564
+ 0, /*tp_str*/
3565
+ 0, /*tp_getattro*/
3566
+ 0, /*tp_setattro*/
3567
+ 0, /*tp_as_buffer*/
2590
3568
  Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
2591
- #endif
2592
- 0, /*tp_doc*/
2593
- (traverseproc)WraptFunctionWrapperBase_traverse, /*tp_traverse*/
2594
- (inquiry)WraptFunctionWrapperBase_clear, /*tp_clear*/
2595
- 0, /*tp_richcompare*/
2596
- offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
2597
- 0, /*tp_iter*/
2598
- 0, /*tp_iternext*/
2599
- WraptFunctionWrapperBase_methods, /*tp_methods*/
2600
- 0, /*tp_members*/
2601
- WraptFunctionWrapperBase_getset, /*tp_getset*/
2602
- 0, /*tp_base*/
2603
- 0, /*tp_dict*/
2604
- (descrgetfunc)WraptFunctionWrapperBase_descr_get, /*tp_descr_get*/
2605
- 0, /*tp_descr_set*/
2606
- 0, /*tp_dictoffset*/
2607
- (initproc)WraptFunctionWrapperBase_init, /*tp_init*/
2608
- 0, /*tp_alloc*/
2609
- WraptFunctionWrapperBase_new, /*tp_new*/
2610
- 0, /*tp_free*/
2611
- 0, /*tp_is_gc*/
3569
+ 0, /*tp_doc*/
3570
+ (traverseproc)WraptFunctionWrapperBase_traverse, /*tp_traverse*/
3571
+ (inquiry)WraptFunctionWrapperBase_clear, /*tp_clear*/
3572
+ 0, /*tp_richcompare*/
3573
+ offsetof(WraptObjectProxyObject, weakreflist), /*tp_weaklistoffset*/
3574
+ 0, /*tp_iter*/
3575
+ 0, /*tp_iternext*/
3576
+ WraptFunctionWrapperBase_methods, /*tp_methods*/
3577
+ 0, /*tp_members*/
3578
+ WraptFunctionWrapperBase_getset, /*tp_getset*/
3579
+ 0, /*tp_base*/
3580
+ 0, /*tp_dict*/
3581
+ (descrgetfunc)WraptFunctionWrapperBase_descr_get, /*tp_descr_get*/
3582
+ 0, /*tp_descr_set*/
3583
+ 0, /*tp_dictoffset*/
3584
+ (initproc)WraptFunctionWrapperBase_init, /*tp_init*/
3585
+ 0, /*tp_alloc*/
3586
+ WraptFunctionWrapperBase_new, /*tp_new*/
3587
+ 0, /*tp_free*/
3588
+ 0, /*tp_is_gc*/
2612
3589
  };
2613
3590
 
2614
3591
  /* ------------------------------------------------------------------------- */
2615
3592
 
2616
3593
  static PyObject *
2617
3594
  WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
2618
- PyObject *kwds) {
3595
+ PyObject *kwds)
3596
+ {
2619
3597
  PyObject *param_args = NULL;
2620
3598
  PyObject *param_kwds = NULL;
2621
3599
 
@@ -2627,8 +3605,10 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
2627
3605
  static PyObject *function_str = NULL;
2628
3606
  static PyObject *callable_str = NULL;
2629
3607
 
2630
- if (self->enabled != Py_None) {
2631
- if (PyCallable_Check(self->enabled)) {
3608
+ if (self->enabled != Py_None)
3609
+ {
3610
+ if (PyCallable_Check(self->enabled))
3611
+ {
2632
3612
  PyObject *object = NULL;
2633
3613
 
2634
3614
  object = PyObject_CallFunctionObjArgs(self->enabled, NULL);
@@ -2636,25 +3616,24 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
2636
3616
  if (!object)
2637
3617
  return NULL;
2638
3618
 
2639
- if (PyObject_Not(object)) {
3619
+ if (PyObject_Not(object))
3620
+ {
2640
3621
  Py_DECREF(object);
2641
3622
  return PyObject_Call(self->object_proxy.wrapped, args, kwds);
2642
3623
  }
2643
3624
 
2644
3625
  Py_DECREF(object);
2645
- } else if (PyObject_Not(self->enabled)) {
3626
+ }
3627
+ else if (PyObject_Not(self->enabled))
3628
+ {
2646
3629
  return PyObject_Call(self->object_proxy.wrapped, args, kwds);
2647
3630
  }
2648
3631
  }
2649
3632
 
2650
- if (!function_str) {
2651
- #if PY_MAJOR_VERSION >= 3
3633
+ if (!function_str)
3634
+ {
2652
3635
  function_str = PyUnicode_InternFromString("function");
2653
3636
  callable_str = PyUnicode_InternFromString("callable");
2654
- #else
2655
- function_str = PyString_InternFromString("function");
2656
- callable_str = PyString_InternFromString("callable");
2657
- #endif
2658
3637
  }
2659
3638
 
2660
3639
  /*
@@ -2665,7 +3644,8 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
2665
3644
  if (self->binding == function_str ||
2666
3645
  PyObject_RichCompareBool(self->binding, function_str, Py_EQ) == 1 ||
2667
3646
  self->binding == callable_str ||
2668
- PyObject_RichCompareBool(self->binding, callable_str, Py_EQ) == 1) {
3647
+ PyObject_RichCompareBool(self->binding, callable_str, Py_EQ) == 1)
3648
+ {
2669
3649
 
2670
3650
  // if (self->instance == Py_None) {
2671
3651
  // /*
@@ -2705,7 +3685,8 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
2705
3685
  // args = param_args;
2706
3686
  // }
2707
3687
 
2708
- if (self->instance == Py_None && PyTuple_Size(args) != 0) {
3688
+ if (self->instance == Py_None && PyTuple_Size(args) != 0)
3689
+ {
2709
3690
  /*
2710
3691
  * This situation can occur where someone is calling the
2711
3692
  * instancemethod via the class type and passing the
@@ -2720,7 +3701,8 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
2720
3701
  if (!instance)
2721
3702
  return NULL;
2722
3703
 
2723
- if (PyObject_IsInstance(instance, self->owner) == 1) {
3704
+ if (PyObject_IsInstance(instance, self->owner) == 1)
3705
+ {
2724
3706
  wrapped = PyObject_CallFunctionObjArgs(
2725
3707
  (PyObject *)&WraptPartialCallableObjectProxy_Type,
2726
3708
  self->object_proxy.wrapped, instance, NULL);
@@ -2730,25 +3712,32 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
2730
3712
 
2731
3713
  param_args = PyTuple_GetSlice(args, 1, PyTuple_Size(args));
2732
3714
 
2733
- if (!param_args) {
3715
+ if (!param_args)
3716
+ {
2734
3717
  Py_DECREF(wrapped);
2735
3718
  return NULL;
2736
3719
  }
2737
3720
 
2738
3721
  args = param_args;
2739
- } else {
3722
+ }
3723
+ else
3724
+ {
2740
3725
  instance = self->instance;
2741
3726
  }
2742
- } else {
3727
+ }
3728
+ else
3729
+ {
2743
3730
  instance = self->instance;
2744
3731
  }
2745
3732
 
2746
- if (!wrapped) {
3733
+ if (!wrapped)
3734
+ {
2747
3735
  Py_INCREF(self->object_proxy.wrapped);
2748
3736
  wrapped = self->object_proxy.wrapped;
2749
3737
  }
2750
3738
 
2751
- if (!kwds) {
3739
+ if (!kwds)
3740
+ {
2752
3741
  param_kwds = PyDict_New();
2753
3742
  kwds = param_kwds;
2754
3743
  }
@@ -2761,7 +3750,9 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
2761
3750
  Py_DECREF(wrapped);
2762
3751
 
2763
3752
  return result;
2764
- } else {
3753
+ }
3754
+ else
3755
+ {
2765
3756
  /*
2766
3757
  * As in this case we would be dealing with a classmethod or
2767
3758
  * staticmethod, then _self_instance will only tell us whether
@@ -2779,13 +3770,15 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
2779
3770
 
2780
3771
  instance = PyObject_GetAttrString(self->object_proxy.wrapped, "__self__");
2781
3772
 
2782
- if (!instance) {
3773
+ if (!instance)
3774
+ {
2783
3775
  PyErr_Clear();
2784
3776
  Py_INCREF(Py_None);
2785
3777
  instance = Py_None;
2786
3778
  }
2787
3779
 
2788
- if (!kwds) {
3780
+ if (!kwds)
3781
+ {
2789
3782
  param_kwds = PyDict_New();
2790
3783
  kwds = param_kwds;
2791
3784
  }
@@ -2857,7 +3850,8 @@ PyTypeObject WraptBoundFunctionWrapper_Type = {
2857
3850
  /* ------------------------------------------------------------------------- */
2858
3851
 
2859
3852
  static int WraptFunctionWrapper_init(WraptFunctionWrapperObject *self,
2860
- PyObject *args, PyObject *kwds) {
3853
+ PyObject *args, PyObject *kwds)
3854
+ {
2861
3855
  PyObject *wrapped = NULL;
2862
3856
  PyObject *wrapper = NULL;
2863
3857
  PyObject *enabled = Py_None;
@@ -2877,64 +3871,91 @@ static int WraptFunctionWrapper_init(WraptFunctionWrapperObject *self,
2877
3871
  char *const kwlist[] = {"wrapped", "wrapper", "enabled", NULL};
2878
3872
 
2879
3873
  if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO|O:FunctionWrapper", kwlist,
2880
- &wrapped, &wrapper, &enabled)) {
3874
+ &wrapped, &wrapper, &enabled))
3875
+ {
2881
3876
  return -1;
2882
3877
  }
2883
3878
 
2884
- if (!function_str) {
3879
+ if (!function_str)
3880
+ {
2885
3881
  function_str = PyUnicode_InternFromString("function");
2886
3882
  }
2887
3883
 
2888
- if (!classmethod_str) {
3884
+ if (!classmethod_str)
3885
+ {
2889
3886
  classmethod_str = PyUnicode_InternFromString("classmethod");
2890
3887
  }
2891
3888
 
2892
- if (!staticmethod_str) {
3889
+ if (!staticmethod_str)
3890
+ {
2893
3891
  staticmethod_str = PyUnicode_InternFromString("staticmethod");
2894
3892
  }
2895
3893
 
2896
- if (!callable_str) {
3894
+ if (!callable_str)
3895
+ {
2897
3896
  callable_str = PyUnicode_InternFromString("callable");
2898
3897
  }
2899
3898
 
2900
- if (!builtin_str) {
3899
+ if (!builtin_str)
3900
+ {
2901
3901
  builtin_str = PyUnicode_InternFromString("builtin");
2902
3902
  }
2903
3903
 
2904
- if (!class_str) {
3904
+ if (!class_str)
3905
+ {
2905
3906
  class_str = PyUnicode_InternFromString("class");
2906
3907
  }
2907
3908
 
2908
- if (!instancemethod_str) {
3909
+ if (!instancemethod_str)
3910
+ {
2909
3911
  instancemethod_str = PyUnicode_InternFromString("instancemethod");
2910
3912
  }
2911
3913
 
2912
3914
  if (PyObject_IsInstance(wrapped,
2913
- (PyObject *)&WraptFunctionWrapperBase_Type)) {
3915
+ (PyObject *)&WraptFunctionWrapperBase_Type))
3916
+ {
2914
3917
  binding = PyObject_GetAttrString(wrapped, "_self_binding");
2915
3918
  }
2916
3919
 
2917
- if (!binding) {
2918
- if (PyCFunction_Check(wrapped)) {
3920
+ if (!binding)
3921
+ {
3922
+ if (PyCFunction_Check(wrapped))
3923
+ {
2919
3924
  binding = builtin_str;
2920
- } else if (PyObject_IsInstance(wrapped, (PyObject *)&PyFunction_Type)) {
3925
+ }
3926
+ else if (PyObject_IsInstance(wrapped, (PyObject *)&PyFunction_Type))
3927
+ {
2921
3928
  binding = function_str;
2922
- } else if (PyObject_IsInstance(wrapped, (PyObject *)&PyClassMethod_Type)) {
3929
+ }
3930
+ else if (PyObject_IsInstance(wrapped, (PyObject *)&PyClassMethod_Type))
3931
+ {
2923
3932
  binding = classmethod_str;
2924
- } else if (PyObject_IsInstance(wrapped, (PyObject *)&PyType_Type)) {
3933
+ }
3934
+ else if (PyObject_IsInstance(wrapped, (PyObject *)&PyType_Type))
3935
+ {
2925
3936
  binding = class_str;
2926
- } else if (PyObject_IsInstance(wrapped, (PyObject *)&PyStaticMethod_Type)) {
3937
+ }
3938
+ else if (PyObject_IsInstance(wrapped, (PyObject *)&PyStaticMethod_Type))
3939
+ {
2927
3940
  binding = staticmethod_str;
2928
- } else if ((instance = PyObject_GetAttrString(wrapped, "__self__")) != 0) {
2929
- if (PyObject_IsInstance(instance, (PyObject *)&PyType_Type)) {
3941
+ }
3942
+ else if ((instance = PyObject_GetAttrString(wrapped, "__self__")) != 0)
3943
+ {
3944
+ if (PyObject_IsInstance(instance, (PyObject *)&PyType_Type))
3945
+ {
2930
3946
  binding = classmethod_str;
2931
- } else if (PyObject_IsInstance(wrapped, (PyObject *)&PyMethod_Type)) {
3947
+ }
3948
+ else if (PyObject_IsInstance(wrapped, (PyObject *)&PyMethod_Type))
3949
+ {
2932
3950
  binding = instancemethod_str;
2933
- } else
3951
+ }
3952
+ else
2934
3953
  binding = callable_str;
2935
3954
 
2936
3955
  Py_DECREF(instance);
2937
- } else {
3956
+ }
3957
+ else
3958
+ {
2938
3959
  PyErr_Clear();
2939
3960
 
2940
3961
  binding = callable_str;
@@ -3014,7 +4035,8 @@ static struct PyModuleDef moduledef = {
3014
4035
  NULL, /* m_free */
3015
4036
  };
3016
4037
 
3017
- static PyObject *moduleinit(void) {
4038
+ static PyObject *moduleinit(void)
4039
+ {
3018
4040
  PyObject *module;
3019
4041
 
3020
4042
  module = PyModule_Create(&moduledef);