wrapt 2.4.0.dev2__py3-none-any.whl → 2.4.0.dev3__py3-none-any.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/__init__.py +1 -1
- wrapt/_wrappers.c +1061 -659
- {wrapt-2.4.0.dev2.dist-info → wrapt-2.4.0.dev3.dist-info}/METADATA +1 -1
- {wrapt-2.4.0.dev2.dist-info → wrapt-2.4.0.dev3.dist-info}/RECORD +7 -7
- {wrapt-2.4.0.dev2.dist-info → wrapt-2.4.0.dev3.dist-info}/WHEEL +0 -0
- {wrapt-2.4.0.dev2.dist-info → wrapt-2.4.0.dev3.dist-info}/licenses/LICENSE +0 -0
- {wrapt-2.4.0.dev2.dist-info → wrapt-2.4.0.dev3.dist-info}/top_level.txt +0 -0
wrapt/_wrappers.c
CHANGED
|
@@ -43,10 +43,8 @@ typedef struct
|
|
|
43
43
|
static struct PyModuleDef moduledef;
|
|
44
44
|
|
|
45
45
|
/* Per-interpreter module state. Holds the heap type objects so that methods
|
|
46
|
-
* can reach them via PyType_GetModuleByDef without using static globals
|
|
47
|
-
*
|
|
48
|
-
* Cached interned strings will be added here in a later stage of the
|
|
49
|
-
* sub-interpreter / free-threading migration. */
|
|
46
|
+
* can reach them via PyType_GetModuleByDef without using static globals,
|
|
47
|
+
* along with the cached interned strings and exception type below. */
|
|
50
48
|
|
|
51
49
|
typedef struct
|
|
52
50
|
{
|
|
@@ -182,6 +180,39 @@ PyObject_GetOptionalAttrString(PyObject *obj, const char *name, PyObject **resul
|
|
|
182
180
|
}
|
|
183
181
|
#endif
|
|
184
182
|
|
|
183
|
+
/* Atomically read a PyObject field of an instance and return a new
|
|
184
|
+
* reference to it, or NULL if the field is NULL (no exception is set).
|
|
185
|
+
* The read and the incref are performed together inside the owning
|
|
186
|
+
* object's critical section so the incref cannot race a writer which
|
|
187
|
+
* has swapped in a new value and is releasing the old one. On builds
|
|
188
|
+
* with the GIL the critical section is a no-op and this reduces to a
|
|
189
|
+
* plain load and incref. This is deliberately used on all builds rather
|
|
190
|
+
* than only free-threaded ones, so that both build variants exercise
|
|
191
|
+
* the same reference lifetimes, and so that a field value can never be
|
|
192
|
+
* freed while still in use when code invoked while operating on the
|
|
193
|
+
* field mutates the instance. */
|
|
194
|
+
|
|
195
|
+
static inline PyObject *wrapt_acquire_field(PyObject *owner, PyObject **field)
|
|
196
|
+
{
|
|
197
|
+
PyObject *value = NULL;
|
|
198
|
+
|
|
199
|
+
Py_BEGIN_CRITICAL_SECTION(owner);
|
|
200
|
+
value = *field;
|
|
201
|
+
Py_XINCREF(value);
|
|
202
|
+
Py_END_CRITICAL_SECTION();
|
|
203
|
+
|
|
204
|
+
return value;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/* Convenience form for the common case of the wrapped object field. */
|
|
208
|
+
|
|
209
|
+
static inline PyObject *wrapt_acquire_wrapped(WraptObjectProxyObject *self)
|
|
210
|
+
{
|
|
211
|
+
return wrapt_acquire_field((PyObject *)self, &self->wrapped);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/* ------------------------------------------------------------------------- */
|
|
215
|
+
|
|
185
216
|
/* Get module state for the wrapt module given any type whose MRO includes
|
|
186
217
|
* one of our heap types. Returns NULL and sets an exception on miss. */
|
|
187
218
|
|
|
@@ -385,6 +416,48 @@ static int raise_uninitialized_wrapper_error(WraptObjectProxyObject *object)
|
|
|
385
416
|
|
|
386
417
|
/* ------------------------------------------------------------------------- */
|
|
387
418
|
|
|
419
|
+
/* Replace *op with a strong reference to the value to actually operate
|
|
420
|
+
* on: the wrapped object if *op is a wrapt proxy, else *op itself. On
|
|
421
|
+
* success the caller owns a reference to the replacement value and must
|
|
422
|
+
* release it after use. Returns -1 with an exception set, and *op
|
|
423
|
+
* unchanged, if *op is an uninitialized proxy which could not be
|
|
424
|
+
* lazily initialized. */
|
|
425
|
+
|
|
426
|
+
static int wrapt_unwrap_operand(PyObject **op)
|
|
427
|
+
{
|
|
428
|
+
WraptObjectProxyObject *proxy;
|
|
429
|
+
PyObject *wrapped;
|
|
430
|
+
|
|
431
|
+
if (!wrapt_is_proxy(*op))
|
|
432
|
+
{
|
|
433
|
+
Py_INCREF(*op);
|
|
434
|
+
return 0;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
proxy = (WraptObjectProxyObject *)*op;
|
|
438
|
+
|
|
439
|
+
if (!proxy->wrapped)
|
|
440
|
+
{
|
|
441
|
+
if (raise_uninitialized_wrapper_error(proxy) == -1)
|
|
442
|
+
return -1;
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
wrapped = wrapt_acquire_wrapped(proxy);
|
|
446
|
+
|
|
447
|
+
if (!wrapped)
|
|
448
|
+
{
|
|
449
|
+
PyErr_Format(PyExc_AttributeError,
|
|
450
|
+
"'%.100s' object has no attribute '__wrapped__'",
|
|
451
|
+
Py_TYPE(proxy)->tp_name);
|
|
452
|
+
return -1;
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
*op = wrapped;
|
|
456
|
+
return 0;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/* ------------------------------------------------------------------------- */
|
|
460
|
+
|
|
388
461
|
static PyObject *WraptObjectProxy_new(PyTypeObject *type, PyObject *args,
|
|
389
462
|
PyObject *kwds)
|
|
390
463
|
{
|
|
@@ -584,13 +657,20 @@ static PyObject *WraptObjectProxy_repr(WraptObjectProxyObject *self)
|
|
|
584
657
|
return NULL;
|
|
585
658
|
}
|
|
586
659
|
|
|
660
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
661
|
+
|
|
587
662
|
char self_addr[24], wrapped_addr[24];
|
|
588
663
|
snprintf(self_addr, sizeof(self_addr), "0x%zx", (Py_uintptr_t)self);
|
|
589
664
|
snprintf(wrapped_addr, sizeof(wrapped_addr), "0x%zx",
|
|
590
|
-
(Py_uintptr_t)
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
665
|
+
(Py_uintptr_t)wrapped);
|
|
666
|
+
PyObject *result = PyUnicode_FromFormat("<%s at %s for %s at %s>",
|
|
667
|
+
Py_TYPE(self)->tp_name, self_addr,
|
|
668
|
+
Py_TYPE(wrapped)->tp_name,
|
|
669
|
+
wrapped_addr);
|
|
670
|
+
|
|
671
|
+
Py_DECREF(wrapped);
|
|
672
|
+
|
|
673
|
+
return result;
|
|
594
674
|
}
|
|
595
675
|
|
|
596
676
|
/* ------------------------------------------------------------------------- */
|
|
@@ -603,7 +683,13 @@ static Py_hash_t WraptObjectProxy_hash(WraptObjectProxyObject *self)
|
|
|
603
683
|
return -1;
|
|
604
684
|
}
|
|
605
685
|
|
|
606
|
-
|
|
686
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
687
|
+
|
|
688
|
+
Py_hash_t result = PyObject_Hash(wrapped);
|
|
689
|
+
|
|
690
|
+
Py_DECREF(wrapped);
|
|
691
|
+
|
|
692
|
+
return result;
|
|
607
693
|
}
|
|
608
694
|
|
|
609
695
|
/* ------------------------------------------------------------------------- */
|
|
@@ -616,152 +702,118 @@ static PyObject *WraptObjectProxy_str(WraptObjectProxyObject *self)
|
|
|
616
702
|
return NULL;
|
|
617
703
|
}
|
|
618
704
|
|
|
619
|
-
|
|
705
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
706
|
+
|
|
707
|
+
PyObject *result = PyObject_Str(wrapped);
|
|
708
|
+
|
|
709
|
+
Py_DECREF(wrapped);
|
|
710
|
+
|
|
711
|
+
return result;
|
|
620
712
|
}
|
|
621
713
|
|
|
622
714
|
/* ------------------------------------------------------------------------- */
|
|
623
715
|
|
|
624
716
|
static PyObject *WraptObjectProxy_add(PyObject *o1, PyObject *o2)
|
|
625
717
|
{
|
|
626
|
-
if (
|
|
627
|
-
|
|
628
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
629
|
-
{
|
|
630
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
631
|
-
return NULL;
|
|
632
|
-
}
|
|
718
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
719
|
+
return NULL;
|
|
633
720
|
|
|
634
|
-
|
|
721
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
722
|
+
{
|
|
723
|
+
Py_DECREF(o1);
|
|
724
|
+
return NULL;
|
|
635
725
|
}
|
|
636
726
|
|
|
637
|
-
|
|
638
|
-
{
|
|
639
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
640
|
-
{
|
|
641
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
642
|
-
return NULL;
|
|
643
|
-
}
|
|
727
|
+
PyObject *result = PyNumber_Add(o1, o2);
|
|
644
728
|
|
|
645
|
-
|
|
646
|
-
|
|
729
|
+
Py_DECREF(o1);
|
|
730
|
+
Py_DECREF(o2);
|
|
647
731
|
|
|
648
|
-
return
|
|
732
|
+
return result;
|
|
649
733
|
}
|
|
650
734
|
|
|
651
735
|
/* ------------------------------------------------------------------------- */
|
|
652
736
|
|
|
653
737
|
static PyObject *WraptObjectProxy_subtract(PyObject *o1, PyObject *o2)
|
|
654
738
|
{
|
|
655
|
-
if (
|
|
656
|
-
|
|
657
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
658
|
-
{
|
|
659
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
660
|
-
return NULL;
|
|
661
|
-
}
|
|
739
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
740
|
+
return NULL;
|
|
662
741
|
|
|
663
|
-
|
|
742
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
743
|
+
{
|
|
744
|
+
Py_DECREF(o1);
|
|
745
|
+
return NULL;
|
|
664
746
|
}
|
|
665
747
|
|
|
666
|
-
|
|
667
|
-
{
|
|
668
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
669
|
-
{
|
|
670
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
671
|
-
return NULL;
|
|
672
|
-
}
|
|
748
|
+
PyObject *result = PyNumber_Subtract(o1, o2);
|
|
673
749
|
|
|
674
|
-
|
|
675
|
-
|
|
750
|
+
Py_DECREF(o1);
|
|
751
|
+
Py_DECREF(o2);
|
|
676
752
|
|
|
677
|
-
return
|
|
753
|
+
return result;
|
|
678
754
|
}
|
|
679
755
|
|
|
680
756
|
/* ------------------------------------------------------------------------- */
|
|
681
757
|
|
|
682
758
|
static PyObject *WraptObjectProxy_multiply(PyObject *o1, PyObject *o2)
|
|
683
759
|
{
|
|
684
|
-
if (
|
|
685
|
-
|
|
686
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
687
|
-
{
|
|
688
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
689
|
-
return NULL;
|
|
690
|
-
}
|
|
760
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
761
|
+
return NULL;
|
|
691
762
|
|
|
692
|
-
|
|
763
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
764
|
+
{
|
|
765
|
+
Py_DECREF(o1);
|
|
766
|
+
return NULL;
|
|
693
767
|
}
|
|
694
768
|
|
|
695
|
-
|
|
696
|
-
{
|
|
697
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
698
|
-
{
|
|
699
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
700
|
-
return NULL;
|
|
701
|
-
}
|
|
769
|
+
PyObject *result = PyNumber_Multiply(o1, o2);
|
|
702
770
|
|
|
703
|
-
|
|
704
|
-
|
|
771
|
+
Py_DECREF(o1);
|
|
772
|
+
Py_DECREF(o2);
|
|
705
773
|
|
|
706
|
-
return
|
|
774
|
+
return result;
|
|
707
775
|
}
|
|
708
776
|
|
|
709
777
|
/* ------------------------------------------------------------------------- */
|
|
710
778
|
|
|
711
779
|
static PyObject *WraptObjectProxy_remainder(PyObject *o1, PyObject *o2)
|
|
712
780
|
{
|
|
713
|
-
if (
|
|
714
|
-
|
|
715
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
716
|
-
{
|
|
717
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
718
|
-
return NULL;
|
|
719
|
-
}
|
|
781
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
782
|
+
return NULL;
|
|
720
783
|
|
|
721
|
-
|
|
784
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
785
|
+
{
|
|
786
|
+
Py_DECREF(o1);
|
|
787
|
+
return NULL;
|
|
722
788
|
}
|
|
723
789
|
|
|
724
|
-
|
|
725
|
-
{
|
|
726
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
727
|
-
{
|
|
728
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
729
|
-
return NULL;
|
|
730
|
-
}
|
|
790
|
+
PyObject *result = PyNumber_Remainder(o1, o2);
|
|
731
791
|
|
|
732
|
-
|
|
733
|
-
|
|
792
|
+
Py_DECREF(o1);
|
|
793
|
+
Py_DECREF(o2);
|
|
734
794
|
|
|
735
|
-
return
|
|
795
|
+
return result;
|
|
736
796
|
}
|
|
737
797
|
|
|
738
798
|
/* ------------------------------------------------------------------------- */
|
|
739
799
|
|
|
740
800
|
static PyObject *WraptObjectProxy_divmod(PyObject *o1, PyObject *o2)
|
|
741
801
|
{
|
|
742
|
-
if (
|
|
743
|
-
|
|
744
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
745
|
-
{
|
|
746
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
747
|
-
return NULL;
|
|
748
|
-
}
|
|
802
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
803
|
+
return NULL;
|
|
749
804
|
|
|
750
|
-
|
|
805
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
806
|
+
{
|
|
807
|
+
Py_DECREF(o1);
|
|
808
|
+
return NULL;
|
|
751
809
|
}
|
|
752
810
|
|
|
753
|
-
|
|
754
|
-
{
|
|
755
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
756
|
-
{
|
|
757
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
758
|
-
return NULL;
|
|
759
|
-
}
|
|
811
|
+
PyObject *result = PyNumber_Divmod(o1, o2);
|
|
760
812
|
|
|
761
|
-
|
|
762
|
-
|
|
813
|
+
Py_DECREF(o1);
|
|
814
|
+
Py_DECREF(o2);
|
|
763
815
|
|
|
764
|
-
return
|
|
816
|
+
return result;
|
|
765
817
|
}
|
|
766
818
|
|
|
767
819
|
/* ------------------------------------------------------------------------- */
|
|
@@ -781,29 +833,21 @@ static PyObject *WraptObjectProxy_power(PyObject *o1, PyObject *o2,
|
|
|
781
833
|
Py_RETURN_NOTIMPLEMENTED;
|
|
782
834
|
}
|
|
783
835
|
|
|
784
|
-
if (
|
|
785
|
-
|
|
786
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
787
|
-
{
|
|
788
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
789
|
-
return NULL;
|
|
790
|
-
}
|
|
836
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
837
|
+
return NULL;
|
|
791
838
|
|
|
792
|
-
|
|
839
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
840
|
+
{
|
|
841
|
+
Py_DECREF(o1);
|
|
842
|
+
return NULL;
|
|
793
843
|
}
|
|
794
844
|
|
|
795
|
-
|
|
796
|
-
{
|
|
797
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
798
|
-
{
|
|
799
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
800
|
-
return NULL;
|
|
801
|
-
}
|
|
845
|
+
PyObject *result = PyNumber_Power(o1, o2, modulo);
|
|
802
846
|
|
|
803
|
-
|
|
804
|
-
|
|
847
|
+
Py_DECREF(o1);
|
|
848
|
+
Py_DECREF(o2);
|
|
805
849
|
|
|
806
|
-
return
|
|
850
|
+
return result;
|
|
807
851
|
}
|
|
808
852
|
|
|
809
853
|
/* ------------------------------------------------------------------------- */
|
|
@@ -816,7 +860,13 @@ static PyObject *WraptObjectProxy_negative(WraptObjectProxyObject *self)
|
|
|
816
860
|
return NULL;
|
|
817
861
|
}
|
|
818
862
|
|
|
819
|
-
|
|
863
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
864
|
+
|
|
865
|
+
PyObject *result = PyNumber_Negative(wrapped);
|
|
866
|
+
|
|
867
|
+
Py_DECREF(wrapped);
|
|
868
|
+
|
|
869
|
+
return result;
|
|
820
870
|
}
|
|
821
871
|
|
|
822
872
|
/* ------------------------------------------------------------------------- */
|
|
@@ -829,7 +879,13 @@ static PyObject *WraptObjectProxy_positive(WraptObjectProxyObject *self)
|
|
|
829
879
|
return NULL;
|
|
830
880
|
}
|
|
831
881
|
|
|
832
|
-
|
|
882
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
883
|
+
|
|
884
|
+
PyObject *result = PyNumber_Positive(wrapped);
|
|
885
|
+
|
|
886
|
+
Py_DECREF(wrapped);
|
|
887
|
+
|
|
888
|
+
return result;
|
|
833
889
|
}
|
|
834
890
|
|
|
835
891
|
/* ------------------------------------------------------------------------- */
|
|
@@ -842,7 +898,13 @@ static PyObject *WraptObjectProxy_absolute(WraptObjectProxyObject *self)
|
|
|
842
898
|
return NULL;
|
|
843
899
|
}
|
|
844
900
|
|
|
845
|
-
|
|
901
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
902
|
+
|
|
903
|
+
PyObject *result = PyNumber_Absolute(wrapped);
|
|
904
|
+
|
|
905
|
+
Py_DECREF(wrapped);
|
|
906
|
+
|
|
907
|
+
return result;
|
|
846
908
|
}
|
|
847
909
|
|
|
848
910
|
/* ------------------------------------------------------------------------- */
|
|
@@ -855,7 +917,13 @@ static int WraptObjectProxy_bool(WraptObjectProxyObject *self)
|
|
|
855
917
|
return -1;
|
|
856
918
|
}
|
|
857
919
|
|
|
858
|
-
|
|
920
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
921
|
+
|
|
922
|
+
int result = PyObject_IsTrue(wrapped);
|
|
923
|
+
|
|
924
|
+
Py_DECREF(wrapped);
|
|
925
|
+
|
|
926
|
+
return result;
|
|
859
927
|
}
|
|
860
928
|
|
|
861
929
|
/* ------------------------------------------------------------------------- */
|
|
@@ -868,152 +936,118 @@ static PyObject *WraptObjectProxy_invert(WraptObjectProxyObject *self)
|
|
|
868
936
|
return NULL;
|
|
869
937
|
}
|
|
870
938
|
|
|
871
|
-
|
|
939
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
940
|
+
|
|
941
|
+
PyObject *result = PyNumber_Invert(wrapped);
|
|
942
|
+
|
|
943
|
+
Py_DECREF(wrapped);
|
|
944
|
+
|
|
945
|
+
return result;
|
|
872
946
|
}
|
|
873
947
|
|
|
874
948
|
/* ------------------------------------------------------------------------- */
|
|
875
949
|
|
|
876
950
|
static PyObject *WraptObjectProxy_lshift(PyObject *o1, PyObject *o2)
|
|
877
951
|
{
|
|
878
|
-
if (
|
|
879
|
-
|
|
880
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
881
|
-
{
|
|
882
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
883
|
-
return NULL;
|
|
884
|
-
}
|
|
952
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
953
|
+
return NULL;
|
|
885
954
|
|
|
886
|
-
|
|
955
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
956
|
+
{
|
|
957
|
+
Py_DECREF(o1);
|
|
958
|
+
return NULL;
|
|
887
959
|
}
|
|
888
960
|
|
|
889
|
-
|
|
890
|
-
{
|
|
891
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
892
|
-
{
|
|
893
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
894
|
-
return NULL;
|
|
895
|
-
}
|
|
961
|
+
PyObject *result = PyNumber_Lshift(o1, o2);
|
|
896
962
|
|
|
897
|
-
|
|
898
|
-
|
|
963
|
+
Py_DECREF(o1);
|
|
964
|
+
Py_DECREF(o2);
|
|
899
965
|
|
|
900
|
-
return
|
|
966
|
+
return result;
|
|
901
967
|
}
|
|
902
968
|
|
|
903
969
|
/* ------------------------------------------------------------------------- */
|
|
904
970
|
|
|
905
971
|
static PyObject *WraptObjectProxy_rshift(PyObject *o1, PyObject *o2)
|
|
906
972
|
{
|
|
907
|
-
if (
|
|
908
|
-
|
|
909
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
910
|
-
{
|
|
911
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
912
|
-
return NULL;
|
|
913
|
-
}
|
|
973
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
974
|
+
return NULL;
|
|
914
975
|
|
|
915
|
-
|
|
976
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
977
|
+
{
|
|
978
|
+
Py_DECREF(o1);
|
|
979
|
+
return NULL;
|
|
916
980
|
}
|
|
917
981
|
|
|
918
|
-
|
|
919
|
-
{
|
|
920
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
921
|
-
{
|
|
922
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
923
|
-
return NULL;
|
|
924
|
-
}
|
|
982
|
+
PyObject *result = PyNumber_Rshift(o1, o2);
|
|
925
983
|
|
|
926
|
-
|
|
927
|
-
|
|
984
|
+
Py_DECREF(o1);
|
|
985
|
+
Py_DECREF(o2);
|
|
928
986
|
|
|
929
|
-
return
|
|
987
|
+
return result;
|
|
930
988
|
}
|
|
931
989
|
|
|
932
990
|
/* ------------------------------------------------------------------------- */
|
|
933
991
|
|
|
934
992
|
static PyObject *WraptObjectProxy_and(PyObject *o1, PyObject *o2)
|
|
935
993
|
{
|
|
936
|
-
if (
|
|
937
|
-
|
|
938
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
939
|
-
{
|
|
940
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
941
|
-
return NULL;
|
|
942
|
-
}
|
|
994
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
995
|
+
return NULL;
|
|
943
996
|
|
|
944
|
-
|
|
997
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
998
|
+
{
|
|
999
|
+
Py_DECREF(o1);
|
|
1000
|
+
return NULL;
|
|
945
1001
|
}
|
|
946
1002
|
|
|
947
|
-
|
|
948
|
-
{
|
|
949
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
950
|
-
{
|
|
951
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
952
|
-
return NULL;
|
|
953
|
-
}
|
|
1003
|
+
PyObject *result = PyNumber_And(o1, o2);
|
|
954
1004
|
|
|
955
|
-
|
|
956
|
-
|
|
1005
|
+
Py_DECREF(o1);
|
|
1006
|
+
Py_DECREF(o2);
|
|
957
1007
|
|
|
958
|
-
return
|
|
1008
|
+
return result;
|
|
959
1009
|
}
|
|
960
1010
|
|
|
961
1011
|
/* ------------------------------------------------------------------------- */
|
|
962
1012
|
|
|
963
1013
|
static PyObject *WraptObjectProxy_xor(PyObject *o1, PyObject *o2)
|
|
964
1014
|
{
|
|
965
|
-
if (
|
|
966
|
-
|
|
967
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
968
|
-
{
|
|
969
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
970
|
-
return NULL;
|
|
971
|
-
}
|
|
1015
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
1016
|
+
return NULL;
|
|
972
1017
|
|
|
973
|
-
|
|
1018
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
1019
|
+
{
|
|
1020
|
+
Py_DECREF(o1);
|
|
1021
|
+
return NULL;
|
|
974
1022
|
}
|
|
975
1023
|
|
|
976
|
-
|
|
977
|
-
{
|
|
978
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
979
|
-
{
|
|
980
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
981
|
-
return NULL;
|
|
982
|
-
}
|
|
1024
|
+
PyObject *result = PyNumber_Xor(o1, o2);
|
|
983
1025
|
|
|
984
|
-
|
|
985
|
-
|
|
1026
|
+
Py_DECREF(o1);
|
|
1027
|
+
Py_DECREF(o2);
|
|
986
1028
|
|
|
987
|
-
return
|
|
1029
|
+
return result;
|
|
988
1030
|
}
|
|
989
1031
|
|
|
990
1032
|
/* ------------------------------------------------------------------------- */
|
|
991
1033
|
|
|
992
1034
|
static PyObject *WraptObjectProxy_or(PyObject *o1, PyObject *o2)
|
|
993
1035
|
{
|
|
994
|
-
if (
|
|
995
|
-
|
|
996
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
997
|
-
{
|
|
998
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
999
|
-
return NULL;
|
|
1000
|
-
}
|
|
1036
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
1037
|
+
return NULL;
|
|
1001
1038
|
|
|
1002
|
-
|
|
1039
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
1040
|
+
{
|
|
1041
|
+
Py_DECREF(o1);
|
|
1042
|
+
return NULL;
|
|
1003
1043
|
}
|
|
1004
1044
|
|
|
1005
|
-
|
|
1006
|
-
{
|
|
1007
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
1008
|
-
{
|
|
1009
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
1010
|
-
return NULL;
|
|
1011
|
-
}
|
|
1045
|
+
PyObject *result = PyNumber_Or(o1, o2);
|
|
1012
1046
|
|
|
1013
|
-
|
|
1014
|
-
|
|
1047
|
+
Py_DECREF(o1);
|
|
1048
|
+
Py_DECREF(o2);
|
|
1015
1049
|
|
|
1016
|
-
return
|
|
1050
|
+
return result;
|
|
1017
1051
|
}
|
|
1018
1052
|
|
|
1019
1053
|
/* ------------------------------------------------------------------------- */
|
|
@@ -1026,7 +1060,13 @@ static PyObject *WraptObjectProxy_long(WraptObjectProxyObject *self)
|
|
|
1026
1060
|
return NULL;
|
|
1027
1061
|
}
|
|
1028
1062
|
|
|
1029
|
-
|
|
1063
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1064
|
+
|
|
1065
|
+
PyObject *result = PyNumber_Long(wrapped);
|
|
1066
|
+
|
|
1067
|
+
Py_DECREF(wrapped);
|
|
1068
|
+
|
|
1069
|
+
return result;
|
|
1030
1070
|
}
|
|
1031
1071
|
|
|
1032
1072
|
/* ------------------------------------------------------------------------- */
|
|
@@ -1039,7 +1079,13 @@ static PyObject *WraptObjectProxy_float(WraptObjectProxyObject *self)
|
|
|
1039
1079
|
return NULL;
|
|
1040
1080
|
}
|
|
1041
1081
|
|
|
1042
|
-
|
|
1082
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1083
|
+
|
|
1084
|
+
PyObject *result = PyNumber_Float(wrapped);
|
|
1085
|
+
|
|
1086
|
+
Py_DECREF(wrapped);
|
|
1087
|
+
|
|
1088
|
+
return result;
|
|
1043
1089
|
}
|
|
1044
1090
|
|
|
1045
1091
|
/* ------------------------------------------------------------------------- */
|
|
@@ -1055,25 +1101,26 @@ static PyObject *WraptObjectProxy_inplace_add(WraptObjectProxyObject *self,
|
|
|
1055
1101
|
return NULL;
|
|
1056
1102
|
}
|
|
1057
1103
|
|
|
1058
|
-
if (
|
|
1059
|
-
|
|
1060
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1061
|
-
{
|
|
1062
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1063
|
-
return NULL;
|
|
1064
|
-
}
|
|
1104
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1105
|
+
return NULL;
|
|
1065
1106
|
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1107
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1068
1108
|
|
|
1069
1109
|
PyObject *attr;
|
|
1070
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1110
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__iadd__", &attr);
|
|
1071
1111
|
Py_XDECREF(attr);
|
|
1072
1112
|
if (rc < 0)
|
|
1113
|
+
{
|
|
1114
|
+
Py_DECREF(wrapped);
|
|
1115
|
+
Py_DECREF(other);
|
|
1073
1116
|
return NULL;
|
|
1117
|
+
}
|
|
1074
1118
|
if (rc)
|
|
1075
1119
|
{
|
|
1076
|
-
object = PyNumber_InPlaceAdd(
|
|
1120
|
+
object = PyNumber_InPlaceAdd(wrapped, other);
|
|
1121
|
+
|
|
1122
|
+
Py_DECREF(wrapped);
|
|
1123
|
+
Py_DECREF(other);
|
|
1077
1124
|
|
|
1078
1125
|
if (!object)
|
|
1079
1126
|
return NULL;
|
|
@@ -1094,7 +1141,10 @@ static PyObject *WraptObjectProxy_inplace_add(WraptObjectProxyObject *self,
|
|
|
1094
1141
|
}
|
|
1095
1142
|
else
|
|
1096
1143
|
{
|
|
1097
|
-
PyObject *result = PyNumber_Add(
|
|
1144
|
+
PyObject *result = PyNumber_Add(wrapped, other);
|
|
1145
|
+
|
|
1146
|
+
Py_DECREF(wrapped);
|
|
1147
|
+
Py_DECREF(other);
|
|
1098
1148
|
|
|
1099
1149
|
if (!result)
|
|
1100
1150
|
return NULL;
|
|
@@ -1146,25 +1196,26 @@ static PyObject *WraptObjectProxy_inplace_subtract(WraptObjectProxyObject *self,
|
|
|
1146
1196
|
return NULL;
|
|
1147
1197
|
}
|
|
1148
1198
|
|
|
1149
|
-
if (
|
|
1150
|
-
|
|
1151
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1152
|
-
{
|
|
1153
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1154
|
-
return NULL;
|
|
1155
|
-
}
|
|
1199
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1200
|
+
return NULL;
|
|
1156
1201
|
|
|
1157
|
-
|
|
1158
|
-
}
|
|
1202
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1159
1203
|
|
|
1160
1204
|
PyObject *attr;
|
|
1161
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1205
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__isub__", &attr);
|
|
1162
1206
|
Py_XDECREF(attr);
|
|
1163
1207
|
if (rc < 0)
|
|
1208
|
+
{
|
|
1209
|
+
Py_DECREF(wrapped);
|
|
1210
|
+
Py_DECREF(other);
|
|
1164
1211
|
return NULL;
|
|
1212
|
+
}
|
|
1165
1213
|
if (rc)
|
|
1166
1214
|
{
|
|
1167
|
-
object = PyNumber_InPlaceSubtract(
|
|
1215
|
+
object = PyNumber_InPlaceSubtract(wrapped, other);
|
|
1216
|
+
|
|
1217
|
+
Py_DECREF(wrapped);
|
|
1218
|
+
Py_DECREF(other);
|
|
1168
1219
|
|
|
1169
1220
|
if (!object)
|
|
1170
1221
|
return NULL;
|
|
@@ -1178,7 +1229,10 @@ static PyObject *WraptObjectProxy_inplace_subtract(WraptObjectProxyObject *self,
|
|
|
1178
1229
|
}
|
|
1179
1230
|
else
|
|
1180
1231
|
{
|
|
1181
|
-
PyObject *result = PyNumber_Subtract(
|
|
1232
|
+
PyObject *result = PyNumber_Subtract(wrapped, other);
|
|
1233
|
+
|
|
1234
|
+
Py_DECREF(wrapped);
|
|
1235
|
+
Py_DECREF(other);
|
|
1182
1236
|
|
|
1183
1237
|
if (!result)
|
|
1184
1238
|
return NULL;
|
|
@@ -1230,25 +1284,26 @@ static PyObject *WraptObjectProxy_inplace_multiply(WraptObjectProxyObject *self,
|
|
|
1230
1284
|
return NULL;
|
|
1231
1285
|
}
|
|
1232
1286
|
|
|
1233
|
-
if (
|
|
1234
|
-
|
|
1235
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1236
|
-
{
|
|
1237
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1238
|
-
return NULL;
|
|
1239
|
-
}
|
|
1287
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1288
|
+
return NULL;
|
|
1240
1289
|
|
|
1241
|
-
|
|
1242
|
-
}
|
|
1290
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1243
1291
|
|
|
1244
1292
|
PyObject *attr;
|
|
1245
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1293
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__imul__", &attr);
|
|
1246
1294
|
Py_XDECREF(attr);
|
|
1247
1295
|
if (rc < 0)
|
|
1296
|
+
{
|
|
1297
|
+
Py_DECREF(wrapped);
|
|
1298
|
+
Py_DECREF(other);
|
|
1248
1299
|
return NULL;
|
|
1300
|
+
}
|
|
1249
1301
|
if (rc)
|
|
1250
1302
|
{
|
|
1251
|
-
object = PyNumber_InPlaceMultiply(
|
|
1303
|
+
object = PyNumber_InPlaceMultiply(wrapped, other);
|
|
1304
|
+
|
|
1305
|
+
Py_DECREF(wrapped);
|
|
1306
|
+
Py_DECREF(other);
|
|
1252
1307
|
|
|
1253
1308
|
if (!object)
|
|
1254
1309
|
return NULL;
|
|
@@ -1262,7 +1317,10 @@ static PyObject *WraptObjectProxy_inplace_multiply(WraptObjectProxyObject *self,
|
|
|
1262
1317
|
}
|
|
1263
1318
|
else
|
|
1264
1319
|
{
|
|
1265
|
-
PyObject *result = PyNumber_Multiply(
|
|
1320
|
+
PyObject *result = PyNumber_Multiply(wrapped, other);
|
|
1321
|
+
|
|
1322
|
+
Py_DECREF(wrapped);
|
|
1323
|
+
Py_DECREF(other);
|
|
1266
1324
|
|
|
1267
1325
|
if (!result)
|
|
1268
1326
|
return NULL;
|
|
@@ -1315,25 +1373,26 @@ WraptObjectProxy_inplace_remainder(WraptObjectProxyObject *self,
|
|
|
1315
1373
|
return NULL;
|
|
1316
1374
|
}
|
|
1317
1375
|
|
|
1318
|
-
if (
|
|
1319
|
-
|
|
1320
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1321
|
-
{
|
|
1322
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1323
|
-
return NULL;
|
|
1324
|
-
}
|
|
1376
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1377
|
+
return NULL;
|
|
1325
1378
|
|
|
1326
|
-
|
|
1327
|
-
}
|
|
1379
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1328
1380
|
|
|
1329
1381
|
PyObject *attr;
|
|
1330
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1382
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__imod__", &attr);
|
|
1331
1383
|
Py_XDECREF(attr);
|
|
1332
1384
|
if (rc < 0)
|
|
1385
|
+
{
|
|
1386
|
+
Py_DECREF(wrapped);
|
|
1387
|
+
Py_DECREF(other);
|
|
1333
1388
|
return NULL;
|
|
1389
|
+
}
|
|
1334
1390
|
if (rc)
|
|
1335
1391
|
{
|
|
1336
|
-
object = PyNumber_InPlaceRemainder(
|
|
1392
|
+
object = PyNumber_InPlaceRemainder(wrapped, other);
|
|
1393
|
+
|
|
1394
|
+
Py_DECREF(wrapped);
|
|
1395
|
+
Py_DECREF(other);
|
|
1337
1396
|
|
|
1338
1397
|
if (!object)
|
|
1339
1398
|
return NULL;
|
|
@@ -1347,7 +1406,10 @@ WraptObjectProxy_inplace_remainder(WraptObjectProxyObject *self,
|
|
|
1347
1406
|
}
|
|
1348
1407
|
else
|
|
1349
1408
|
{
|
|
1350
|
-
PyObject *result = PyNumber_Remainder(
|
|
1409
|
+
PyObject *result = PyNumber_Remainder(wrapped, other);
|
|
1410
|
+
|
|
1411
|
+
Py_DECREF(wrapped);
|
|
1412
|
+
Py_DECREF(other);
|
|
1351
1413
|
|
|
1352
1414
|
if (!result)
|
|
1353
1415
|
return NULL;
|
|
@@ -1400,25 +1462,26 @@ static PyObject *WraptObjectProxy_inplace_power(WraptObjectProxyObject *self,
|
|
|
1400
1462
|
return NULL;
|
|
1401
1463
|
}
|
|
1402
1464
|
|
|
1403
|
-
if (
|
|
1404
|
-
|
|
1405
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1406
|
-
{
|
|
1407
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1408
|
-
return NULL;
|
|
1409
|
-
}
|
|
1465
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1466
|
+
return NULL;
|
|
1410
1467
|
|
|
1411
|
-
|
|
1412
|
-
}
|
|
1468
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1413
1469
|
|
|
1414
1470
|
PyObject *attr;
|
|
1415
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1471
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__ipow__", &attr);
|
|
1416
1472
|
Py_XDECREF(attr);
|
|
1417
1473
|
if (rc < 0)
|
|
1474
|
+
{
|
|
1475
|
+
Py_DECREF(wrapped);
|
|
1476
|
+
Py_DECREF(other);
|
|
1418
1477
|
return NULL;
|
|
1478
|
+
}
|
|
1419
1479
|
if (rc)
|
|
1420
1480
|
{
|
|
1421
|
-
object = PyNumber_InPlacePower(
|
|
1481
|
+
object = PyNumber_InPlacePower(wrapped, other, modulo);
|
|
1482
|
+
|
|
1483
|
+
Py_DECREF(wrapped);
|
|
1484
|
+
Py_DECREF(other);
|
|
1422
1485
|
|
|
1423
1486
|
if (!object)
|
|
1424
1487
|
return NULL;
|
|
@@ -1432,7 +1495,10 @@ static PyObject *WraptObjectProxy_inplace_power(WraptObjectProxyObject *self,
|
|
|
1432
1495
|
}
|
|
1433
1496
|
else
|
|
1434
1497
|
{
|
|
1435
|
-
PyObject *result = PyNumber_Power(
|
|
1498
|
+
PyObject *result = PyNumber_Power(wrapped, other, modulo);
|
|
1499
|
+
|
|
1500
|
+
Py_DECREF(wrapped);
|
|
1501
|
+
Py_DECREF(other);
|
|
1436
1502
|
|
|
1437
1503
|
if (!result)
|
|
1438
1504
|
return NULL;
|
|
@@ -1484,25 +1550,26 @@ static PyObject *WraptObjectProxy_inplace_lshift(WraptObjectProxyObject *self,
|
|
|
1484
1550
|
return NULL;
|
|
1485
1551
|
}
|
|
1486
1552
|
|
|
1487
|
-
if (
|
|
1488
|
-
|
|
1489
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1490
|
-
{
|
|
1491
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1492
|
-
return NULL;
|
|
1493
|
-
}
|
|
1553
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1554
|
+
return NULL;
|
|
1494
1555
|
|
|
1495
|
-
|
|
1496
|
-
}
|
|
1556
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1497
1557
|
|
|
1498
1558
|
PyObject *attr;
|
|
1499
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1559
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__ilshift__", &attr);
|
|
1500
1560
|
Py_XDECREF(attr);
|
|
1501
1561
|
if (rc < 0)
|
|
1562
|
+
{
|
|
1563
|
+
Py_DECREF(wrapped);
|
|
1564
|
+
Py_DECREF(other);
|
|
1502
1565
|
return NULL;
|
|
1566
|
+
}
|
|
1503
1567
|
if (rc)
|
|
1504
1568
|
{
|
|
1505
|
-
object = PyNumber_InPlaceLshift(
|
|
1569
|
+
object = PyNumber_InPlaceLshift(wrapped, other);
|
|
1570
|
+
|
|
1571
|
+
Py_DECREF(wrapped);
|
|
1572
|
+
Py_DECREF(other);
|
|
1506
1573
|
|
|
1507
1574
|
if (!object)
|
|
1508
1575
|
return NULL;
|
|
@@ -1516,7 +1583,10 @@ static PyObject *WraptObjectProxy_inplace_lshift(WraptObjectProxyObject *self,
|
|
|
1516
1583
|
}
|
|
1517
1584
|
else
|
|
1518
1585
|
{
|
|
1519
|
-
PyObject *result = PyNumber_Lshift(
|
|
1586
|
+
PyObject *result = PyNumber_Lshift(wrapped, other);
|
|
1587
|
+
|
|
1588
|
+
Py_DECREF(wrapped);
|
|
1589
|
+
Py_DECREF(other);
|
|
1520
1590
|
|
|
1521
1591
|
if (!result)
|
|
1522
1592
|
return NULL;
|
|
@@ -1568,25 +1638,26 @@ static PyObject *WraptObjectProxy_inplace_rshift(WraptObjectProxyObject *self,
|
|
|
1568
1638
|
return NULL;
|
|
1569
1639
|
}
|
|
1570
1640
|
|
|
1571
|
-
if (
|
|
1572
|
-
|
|
1573
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1574
|
-
{
|
|
1575
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1576
|
-
return NULL;
|
|
1577
|
-
}
|
|
1641
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1642
|
+
return NULL;
|
|
1578
1643
|
|
|
1579
|
-
|
|
1580
|
-
}
|
|
1644
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1581
1645
|
|
|
1582
1646
|
PyObject *attr;
|
|
1583
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1647
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__irshift__", &attr);
|
|
1584
1648
|
Py_XDECREF(attr);
|
|
1585
1649
|
if (rc < 0)
|
|
1650
|
+
{
|
|
1651
|
+
Py_DECREF(wrapped);
|
|
1652
|
+
Py_DECREF(other);
|
|
1586
1653
|
return NULL;
|
|
1654
|
+
}
|
|
1587
1655
|
if (rc)
|
|
1588
1656
|
{
|
|
1589
|
-
object = PyNumber_InPlaceRshift(
|
|
1657
|
+
object = PyNumber_InPlaceRshift(wrapped, other);
|
|
1658
|
+
|
|
1659
|
+
Py_DECREF(wrapped);
|
|
1660
|
+
Py_DECREF(other);
|
|
1590
1661
|
|
|
1591
1662
|
if (!object)
|
|
1592
1663
|
return NULL;
|
|
@@ -1600,7 +1671,10 @@ static PyObject *WraptObjectProxy_inplace_rshift(WraptObjectProxyObject *self,
|
|
|
1600
1671
|
}
|
|
1601
1672
|
else
|
|
1602
1673
|
{
|
|
1603
|
-
PyObject *result = PyNumber_Rshift(
|
|
1674
|
+
PyObject *result = PyNumber_Rshift(wrapped, other);
|
|
1675
|
+
|
|
1676
|
+
Py_DECREF(wrapped);
|
|
1677
|
+
Py_DECREF(other);
|
|
1604
1678
|
|
|
1605
1679
|
if (!result)
|
|
1606
1680
|
return NULL;
|
|
@@ -1652,25 +1726,26 @@ static PyObject *WraptObjectProxy_inplace_and(WraptObjectProxyObject *self,
|
|
|
1652
1726
|
return NULL;
|
|
1653
1727
|
}
|
|
1654
1728
|
|
|
1655
|
-
if (
|
|
1656
|
-
|
|
1657
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1658
|
-
{
|
|
1659
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1660
|
-
return NULL;
|
|
1661
|
-
}
|
|
1729
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1730
|
+
return NULL;
|
|
1662
1731
|
|
|
1663
|
-
|
|
1664
|
-
}
|
|
1732
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1665
1733
|
|
|
1666
1734
|
PyObject *attr;
|
|
1667
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1735
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__iand__", &attr);
|
|
1668
1736
|
Py_XDECREF(attr);
|
|
1669
1737
|
if (rc < 0)
|
|
1738
|
+
{
|
|
1739
|
+
Py_DECREF(wrapped);
|
|
1740
|
+
Py_DECREF(other);
|
|
1670
1741
|
return NULL;
|
|
1742
|
+
}
|
|
1671
1743
|
if (rc)
|
|
1672
1744
|
{
|
|
1673
|
-
object = PyNumber_InPlaceAnd(
|
|
1745
|
+
object = PyNumber_InPlaceAnd(wrapped, other);
|
|
1746
|
+
|
|
1747
|
+
Py_DECREF(wrapped);
|
|
1748
|
+
Py_DECREF(other);
|
|
1674
1749
|
|
|
1675
1750
|
if (!object)
|
|
1676
1751
|
return NULL;
|
|
@@ -1684,7 +1759,10 @@ static PyObject *WraptObjectProxy_inplace_and(WraptObjectProxyObject *self,
|
|
|
1684
1759
|
}
|
|
1685
1760
|
else
|
|
1686
1761
|
{
|
|
1687
|
-
PyObject *result = PyNumber_And(
|
|
1762
|
+
PyObject *result = PyNumber_And(wrapped, other);
|
|
1763
|
+
|
|
1764
|
+
Py_DECREF(wrapped);
|
|
1765
|
+
Py_DECREF(other);
|
|
1688
1766
|
|
|
1689
1767
|
if (!result)
|
|
1690
1768
|
return NULL;
|
|
@@ -1736,25 +1814,26 @@ static PyObject *WraptObjectProxy_inplace_xor(WraptObjectProxyObject *self,
|
|
|
1736
1814
|
return NULL;
|
|
1737
1815
|
}
|
|
1738
1816
|
|
|
1739
|
-
if (
|
|
1740
|
-
|
|
1741
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1742
|
-
{
|
|
1743
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1744
|
-
return NULL;
|
|
1745
|
-
}
|
|
1817
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1818
|
+
return NULL;
|
|
1746
1819
|
|
|
1747
|
-
|
|
1748
|
-
}
|
|
1820
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1749
1821
|
|
|
1750
1822
|
PyObject *attr;
|
|
1751
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1823
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__ixor__", &attr);
|
|
1752
1824
|
Py_XDECREF(attr);
|
|
1753
1825
|
if (rc < 0)
|
|
1826
|
+
{
|
|
1827
|
+
Py_DECREF(wrapped);
|
|
1828
|
+
Py_DECREF(other);
|
|
1754
1829
|
return NULL;
|
|
1830
|
+
}
|
|
1755
1831
|
if (rc)
|
|
1756
1832
|
{
|
|
1757
|
-
object = PyNumber_InPlaceXor(
|
|
1833
|
+
object = PyNumber_InPlaceXor(wrapped, other);
|
|
1834
|
+
|
|
1835
|
+
Py_DECREF(wrapped);
|
|
1836
|
+
Py_DECREF(other);
|
|
1758
1837
|
|
|
1759
1838
|
if (!object)
|
|
1760
1839
|
return NULL;
|
|
@@ -1768,7 +1847,10 @@ static PyObject *WraptObjectProxy_inplace_xor(WraptObjectProxyObject *self,
|
|
|
1768
1847
|
}
|
|
1769
1848
|
else
|
|
1770
1849
|
{
|
|
1771
|
-
PyObject *result = PyNumber_Xor(
|
|
1850
|
+
PyObject *result = PyNumber_Xor(wrapped, other);
|
|
1851
|
+
|
|
1852
|
+
Py_DECREF(wrapped);
|
|
1853
|
+
Py_DECREF(other);
|
|
1772
1854
|
|
|
1773
1855
|
if (!result)
|
|
1774
1856
|
return NULL;
|
|
@@ -1820,25 +1902,26 @@ static PyObject *WraptObjectProxy_inplace_or(WraptObjectProxyObject *self,
|
|
|
1820
1902
|
return NULL;
|
|
1821
1903
|
}
|
|
1822
1904
|
|
|
1823
|
-
if (
|
|
1824
|
-
|
|
1825
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1826
|
-
{
|
|
1827
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1828
|
-
return NULL;
|
|
1829
|
-
}
|
|
1905
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
1906
|
+
return NULL;
|
|
1830
1907
|
|
|
1831
|
-
|
|
1832
|
-
}
|
|
1908
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1833
1909
|
|
|
1834
1910
|
PyObject *attr;
|
|
1835
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
1911
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__ior__", &attr);
|
|
1836
1912
|
Py_XDECREF(attr);
|
|
1837
1913
|
if (rc < 0)
|
|
1914
|
+
{
|
|
1915
|
+
Py_DECREF(wrapped);
|
|
1916
|
+
Py_DECREF(other);
|
|
1838
1917
|
return NULL;
|
|
1918
|
+
}
|
|
1839
1919
|
if (rc)
|
|
1840
1920
|
{
|
|
1841
|
-
object = PyNumber_InPlaceOr(
|
|
1921
|
+
object = PyNumber_InPlaceOr(wrapped, other);
|
|
1922
|
+
|
|
1923
|
+
Py_DECREF(wrapped);
|
|
1924
|
+
Py_DECREF(other);
|
|
1842
1925
|
|
|
1843
1926
|
if (!object)
|
|
1844
1927
|
return NULL;
|
|
@@ -1852,7 +1935,10 @@ static PyObject *WraptObjectProxy_inplace_or(WraptObjectProxyObject *self,
|
|
|
1852
1935
|
}
|
|
1853
1936
|
else
|
|
1854
1937
|
{
|
|
1855
|
-
PyObject *result = PyNumber_Or(
|
|
1938
|
+
PyObject *result = PyNumber_Or(wrapped, other);
|
|
1939
|
+
|
|
1940
|
+
Py_DECREF(wrapped);
|
|
1941
|
+
Py_DECREF(other);
|
|
1856
1942
|
|
|
1857
1943
|
if (!result)
|
|
1858
1944
|
return NULL;
|
|
@@ -1895,58 +1981,42 @@ static PyObject *WraptObjectProxy_inplace_or(WraptObjectProxyObject *self,
|
|
|
1895
1981
|
|
|
1896
1982
|
static PyObject *WraptObjectProxy_floor_divide(PyObject *o1, PyObject *o2)
|
|
1897
1983
|
{
|
|
1898
|
-
if (
|
|
1899
|
-
|
|
1900
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
1901
|
-
{
|
|
1902
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
1903
|
-
return NULL;
|
|
1904
|
-
}
|
|
1984
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
1985
|
+
return NULL;
|
|
1905
1986
|
|
|
1906
|
-
|
|
1987
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
1988
|
+
{
|
|
1989
|
+
Py_DECREF(o1);
|
|
1990
|
+
return NULL;
|
|
1907
1991
|
}
|
|
1908
1992
|
|
|
1909
|
-
|
|
1910
|
-
{
|
|
1911
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
1912
|
-
{
|
|
1913
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
1914
|
-
return NULL;
|
|
1915
|
-
}
|
|
1993
|
+
PyObject *result = PyNumber_FloorDivide(o1, o2);
|
|
1916
1994
|
|
|
1917
|
-
|
|
1918
|
-
|
|
1995
|
+
Py_DECREF(o1);
|
|
1996
|
+
Py_DECREF(o2);
|
|
1919
1997
|
|
|
1920
|
-
return
|
|
1998
|
+
return result;
|
|
1921
1999
|
}
|
|
1922
2000
|
|
|
1923
2001
|
/* ------------------------------------------------------------------------- */
|
|
1924
2002
|
|
|
1925
2003
|
static PyObject *WraptObjectProxy_true_divide(PyObject *o1, PyObject *o2)
|
|
1926
2004
|
{
|
|
1927
|
-
if (
|
|
1928
|
-
|
|
1929
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
1930
|
-
{
|
|
1931
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
1932
|
-
return NULL;
|
|
1933
|
-
}
|
|
2005
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
2006
|
+
return NULL;
|
|
1934
2007
|
|
|
1935
|
-
|
|
2008
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
2009
|
+
{
|
|
2010
|
+
Py_DECREF(o1);
|
|
2011
|
+
return NULL;
|
|
1936
2012
|
}
|
|
1937
2013
|
|
|
1938
|
-
|
|
1939
|
-
{
|
|
1940
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
1941
|
-
{
|
|
1942
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
1943
|
-
return NULL;
|
|
1944
|
-
}
|
|
2014
|
+
PyObject *result = PyNumber_TrueDivide(o1, o2);
|
|
1945
2015
|
|
|
1946
|
-
|
|
1947
|
-
|
|
2016
|
+
Py_DECREF(o1);
|
|
2017
|
+
Py_DECREF(o2);
|
|
1948
2018
|
|
|
1949
|
-
return
|
|
2019
|
+
return result;
|
|
1950
2020
|
}
|
|
1951
2021
|
|
|
1952
2022
|
/* ------------------------------------------------------------------------- */
|
|
@@ -1963,25 +2033,26 @@ WraptObjectProxy_inplace_floor_divide(WraptObjectProxyObject *self,
|
|
|
1963
2033
|
return NULL;
|
|
1964
2034
|
}
|
|
1965
2035
|
|
|
1966
|
-
if (
|
|
1967
|
-
|
|
1968
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
1969
|
-
{
|
|
1970
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
1971
|
-
return NULL;
|
|
1972
|
-
}
|
|
2036
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
2037
|
+
return NULL;
|
|
1973
2038
|
|
|
1974
|
-
|
|
1975
|
-
}
|
|
2039
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
1976
2040
|
|
|
1977
2041
|
PyObject *attr;
|
|
1978
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
2042
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__ifloordiv__", &attr);
|
|
1979
2043
|
Py_XDECREF(attr);
|
|
1980
2044
|
if (rc < 0)
|
|
2045
|
+
{
|
|
2046
|
+
Py_DECREF(wrapped);
|
|
2047
|
+
Py_DECREF(other);
|
|
1981
2048
|
return NULL;
|
|
2049
|
+
}
|
|
1982
2050
|
if (rc)
|
|
1983
2051
|
{
|
|
1984
|
-
object = PyNumber_InPlaceFloorDivide(
|
|
2052
|
+
object = PyNumber_InPlaceFloorDivide(wrapped, other);
|
|
2053
|
+
|
|
2054
|
+
Py_DECREF(wrapped);
|
|
2055
|
+
Py_DECREF(other);
|
|
1985
2056
|
|
|
1986
2057
|
if (!object)
|
|
1987
2058
|
return NULL;
|
|
@@ -1995,7 +2066,10 @@ WraptObjectProxy_inplace_floor_divide(WraptObjectProxyObject *self,
|
|
|
1995
2066
|
}
|
|
1996
2067
|
else
|
|
1997
2068
|
{
|
|
1998
|
-
PyObject *result = PyNumber_FloorDivide(
|
|
2069
|
+
PyObject *result = PyNumber_FloorDivide(wrapped, other);
|
|
2070
|
+
|
|
2071
|
+
Py_DECREF(wrapped);
|
|
2072
|
+
Py_DECREF(other);
|
|
1999
2073
|
|
|
2000
2074
|
if (!result)
|
|
2001
2075
|
return NULL;
|
|
@@ -2048,25 +2122,26 @@ WraptObjectProxy_inplace_true_divide(WraptObjectProxyObject *self,
|
|
|
2048
2122
|
return NULL;
|
|
2049
2123
|
}
|
|
2050
2124
|
|
|
2051
|
-
if (
|
|
2052
|
-
|
|
2053
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
2054
|
-
{
|
|
2055
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
2056
|
-
return NULL;
|
|
2057
|
-
}
|
|
2125
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
2126
|
+
return NULL;
|
|
2058
2127
|
|
|
2059
|
-
|
|
2060
|
-
}
|
|
2128
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2061
2129
|
|
|
2062
2130
|
PyObject *attr;
|
|
2063
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
2131
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__itruediv__", &attr);
|
|
2064
2132
|
Py_XDECREF(attr);
|
|
2065
2133
|
if (rc < 0)
|
|
2134
|
+
{
|
|
2135
|
+
Py_DECREF(wrapped);
|
|
2136
|
+
Py_DECREF(other);
|
|
2066
2137
|
return NULL;
|
|
2138
|
+
}
|
|
2067
2139
|
if (rc)
|
|
2068
2140
|
{
|
|
2069
|
-
object = PyNumber_InPlaceTrueDivide(
|
|
2141
|
+
object = PyNumber_InPlaceTrueDivide(wrapped, other);
|
|
2142
|
+
|
|
2143
|
+
Py_DECREF(wrapped);
|
|
2144
|
+
Py_DECREF(other);
|
|
2070
2145
|
|
|
2071
2146
|
if (!object)
|
|
2072
2147
|
return NULL;
|
|
@@ -2080,7 +2155,10 @@ WraptObjectProxy_inplace_true_divide(WraptObjectProxyObject *self,
|
|
|
2080
2155
|
}
|
|
2081
2156
|
else
|
|
2082
2157
|
{
|
|
2083
|
-
PyObject *result = PyNumber_TrueDivide(
|
|
2158
|
+
PyObject *result = PyNumber_TrueDivide(wrapped, other);
|
|
2159
|
+
|
|
2160
|
+
Py_DECREF(wrapped);
|
|
2161
|
+
Py_DECREF(other);
|
|
2084
2162
|
|
|
2085
2163
|
if (!result)
|
|
2086
2164
|
return NULL;
|
|
@@ -2129,36 +2207,34 @@ static PyObject *WraptObjectProxy_index(WraptObjectProxyObject *self)
|
|
|
2129
2207
|
return NULL;
|
|
2130
2208
|
}
|
|
2131
2209
|
|
|
2132
|
-
|
|
2210
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2211
|
+
|
|
2212
|
+
PyObject *result = PyNumber_Index(wrapped);
|
|
2213
|
+
|
|
2214
|
+
Py_DECREF(wrapped);
|
|
2215
|
+
|
|
2216
|
+
return result;
|
|
2133
2217
|
}
|
|
2134
2218
|
|
|
2135
2219
|
/* ------------------------------------------------------------------------- */
|
|
2136
2220
|
|
|
2137
2221
|
static PyObject *WraptObjectProxy_matrix_multiply(PyObject *o1, PyObject *o2)
|
|
2138
2222
|
{
|
|
2139
|
-
if (
|
|
2140
|
-
|
|
2141
|
-
if (!((WraptObjectProxyObject *)o1)->wrapped)
|
|
2142
|
-
{
|
|
2143
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o1) == -1)
|
|
2144
|
-
return NULL;
|
|
2145
|
-
}
|
|
2223
|
+
if (wrapt_unwrap_operand(&o1) == -1)
|
|
2224
|
+
return NULL;
|
|
2146
2225
|
|
|
2147
|
-
|
|
2226
|
+
if (wrapt_unwrap_operand(&o2) == -1)
|
|
2227
|
+
{
|
|
2228
|
+
Py_DECREF(o1);
|
|
2229
|
+
return NULL;
|
|
2148
2230
|
}
|
|
2149
2231
|
|
|
2150
|
-
|
|
2151
|
-
{
|
|
2152
|
-
if (!((WraptObjectProxyObject *)o2)->wrapped)
|
|
2153
|
-
{
|
|
2154
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)o2) == -1)
|
|
2155
|
-
return NULL;
|
|
2156
|
-
}
|
|
2232
|
+
PyObject *result = PyNumber_MatrixMultiply(o1, o2);
|
|
2157
2233
|
|
|
2158
|
-
|
|
2159
|
-
|
|
2234
|
+
Py_DECREF(o1);
|
|
2235
|
+
Py_DECREF(o2);
|
|
2160
2236
|
|
|
2161
|
-
return
|
|
2237
|
+
return result;
|
|
2162
2238
|
}
|
|
2163
2239
|
|
|
2164
2240
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2174,25 +2250,26 @@ static PyObject *WraptObjectProxy_inplace_matrix_multiply(
|
|
|
2174
2250
|
return NULL;
|
|
2175
2251
|
}
|
|
2176
2252
|
|
|
2177
|
-
if (
|
|
2178
|
-
|
|
2179
|
-
if (!((WraptObjectProxyObject *)other)->wrapped)
|
|
2180
|
-
{
|
|
2181
|
-
if (raise_uninitialized_wrapper_error((WraptObjectProxyObject *)other) == -1)
|
|
2182
|
-
return NULL;
|
|
2183
|
-
}
|
|
2253
|
+
if (wrapt_unwrap_operand(&other) == -1)
|
|
2254
|
+
return NULL;
|
|
2184
2255
|
|
|
2185
|
-
|
|
2186
|
-
}
|
|
2256
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2187
2257
|
|
|
2188
2258
|
PyObject *attr;
|
|
2189
|
-
int rc = PyObject_GetOptionalAttrString(
|
|
2259
|
+
int rc = PyObject_GetOptionalAttrString(wrapped, "__imatmul__", &attr);
|
|
2190
2260
|
Py_XDECREF(attr);
|
|
2191
2261
|
if (rc < 0)
|
|
2262
|
+
{
|
|
2263
|
+
Py_DECREF(wrapped);
|
|
2264
|
+
Py_DECREF(other);
|
|
2192
2265
|
return NULL;
|
|
2266
|
+
}
|
|
2193
2267
|
if (rc)
|
|
2194
2268
|
{
|
|
2195
|
-
object = PyNumber_InPlaceMatrixMultiply(
|
|
2269
|
+
object = PyNumber_InPlaceMatrixMultiply(wrapped, other);
|
|
2270
|
+
|
|
2271
|
+
Py_DECREF(wrapped);
|
|
2272
|
+
Py_DECREF(other);
|
|
2196
2273
|
|
|
2197
2274
|
if (!object)
|
|
2198
2275
|
return NULL;
|
|
@@ -2206,7 +2283,10 @@ static PyObject *WraptObjectProxy_inplace_matrix_multiply(
|
|
|
2206
2283
|
}
|
|
2207
2284
|
else
|
|
2208
2285
|
{
|
|
2209
|
-
PyObject *result = PyNumber_MatrixMultiply(
|
|
2286
|
+
PyObject *result = PyNumber_MatrixMultiply(wrapped, other);
|
|
2287
|
+
|
|
2288
|
+
Py_DECREF(wrapped);
|
|
2289
|
+
Py_DECREF(other);
|
|
2210
2290
|
|
|
2211
2291
|
if (!result)
|
|
2212
2292
|
return NULL;
|
|
@@ -2255,7 +2335,13 @@ static Py_ssize_t WraptObjectProxy_length(WraptObjectProxyObject *self)
|
|
|
2255
2335
|
return -1;
|
|
2256
2336
|
}
|
|
2257
2337
|
|
|
2258
|
-
|
|
2338
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2339
|
+
|
|
2340
|
+
Py_ssize_t result = PyObject_Length(wrapped);
|
|
2341
|
+
|
|
2342
|
+
Py_DECREF(wrapped);
|
|
2343
|
+
|
|
2344
|
+
return result;
|
|
2259
2345
|
}
|
|
2260
2346
|
|
|
2261
2347
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2269,7 +2355,13 @@ static int WraptObjectProxy_contains(WraptObjectProxyObject *self,
|
|
|
2269
2355
|
return -1;
|
|
2270
2356
|
}
|
|
2271
2357
|
|
|
2272
|
-
|
|
2358
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2359
|
+
|
|
2360
|
+
int result = PySequence_Contains(wrapped, value);
|
|
2361
|
+
|
|
2362
|
+
Py_DECREF(wrapped);
|
|
2363
|
+
|
|
2364
|
+
return result;
|
|
2273
2365
|
}
|
|
2274
2366
|
|
|
2275
2367
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2283,7 +2375,13 @@ static PyObject *WraptObjectProxy_getitem(WraptObjectProxyObject *self,
|
|
|
2283
2375
|
return NULL;
|
|
2284
2376
|
}
|
|
2285
2377
|
|
|
2286
|
-
|
|
2378
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2379
|
+
|
|
2380
|
+
PyObject *result = PyObject_GetItem(wrapped, key);
|
|
2381
|
+
|
|
2382
|
+
Py_DECREF(wrapped);
|
|
2383
|
+
|
|
2384
|
+
return result;
|
|
2287
2385
|
}
|
|
2288
2386
|
|
|
2289
2387
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2297,10 +2395,18 @@ static int WraptObjectProxy_setitem(WraptObjectProxyObject *self, PyObject *key,
|
|
|
2297
2395
|
return -1;
|
|
2298
2396
|
}
|
|
2299
2397
|
|
|
2398
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2399
|
+
|
|
2400
|
+
int result;
|
|
2401
|
+
|
|
2300
2402
|
if (value == NULL)
|
|
2301
|
-
|
|
2403
|
+
result = PyObject_DelItem(wrapped, key);
|
|
2302
2404
|
else
|
|
2303
|
-
|
|
2405
|
+
result = PyObject_SetItem(wrapped, key, value);
|
|
2406
|
+
|
|
2407
|
+
Py_DECREF(wrapped);
|
|
2408
|
+
|
|
2409
|
+
return result;
|
|
2304
2410
|
}
|
|
2305
2411
|
|
|
2306
2412
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2333,7 +2439,13 @@ static PyObject *WraptObjectProxy_dir(WraptObjectProxyObject *self,
|
|
|
2333
2439
|
return NULL;
|
|
2334
2440
|
}
|
|
2335
2441
|
|
|
2336
|
-
|
|
2442
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2443
|
+
|
|
2444
|
+
PyObject *result = PyObject_Dir(wrapped);
|
|
2445
|
+
|
|
2446
|
+
Py_DECREF(wrapped);
|
|
2447
|
+
|
|
2448
|
+
return result;
|
|
2337
2449
|
}
|
|
2338
2450
|
|
|
2339
2451
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2354,7 +2466,11 @@ static PyObject *WraptObjectProxy_enter(WraptObjectProxyObject *self,
|
|
|
2354
2466
|
if (!state)
|
|
2355
2467
|
return NULL;
|
|
2356
2468
|
|
|
2357
|
-
|
|
2469
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2470
|
+
|
|
2471
|
+
method = PyObject_GetAttr(wrapped, state->str_enter);
|
|
2472
|
+
|
|
2473
|
+
Py_DECREF(wrapped);
|
|
2358
2474
|
|
|
2359
2475
|
if (!method)
|
|
2360
2476
|
return NULL;
|
|
@@ -2384,7 +2500,11 @@ static PyObject *WraptObjectProxy_exit(WraptObjectProxyObject *self,
|
|
|
2384
2500
|
if (!state)
|
|
2385
2501
|
return NULL;
|
|
2386
2502
|
|
|
2387
|
-
|
|
2503
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2504
|
+
|
|
2505
|
+
method = PyObject_GetAttr(wrapped, state->str_exit);
|
|
2506
|
+
|
|
2507
|
+
Py_DECREF(wrapped);
|
|
2388
2508
|
|
|
2389
2509
|
if (!method)
|
|
2390
2510
|
return NULL;
|
|
@@ -2414,7 +2534,11 @@ static PyObject *WraptObjectProxy_aenter(WraptObjectProxyObject *self,
|
|
|
2414
2534
|
if (!state)
|
|
2415
2535
|
return NULL;
|
|
2416
2536
|
|
|
2417
|
-
|
|
2537
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2538
|
+
|
|
2539
|
+
method = PyObject_GetAttr(wrapped, state->str_aenter);
|
|
2540
|
+
|
|
2541
|
+
Py_DECREF(wrapped);
|
|
2418
2542
|
|
|
2419
2543
|
if (!method)
|
|
2420
2544
|
return NULL;
|
|
@@ -2444,7 +2568,11 @@ static PyObject *WraptObjectProxy_aexit(WraptObjectProxyObject *self,
|
|
|
2444
2568
|
if (!state)
|
|
2445
2569
|
return NULL;
|
|
2446
2570
|
|
|
2447
|
-
|
|
2571
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2572
|
+
|
|
2573
|
+
method = PyObject_GetAttr(wrapped, state->str_aexit);
|
|
2574
|
+
|
|
2575
|
+
Py_DECREF(wrapped);
|
|
2448
2576
|
|
|
2449
2577
|
if (!method)
|
|
2450
2578
|
return NULL;
|
|
@@ -2500,8 +2628,14 @@ static PyObject *WraptObjectProxy_bytes(WraptObjectProxyObject *self,
|
|
|
2500
2628
|
return NULL;
|
|
2501
2629
|
}
|
|
2502
2630
|
|
|
2503
|
-
|
|
2504
|
-
|
|
2631
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2632
|
+
|
|
2633
|
+
PyObject *result = PyObject_CallFunctionObjArgs((PyObject *)&PyBytes_Type,
|
|
2634
|
+
wrapped, NULL);
|
|
2635
|
+
|
|
2636
|
+
Py_DECREF(wrapped);
|
|
2637
|
+
|
|
2638
|
+
return result;
|
|
2505
2639
|
}
|
|
2506
2640
|
|
|
2507
2641
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2520,7 +2654,13 @@ static PyObject *WraptObjectProxy_format(WraptObjectProxyObject *self,
|
|
|
2520
2654
|
if (!PyArg_ParseTuple(args, "O:format", &format_spec))
|
|
2521
2655
|
return NULL;
|
|
2522
2656
|
|
|
2523
|
-
|
|
2657
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2658
|
+
|
|
2659
|
+
PyObject *result = PyObject_Format(wrapped, format_spec);
|
|
2660
|
+
|
|
2661
|
+
Py_DECREF(wrapped);
|
|
2662
|
+
|
|
2663
|
+
return result;
|
|
2524
2664
|
}
|
|
2525
2665
|
|
|
2526
2666
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2534,8 +2674,14 @@ static PyObject *WraptObjectProxy_reversed(WraptObjectProxyObject *self,
|
|
|
2534
2674
|
return NULL;
|
|
2535
2675
|
}
|
|
2536
2676
|
|
|
2537
|
-
|
|
2538
|
-
|
|
2677
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2678
|
+
|
|
2679
|
+
PyObject *result = PyObject_CallFunctionObjArgs((PyObject *)&PyReversed_Type,
|
|
2680
|
+
wrapped, NULL);
|
|
2681
|
+
|
|
2682
|
+
Py_DECREF(wrapped);
|
|
2683
|
+
|
|
2684
|
+
return result;
|
|
2539
2685
|
}
|
|
2540
2686
|
|
|
2541
2687
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2579,8 +2725,11 @@ static PyObject *WraptObjectProxy_round(WraptObjectProxyObject *self,
|
|
|
2579
2725
|
|
|
2580
2726
|
Py_DECREF(module);
|
|
2581
2727
|
|
|
2582
|
-
|
|
2728
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2583
2729
|
|
|
2730
|
+
result = PyObject_CallFunctionObjArgs(round, wrapped, ndigits, NULL);
|
|
2731
|
+
|
|
2732
|
+
Py_DECREF(wrapped);
|
|
2584
2733
|
Py_DECREF(round);
|
|
2585
2734
|
|
|
2586
2735
|
return result;
|
|
@@ -2616,8 +2765,11 @@ static PyObject *wrapt_call_math_unary(WraptObjectProxyObject *self,
|
|
|
2616
2765
|
|
|
2617
2766
|
Py_DECREF(module);
|
|
2618
2767
|
|
|
2619
|
-
|
|
2768
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2769
|
+
|
|
2770
|
+
result = PyObject_CallFunctionObjArgs(function, wrapped, NULL);
|
|
2620
2771
|
|
|
2772
|
+
Py_DECREF(wrapped);
|
|
2621
2773
|
Py_DECREF(function);
|
|
2622
2774
|
|
|
2623
2775
|
return result;
|
|
@@ -2658,8 +2810,14 @@ static PyObject *WraptObjectProxy_complex(WraptObjectProxyObject *self,
|
|
|
2658
2810
|
return NULL;
|
|
2659
2811
|
}
|
|
2660
2812
|
|
|
2661
|
-
|
|
2662
|
-
|
|
2813
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2814
|
+
|
|
2815
|
+
PyObject *result = PyObject_CallFunctionObjArgs((PyObject *)&PyComplex_Type,
|
|
2816
|
+
wrapped, NULL);
|
|
2817
|
+
|
|
2818
|
+
Py_DECREF(wrapped);
|
|
2819
|
+
|
|
2820
|
+
return result;
|
|
2663
2821
|
}
|
|
2664
2822
|
|
|
2665
2823
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2678,7 +2836,7 @@ static PyObject *WraptObjectProxy_mro_entries(WraptObjectProxyObject *self,
|
|
|
2678
2836
|
return NULL;
|
|
2679
2837
|
}
|
|
2680
2838
|
|
|
2681
|
-
wrapped = self
|
|
2839
|
+
wrapped = wrapt_acquire_wrapped(self);
|
|
2682
2840
|
|
|
2683
2841
|
// Check if wrapped is a type (class).
|
|
2684
2842
|
|
|
@@ -2690,7 +2848,10 @@ static PyObject *WraptObjectProxy_mro_entries(WraptObjectProxyObject *self,
|
|
|
2690
2848
|
{
|
|
2691
2849
|
wrapt_module_state *state = wrapt_state_from_type(Py_TYPE(self));
|
|
2692
2850
|
if (!state)
|
|
2851
|
+
{
|
|
2852
|
+
Py_DECREF(wrapped);
|
|
2693
2853
|
return NULL;
|
|
2854
|
+
}
|
|
2694
2855
|
|
|
2695
2856
|
mro_entries_method = PyObject_GetAttr(wrapped, state->str_mro_entries);
|
|
2696
2857
|
|
|
@@ -2701,18 +2862,26 @@ static PyObject *WraptObjectProxy_mro_entries(WraptObjectProxyObject *self,
|
|
|
2701
2862
|
result = PyObject_Call(mro_entries_method, args, kwds);
|
|
2702
2863
|
|
|
2703
2864
|
Py_DECREF(mro_entries_method);
|
|
2865
|
+
Py_DECREF(wrapped);
|
|
2704
2866
|
|
|
2705
2867
|
return result;
|
|
2706
2868
|
}
|
|
2707
2869
|
else
|
|
2708
2870
|
{
|
|
2709
2871
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
2872
|
+
{
|
|
2873
|
+
Py_DECREF(wrapped);
|
|
2710
2874
|
return NULL;
|
|
2875
|
+
}
|
|
2711
2876
|
PyErr_Clear();
|
|
2712
2877
|
}
|
|
2713
2878
|
}
|
|
2714
2879
|
|
|
2715
|
-
|
|
2880
|
+
result = Py_BuildValue("(O)", wrapped);
|
|
2881
|
+
|
|
2882
|
+
Py_DECREF(wrapped);
|
|
2883
|
+
|
|
2884
|
+
return result;
|
|
2716
2885
|
}
|
|
2717
2886
|
|
|
2718
2887
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2729,7 +2898,13 @@ static PyObject *WraptObjectProxy_get_name(WraptObjectProxyObject *self)
|
|
|
2729
2898
|
if (!state)
|
|
2730
2899
|
return NULL;
|
|
2731
2900
|
|
|
2732
|
-
|
|
2901
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2902
|
+
|
|
2903
|
+
PyObject *result = PyObject_GetAttr(wrapped, state->str_name);
|
|
2904
|
+
|
|
2905
|
+
Py_DECREF(wrapped);
|
|
2906
|
+
|
|
2907
|
+
return result;
|
|
2733
2908
|
}
|
|
2734
2909
|
|
|
2735
2910
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2747,7 +2922,13 @@ static int WraptObjectProxy_set_name(WraptObjectProxyObject *self,
|
|
|
2747
2922
|
if (!state)
|
|
2748
2923
|
return -1;
|
|
2749
2924
|
|
|
2750
|
-
|
|
2925
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2926
|
+
|
|
2927
|
+
int result = PyObject_SetAttr(wrapped, state->str_name, value);
|
|
2928
|
+
|
|
2929
|
+
Py_DECREF(wrapped);
|
|
2930
|
+
|
|
2931
|
+
return result;
|
|
2751
2932
|
}
|
|
2752
2933
|
|
|
2753
2934
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2764,7 +2945,13 @@ static PyObject *WraptObjectProxy_get_qualname(WraptObjectProxyObject *self)
|
|
|
2764
2945
|
if (!state)
|
|
2765
2946
|
return NULL;
|
|
2766
2947
|
|
|
2767
|
-
|
|
2948
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2949
|
+
|
|
2950
|
+
PyObject *result = PyObject_GetAttr(wrapped, state->str_qualname);
|
|
2951
|
+
|
|
2952
|
+
Py_DECREF(wrapped);
|
|
2953
|
+
|
|
2954
|
+
return result;
|
|
2768
2955
|
}
|
|
2769
2956
|
|
|
2770
2957
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2782,7 +2969,13 @@ static int WraptObjectProxy_set_qualname(WraptObjectProxyObject *self,
|
|
|
2782
2969
|
if (!state)
|
|
2783
2970
|
return -1;
|
|
2784
2971
|
|
|
2785
|
-
|
|
2972
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2973
|
+
|
|
2974
|
+
int result = PyObject_SetAttr(wrapped, state->str_qualname, value);
|
|
2975
|
+
|
|
2976
|
+
Py_DECREF(wrapped);
|
|
2977
|
+
|
|
2978
|
+
return result;
|
|
2786
2979
|
}
|
|
2787
2980
|
|
|
2788
2981
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2799,7 +2992,13 @@ static PyObject *WraptObjectProxy_get_module(WraptObjectProxyObject *self)
|
|
|
2799
2992
|
if (!state)
|
|
2800
2993
|
return NULL;
|
|
2801
2994
|
|
|
2802
|
-
|
|
2995
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
2996
|
+
|
|
2997
|
+
PyObject *result = PyObject_GetAttr(wrapped, state->str_module);
|
|
2998
|
+
|
|
2999
|
+
Py_DECREF(wrapped);
|
|
3000
|
+
|
|
3001
|
+
return result;
|
|
2803
3002
|
}
|
|
2804
3003
|
|
|
2805
3004
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2817,8 +3016,15 @@ static int WraptObjectProxy_set_module(WraptObjectProxyObject *self,
|
|
|
2817
3016
|
if (!state)
|
|
2818
3017
|
return -1;
|
|
2819
3018
|
|
|
2820
|
-
|
|
3019
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3020
|
+
|
|
3021
|
+
if (PyObject_SetAttr(wrapped, state->str_module, value) == -1)
|
|
3022
|
+
{
|
|
3023
|
+
Py_DECREF(wrapped);
|
|
2821
3024
|
return -1;
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
Py_DECREF(wrapped);
|
|
2822
3028
|
|
|
2823
3029
|
return PyDict_SetItemString(self->dict, "__module__", value);
|
|
2824
3030
|
}
|
|
@@ -2837,7 +3043,13 @@ static PyObject *WraptObjectProxy_get_doc(WraptObjectProxyObject *self)
|
|
|
2837
3043
|
if (!state)
|
|
2838
3044
|
return NULL;
|
|
2839
3045
|
|
|
2840
|
-
|
|
3046
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3047
|
+
|
|
3048
|
+
PyObject *result = PyObject_GetAttr(wrapped, state->str_doc);
|
|
3049
|
+
|
|
3050
|
+
Py_DECREF(wrapped);
|
|
3051
|
+
|
|
3052
|
+
return result;
|
|
2841
3053
|
}
|
|
2842
3054
|
|
|
2843
3055
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2855,8 +3067,15 @@ static int WraptObjectProxy_set_doc(WraptObjectProxyObject *self,
|
|
|
2855
3067
|
if (!state)
|
|
2856
3068
|
return -1;
|
|
2857
3069
|
|
|
2858
|
-
|
|
3070
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3071
|
+
|
|
3072
|
+
if (PyObject_SetAttr(wrapped, state->str_doc, value) == -1)
|
|
3073
|
+
{
|
|
3074
|
+
Py_DECREF(wrapped);
|
|
2859
3075
|
return -1;
|
|
3076
|
+
}
|
|
3077
|
+
|
|
3078
|
+
Py_DECREF(wrapped);
|
|
2860
3079
|
|
|
2861
3080
|
return PyDict_SetItemString(self->dict, "__doc__", value);
|
|
2862
3081
|
}
|
|
@@ -2875,7 +3094,13 @@ static PyObject *WraptObjectProxy_get_class(WraptObjectProxyObject *self)
|
|
|
2875
3094
|
if (!state)
|
|
2876
3095
|
return NULL;
|
|
2877
3096
|
|
|
2878
|
-
|
|
3097
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3098
|
+
|
|
3099
|
+
PyObject *result = PyObject_GetAttr(wrapped, state->str_dunder_class);
|
|
3100
|
+
|
|
3101
|
+
Py_DECREF(wrapped);
|
|
3102
|
+
|
|
3103
|
+
return result;
|
|
2879
3104
|
}
|
|
2880
3105
|
|
|
2881
3106
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2893,7 +3118,13 @@ static int WraptObjectProxy_set_class(WraptObjectProxyObject *self,
|
|
|
2893
3118
|
if (!state)
|
|
2894
3119
|
return -1;
|
|
2895
3120
|
|
|
2896
|
-
|
|
3121
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3122
|
+
|
|
3123
|
+
int result = PyObject_SetAttr(wrapped, state->str_dunder_class, value);
|
|
3124
|
+
|
|
3125
|
+
Py_DECREF(wrapped);
|
|
3126
|
+
|
|
3127
|
+
return result;
|
|
2897
3128
|
}
|
|
2898
3129
|
|
|
2899
3130
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2911,7 +3142,13 @@ WraptObjectProxy_get_annotations(WraptObjectProxyObject *self)
|
|
|
2911
3142
|
if (!state)
|
|
2912
3143
|
return NULL;
|
|
2913
3144
|
|
|
2914
|
-
|
|
3145
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3146
|
+
|
|
3147
|
+
PyObject *result = PyObject_GetAttr(wrapped, state->str_annotations);
|
|
3148
|
+
|
|
3149
|
+
Py_DECREF(wrapped);
|
|
3150
|
+
|
|
3151
|
+
return result;
|
|
2915
3152
|
}
|
|
2916
3153
|
|
|
2917
3154
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2929,7 +3166,13 @@ static int WraptObjectProxy_set_annotations(WraptObjectProxyObject *self,
|
|
|
2929
3166
|
if (!state)
|
|
2930
3167
|
return -1;
|
|
2931
3168
|
|
|
2932
|
-
|
|
3169
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3170
|
+
|
|
3171
|
+
int result = PyObject_SetAttr(wrapped, state->str_annotations, value);
|
|
3172
|
+
|
|
3173
|
+
Py_DECREF(wrapped);
|
|
3174
|
+
|
|
3175
|
+
return result;
|
|
2933
3176
|
}
|
|
2934
3177
|
|
|
2935
3178
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2946,7 +3189,13 @@ static PyObject *WraptObjectProxy_get_dict(WraptObjectProxyObject *self)
|
|
|
2946
3189
|
if (!state)
|
|
2947
3190
|
return NULL;
|
|
2948
3191
|
|
|
2949
|
-
|
|
3192
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3193
|
+
|
|
3194
|
+
PyObject *result = PyObject_GetAttr(wrapped, state->str_dict);
|
|
3195
|
+
|
|
3196
|
+
Py_DECREF(wrapped);
|
|
3197
|
+
|
|
3198
|
+
return result;
|
|
2950
3199
|
}
|
|
2951
3200
|
|
|
2952
3201
|
/* ------------------------------------------------------------------------- */
|
|
@@ -2992,14 +3241,17 @@ static PyObject *WraptObjectProxy_get_self_dict(WraptObjectProxyObject *self)
|
|
|
2992
3241
|
|
|
2993
3242
|
static PyObject *WraptObjectProxy_get_wrapped(WraptObjectProxyObject *self)
|
|
2994
3243
|
{
|
|
3244
|
+
PyObject *value = NULL;
|
|
3245
|
+
|
|
2995
3246
|
if (!self->wrapped)
|
|
2996
3247
|
{
|
|
2997
3248
|
if (raise_uninitialized_wrapper_error(self) == -1)
|
|
2998
3249
|
return NULL;
|
|
2999
3250
|
}
|
|
3000
3251
|
|
|
3001
|
-
|
|
3002
|
-
|
|
3252
|
+
value = wrapt_acquire_wrapped(self);
|
|
3253
|
+
|
|
3254
|
+
return value;
|
|
3003
3255
|
}
|
|
3004
3256
|
|
|
3005
3257
|
/* ------------------------------------------------------------------------- */
|
|
@@ -3116,6 +3368,8 @@ static PyObject *WraptObjectProxy_getattr(WraptObjectProxyObject *self,
|
|
|
3116
3368
|
PyObject *args)
|
|
3117
3369
|
{
|
|
3118
3370
|
PyObject *name = NULL;
|
|
3371
|
+
PyObject *wrapped = NULL;
|
|
3372
|
+
PyObject *result = NULL;
|
|
3119
3373
|
|
|
3120
3374
|
if (!PyArg_ParseTuple(args, "U:__getattr__", &name))
|
|
3121
3375
|
return NULL;
|
|
@@ -3126,7 +3380,19 @@ static PyObject *WraptObjectProxy_getattr(WraptObjectProxyObject *self,
|
|
|
3126
3380
|
return NULL;
|
|
3127
3381
|
}
|
|
3128
3382
|
|
|
3129
|
-
|
|
3383
|
+
/* Hold a strong reference across the attribute lookup so a concurrent
|
|
3384
|
+
* swap of the wrapped object cannot release it mid lookup. Note this
|
|
3385
|
+
* path is reached from the __wrapped__ setter itself via the lookup
|
|
3386
|
+
* of __wrapped_setattr_fixups__, so even a workload consisting purely
|
|
3387
|
+
* of writers performs this read. */
|
|
3388
|
+
|
|
3389
|
+
wrapped = wrapt_acquire_wrapped(self);
|
|
3390
|
+
|
|
3391
|
+
result = PyObject_GetAttr(wrapped, name);
|
|
3392
|
+
|
|
3393
|
+
Py_XDECREF(wrapped);
|
|
3394
|
+
|
|
3395
|
+
return result;
|
|
3130
3396
|
}
|
|
3131
3397
|
|
|
3132
3398
|
/* ------------------------------------------------------------------------- */
|
|
@@ -3165,7 +3431,13 @@ static int WraptObjectProxy_setattro(WraptObjectProxyObject *self,
|
|
|
3165
3431
|
return -1;
|
|
3166
3432
|
}
|
|
3167
3433
|
|
|
3168
|
-
|
|
3434
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3435
|
+
|
|
3436
|
+
int result = PyObject_SetAttr(wrapped, name, value);
|
|
3437
|
+
|
|
3438
|
+
Py_DECREF(wrapped);
|
|
3439
|
+
|
|
3440
|
+
return result;
|
|
3169
3441
|
}
|
|
3170
3442
|
|
|
3171
3443
|
/* ------------------------------------------------------------------------- */
|
|
@@ -3179,7 +3451,13 @@ static PyObject *WraptObjectProxy_richcompare(WraptObjectProxyObject *self,
|
|
|
3179
3451
|
return NULL;
|
|
3180
3452
|
}
|
|
3181
3453
|
|
|
3182
|
-
|
|
3454
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3455
|
+
|
|
3456
|
+
PyObject *result = PyObject_RichCompare(wrapped, other, opcode);
|
|
3457
|
+
|
|
3458
|
+
Py_DECREF(wrapped);
|
|
3459
|
+
|
|
3460
|
+
return result;
|
|
3183
3461
|
}
|
|
3184
3462
|
|
|
3185
3463
|
/* ------------------------------------------------------------------------- */
|
|
@@ -3196,7 +3474,11 @@ WraptObjectProxy_instancecheck(WraptObjectProxyObject *self,
|
|
|
3196
3474
|
return NULL;
|
|
3197
3475
|
}
|
|
3198
3476
|
|
|
3199
|
-
|
|
3477
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3478
|
+
|
|
3479
|
+
check = PyObject_IsInstance(instance, wrapped);
|
|
3480
|
+
|
|
3481
|
+
Py_DECREF(wrapped);
|
|
3200
3482
|
|
|
3201
3483
|
if (check < 0)
|
|
3202
3484
|
{
|
|
@@ -3240,9 +3522,11 @@ WraptObjectProxy_subclasscheck(WraptObjectProxyObject *self,
|
|
|
3240
3522
|
PyErr_Clear();
|
|
3241
3523
|
}
|
|
3242
3524
|
|
|
3243
|
-
|
|
3244
|
-
self->wrapped);
|
|
3525
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3245
3526
|
|
|
3527
|
+
check = PyObject_IsSubclass(object ? object : subclass, wrapped);
|
|
3528
|
+
|
|
3529
|
+
Py_DECREF(wrapped);
|
|
3246
3530
|
Py_XDECREF(object);
|
|
3247
3531
|
|
|
3248
3532
|
if (check == -1)
|
|
@@ -3397,7 +3681,13 @@ static PyObject *WraptCallableObjectProxy_call(WraptObjectProxyObject *self,
|
|
|
3397
3681
|
return NULL;
|
|
3398
3682
|
}
|
|
3399
3683
|
|
|
3400
|
-
|
|
3684
|
+
PyObject *wrapped = wrapt_acquire_wrapped(self);
|
|
3685
|
+
|
|
3686
|
+
PyObject *result = PyObject_Call(wrapped, args, kwds);
|
|
3687
|
+
|
|
3688
|
+
Py_DECREF(wrapped);
|
|
3689
|
+
|
|
3690
|
+
return result;
|
|
3401
3691
|
}
|
|
3402
3692
|
|
|
3403
3693
|
/* ------------------------------------------------------------------------- */;
|
|
@@ -3583,20 +3873,28 @@ static PyObject *WraptPartialCallableObjectProxy_call(
|
|
|
3583
3873
|
return NULL;
|
|
3584
3874
|
}
|
|
3585
3875
|
|
|
3586
|
-
|
|
3876
|
+
/* Hold strong references to the wrapped object and the captured
|
|
3877
|
+
* arguments across the call so a concurrent re-initialization of the
|
|
3878
|
+
* partial cannot release them while they are in use. */
|
|
3879
|
+
|
|
3880
|
+
PyObject *wrapped = wrapt_acquire_wrapped(&self->object_proxy);
|
|
3881
|
+
PyObject *cargs = wrapt_acquire_field((PyObject *)self, &self->args);
|
|
3882
|
+
PyObject *ckwargs = wrapt_acquire_field((PyObject *)self, &self->kwargs);
|
|
3883
|
+
|
|
3884
|
+
fnargs = PyTuple_New(PyTuple_GET_SIZE(cargs) + PyTuple_GET_SIZE(args));
|
|
3587
3885
|
|
|
3588
3886
|
if (!fnargs)
|
|
3589
|
-
|
|
3887
|
+
goto finally;
|
|
3590
3888
|
|
|
3591
|
-
for (i = 0; i < PyTuple_GET_SIZE(
|
|
3889
|
+
for (i = 0; i < PyTuple_GET_SIZE(cargs); i++)
|
|
3592
3890
|
{
|
|
3593
3891
|
PyObject *item;
|
|
3594
|
-
item = PyTuple_GetItem(
|
|
3892
|
+
item = PyTuple_GetItem(cargs, i);
|
|
3595
3893
|
Py_INCREF(item);
|
|
3596
3894
|
PyTuple_SetItem(fnargs, i, item);
|
|
3597
3895
|
}
|
|
3598
3896
|
|
|
3599
|
-
offset = PyTuple_GET_SIZE(
|
|
3897
|
+
offset = PyTuple_GET_SIZE(cargs);
|
|
3600
3898
|
|
|
3601
3899
|
for (i = 0; i < PyTuple_GET_SIZE(args); i++)
|
|
3602
3900
|
{
|
|
@@ -3609,29 +3907,23 @@ static PyObject *WraptPartialCallableObjectProxy_call(
|
|
|
3609
3907
|
fnkwargs = PyDict_New();
|
|
3610
3908
|
|
|
3611
3909
|
if (!fnkwargs)
|
|
3612
|
-
|
|
3613
|
-
Py_DECREF(fnargs);
|
|
3614
|
-
return NULL;
|
|
3615
|
-
}
|
|
3910
|
+
goto finally;
|
|
3616
3911
|
|
|
3617
|
-
if (
|
|
3618
|
-
|
|
3619
|
-
Py_DECREF(fnargs);
|
|
3620
|
-
Py_DECREF(fnkwargs);
|
|
3621
|
-
return NULL;
|
|
3622
|
-
}
|
|
3912
|
+
if (ckwargs && PyDict_Update(fnkwargs, ckwargs) == -1)
|
|
3913
|
+
goto finally;
|
|
3623
3914
|
|
|
3624
3915
|
if (kwds && PyDict_Update(fnkwargs, kwds) == -1)
|
|
3625
|
-
|
|
3626
|
-
Py_DECREF(fnargs);
|
|
3627
|
-
Py_DECREF(fnkwargs);
|
|
3628
|
-
return NULL;
|
|
3629
|
-
}
|
|
3916
|
+
goto finally;
|
|
3630
3917
|
|
|
3631
|
-
result = PyObject_Call(
|
|
3918
|
+
result = PyObject_Call(wrapped, fnargs, fnkwargs);
|
|
3632
3919
|
|
|
3633
|
-
|
|
3634
|
-
|
|
3920
|
+
finally:
|
|
3921
|
+
Py_XDECREF(fnargs);
|
|
3922
|
+
Py_XDECREF(fnkwargs);
|
|
3923
|
+
|
|
3924
|
+
Py_DECREF(wrapped);
|
|
3925
|
+
Py_DECREF(cargs);
|
|
3926
|
+
Py_XDECREF(ckwargs);
|
|
3635
3927
|
|
|
3636
3928
|
return result;
|
|
3637
3929
|
}
|
|
@@ -3820,6 +4112,12 @@ static PyObject *WraptFunctionWrapperBase_call(WraptFunctionWrapperObject *self,
|
|
|
3820
4112
|
{
|
|
3821
4113
|
PyObject *param_kwds = NULL;
|
|
3822
4114
|
|
|
4115
|
+
PyObject *wrapped = NULL;
|
|
4116
|
+
PyObject *instance = NULL;
|
|
4117
|
+
PyObject *wrapper = NULL;
|
|
4118
|
+
PyObject *enabled = NULL;
|
|
4119
|
+
PyObject *binding = NULL;
|
|
4120
|
+
|
|
3823
4121
|
PyObject *result = NULL;
|
|
3824
4122
|
|
|
3825
4123
|
if (!self->object_proxy.wrapped)
|
|
@@ -3832,36 +4130,53 @@ static PyObject *WraptFunctionWrapperBase_call(WraptFunctionWrapperObject *self,
|
|
|
3832
4130
|
if (!state)
|
|
3833
4131
|
return NULL;
|
|
3834
4132
|
|
|
3835
|
-
|
|
4133
|
+
/* Hold strong references to the fields used across the call so a
|
|
4134
|
+
* concurrent re-initialization of the wrapper cannot release them
|
|
4135
|
+
* while in use. Fields are acquired independently, so a consistent
|
|
4136
|
+
* snapshot across all of them is not guaranteed, as documented. */
|
|
4137
|
+
|
|
4138
|
+
wrapped = wrapt_acquire_wrapped(&self->object_proxy);
|
|
4139
|
+
instance = wrapt_acquire_field((PyObject *)self, &self->instance);
|
|
4140
|
+
wrapper = wrapt_acquire_field((PyObject *)self, &self->wrapper);
|
|
4141
|
+
enabled = wrapt_acquire_field((PyObject *)self, &self->enabled);
|
|
4142
|
+
binding = wrapt_acquire_field((PyObject *)self, &self->binding);
|
|
4143
|
+
|
|
4144
|
+
if (enabled != Py_None)
|
|
3836
4145
|
{
|
|
3837
|
-
if (PyCallable_Check(
|
|
4146
|
+
if (PyCallable_Check(enabled))
|
|
3838
4147
|
{
|
|
3839
4148
|
PyObject *object = NULL;
|
|
3840
4149
|
int is_false;
|
|
3841
4150
|
|
|
3842
|
-
object = PyObject_CallFunctionObjArgs(
|
|
4151
|
+
object = PyObject_CallFunctionObjArgs(enabled, NULL);
|
|
3843
4152
|
|
|
3844
4153
|
if (!object)
|
|
3845
|
-
|
|
4154
|
+
goto finally;
|
|
3846
4155
|
|
|
3847
4156
|
is_false = PyObject_Not(object);
|
|
3848
4157
|
Py_DECREF(object);
|
|
3849
4158
|
|
|
3850
4159
|
if (is_false < 0)
|
|
3851
|
-
|
|
4160
|
+
goto finally;
|
|
3852
4161
|
|
|
3853
4162
|
if (is_false)
|
|
3854
|
-
|
|
4163
|
+
{
|
|
4164
|
+
result = PyObject_Call(wrapped, args, kwds);
|
|
4165
|
+
goto finally;
|
|
4166
|
+
}
|
|
3855
4167
|
}
|
|
3856
4168
|
else
|
|
3857
4169
|
{
|
|
3858
|
-
int is_false = PyObject_Not(
|
|
4170
|
+
int is_false = PyObject_Not(enabled);
|
|
3859
4171
|
|
|
3860
4172
|
if (is_false < 0)
|
|
3861
|
-
|
|
4173
|
+
goto finally;
|
|
3862
4174
|
|
|
3863
4175
|
if (is_false)
|
|
3864
|
-
|
|
4176
|
+
{
|
|
4177
|
+
result = PyObject_Call(wrapped, args, kwds);
|
|
4178
|
+
goto finally;
|
|
4179
|
+
}
|
|
3865
4180
|
}
|
|
3866
4181
|
}
|
|
3867
4182
|
|
|
@@ -3869,55 +4184,54 @@ static PyObject *WraptFunctionWrapperBase_call(WraptFunctionWrapperObject *self,
|
|
|
3869
4184
|
{
|
|
3870
4185
|
param_kwds = PyDict_New();
|
|
3871
4186
|
if (!param_kwds)
|
|
3872
|
-
|
|
4187
|
+
goto finally;
|
|
3873
4188
|
kwds = param_kwds;
|
|
3874
4189
|
}
|
|
3875
4190
|
|
|
3876
|
-
if (
|
|
4191
|
+
if (instance == Py_None)
|
|
3877
4192
|
{
|
|
3878
4193
|
int matched =
|
|
3879
|
-
PyUnicode_CompareWithASCIIString(
|
|
3880
|
-
PyUnicode_CompareWithASCIIString(
|
|
3881
|
-
PyUnicode_CompareWithASCIIString(
|
|
3882
|
-
PyUnicode_CompareWithASCIIString(
|
|
4194
|
+
PyUnicode_CompareWithASCIIString(binding, "function") == 0 ||
|
|
4195
|
+
PyUnicode_CompareWithASCIIString(binding, "instancemethod") == 0 ||
|
|
4196
|
+
PyUnicode_CompareWithASCIIString(binding, "callable") == 0 ||
|
|
4197
|
+
PyUnicode_CompareWithASCIIString(binding, "classmethod") == 0;
|
|
3883
4198
|
|
|
3884
4199
|
if (matched)
|
|
3885
4200
|
{
|
|
3886
|
-
PyObject *
|
|
4201
|
+
PyObject *bound_instance = NULL;
|
|
3887
4202
|
|
|
3888
|
-
|
|
3889
|
-
PyObject_GetAttr(self->object_proxy.wrapped, state->str_self);
|
|
4203
|
+
bound_instance = PyObject_GetAttr(wrapped, state->str_self);
|
|
3890
4204
|
|
|
3891
|
-
if (
|
|
4205
|
+
if (bound_instance)
|
|
3892
4206
|
{
|
|
3893
|
-
result = PyObject_CallFunctionObjArgs(
|
|
3894
|
-
|
|
3895
|
-
instance, args, kwds, NULL);
|
|
4207
|
+
result = PyObject_CallFunctionObjArgs(wrapper, wrapped, bound_instance,
|
|
4208
|
+
args, kwds, NULL);
|
|
3896
4209
|
|
|
3897
|
-
|
|
3898
|
-
|
|
3899
|
-
Py_DECREF(instance);
|
|
4210
|
+
Py_DECREF(bound_instance);
|
|
3900
4211
|
|
|
3901
|
-
|
|
4212
|
+
goto finally;
|
|
3902
4213
|
}
|
|
3903
4214
|
else
|
|
3904
4215
|
{
|
|
3905
4216
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
3906
|
-
|
|
3907
|
-
Py_XDECREF(param_kwds);
|
|
3908
|
-
return NULL;
|
|
3909
|
-
}
|
|
4217
|
+
goto finally;
|
|
3910
4218
|
PyErr_Clear();
|
|
3911
4219
|
}
|
|
3912
4220
|
}
|
|
3913
4221
|
}
|
|
3914
4222
|
|
|
3915
|
-
result =
|
|
3916
|
-
|
|
3917
|
-
self->instance, args, kwds, NULL);
|
|
4223
|
+
result = PyObject_CallFunctionObjArgs(wrapper, wrapped, instance, args, kwds,
|
|
4224
|
+
NULL);
|
|
3918
4225
|
|
|
4226
|
+
finally:
|
|
3919
4227
|
Py_XDECREF(param_kwds);
|
|
3920
4228
|
|
|
4229
|
+
Py_DECREF(wrapped);
|
|
4230
|
+
Py_XDECREF(instance);
|
|
4231
|
+
Py_XDECREF(wrapper);
|
|
4232
|
+
Py_XDECREF(enabled);
|
|
4233
|
+
Py_XDECREF(binding);
|
|
4234
|
+
|
|
3921
4235
|
return result;
|
|
3922
4236
|
}
|
|
3923
4237
|
|
|
@@ -3929,6 +4243,14 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
|
|
|
3929
4243
|
{
|
|
3930
4244
|
PyObject *bound_type = NULL;
|
|
3931
4245
|
PyObject *descriptor = NULL;
|
|
4246
|
+
|
|
4247
|
+
PyObject *wrapped = NULL;
|
|
4248
|
+
PyObject *instance = NULL;
|
|
4249
|
+
PyObject *wrapper = NULL;
|
|
4250
|
+
PyObject *enabled = NULL;
|
|
4251
|
+
PyObject *binding = NULL;
|
|
4252
|
+
PyObject *parent = NULL;
|
|
4253
|
+
|
|
3932
4254
|
PyObject *result = NULL;
|
|
3933
4255
|
|
|
3934
4256
|
wrapt_module_state *state = wrapt_state_from_type(Py_TYPE(self));
|
|
@@ -3943,31 +4265,45 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
|
|
|
3943
4265
|
return NULL;
|
|
3944
4266
|
}
|
|
3945
4267
|
|
|
3946
|
-
|
|
4268
|
+
/* Hold strong references to the fields used across the binding so a
|
|
4269
|
+
* concurrent re-initialization of the wrapper cannot release them
|
|
4270
|
+
* while in use. Fields are acquired independently, so a consistent
|
|
4271
|
+
* snapshot across all of them is not guaranteed, as documented. */
|
|
4272
|
+
|
|
4273
|
+
wrapped = wrapt_acquire_wrapped(&self->object_proxy);
|
|
4274
|
+
instance = wrapt_acquire_field((PyObject *)self, &self->instance);
|
|
4275
|
+
wrapper = wrapt_acquire_field((PyObject *)self, &self->wrapper);
|
|
4276
|
+
enabled = wrapt_acquire_field((PyObject *)self, &self->enabled);
|
|
4277
|
+
binding = wrapt_acquire_field((PyObject *)self, &self->binding);
|
|
4278
|
+
parent = wrapt_acquire_field((PyObject *)self, &self->parent);
|
|
4279
|
+
|
|
4280
|
+
if (parent == Py_None)
|
|
3947
4281
|
{
|
|
3948
|
-
if (PyUnicode_CompareWithASCIIString(
|
|
4282
|
+
if (PyUnicode_CompareWithASCIIString(binding, "builtin") == 0)
|
|
3949
4283
|
{
|
|
3950
4284
|
Py_INCREF(self);
|
|
3951
|
-
|
|
4285
|
+
result = (PyObject *)self;
|
|
4286
|
+
goto finally;
|
|
3952
4287
|
}
|
|
3953
4288
|
|
|
3954
|
-
if (PyUnicode_CompareWithASCIIString(
|
|
4289
|
+
if (PyUnicode_CompareWithASCIIString(binding, "class") == 0)
|
|
3955
4290
|
{
|
|
3956
4291
|
Py_INCREF(self);
|
|
3957
|
-
|
|
4292
|
+
result = (PyObject *)self;
|
|
4293
|
+
goto finally;
|
|
3958
4294
|
}
|
|
3959
4295
|
|
|
3960
|
-
if (Py_TYPE(
|
|
4296
|
+
if (Py_TYPE(wrapped)->tp_descr_get == NULL)
|
|
3961
4297
|
{
|
|
3962
4298
|
Py_INCREF(self);
|
|
3963
|
-
|
|
4299
|
+
result = (PyObject *)self;
|
|
4300
|
+
goto finally;
|
|
3964
4301
|
}
|
|
3965
4302
|
|
|
3966
|
-
descriptor = (Py_TYPE(
|
|
3967
|
-
self->object_proxy.wrapped, obj, type);
|
|
4303
|
+
descriptor = (Py_TYPE(wrapped)->tp_descr_get)(wrapped, obj, type);
|
|
3968
4304
|
|
|
3969
4305
|
if (!descriptor)
|
|
3970
|
-
|
|
4306
|
+
goto finally;
|
|
3971
4307
|
|
|
3972
4308
|
if (Py_TYPE(self) != state->FunctionWrapper_Type)
|
|
3973
4309
|
{
|
|
@@ -3976,10 +4312,7 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
|
|
|
3976
4312
|
if (!bound_type)
|
|
3977
4313
|
{
|
|
3978
4314
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
3979
|
-
|
|
3980
|
-
Py_DECREF(descriptor);
|
|
3981
|
-
return NULL;
|
|
3982
|
-
}
|
|
4315
|
+
goto finally;
|
|
3983
4316
|
PyErr_Clear();
|
|
3984
4317
|
}
|
|
3985
4318
|
}
|
|
@@ -3989,77 +4322,68 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
|
|
|
3989
4322
|
|
|
3990
4323
|
result = PyObject_CallFunctionObjArgs(
|
|
3991
4324
|
bound_type ? bound_type : (PyObject *)state->BoundFunctionWrapper_Type,
|
|
3992
|
-
descriptor, obj,
|
|
3993
|
-
type, NULL);
|
|
3994
|
-
|
|
3995
|
-
Py_XDECREF(bound_type);
|
|
3996
|
-
Py_DECREF(descriptor);
|
|
4325
|
+
descriptor, obj, wrapper, enabled, binding, self, type, NULL);
|
|
3997
4326
|
|
|
3998
|
-
|
|
4327
|
+
goto finally;
|
|
3999
4328
|
}
|
|
4000
4329
|
|
|
4001
|
-
if (
|
|
4330
|
+
if (instance == Py_None)
|
|
4002
4331
|
{
|
|
4003
4332
|
int matched =
|
|
4004
|
-
PyUnicode_CompareWithASCIIString(
|
|
4005
|
-
PyUnicode_CompareWithASCIIString(
|
|
4006
|
-
PyUnicode_CompareWithASCIIString(
|
|
4333
|
+
PyUnicode_CompareWithASCIIString(binding, "function") == 0 ||
|
|
4334
|
+
PyUnicode_CompareWithASCIIString(binding, "instancemethod") == 0 ||
|
|
4335
|
+
PyUnicode_CompareWithASCIIString(binding, "callable") == 0;
|
|
4007
4336
|
|
|
4008
4337
|
if (matched)
|
|
4009
4338
|
{
|
|
4010
|
-
PyObject *
|
|
4339
|
+
PyObject *parent_wrapped = NULL;
|
|
4011
4340
|
|
|
4012
|
-
if (PyObject_TypeCheck(
|
|
4341
|
+
if (PyObject_TypeCheck(parent, state->ObjectProxy_Type))
|
|
4013
4342
|
{
|
|
4014
|
-
WraptObjectProxyObject *parent_proxy =
|
|
4015
|
-
(WraptObjectProxyObject *)self->parent;
|
|
4343
|
+
WraptObjectProxyObject *parent_proxy = (WraptObjectProxyObject *)parent;
|
|
4016
4344
|
|
|
4017
4345
|
if (!parent_proxy->wrapped)
|
|
4018
4346
|
{
|
|
4019
4347
|
if (raise_uninitialized_wrapper_error(parent_proxy) == -1)
|
|
4020
|
-
|
|
4348
|
+
goto finally;
|
|
4021
4349
|
}
|
|
4022
4350
|
|
|
4023
|
-
|
|
4024
|
-
Py_INCREF(wrapped);
|
|
4351
|
+
parent_wrapped = wrapt_acquire_wrapped(parent_proxy);
|
|
4025
4352
|
}
|
|
4026
4353
|
else
|
|
4027
4354
|
{
|
|
4028
4355
|
/* Fallback for the unusual case where parent is not a wrapt proxy. */
|
|
4029
|
-
|
|
4356
|
+
parent_wrapped = PyObject_GetAttr(parent, state->str_wrapped);
|
|
4030
4357
|
|
|
4031
|
-
if (!
|
|
4032
|
-
|
|
4358
|
+
if (!parent_wrapped)
|
|
4359
|
+
goto finally;
|
|
4033
4360
|
}
|
|
4034
4361
|
|
|
4035
|
-
if (Py_TYPE(
|
|
4362
|
+
if (Py_TYPE(parent_wrapped)->tp_descr_get == NULL)
|
|
4036
4363
|
{
|
|
4037
4364
|
PyErr_Format(PyExc_AttributeError,
|
|
4038
4365
|
"'%s' object has no attribute '__get__'",
|
|
4039
|
-
Py_TYPE(
|
|
4040
|
-
Py_DECREF(
|
|
4041
|
-
|
|
4366
|
+
Py_TYPE(parent_wrapped)->tp_name);
|
|
4367
|
+
Py_DECREF(parent_wrapped);
|
|
4368
|
+
goto finally;
|
|
4042
4369
|
}
|
|
4043
4370
|
|
|
4044
|
-
descriptor =
|
|
4371
|
+
descriptor =
|
|
4372
|
+
(Py_TYPE(parent_wrapped)->tp_descr_get)(parent_wrapped, obj, type);
|
|
4045
4373
|
|
|
4046
|
-
Py_DECREF(
|
|
4374
|
+
Py_DECREF(parent_wrapped);
|
|
4047
4375
|
|
|
4048
4376
|
if (!descriptor)
|
|
4049
|
-
|
|
4377
|
+
goto finally;
|
|
4050
4378
|
|
|
4051
|
-
if (Py_TYPE(
|
|
4379
|
+
if (Py_TYPE(parent) != state->FunctionWrapper_Type)
|
|
4052
4380
|
{
|
|
4053
|
-
bound_type =
|
|
4054
|
-
PyObject_GenericGetAttr((PyObject *)self->parent, bound_type_str);
|
|
4381
|
+
bound_type = PyObject_GenericGetAttr(parent, bound_type_str);
|
|
4055
4382
|
|
|
4056
4383
|
if (!bound_type)
|
|
4057
4384
|
{
|
|
4058
4385
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
4059
|
-
|
|
4060
|
-
Py_DECREF(descriptor);
|
|
4061
|
-
return NULL;
|
|
4062
|
-
}
|
|
4386
|
+
goto finally;
|
|
4063
4387
|
PyErr_Clear();
|
|
4064
4388
|
}
|
|
4065
4389
|
}
|
|
@@ -4069,18 +4393,27 @@ WraptFunctionWrapperBase_descr_get(WraptFunctionWrapperObject *self,
|
|
|
4069
4393
|
|
|
4070
4394
|
result = PyObject_CallFunctionObjArgs(
|
|
4071
4395
|
bound_type ? bound_type : (PyObject *)state->BoundFunctionWrapper_Type,
|
|
4072
|
-
descriptor, obj,
|
|
4073
|
-
self->parent, type, NULL);
|
|
4074
|
-
|
|
4075
|
-
Py_XDECREF(bound_type);
|
|
4076
|
-
Py_DECREF(descriptor);
|
|
4396
|
+
descriptor, obj, wrapper, enabled, binding, parent, type, NULL);
|
|
4077
4397
|
|
|
4078
|
-
|
|
4398
|
+
goto finally;
|
|
4079
4399
|
}
|
|
4080
4400
|
}
|
|
4081
4401
|
|
|
4082
4402
|
Py_INCREF(self);
|
|
4083
|
-
|
|
4403
|
+
result = (PyObject *)self;
|
|
4404
|
+
|
|
4405
|
+
finally:
|
|
4406
|
+
Py_XDECREF(bound_type);
|
|
4407
|
+
Py_XDECREF(descriptor);
|
|
4408
|
+
|
|
4409
|
+
Py_DECREF(wrapped);
|
|
4410
|
+
Py_XDECREF(instance);
|
|
4411
|
+
Py_XDECREF(wrapper);
|
|
4412
|
+
Py_XDECREF(enabled);
|
|
4413
|
+
Py_XDECREF(binding);
|
|
4414
|
+
Py_XDECREF(parent);
|
|
4415
|
+
|
|
4416
|
+
return result;
|
|
4084
4417
|
}
|
|
4085
4418
|
|
|
4086
4419
|
/* ------------------------------------------------------------------------- */
|
|
@@ -4103,7 +4436,11 @@ WraptFunctionWrapperBase_set_name(WraptFunctionWrapperObject *self,
|
|
|
4103
4436
|
if (!state)
|
|
4104
4437
|
return NULL;
|
|
4105
4438
|
|
|
4106
|
-
|
|
4439
|
+
PyObject *wrapped = wrapt_acquire_wrapped(&self->object_proxy);
|
|
4440
|
+
|
|
4441
|
+
method = PyObject_GetAttr(wrapped, state->str_set_name);
|
|
4442
|
+
|
|
4443
|
+
Py_DECREF(wrapped);
|
|
4107
4444
|
|
|
4108
4445
|
if (!method)
|
|
4109
4446
|
{
|
|
@@ -4126,13 +4463,16 @@ static PyObject *
|
|
|
4126
4463
|
WraptFunctionWrapperBase_get_self_instance(WraptFunctionWrapperObject *self,
|
|
4127
4464
|
void *closure)
|
|
4128
4465
|
{
|
|
4129
|
-
|
|
4466
|
+
PyObject *value = NULL;
|
|
4467
|
+
|
|
4468
|
+
value = wrapt_acquire_field((PyObject *)self, &self->instance);
|
|
4469
|
+
|
|
4470
|
+
if (!value)
|
|
4130
4471
|
{
|
|
4131
4472
|
Py_RETURN_NONE;
|
|
4132
4473
|
}
|
|
4133
4474
|
|
|
4134
|
-
|
|
4135
|
-
return self->instance;
|
|
4475
|
+
return value;
|
|
4136
4476
|
}
|
|
4137
4477
|
|
|
4138
4478
|
/* ------------------------------------------------------------------------- */
|
|
@@ -4141,13 +4481,16 @@ static PyObject *
|
|
|
4141
4481
|
WraptFunctionWrapperBase_get_self_wrapper(WraptFunctionWrapperObject *self,
|
|
4142
4482
|
void *closure)
|
|
4143
4483
|
{
|
|
4144
|
-
|
|
4484
|
+
PyObject *value = NULL;
|
|
4485
|
+
|
|
4486
|
+
value = wrapt_acquire_field((PyObject *)self, &self->wrapper);
|
|
4487
|
+
|
|
4488
|
+
if (!value)
|
|
4145
4489
|
{
|
|
4146
4490
|
Py_RETURN_NONE;
|
|
4147
4491
|
}
|
|
4148
4492
|
|
|
4149
|
-
|
|
4150
|
-
return self->wrapper;
|
|
4493
|
+
return value;
|
|
4151
4494
|
}
|
|
4152
4495
|
|
|
4153
4496
|
/* ------------------------------------------------------------------------- */
|
|
@@ -4156,13 +4499,16 @@ static PyObject *
|
|
|
4156
4499
|
WraptFunctionWrapperBase_get_self_enabled(WraptFunctionWrapperObject *self,
|
|
4157
4500
|
void *closure)
|
|
4158
4501
|
{
|
|
4159
|
-
|
|
4502
|
+
PyObject *value = NULL;
|
|
4503
|
+
|
|
4504
|
+
value = wrapt_acquire_field((PyObject *)self, &self->enabled);
|
|
4505
|
+
|
|
4506
|
+
if (!value)
|
|
4160
4507
|
{
|
|
4161
4508
|
Py_RETURN_NONE;
|
|
4162
4509
|
}
|
|
4163
4510
|
|
|
4164
|
-
|
|
4165
|
-
return self->enabled;
|
|
4511
|
+
return value;
|
|
4166
4512
|
}
|
|
4167
4513
|
|
|
4168
4514
|
/* ------------------------------------------------------------------------- */
|
|
@@ -4171,13 +4517,16 @@ static PyObject *
|
|
|
4171
4517
|
WraptFunctionWrapperBase_get_self_binding(WraptFunctionWrapperObject *self,
|
|
4172
4518
|
void *closure)
|
|
4173
4519
|
{
|
|
4174
|
-
|
|
4520
|
+
PyObject *value = NULL;
|
|
4521
|
+
|
|
4522
|
+
value = wrapt_acquire_field((PyObject *)self, &self->binding);
|
|
4523
|
+
|
|
4524
|
+
if (!value)
|
|
4175
4525
|
{
|
|
4176
4526
|
Py_RETURN_NONE;
|
|
4177
4527
|
}
|
|
4178
4528
|
|
|
4179
|
-
|
|
4180
|
-
return self->binding;
|
|
4529
|
+
return value;
|
|
4181
4530
|
}
|
|
4182
4531
|
|
|
4183
4532
|
/* ------------------------------------------------------------------------- */
|
|
@@ -4186,13 +4535,16 @@ static PyObject *
|
|
|
4186
4535
|
WraptFunctionWrapperBase_get_self_parent(WraptFunctionWrapperObject *self,
|
|
4187
4536
|
void *closure)
|
|
4188
4537
|
{
|
|
4189
|
-
|
|
4538
|
+
PyObject *value = NULL;
|
|
4539
|
+
|
|
4540
|
+
value = wrapt_acquire_field((PyObject *)self, &self->parent);
|
|
4541
|
+
|
|
4542
|
+
if (!value)
|
|
4190
4543
|
{
|
|
4191
4544
|
Py_RETURN_NONE;
|
|
4192
4545
|
}
|
|
4193
4546
|
|
|
4194
|
-
|
|
4195
|
-
return self->parent;
|
|
4547
|
+
return value;
|
|
4196
4548
|
}
|
|
4197
4549
|
|
|
4198
4550
|
/* ------------------------------------------------------------------------- */
|
|
@@ -4201,13 +4553,16 @@ static PyObject *
|
|
|
4201
4553
|
WraptFunctionWrapperBase_get_self_owner(WraptFunctionWrapperObject *self,
|
|
4202
4554
|
void *closure)
|
|
4203
4555
|
{
|
|
4204
|
-
|
|
4556
|
+
PyObject *value = NULL;
|
|
4557
|
+
|
|
4558
|
+
value = wrapt_acquire_field((PyObject *)self, &self->owner);
|
|
4559
|
+
|
|
4560
|
+
if (!value)
|
|
4205
4561
|
{
|
|
4206
4562
|
Py_RETURN_NONE;
|
|
4207
4563
|
}
|
|
4208
4564
|
|
|
4209
|
-
|
|
4210
|
-
return self->owner;
|
|
4565
|
+
return value;
|
|
4211
4566
|
}
|
|
4212
4567
|
|
|
4213
4568
|
/* ------------------------------------------------------------------------- */;
|
|
@@ -4266,6 +4621,12 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
|
|
|
4266
4621
|
|
|
4267
4622
|
PyObject *wrapped = NULL;
|
|
4268
4623
|
PyObject *instance = NULL;
|
|
4624
|
+
PyObject *wrapper = NULL;
|
|
4625
|
+
PyObject *enabled = NULL;
|
|
4626
|
+
PyObject *binding = NULL;
|
|
4627
|
+
PyObject *owner = NULL;
|
|
4628
|
+
|
|
4629
|
+
PyObject *call_instance = NULL;
|
|
4269
4630
|
|
|
4270
4631
|
PyObject *result = NULL;
|
|
4271
4632
|
|
|
@@ -4281,36 +4642,57 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
|
|
|
4281
4642
|
if (!state)
|
|
4282
4643
|
return NULL;
|
|
4283
4644
|
|
|
4284
|
-
|
|
4645
|
+
/* Hold strong references to the fields used across the call so a
|
|
4646
|
+
* concurrent re-initialization of the wrapper cannot release them
|
|
4647
|
+
* while in use. Fields are acquired independently, so a consistent
|
|
4648
|
+
* snapshot across all of them is not guaranteed, as documented. The
|
|
4649
|
+
* call_instance local always holds an owned reference to whichever
|
|
4650
|
+
* instance value is passed through to the wrapper. */
|
|
4651
|
+
|
|
4652
|
+
instance = wrapt_acquire_field((PyObject *)self, &self->instance);
|
|
4653
|
+
wrapper = wrapt_acquire_field((PyObject *)self, &self->wrapper);
|
|
4654
|
+
enabled = wrapt_acquire_field((PyObject *)self, &self->enabled);
|
|
4655
|
+
binding = wrapt_acquire_field((PyObject *)self, &self->binding);
|
|
4656
|
+
owner = wrapt_acquire_field((PyObject *)self, &self->owner);
|
|
4657
|
+
|
|
4658
|
+
if (enabled != Py_None)
|
|
4285
4659
|
{
|
|
4286
|
-
if (PyCallable_Check(
|
|
4660
|
+
if (PyCallable_Check(enabled))
|
|
4287
4661
|
{
|
|
4288
4662
|
PyObject *object = NULL;
|
|
4289
4663
|
int is_false;
|
|
4290
4664
|
|
|
4291
|
-
object = PyObject_CallFunctionObjArgs(
|
|
4665
|
+
object = PyObject_CallFunctionObjArgs(enabled, NULL);
|
|
4292
4666
|
|
|
4293
4667
|
if (!object)
|
|
4294
|
-
|
|
4668
|
+
goto finally;
|
|
4295
4669
|
|
|
4296
4670
|
is_false = PyObject_Not(object);
|
|
4297
4671
|
Py_DECREF(object);
|
|
4298
4672
|
|
|
4299
4673
|
if (is_false < 0)
|
|
4300
|
-
|
|
4674
|
+
goto finally;
|
|
4301
4675
|
|
|
4302
4676
|
if (is_false)
|
|
4303
|
-
|
|
4677
|
+
{
|
|
4678
|
+
wrapped = wrapt_acquire_wrapped(&self->object_proxy);
|
|
4679
|
+
result = PyObject_Call(wrapped, args, kwds);
|
|
4680
|
+
goto finally;
|
|
4681
|
+
}
|
|
4304
4682
|
}
|
|
4305
4683
|
else
|
|
4306
4684
|
{
|
|
4307
|
-
int is_false = PyObject_Not(
|
|
4685
|
+
int is_false = PyObject_Not(enabled);
|
|
4308
4686
|
|
|
4309
4687
|
if (is_false < 0)
|
|
4310
|
-
|
|
4688
|
+
goto finally;
|
|
4311
4689
|
|
|
4312
4690
|
if (is_false)
|
|
4313
|
-
|
|
4691
|
+
{
|
|
4692
|
+
wrapped = wrapt_acquire_wrapped(&self->object_proxy);
|
|
4693
|
+
result = PyObject_Call(wrapped, args, kwds);
|
|
4694
|
+
goto finally;
|
|
4695
|
+
}
|
|
4314
4696
|
}
|
|
4315
4697
|
}
|
|
4316
4698
|
|
|
@@ -4320,13 +4702,13 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
|
|
|
4320
4702
|
*/
|
|
4321
4703
|
|
|
4322
4704
|
matched =
|
|
4323
|
-
PyUnicode_CompareWithASCIIString(
|
|
4324
|
-
PyUnicode_CompareWithASCIIString(
|
|
4705
|
+
PyUnicode_CompareWithASCIIString(binding, "function") == 0 ||
|
|
4706
|
+
PyUnicode_CompareWithASCIIString(binding, "callable") == 0;
|
|
4325
4707
|
|
|
4326
4708
|
if (matched)
|
|
4327
4709
|
{
|
|
4328
4710
|
|
|
4329
|
-
if (
|
|
4711
|
+
if (instance == Py_None && PyTuple_GET_SIZE(args) != 0)
|
|
4330
4712
|
{
|
|
4331
4713
|
/*
|
|
4332
4714
|
* This situation can occur where someone is calling the
|
|
@@ -4337,74 +4719,66 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
|
|
|
4337
4719
|
* so the wrapper doesn't see anything as being different.
|
|
4338
4720
|
*/
|
|
4339
4721
|
|
|
4340
|
-
|
|
4722
|
+
call_instance = PyTuple_GetItem(args, 0);
|
|
4341
4723
|
|
|
4342
|
-
if (!
|
|
4343
|
-
|
|
4724
|
+
if (!call_instance)
|
|
4725
|
+
goto finally;
|
|
4726
|
+
|
|
4727
|
+
Py_INCREF(call_instance);
|
|
4344
4728
|
|
|
4345
|
-
int check = PyObject_IsInstance(
|
|
4729
|
+
int check = PyObject_IsInstance(call_instance, owner);
|
|
4346
4730
|
|
|
4347
4731
|
if (check < 0)
|
|
4348
|
-
|
|
4732
|
+
goto finally;
|
|
4349
4733
|
|
|
4350
4734
|
if (check)
|
|
4351
4735
|
{
|
|
4352
|
-
|
|
4353
|
-
|
|
4354
|
-
return NULL;
|
|
4736
|
+
PyObject *inner_wrapped = wrapt_acquire_wrapped(&self->object_proxy);
|
|
4737
|
+
|
|
4355
4738
|
wrapped = PyObject_CallFunctionObjArgs(
|
|
4356
4739
|
(PyObject *)state->PartialCallableObjectProxy_Type,
|
|
4357
|
-
|
|
4740
|
+
inner_wrapped, call_instance, NULL);
|
|
4741
|
+
|
|
4742
|
+
Py_DECREF(inner_wrapped);
|
|
4358
4743
|
|
|
4359
4744
|
if (!wrapped)
|
|
4360
|
-
|
|
4745
|
+
goto finally;
|
|
4361
4746
|
|
|
4362
4747
|
param_args = PyTuple_GetSlice(args, 1, PyTuple_GET_SIZE(args));
|
|
4363
4748
|
|
|
4364
4749
|
if (!param_args)
|
|
4365
|
-
|
|
4366
|
-
Py_DECREF(wrapped);
|
|
4367
|
-
return NULL;
|
|
4368
|
-
}
|
|
4750
|
+
goto finally;
|
|
4369
4751
|
|
|
4370
4752
|
args = param_args;
|
|
4371
4753
|
}
|
|
4372
4754
|
else
|
|
4373
4755
|
{
|
|
4374
|
-
|
|
4756
|
+
Py_DECREF(call_instance);
|
|
4757
|
+
call_instance = instance;
|
|
4758
|
+
Py_XINCREF(call_instance);
|
|
4375
4759
|
}
|
|
4376
4760
|
}
|
|
4377
4761
|
else
|
|
4378
4762
|
{
|
|
4379
|
-
|
|
4763
|
+
call_instance = instance;
|
|
4764
|
+
Py_XINCREF(call_instance);
|
|
4380
4765
|
}
|
|
4381
4766
|
|
|
4382
4767
|
if (!wrapped)
|
|
4383
4768
|
{
|
|
4384
|
-
|
|
4385
|
-
wrapped = self->object_proxy.wrapped;
|
|
4769
|
+
wrapped = wrapt_acquire_wrapped(&self->object_proxy);
|
|
4386
4770
|
}
|
|
4387
4771
|
|
|
4388
4772
|
if (!kwds)
|
|
4389
4773
|
{
|
|
4390
4774
|
param_kwds = PyDict_New();
|
|
4391
4775
|
if (!param_kwds)
|
|
4392
|
-
|
|
4393
|
-
Py_XDECREF(param_args);
|
|
4394
|
-
Py_DECREF(wrapped);
|
|
4395
|
-
return NULL;
|
|
4396
|
-
}
|
|
4776
|
+
goto finally;
|
|
4397
4777
|
kwds = param_kwds;
|
|
4398
4778
|
}
|
|
4399
4779
|
|
|
4400
|
-
result = PyObject_CallFunctionObjArgs(
|
|
4780
|
+
result = PyObject_CallFunctionObjArgs(wrapper, wrapped, call_instance,
|
|
4401
4781
|
args, kwds, NULL);
|
|
4402
|
-
|
|
4403
|
-
Py_XDECREF(param_args);
|
|
4404
|
-
Py_XDECREF(param_kwds);
|
|
4405
|
-
Py_DECREF(wrapped);
|
|
4406
|
-
|
|
4407
|
-
return result;
|
|
4408
4782
|
}
|
|
4409
4783
|
else
|
|
4410
4784
|
{
|
|
@@ -4423,37 +4797,45 @@ WraptBoundFunctionWrapper_call(WraptFunctionWrapperObject *self, PyObject *args,
|
|
|
4423
4797
|
* available in the decoratored function.
|
|
4424
4798
|
*/
|
|
4425
4799
|
|
|
4426
|
-
|
|
4800
|
+
wrapped = wrapt_acquire_wrapped(&self->object_proxy);
|
|
4427
4801
|
|
|
4428
|
-
|
|
4802
|
+
call_instance = PyObject_GetAttr(wrapped, state->str_self);
|
|
4803
|
+
|
|
4804
|
+
if (!call_instance)
|
|
4429
4805
|
{
|
|
4430
4806
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
4431
|
-
|
|
4807
|
+
goto finally;
|
|
4432
4808
|
PyErr_Clear();
|
|
4433
4809
|
Py_INCREF(Py_None);
|
|
4434
|
-
|
|
4810
|
+
call_instance = Py_None;
|
|
4435
4811
|
}
|
|
4436
4812
|
|
|
4437
4813
|
if (!kwds)
|
|
4438
4814
|
{
|
|
4439
4815
|
param_kwds = PyDict_New();
|
|
4440
4816
|
if (!param_kwds)
|
|
4441
|
-
|
|
4442
|
-
Py_DECREF(instance);
|
|
4443
|
-
return NULL;
|
|
4444
|
-
}
|
|
4817
|
+
goto finally;
|
|
4445
4818
|
kwds = param_kwds;
|
|
4446
4819
|
}
|
|
4447
4820
|
|
|
4448
|
-
result = PyObject_CallFunctionObjArgs(
|
|
4449
|
-
|
|
4821
|
+
result = PyObject_CallFunctionObjArgs(wrapper, wrapped, call_instance,
|
|
4822
|
+
args, kwds, NULL);
|
|
4823
|
+
}
|
|
4824
|
+
|
|
4825
|
+
finally:
|
|
4826
|
+
Py_XDECREF(param_args);
|
|
4827
|
+
Py_XDECREF(param_kwds);
|
|
4450
4828
|
|
|
4451
|
-
|
|
4829
|
+
Py_XDECREF(call_instance);
|
|
4452
4830
|
|
|
4453
|
-
|
|
4831
|
+
Py_XDECREF(wrapped);
|
|
4832
|
+
Py_XDECREF(instance);
|
|
4833
|
+
Py_XDECREF(wrapper);
|
|
4834
|
+
Py_XDECREF(enabled);
|
|
4835
|
+
Py_XDECREF(binding);
|
|
4836
|
+
Py_XDECREF(owner);
|
|
4454
4837
|
|
|
4455
|
-
|
|
4456
|
-
}
|
|
4838
|
+
return result;
|
|
4457
4839
|
}
|
|
4458
4840
|
|
|
4459
4841
|
/* ------------------------------------------------------------------------- */
|
|
@@ -4466,19 +4848,29 @@ static PyObject *WraptBoundFunctionWrapper_getattr(
|
|
|
4466
4848
|
if (!PyArg_ParseTuple(args, "U:__getattr__", &name))
|
|
4467
4849
|
return NULL;
|
|
4468
4850
|
|
|
4469
|
-
|
|
4851
|
+
PyObject *parent = wrapt_acquire_field((PyObject *)self, &self->parent);
|
|
4852
|
+
|
|
4853
|
+
if (parent && parent != Py_None)
|
|
4470
4854
|
{
|
|
4471
|
-
PyObject *result = PyObject_GetAttr(
|
|
4855
|
+
PyObject *result = PyObject_GetAttr(parent, name);
|
|
4472
4856
|
|
|
4473
4857
|
if (result)
|
|
4858
|
+
{
|
|
4859
|
+
Py_DECREF(parent);
|
|
4474
4860
|
return result;
|
|
4861
|
+
}
|
|
4475
4862
|
|
|
4476
4863
|
if (!PyErr_ExceptionMatches(PyExc_AttributeError))
|
|
4864
|
+
{
|
|
4865
|
+
Py_DECREF(parent);
|
|
4477
4866
|
return NULL;
|
|
4867
|
+
}
|
|
4478
4868
|
|
|
4479
4869
|
PyErr_Clear();
|
|
4480
4870
|
}
|
|
4481
4871
|
|
|
4872
|
+
Py_XDECREF(parent);
|
|
4873
|
+
|
|
4482
4874
|
return WraptObjectProxy_getattr((WraptObjectProxyObject *)self, args);
|
|
4483
4875
|
}
|
|
4484
4876
|
|
|
@@ -4503,8 +4895,18 @@ static int WraptBoundFunctionWrapper_setattro(
|
|
|
4503
4895
|
return PyObject_GenericSetAttr((PyObject *)self, name, value);
|
|
4504
4896
|
|
|
4505
4897
|
/* User-defined _self_ attribute — delegate to parent */
|
|
4506
|
-
|
|
4507
|
-
|
|
4898
|
+
PyObject *parent = wrapt_acquire_field((PyObject *)self, &self->parent);
|
|
4899
|
+
|
|
4900
|
+
if (parent && parent != Py_None)
|
|
4901
|
+
{
|
|
4902
|
+
int result = PyObject_GenericSetAttr(parent, name, value);
|
|
4903
|
+
|
|
4904
|
+
Py_DECREF(parent);
|
|
4905
|
+
|
|
4906
|
+
return result;
|
|
4907
|
+
}
|
|
4908
|
+
|
|
4909
|
+
Py_XDECREF(parent);
|
|
4508
4910
|
}
|
|
4509
4911
|
|
|
4510
4912
|
/* Fall through to base ObjectProxy setattro for everything else */
|