by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Noah
    @coolreader18
    That looks like a span issue in rustc, because there's nothing in vm.set_attr that requires that trait bound
    @KaiserKarel my bet is that it's something to do with the open function not being a valid IntoPyFunc
    What specifically is the type of open_wrapper? You can do something like let open_wrapper: () = ... to get an error message with the full type
    Karel L. Kubat
    @KaiserKarel
    pub fn io_open_with_capabilities(capabilities: Privilege<HashSet<Capability>>) -> PyNativeFunc {
        let open_fn =  |file: PyObjectRef, mode: OptionalArg<PyStringRef>, opts: OpenArgs, vm: &VirtualMachine| {
            match &capabilities {
                Privilege::None => return Err(vm.new_value_error("Filesystem capabilities are not enabled.".to_owned())),
                Privilege::Total => {
                    let mode = mode.as_ref().into_option().map(|s| s.as_str());
                    return python::stdlib::io::io_open(file, mode, opts, vm)
                },
                Privilege::Limited(caps) => {
                    todo!("check if the file should be opened based on the capabilities.");
                    let mode = mode.as_ref().into_option().map(|s| s.as_str());
                    python::stdlib::io::io_open(file, mode, opts, vm)
                }
            }
        };
    
        IntoPyNativeFunc::into_func(open_fn)
    }
    This produces the open_wrapper
    and the type is
    error[E0308]: mismatched types
      --> src/vm.rs:89:36
       |
    89 |             let open_wrapper: () = crate::stdlib::io::io_open_with_capabilities(self.cap.clone().fs);
       |                               --   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found struct `smallbox::smallbox::SmallBox`
       |                               |
       |                               expected due to this
       |
       = note: expected unit type `()`
                     found struct `smallbox::smallbox::SmallBox<(dyn for<'r> std::ops::Fn(&'r rustpython_vm::vm::VirtualMachine, rustpython_vm::function::PyFuncArgs) -> std::result::Result<std::sync::Arc<rustpython_vm::pyobject::PyObject<(dyn rustpython_vm::pyobject::PyObjectPayload + 'static)>>, rustpython_vm::pyobject::PyRef<rustpython_vm::exceptions::PyBaseException>> + std::marker::Send + std::marker::Sync + 'static), smallbox::space::S1>`
    
    error: could not compile `psammophis`.
    Karel L. Kubat
    @KaiserKarel
    io_open_with_capabilities does compile; so open_wrapper should be a valid PyNativeFunc
    Maybe something is going wrong with lifetimes since I am using a closure?
    Noah
    @coolreader18
    You need to convert it to a Python function from a rust closure, try passing vm.ctx.new_function(open_wrapper) as the third argument to set_attr
    Alan Justino da Silva
    @alanjds
    Question: How do I call the equivalent of super() during a #[pyproperty]?
    Noah
    @coolreader18
    You could in theory construct a PySuper object with zelf and Self::class(vm), and then get an attribute of it, but I'm not sure what the rust API of PySuper is looking like right now
    Karel L. Kubat
    @KaiserKarel
    That did the trick @coolreader18! Thanks for the help.
    Karel L. Kubat
    @KaiserKarel
    I feel like I keep asking stupid questions; but I am getting a couldn't init zipimport panic, originating from a ModuleNotFoundError: No module named 'io' in the initialize method of vm. I've copied the root level Lib from rustpython; and set the env variable RUSTPYTHONPATH=/path/to/lib
    James Webber
    @jamestwebber
    hello! on the topic of possibly-stupid questions: I'm not sure what's wrong but cargo run demo.py is failing for me with compilation errors
    fresh install of rust 1.40.0 and python 3.8 in a new conda env on Ubuntu 20.04
    most popular error is error[E0658]: custom attributes cannot be applied to modules
    Jeong YunWon
    @youknowone
    @jamestwebber Try to update rust to most recent version
    rustup update will work when you used rustup
    James Webber
    @jamestwebber
    ahh i used conda to install rust, didn't realize it was out of date
    James Webber
    @jamestwebber
    it works :tada:
    James Webber
    @jamestwebber
    is there a way to run a specific cpython test?
    cargo run Lib/test/test_whatever.py will run a whole file which takes a while
    James Webber
    @jamestwebber
    okay now i'm struggling debugging a test that should fail with python exception but is panicking with "no more blocks to pop"
    tried copying test_pickle.py and friends into the project
    James Webber
    @jamestwebber
    ^ dug a little deeper, it seems like a particular type of bad input caused this, b'V...'. there are a bunch of other errors in the tests but they at least run once i commented out those specific cases
    Noah
    @coolreader18
    @jamestwebber you can do something like cargo run --release -- -m test.test_whatever -k test_name
    @KaiserKarel I'm not sure why zipimport isn't working, but I think that should just be a warning, not a panic?
    James Webber
    @jamestwebber
    ah close, it was cargo run -- -m unittest test.test_pickle.PyPickleTests.test_callapi
    or least that worked
    i'm more used to pytest
    Jeong YunWon
    @youknowone
    -k option is searching as same as pytest
    James Webber
    @jamestwebber
    it didn't seem to work when i tried, not sure why
    was running everything
    Aurelien Montmejat
    @aurelien-m

    Hi everyone, I have the following error, do you know if this can run on a Raspberry Pi/ARM processor ?

    error[E0277]: the trait bound i32: std::convert::From<u32> is not satisfied
    --> vm/src/stdlib/time_module.rs:23:37
    |
    23 | tv_nsec: dur.subsec_nanos().into(),
    | ^^^^ the trait std::convert::From<u32> is not implemented for i32
    |
    = help: the following implementations were found:
    <i32 as std::convert::From<bool>>
    <i32 as std::convert::From<dns_lookup::types::AddrFamily>>
    <i32 as std::convert::From<dns_lookup::types::Protocol>>
    <i32 as std::convert::From<dns_lookup::types::SockType>>
    and 9 others
    = note: required because of the requirements on the impl of std::convert::Into<i32> for u32

    error: aborting due to previous error

    For more information about this error, try rustc --explain E0277.
    error: could not compile rustpython-vm.

    Noah
    @coolreader18
    Hmm, if that's the only error it shouldn't be too hard to fix, try just replacing the .into() with as _ and see if that works? I wouldn't be too surprised if there's runtime errors as well, but there might not be.
    James Webber
    @jamestwebber
    what model RPi is it?
    it looks like rust thinks isize is 32 bit, which maybe implies the processor is 32-bit, which probably won't work...
    Alan Justino da Silva
    @alanjds
    It is not compatible with 32-bit machines?
    James Webber
    @jamestwebber
    i don't know if it's meant to be (very new to the project!) but it looks like 64-bit types are assumed in the code
    and i guess i don't know enough rust to say if that's a deal breaker but i wouldn't be surprised if some aspects assume 64-bittedness
    Alan Justino da Silva
    @alanjds
    Me too. May the RustPython code is overlooking something on this. May nobody had tried a 32bit machine yet.
    If in a hurry, I think you can run on RPi via wasmer for now.
    Noah
    @coolreader18
    I think that should be just that one instance, since it's using libc timespec and libc doesn't use types like isize, it just typedefs according to the platform. I think we've tried to ensure that we don't assume anything about pointer size/endianness, so it should work if you fix that error.
    Aurelien Montmejat
    @aurelien-m
    Thanks for the replies, I tried doing tv_nsec: dur.subsec_nanos() as i32 and it doesn't show that error but it just crashes every time I try to build (if you guys have tips on how to access some logs that would be cool). Right now I'm running with a 32 bit architecture, I'll try to find a 64 bit OS (I have a RPi3 so it should be compatible) and I'll try via wasmer
    Ruwan Egodawatte
    @ruwanego
    Hi all, I'm new to Rust lang and RustPython... I'd like to contribute to the project and learn Rust in the process.. I've looked in to RustPython/RustPython#1175 "Extend the os module".. and if I want to start working on, say, get_exec_path().. where should I start? I might be asking for baby steps.. but I think baby steps are good for really UNDERSTANDING how the code works..
    12 replies
    Mathieu Dupuy
    @deronnax
    hello. No way to make a donation to the project ?
    Jeong YunWon
    @youknowone
    is there any free CI supporting 32-bit?
    4 replies
    Reuben Staley
    @CodeTriangle
    Hey all! Finally got RustPython working on OpenBSD. I had to fork libc, and I'm getting a few warnings from my local copy of that, but at least it works. I might also look into doing maintenance work other OSes that are not tested by CI. Other BSDs, perhaps?
    Ruwan Egodawatte
    @ruwanego
    when I cargo run, I get the error, "Python compile error from Lib/python_builtins/_frozen_importlib.py: Got unexpected token '.' at line 1 column 1"
    any suggestions?