Commit e5a9eaa3 authored by Grégory Wisniewski's avatar Grégory Wisniewski

dump() and bin() handle None values.


git-svn-id: https://svn.erp5.org/repos/neo/branches/prototype3@1262 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent c225ee37
...@@ -27,6 +27,8 @@ def p64(n): ...@@ -27,6 +27,8 @@ def p64(n):
def dump(s): def dump(s):
"""Dump a binary string in hex.""" """Dump a binary string in hex."""
if s is None:
return None
if isinstance(s, str): if isinstance(s, str):
ret = [] ret = []
for c in s: for c in s:
...@@ -38,6 +40,8 @@ def dump(s): ...@@ -38,6 +40,8 @@ def dump(s):
def bin(s): def bin(s):
"""Inverse of dump method.""" """Inverse of dump method."""
if s is None:
return None
ret = [] ret = []
while len(s): while len(s):
ret.append(chr(int(s[:2], 16))) ret.append(chr(int(s[:2], 16)))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment