@@ -65,7 +65,7 @@ def serialize(self):
6565
6666 @classmethod
6767 def parse (typ , data ):
68- if data [ - 1 ] != b'\x00 ' :
68+ if not data . endswith ( b'\x00 ' ) :
6969 raise ValueError ("string message not NUL-terminated" )
7070 return typ (data [:- 1 ])
7171
@@ -618,11 +618,7 @@ class Synchronize(EmptyMessage):
618618class Query (StringMessage ):
619619 """Execute the query with the given arguments"""
620620 type = b'Q'
621- __slots__ = ()
622-
623- @classmethod
624- def parse (typ , data ):
625- return typ (data [0 :- 1 ])
621+ __slots__ = ('data' ,)
626622
627623class Parse (Message ):
628624 """Parse a query with the specified argument types"""
@@ -739,7 +735,7 @@ def parse(typ, data):
739735class Describe (StringMessage ):
740736 """Describe a Portal or Prepared Statement"""
741737 type = b'D'
742- __slots__ = ()
738+ __slots__ = ('data' , )
743739
744740 def serialize (self ):
745741 return self .subtype + self .data + b'\x00 '
@@ -752,15 +748,15 @@ def parse(typ, data):
752748 typ .subtype , data [0 :1 ]
753749 )
754750 )
755- return typ ( data [1 :- 1 ])
751+ return super (). parse ( data [1 :])
756752
757753class DescribeStatement (Describe ):
758754 subtype = b'S'
759- __slots__ = ()
755+ __slots__ = ('data' , )
760756
761757class DescribePortal (Describe ):
762758 subtype = b'P'
763- __slots__ = ()
759+ __slots__ = ('data' , )
764760
765761class Close (StringMessage ):
766762 """Generic Close"""
@@ -778,7 +774,7 @@ def parse(typ, data):
778774 typ .subtype , data [0 :1 ]
779775 )
780776 )
781- return typ ( data [1 :- 1 ])
777+ return super (). parse ( data [1 :])
782778
783779class CloseStatement (Close ):
784780 """Close the specified Statement"""
@@ -888,14 +884,10 @@ def parse(typ, data):
888884
889885class CopyFail (StringMessage ):
890886 type = b'f'
891- __slots__ = ()
892-
893- @classmethod
894- def parse (typ , data ):
895- return typ (data [:- 1 ])
887+ __slots__ = ('data' ,)
896888
897889class CopyDone (EmptyMessage ):
898890 type = b'c'
899- __slots__ = ()
891+ __slots__ = ('data' , )
900892CopyDoneMessage = Message .__new__ (CopyDone )
901893CopyDone .SingleInstance = CopyDoneMessage
0 commit comments