@@ -1635,14 +1635,7 @@ def _deserialize(
1635
1635
if value is None :
1636
1636
return None
1637
1637
try :
1638
- if not isinstance (value , str ):
1639
- # ip_address function is flexible in the terms of input value. In the case of
1640
- # marshalling, integer and binary address representation parsing may lead to
1641
- # confusion.
1642
- raise TypeError (
1643
- "Only dot-decimal and hexadecimal groups notations are supported."
1644
- )
1645
- return ipaddress .ip_address (value )
1638
+ return ipaddress .ip_address (utils .ensure_text_type (value ))
1646
1639
except (ValueError , TypeError ) as error :
1647
1640
raise self .make_error ("invalid_ip" ) from error
1648
1641
@@ -1658,9 +1651,7 @@ def _deserialize(
1658
1651
if value is None :
1659
1652
return None
1660
1653
try :
1661
- if not isinstance (value , str ):
1662
- raise TypeError ("Only dot-decimal notation is supported." )
1663
- return ipaddress .IPv4Address (value )
1654
+ return ipaddress .IPv4Address (utils .ensure_text_type (value ))
1664
1655
except (ValueError , TypeError ) as error :
1665
1656
raise self .make_error ("invalid_ip" ) from error
1666
1657
@@ -1676,9 +1667,7 @@ def _deserialize(
1676
1667
if value is None :
1677
1668
return None
1678
1669
try :
1679
- if not isinstance (value , str ):
1680
- raise TypeError ("Only hexadecimal groups notation is supported." )
1681
- return ipaddress .IPv6Address (value )
1670
+ return ipaddress .IPv6Address (utils .ensure_text_type (value ))
1682
1671
except (ValueError , TypeError ) as error :
1683
1672
raise self .make_error ("invalid_ip" ) from error
1684
1673
@@ -1767,7 +1756,7 @@ def __init__(
1767
1756
typing .Callable [[typing .Any ], typing .Any ],
1768
1757
typing .Callable [[typing .Any , typing .Dict ], typing .Any ],
1769
1758
] = None ,
1770
- ** kwargs
1759
+ ** kwargs ,
1771
1760
):
1772
1761
# Set dump_only and load_only based on arguments
1773
1762
kwargs ["dump_only" ] = bool (serialize ) and not bool (deserialize )
0 commit comments