mirror of
https://github.com/RustPython/RustPython.git
synced 2026-06-02 19:39:49 +09:00
Compare commits
7 Commits
2025-03-10
...
impl_del_o
| Author | SHA1 | Date | |
|---|---|---|---|
| 20c053a3c0 | |||
|
|
6181bf4a7a | ||
| b333ffa781 | |||
| 308b95ec13 | |||
| 5f77ce5b4f | |||
| 4da57d42de | |||
| 2777588bb4 |
23
.github/workflows/ai-review.yml
vendored
Normal file
23
.github/workflows/ai-review.yml
vendored
Normal 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"
|
||||
@@ -495,9 +495,18 @@ 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: PyDictRef, vm: &VirtualMachine) -> PyResult<()> {
|
||||
obj.set_dict(dict)
|
||||
.map_err(|_| vm.new_attribute_error("This object has no __dict__".to_owned()))
|
||||
|
||||
pub fn object_set_dict(obj: PyObjectRef, dict: PySetterValue<PyDictRef>, vm: &VirtualMachine) -> PyResult<()> {
|
||||
match dict {
|
||||
PySetterValue::Assign(dict) => {
|
||||
obj.set_dict(dict)
|
||||
.map_err(|_| vm.new_attribute_error("This object has no __dict__".to_owned()))
|
||||
}
|
||||
PySetterValue::Delete => {
|
||||
obj.delete_dict()
|
||||
.map_err(|_| vm.new_attribute_error("This object has no deletable __dict__".to_owned()))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(ctx: &Context) {
|
||||
|
||||
@@ -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, value.try_into_value(vm)?, vm)?;
|
||||
object::object_set_dict(obj, PySetterValue::Delete, vm)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,8 +36,10 @@ where
|
||||
{
|
||||
#[inline]
|
||||
fn from_setter_value(vm: &VirtualMachine, obj: PySetterValue) -> PyResult<Self> {
|
||||
let obj = obj.ok_or_else(|| vm.new_type_error("can't delete attribute".to_owned()))?;
|
||||
T::try_from_object(vm, obj)
|
||||
match obj {
|
||||
PySetterValue::Assign(obj) => T::try_from_object(vm, obj),
|
||||
PySetterValue::Delete => T::try_from_object(vm, vm.ctx.none()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -717,6 +717,19 @@ impl PyObject {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn delete_dict(&self) -> Result<(), ()> {
|
||||
match self.instance_dict() {
|
||||
Some(_) => {
|
||||
unsafe {
|
||||
let ptr = self as *const _ as *mut PyObject;
|
||||
(*ptr).0.dict = None;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
None => Err(()),
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn payload_if_subclass<T: crate::PyPayload>(&self, vm: &VirtualMachine) -> Option<&T> {
|
||||
if self.class().fast_issubclass(T::class(&vm.ctx)) {
|
||||
|
||||
Reference in New Issue
Block a user