@@ -2776,6 +2776,15 @@ def pie(self):
2776
2776
unpickled = self .loads (self .dumps (method , proto ))
2777
2777
self .assertEqual (method (obj ), unpickled (obj ))
2778
2778
2779
+ descriptors = (
2780
+ PyMethodsTest .__dict__ ['cheese' ], # static method descriptor
2781
+ PyMethodsTest .__dict__ ['wine' ], # class method descriptor
2782
+ )
2783
+ for proto in range (pickle .HIGHEST_PROTOCOL + 1 ):
2784
+ for descr in descriptors :
2785
+ with self .subTest (proto = proto , descr = descr ):
2786
+ self .assertRaises (TypeError , self .dumps , descr , proto )
2787
+
2779
2788
def test_c_methods (self ):
2780
2789
global Subclass
2781
2790
class Subclass (tuple ):
@@ -2811,6 +2820,15 @@ class Nested(str):
2811
2820
unpickled = self .loads (self .dumps (method , proto ))
2812
2821
self .assertEqual (method (* args ), unpickled (* args ))
2813
2822
2823
+ descriptors = (
2824
+ bytearray .__dict__ ['maketrans' ], # built-in static method descriptor
2825
+ dict .__dict__ ['fromkeys' ], # built-in class method descriptor
2826
+ )
2827
+ for proto in range (pickle .HIGHEST_PROTOCOL + 1 ):
2828
+ for descr in descriptors :
2829
+ with self .subTest (proto = proto , descr = descr ):
2830
+ self .assertRaises (TypeError , self .dumps , descr , proto )
2831
+
2814
2832
def test_compat_pickle (self ):
2815
2833
tests = [
2816
2834
(range (1 , 7 ), '__builtin__' , 'xrange' ),
0 commit comments