Compare commits

..

5 Commits

Author SHA1 Message Date
b333ffa781 merge upstream
Some checks failed
CI / Run rust tests (macos-latest) (push) Has been cancelled
CI / Run rust tests (ubuntu-latest) (push) Has been cancelled
CI / Run rust tests (windows-latest) (push) Has been cancelled
CI / Ensure compilation on various targets (push) Has been cancelled
CI / Run snippets and cpython tests (macos-latest) (push) Has been cancelled
CI / Run snippets and cpython tests (ubuntu-latest) (push) Has been cancelled
CI / Run snippets and cpython tests (windows-latest) (push) Has been cancelled
CI / Check Rust code with rustfmt and clippy (push) Has been cancelled
CI / Run tests under miri (push) Has been cancelled
CI / Check the WASM package and demo (push) Has been cancelled
CI / Run snippets and cpython tests on wasm-wasi (push) Has been cancelled
2025-02-08 16:33:07 +09:00
308b95ec13 Update .github/workflows/ai-review.yml 2025-01-11 01:53:46 +09:00
5f77ce5b4f Update .github/workflows/ai-review.yml 2025-01-11 00:44:09 +09:00
4da57d42de Update .github/workflows/ai-review.yml
Some checks failed
CI / Run rust tests (macos-latest) (push) Has been cancelled
CI / Run rust tests (windows-latest) (push) Has been cancelled
CI / Ensure compilation on various targets (push) Has been cancelled
CI / Run snippets and cpython tests (macos-latest) (push) Has been cancelled
CI / Run snippets and cpython tests (ubuntu-latest) (push) Has been cancelled
CI / Run snippets and cpython tests (windows-latest) (push) Has been cancelled
CI / Check Rust code with rustfmt and clippy (push) Has been cancelled
CI / Run tests under miri (push) Has been cancelled
CI / Check the WASM package and demo (push) Has been cancelled
CI / Run snippets and cpython tests on wasm-wasi (push) Has been cancelled
CI / Run rust tests (ubuntu-latest) (push) Has been cancelled
2025-01-10 13:54:55 +09:00
2777588bb4 Add ci
Some checks failed
CI / Run rust tests (macos-latest) (push) Has been cancelled
CI / Run rust tests (windows-latest) (push) Has been cancelled
CI / Ensure compilation on various targets (push) Has been cancelled
CI / Run snippets and cpython tests (macos-latest) (push) Has been cancelled
CI / Run snippets and cpython tests (ubuntu-latest) (push) Has been cancelled
CI / Run snippets and cpython tests (windows-latest) (push) Has been cancelled
CI / Check Rust code with rustfmt and clippy (push) Has been cancelled
CI / Run tests under miri (push) Has been cancelled
CI / Check the WASM package and demo (push) Has been cancelled
CI / Run snippets and cpython tests on wasm-wasi (push) Has been cancelled
CI / Run rust tests (ubuntu-latest) (push) Has been cancelled
2025-01-10 11:48:55 +09:00
5 changed files with 32 additions and 31 deletions

23
.github/workflows/ai-review.yml vendored Normal file
View File

@@ -0,0 +1,23 @@
name: PR Review
on:
pull_request:
types: [opened, synchronize]
permissions:
contents: read
pull-requests: write
jobs:
review:
runs-on: ubuntu-latest
steps:
- name: AI Code Review
uses: gitea-actions/ai-reviewer@v0.6
with:
access-token: ${{ secrets.ACCESS_TOKEN }}
full-context-model: "gpt-4o"
full-context-api-key: ${{ secrets.OPENAI_API_KEY }}
single-chunk-model: "claude-3-5-sonnet"
single-chunk-api-key: ${{ secrets.ANTHROPIC_API_KEY }}
exclude-files: "*.md,*.yaml"

View File

@@ -495,14 +495,9 @@ pub fn object_get_dict(obj: PyObjectRef, vm: &VirtualMachine) -> PyResult<PyDict
obj.dict()
.ok_or_else(|| vm.new_attribute_error("This object has no __dict__".to_owned()))
}
pub fn object_set_dict(
obj: PyObjectRef,
dict: PySetterValue<PyDictRef>,
vm: &VirtualMachine,
) -> PyResult<()> {
pub fn object_set_dict(obj: PyObjectRef, dict: PyDictRef, vm: &VirtualMachine) -> PyResult<()> {
obj.set_dict(dict)
.map_err(|_| vm.new_attribute_error("This object has no __dict__ to delete".to_owned()))
.map_err(|_| vm.new_attribute_error("This object has no __dict__".to_owned()))
}
pub fn init(ctx: &Context) {

View File

@@ -1288,7 +1288,7 @@ fn subtype_set_dict(obj: PyObjectRef, value: PyObjectRef, vm: &VirtualMachine) -
descr_set(&descr, obj, PySetterValue::Assign(value), vm)
}
None => {
object::object_set_dict(obj, PySetterValue::Assign(value.try_into_value(vm)?), vm)?;
object::object_set_dict(obj, value.try_into_value(vm)?, vm)?;
Ok(())
}
}

View File

@@ -36,10 +36,8 @@ where
{
#[inline]
fn from_setter_value(vm: &VirtualMachine, obj: PySetterValue) -> PyResult<Self> {
match obj {
PySetterValue::Assign(obj) => T::try_from_object(vm, obj),
PySetterValue::Delete => T::try_from_object(vm, vm.ctx.none()),
}
let obj = obj.ok_or_else(|| vm.new_type_error("can't delete attribute".to_owned()))?;
T::try_from_object(vm, obj)
}
}

View File

@@ -25,7 +25,6 @@ use crate::{
lock::{PyMutex, PyMutexGuard, PyRwLock},
refcount::RefCount,
},
function::PySetterValue,
vm::VirtualMachine,
};
use itertools::Itertools;
@@ -708,27 +707,13 @@ impl PyObject {
/// Set the dict field. Returns `Err(dict)` if this object does not have a dict field
/// in the first place.
pub fn set_dict(&self, dict: PySetterValue<PyDictRef>) -> Result<(), PySetterValue<PyDictRef>> {
match (self.instance_dict(), dict) {
(Some(d), PySetterValue::Assign(dict)) => {
pub fn set_dict(&self, dict: PyDictRef) -> Result<(), PyDictRef> {
match self.instance_dict() {
Some(d) => {
d.set(dict);
Ok(())
}
(None, PySetterValue::Assign(dict)) => {
unsafe {
let ptr = self as *const _ as *mut PyObject;
(*ptr).0.dict = Some(InstanceDict::new(dict));
}
Ok(())
}
(Some(_), PySetterValue::Delete) => {
unsafe {
let ptr = self as *const _ as *mut PyObject;
(*ptr).0.dict = None;
}
Ok(())
}
(None, PySetterValue::Delete) => Err(PySetterValue::Delete),
None => Err(dict),
}
}