Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

_ctypes pt. 4 #5582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Mar 25, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
more tmp
  • Loading branch information
arihant2math committed Mar 24, 2025
commit b47bbc3e2d106f70c05697e2911b391ed6f315d0
1 change: 1 addition & 0 deletions 1 extra_tests/snippets/builtins_ctypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,7 @@ def LoadLibrary(self, name):
cdll = LibraryLoader(CDLL)

test_byte_array = create_string_buffer(b"Hello, World!")
assert test_byte_array._length_ == 14

if _os.name == "posix" or _sys.platform == "darwin":
pass
Expand Down
17 changes: 15 additions & 2 deletions 17 vm/src/stdlib/ctypes/function.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::builtins::{PyStr, PyTupleRef, PyTypeRef};
use crate::class::StaticType;
use crate::convert::ToPyObject;
use crate::function::FuncArgs;
use crate::stdlib::ctypes::PyCData;
Expand Down Expand Up @@ -38,13 +39,25 @@ impl Function {
let args = args
.iter()
.map(|arg| {
if let Some(data) = arg.downcast_ref::<PyCSimple>() {
Ok(ffi_type_from_str(&data._type_).unwrap())
dbg!();
if arg.obj_type().is_subclass(PyCSimple::static_type().into(), vm)? {
dbg!();
let typ = arg.get_attr("_type_", vm)?;
let typ = typ.downcast_ref::<PyStr>().unwrap();
let converted = ffi_type_from_str(typ.as_str());
match converted {
Some(t) => Ok(t),
None => Err(vm.new_type_error(format!(
"Invalid type: {}",
typ.as_str()
))),
}
} else {
Err(vm.new_type_error("Expected a ctypes simple type".to_string()))
}
})
.collect::<PyResult<Vec<Type>>>()?;
dbg!();
let terminated = format!("{}\0", function);
let pointer: Symbol<'_, FP> = unsafe {
library
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.