From 696aa99b807b062516d72efc7d7f9f8586d58862 Mon Sep 17 00:00:00 2001 From: Noah <33094578+coolreader18@users.noreply.github.com> Date: Wed, 21 Apr 2021 20:44:18 -0500 Subject: [PATCH] Apply review comments --- Cargo.lock | 2 ++ vm/src/byteslike.rs | 1 + vm/src/stdlib/resource.rs | 8 ++++++-- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e9ef09e9e..a8b5ebc71 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2336,6 +2336,8 @@ dependencies = [ [[package]] name = "sre-engine" version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5872399287c284fed4bc773cb7f6041623ac88213774f5e11e89e2131681fc1" dependencies = [ "bitflags", "num_enum", diff --git a/vm/src/byteslike.rs b/vm/src/byteslike.rs index 6be682978..eb0b0b078 100644 --- a/vm/src/byteslike.rs +++ b/vm/src/byteslike.rs @@ -126,6 +126,7 @@ impl<'a> BorrowValue<'a> for PyRwBytesLike { } } +/// A buffer or utf8 string. Like the `s*` format code for `PyArg_Parse` in CPython. pub enum BufOrStr { Buf(PyBytesLike), Str(PyStrRef), diff --git a/vm/src/stdlib/resource.rs b/vm/src/stdlib/resource.rs index 76212dbc8..f04b342b9 100644 --- a/vm/src/stdlib/resource.rs +++ b/vm/src/stdlib/resource.rs @@ -12,9 +12,13 @@ mod resource { if #[cfg(target_os = "linux")] { use libc::RLIMIT_NLIMITS as RLIM_NLIMITS; } else if #[cfg(target_os = "android")] { - pub const RLIM_NLIMITS: i32 = 16; + // TODO: this should be in libc soon + const RLIM_NLIMITS: i32 = 16; } else { - use libc::RLIM_NLIMITS; + // in bsd-ish platforms, this constant isn't abi-stable across os versions, so we just + // pick a high number so we don't get false positive ValueErrors and just bubble up the + // EINVAL that get/setrlimit return on an invalid resource + const RLIM_NLIMITS: i32 = 256; } }