Merge pull request #4427 from yt2b/fix_integer_format

Fix integer format
This commit is contained in:
Jeong YunWon authored and GitHub committed 2023-01-07 19:41:32 +09:00
commit 55aac852fd
2 files changed
+15 -1

No files matched your search

+1 -1
View File
@@ -600,7 +600,7 @@ impl FormatSpec {
let sign_prefix = format!("{}{}", sign_str, prefix);
let magnitude_str = self.add_magnitude_separators(raw_magnitude_str?, &sign_prefix);
self.format_sign_and_align(
unsafe { &BorrowedStr::from_ascii_unchecked(magnitude_str.as_bytes()) },
&BorrowedStr::from_bytes(magnitude_str.as_bytes()),
&sign_prefix,
FormatAlign::Right,
)
+14
View File
@@ -80,6 +80,20 @@ impl<'a> BorrowedStr<'a> {
}
}
#[inline]
pub fn from_bytes(s: &'a [u8]) -> Self {
let k = if s.is_ascii() {
PyStrKind::Ascii.new_data()
} else {
PyStrKind::Utf8.new_data()
};
Self {
bytes: s,
kind: k,
hash: PyAtomic::<PyHash>::new(0),
}
}
#[inline]
pub fn as_str(&self) -> &str {
unsafe {