Remove cstr macro
This commit is contained in:
parent
d8dc3a17bd
commit
09883574e5
|
@ -279,7 +279,7 @@ impl PyBuffer {
|
|||
#[inline]
|
||||
pub fn format(&self) -> &CStr {
|
||||
if self.0.format.is_null() {
|
||||
cstr!("B")
|
||||
CStr::from_bytes_with_nul("B".as_bytes()).unwrap()
|
||||
} else {
|
||||
unsafe { CStr::from_ptr(self.0.format) }
|
||||
}
|
||||
|
|
|
@ -340,10 +340,10 @@ impl UnicodeDecodeError {
|
|||
let pos = err.valid_up_to();
|
||||
UnicodeDecodeError::new_err(
|
||||
py,
|
||||
cstr!("utf-8"),
|
||||
CStr::from_bytes_with_nul("utf-8".as_bytes()).unwrap(),
|
||||
input,
|
||||
pos..pos + 1,
|
||||
cstr!("invalid utf-8"),
|
||||
CStr::from_bytes_with_nul("invalid utf-8".as_bytes()).unwrap(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -147,19 +147,10 @@ mod ffi2;
|
|||
#[cfg(Py_3)]
|
||||
mod ffi3;
|
||||
|
||||
pub mod class;
|
||||
|
||||
/// Constructs a `&'static CStr` literal.
|
||||
macro_rules! cstr {
|
||||
($s: tt) => {
|
||||
// TODO: verify that $s is a string literal without nuls
|
||||
unsafe { ::std::ffi::CStr::from_ptr(concat!($s, "\0").as_ptr() as *const _) }
|
||||
};
|
||||
}
|
||||
|
||||
pub mod buffer;
|
||||
#[doc(hidden)]
|
||||
pub mod callback;
|
||||
pub mod class;
|
||||
mod conversion;
|
||||
#[doc(hidden)]
|
||||
pub mod derive_utils;
|
||||
|
|
Loading…
Reference in New Issue