Skip to content

Commit fe15286

Browse files
committed
Use PyRwBytesLike
1 parent a5ba203 commit fe15286

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

vm/src/stdlib/ssl.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use super::os::PyPathLike;
22
use super::socket::PySocketRef;
3-
use crate::builtins::bytearray::PyByteArrayRef;
43
use crate::builtins::pystr::PyStrRef;
54
use crate::builtins::{pytype::PyTypeRef, weakref::PyWeak};
6-
use crate::byteslike::PyBytesLike;
5+
use crate::byteslike::{PyBytesLike, PyRwBytesLike};
76
use crate::common::lock::{PyRwLock, PyRwLockReadGuard, PyRwLockWriteGuard};
87
use crate::exceptions::{IntoPyException, PyBaseExceptionRef};
98
use crate::function::{OptionalArg, OptionalOption};
@@ -688,14 +687,11 @@ impl PySslSocket {
688687
}
689688

690689
#[pymethod]
691-
fn read(&self, n: usize, buffer: OptionalArg<PyByteArrayRef>, vm: &VirtualMachine) -> PyResult {
690+
fn read(&self, n: usize, buffer: OptionalArg<PyRwBytesLike>, vm: &VirtualMachine) -> PyResult {
692691
let mut stream = self.stream_mut();
693692
let ret_nread = buffer.is_present();
694693
let ssl_res = if let OptionalArg::Present(buffer) = buffer {
695-
let mut buf = buffer.borrow_value_mut();
696-
stream
697-
.ssl_read(&mut buf.elements)
698-
.map(|n| vm.ctx.new_int(n))
694+
buffer.with_ref(|buf| stream.ssl_read(buf).map(|n| vm.ctx.new_int(n)))
699695
} else {
700696
let mut buf = vec![0u8; n];
701697
stream.ssl_read(&mut buf).map(|n| {

0 commit comments

Comments
 (0)