def strip_PKCS7_padding(s):
 if ((len(s) % 16) or (not s)):
  raise ValueError(("String of len %d can't be PCKS7-padded" % len(s)))
 numpads = ord(s[(-1)])
 if (numpads > 16):
  raise ValueError(("String ending with %r can't be PCKS7-padded" % s[(-1)]))
 if (s[(- numpads):] != (numpads * chr(numpads))):
  raise ValueError('Invalid PKCS7 padding')
 return s[:(- numpads)]

def strip_PKCS7_padding ( s ) : if ( ( len ( s ) % 16 ) or ( not s ) ) : raise ValueError ( ( "String of len %d can't be PCKS7-padded" % len ( s ) ) ) numpads = ord ( s [ ( - 1 ) ] ) if ( numpads > 16 ) : raise ValueError ( ( "String ending with %r can't be PCKS7-padded" % s [ ( - 1 ) ] ) ) if ( s [ ( - numpads ) : ] != ( numpads * chr ( numpads ) ) ) : raise ValueError ( 'Invalid PKCS7 padding' ) return s [ : ( - numpads ) ]
return s stripped of pkcs7 padding .