File tree Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Expand file tree Collapse file tree 2 files changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -599,6 +599,8 @@ def _term_to_binary(term):
599599 return _dict_to_binary (term )
600600 elif type (term ) == bool :
601601 return OtpErlangAtom (term and b'true' or b'false' ).binary ()
602+ elif term is None :
603+ return OtpErlangAtom (b'undefined' ).binary ()
602604 elif isinstance (term , OtpErlangAtom ):
603605 return term .binary ()
604606 elif isinstance (term , OtpErlangList ):
Original file line number Diff line number Diff line change @@ -434,9 +434,10 @@ def test_term_to_binary_string_basic(self):
434434 def test_term_to_binary_string (self ):
435435 self .assertEqual (b'\x83 j' , erlang .term_to_binary ('' ))
436436 self .assertEqual (b'\x83 k\0 \4 test' , erlang .term_to_binary ('test' ))
437- def test_term_to_binary_boolean (self ):
437+ def test_term_to_binary_predefined_atom (self ):
438438 self .assertEqual (b'\x83 s\4 true' , erlang .term_to_binary (True ))
439439 self .assertEqual (b'\x83 s\5 false' , erlang .term_to_binary (False ))
440+ self .assertEqual (b'\x83 s\x09 undefined' , erlang .term_to_binary (None ))
440441 def test_term_to_binary_short_integer (self ):
441442 self .assertEqual (b'\x83 a\0 ' , erlang .term_to_binary (0 ))
442443 self .assertEqual (b'\x83 a\xff ' , erlang .term_to_binary (255 ))
You can’t perform that action at this time.
0 commit comments