Merge pull request #523 from ijl/fix-deprecation

Fix deprecation warnings on sync and mem
This commit is contained in:
Yuji Kanagawa 2019-07-09 20:03:12 +09:00 committed by GitHub
commit 83d0ac4e70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 12 deletions

View File

@ -21,7 +21,7 @@ matrix:
- name: Minimum nightly - name: Minimum nightly
python: "3.7" python: "3.7"
# Keep this synced up with build.rs # 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) # Tested via anaconda PyPy (since travis's PyPy version is too old)
- name: PyPy3.5 7.0 - name: PyPy3.5 7.0
python: "3.7" python: "3.7"
@ -49,7 +49,7 @@ before_install:
- source ./ci/travis/setup.sh - source ./ci/travis/setup.sh
install: install:
- pip install setuptools-rust pytest pytest-benchmark tox tox-venv - pip install setuptools-rust pytest pytest-benchmark tox
script: script:
- ./ci/travis/test.sh - ./ci/travis/test.sh

View File

@ -16,8 +16,8 @@ use version_check::{is_min_date, is_min_version, supports_features};
/// Specifies the minimum nightly version needed to compile pyo3. /// Specifies the minimum nightly version needed to compile pyo3.
/// Keep this synced up with the travis ci config, /// Keep this synced up with the travis ci config,
/// But note that this is the rustc version which can be lower than the nightly version /// But note that this is the rustc version which can be lower than the nightly version
const MIN_DATE: &'static str = "2019-02-06"; const MIN_DATE: &'static str = "2019-06-21";
const MIN_VERSION: &'static str = "1.34.0-nightly"; const MIN_VERSION: &'static str = "1.37.0-nightly";
/// Information returned from python interpreter /// Information returned from python interpreter
#[derive(Deserialize, Debug)] #[derive(Deserialize, Debug)]

View File

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

View File

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

View File

@ -12,7 +12,7 @@ use crate::AsPyPointer;
use crate::Python; use crate::Python;
use std::borrow::Cow; use std::borrow::Cow;
use std::os::raw::c_char; use std::os::raw::c_char;
use std::{mem, str}; use std::str;
/// Represents a Python `string`. /// Represents a Python `string`.
#[repr(transparent)] #[repr(transparent)]
@ -56,7 +56,7 @@ impl PyString {
#[inline] #[inline]
pub fn as_bytes(&self) -> &[u8] { pub fn as_bytes(&self) -> &[u8] {
unsafe { 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; 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 // PyUnicode_AsUTF8AndSize would return null if the pointer did not reference a valid
// unicode object, but because we have a valid PyString, assume success // unicode object, but because we have a valid PyString, assume success