Fix deprecation warnings on sync and mem

This commit is contained in:
ijl 2019-07-07 09:52:25 +00:00
parent 9669edbfe3
commit c27d9947a8
4 changed files with 10 additions and 9 deletions

View file

@ -21,7 +21,7 @@ matrix:
- name: Minimum nightly
python: "3.7"
# Keep this synced up with build.rs
env: TRAVIS_RUST_VERSION=nightly-2019-02-07
env: TRAVIS_RUST_VERSION=nightly-2019-06-22
# Tested via anaconda PyPy (since travis's PyPy version is too old)
- name: PyPy3.5 7.0
python: "3.7"

View file

@ -9,8 +9,8 @@ use spin;
use std::ptr::NonNull;
use std::{any, marker, rc, sync};
static START: sync::Once = sync::ONCE_INIT;
static START_PYO3: sync::Once = sync::ONCE_INIT;
static START: sync::Once = sync::Once::new();
static START_PYO3: sync::Once = sync::Once::new();
/// Prepares the use of Python in a free-threaded context.
///
@ -301,7 +301,8 @@ mod array_list {
pub fn push_back(&mut self, item: T) -> &T {
let next_idx = self.next_idx();
if next_idx == 0 {
self.inner.push_back(unsafe { mem::uninitialized() });
self.inner
.push_back(unsafe { mem::MaybeUninit::uninit().assume_init() });
}
self.inner.back_mut().unwrap()[next_idx] = item;
self.length += 1;

View file

@ -10,7 +10,7 @@ use crate::AsPyPointer;
use crate::IntoPyPointer;
use crate::Python;
use crate::{IntoPyObject, ToBorrowedObject, ToPyObject};
use std::{cmp, collections, hash, mem};
use std::{cmp, collections, hash};
/// Represents a Python `dict`.
#[repr(transparent)]
@ -172,8 +172,8 @@ impl<'py> Iterator for PyDictIterator<'py> {
#[inline]
fn next(&mut self) -> Option<Self::Item> {
unsafe {
let mut key: *mut ffi::PyObject = mem::uninitialized();
let mut value: *mut ffi::PyObject = mem::uninitialized();
let mut key: *mut ffi::PyObject = std::ptr::null_mut();
let mut value: *mut ffi::PyObject = std::ptr::null_mut();
if ffi::PyDict_Next(self.dict.as_ptr(), &mut self.pos, &mut key, &mut value) != 0 {
let py = self.py;
Some((py.from_borrowed_ptr(key), py.from_borrowed_ptr(value)))

View file

@ -12,7 +12,7 @@ use crate::AsPyPointer;
use crate::Python;
use std::borrow::Cow;
use std::os::raw::c_char;
use std::{mem, str};
use std::str;
/// Represents a Python `string`.
#[repr(transparent)]
@ -56,7 +56,7 @@ impl PyString {
#[inline]
pub fn as_bytes(&self) -> &[u8] {
unsafe {
let mut size: ffi::Py_ssize_t = mem::uninitialized();
let mut size: ffi::Py_ssize_t = 0;
let data = ffi::PyUnicode_AsUTF8AndSize(self.0.as_ptr(), &mut size) as *const u8;
// PyUnicode_AsUTF8AndSize would return null if the pointer did not reference a valid
// unicode object, but because we have a valid PyString, assume success