Permalink
Browse files

Added an exception if trying to serialize a regex object. It's imposs…

…ible in CPython to get information about a compiled regex.
  • Loading branch information...
1 parent 75afaf1 commit 5f65d2e74bd2c03b94ff54ffe7dda9ddfe2305d1 @samuel committed Oct 22, 2009
Showing with 2 additions and 1 deletion.
  1. +2 −1 bert/codec.py
View
@@ -72,11 +72,12 @@ def convert(self, obj):
megaseconds = seconds // 1000000
seconds = seconds % 1000000
return (Atom("bert"), Atom("time"), megaseconds, seconds, microseconds)
- # elif isinstance(obj, re):
elif isinstance(obj, list):
return [self.convert(item) for item in obj]
elif isinstance(obj, tuple):
return tuple(self.convert(item) for item in obj)
+ elif str(type(obj)).startswith('<_sre.SRE_Pattern object'):
+ raise NotImplementedError("It is impossible to serialize a regex object")
return obj
def datetime_to_split_time(dt):

0 comments on commit 5f65d2e

Please sign in to comment.