From c6105ad29bf398ce6166244fec686ca09feec107 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Thu, 1 Jun 2023 17:57:44 +0200 Subject: [PATCH] move statics into `to_object` bodies --- src/conversions/std/ipaddr.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/conversions/std/ipaddr.rs b/src/conversions/std/ipaddr.rs index b1f94982465..419734f8e71 100755 --- a/src/conversions/std/ipaddr.rs +++ b/src/conversions/std/ipaddr.rs @@ -17,9 +17,6 @@ impl GILOnceCell> { } } -static IPV4_ADDRESS: GILOnceCell> = GILOnceCell::new(); -static IPV6_ADDRESS: GILOnceCell> = GILOnceCell::new(); - impl FromPyObject<'_> for IpAddr { fn extract(obj: &PyAny) -> PyResult { match obj.getattr(intern!(obj.py(), "packed")) { @@ -42,6 +39,7 @@ impl FromPyObject<'_> for IpAddr { impl ToPyObject for Ipv4Addr { fn to_object(&self, py: Python<'_>) -> PyObject { + static IPV4_ADDRESS: GILOnceCell> = GILOnceCell::new(); IPV4_ADDRESS .get_or_try_init_type_ref(py, "ipaddress", "IPv4Address") .expect("failed to load ipaddress.IPv4Address") @@ -53,6 +51,7 @@ impl ToPyObject for Ipv4Addr { impl ToPyObject for Ipv6Addr { fn to_object(&self, py: Python<'_>) -> PyObject { + static IPV6_ADDRESS: GILOnceCell> = GILOnceCell::new(); IPV6_ADDRESS .get_or_try_init_type_ref(py, "ipaddress", "IPv6Address") .expect("failed to load ipaddress.IPv6Address")