22//! constructing Python strings using Rust's `fmt::Write` trait.
33//! It allows for incremental string construction, without the need for repeated allocations, and
44//! is particularly useful for building strings in a performance-sensitive context.
5- #[ cfg( not( Py_LIMITED_API ) ) ]
5+ #[ cfg( not( any ( Py_LIMITED_API , PyPy ) ) ) ]
66use {
77 crate :: ffi:: compat:: {
88 PyUnicodeWriter_Create , PyUnicodeWriter_Discard , PyUnicodeWriter_Finish ,
@@ -24,14 +24,14 @@ macro_rules! py_format {
2424 }
2525}
2626
27- #[ cfg( not( Py_LIMITED_API ) ) ]
27+ #[ cfg( not( any ( Py_LIMITED_API , PyPy ) ) ) ]
2828/// The `PyUnicodeWriter` is a utility for efficiently constructing Python strings
2929pub struct PyUnicodeWriter {
3030 writer : NonNull < ffi:: PyUnicodeWriter > ,
3131 last_error : Option < PyErr > ,
3232}
3333
34- #[ cfg( not( Py_LIMITED_API ) ) ]
34+ #[ cfg( not( any ( Py_LIMITED_API , PyPy ) ) ) ]
3535impl PyUnicodeWriter {
3636 /// Creates a new `PyUnicodeWriter`.
3737 pub fn new ( py : Python < ' _ > ) -> PyResult < Self > {
@@ -76,7 +76,7 @@ impl PyUnicodeWriter {
7676 }
7777}
7878
79- #[ cfg( not( Py_LIMITED_API ) ) ]
79+ #[ cfg( not( any ( Py_LIMITED_API , PyPy ) ) ) ]
8080impl fmt:: Write for PyUnicodeWriter {
8181 fn write_str ( & mut self , s : & str ) -> fmt:: Result {
8282 let result = unsafe {
@@ -101,7 +101,7 @@ impl fmt::Write for PyUnicodeWriter {
101101 }
102102}
103103
104- #[ cfg( not( Py_LIMITED_API ) ) ]
104+ #[ cfg( not( any ( Py_LIMITED_API , PyPy ) ) ) ]
105105impl Drop for PyUnicodeWriter {
106106 fn drop ( & mut self ) {
107107 unsafe {
@@ -112,14 +112,14 @@ impl Drop for PyUnicodeWriter {
112112
113113#[ cfg( test) ]
114114mod tests {
115- #[ cfg( not( Py_LIMITED_API ) ) ]
115+ #[ cfg( not( any ( Py_LIMITED_API , PyPy ) ) ) ]
116116 use super :: * ;
117117 use crate :: types:: PyStringMethods ;
118118 use crate :: { IntoPyObject , Python } ;
119119
120120 #[ test]
121121 #[ allow( clippy:: write_literal) ]
122- #[ cfg( not( Py_LIMITED_API ) ) ]
122+ #[ cfg( not( any ( Py_LIMITED_API , PyPy ) ) ) ]
123123 fn unicode_writer_test ( ) {
124124 use std:: fmt:: Write ;
125125 Python :: with_gil ( |py| {
0 commit comments