Repository: RustPython/RustPython (language: rust)

Issue:
Fix memoryview iter in whats_left.py
`memoryview` has no `__iter__`


Discussion / hints:
Hold on, I might have completely misread this and the error is something different.
Hi @tekknolagi and thanks for the PR. You probably ran this with Python 3.9 which did not have a dedicated iterator. `memoryview.__iter__` was added in 3.10 (https://github.com/python/cpython/pull/22119) which we are currently following. 

It might make sense to add a check in `whats_left.py` to inform people that >=3.10 is expected (similarly to the two other checks for the implementation and the `-I` flag).
Oh! I can pivot to doing that instead.
@DimitrisJim should we be advertising for Python 3.11, or is it too early to do that?
Hey! Couldn't say with certainty, after we update some libs to 3.11 it might make sense.
I see what you were trying to do here (fix the cron job for whatsleft.py?). 

In that case, this could be solved easily by specifying that python 3.10 be used for the job (see the `with` used in the equivalent job for generating the cov data). 

Fix patch:
diff --git a/.cspell.json b/.cspell.json
index 090b581c1a..f1b9b7f6d7 100644
--- a/.cspell.json
+++ b/.cspell.json
@@ -80,11 +80,13 @@
     "rdiv",
     "idiv",
     "ndim",
+    "unionable",
     "varnames",
     "getweakrefs",
     "getweakrefcount",
     "stacklevel",
     "MemoryView",
+    "metatype",
     "warningregistry",
     "defaultaction",
     "unraisablehook",
@@ -129,7 +131,12 @@
     "posonlyargs",
     "kwonlyargs",
     "uninit",
-    "miri"
+    "miri",
+    // cpython
+    "linearise",
+    "dictoffset",
+    "heaptype",
+    "IMMUTABLETYPE"
   ],
   // flagWords - list of words to be always considered incorrect
   "flagWords": [
diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml
index a06efd52cf..ccc1ad6ed9 100644
--- a/.github/workflows/ci.yaml
+++ b/.github/workflows/ci.yaml
@@ -295,6 +295,8 @@ jobs:
         run: |
           mkdir site-packages
           target/release/rustpython --install-pip ensurepip --user
+      - name: Check whats_left is not broken
+        run: python -I whats_left.py
 
   lalrpop:
     if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
@@ -361,8 +363,6 @@ jobs:
         run: cd wasm && git ls-files -z | xargs -0 prettier --check -u
       - name: Check update_asdl.sh consistency
         run: bash scripts/update_asdl.sh && git diff --exit-code
-      - name: Check whats_left is not broken
-        run: python -I whats_left.py
 
   miri:
     if: ${{ !contains(github.event.pull_request.labels.*.name, 'skip:ci') }}
diff --git a/stdlib/src/ssl.rs b/stdlib/src/ssl.rs
index c7726203cd..ec1c52fef8 100644
--- a/stdlib/src/ssl.rs
+++ b/stdlib/src/ssl.rs
@@ -121,7 +121,7 @@ mod _ssl {
     #[pyattr]
     const PROTO_MAXIMUM_SUPPORTED: i32 = ProtoVersion::MaxSupported as i32;
     #[pyattr]
-    const OP_ALL: libc::c_ulong = sys::SSL_OP_ALL & !sys::SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS;
+    const OP_ALL: libc::c_ulong = (sys::SSL_OP_ALL & !sys::SSL_OP_DONT_INSERT_EMPTY_FRAGMENTS) as _;
     #[pyattr]
     const HAS_TLS_UNIQUE: bool = true;
     #[pyattr]
diff --git a/vm/src/builtins/type.rs b/vm/src/builtins/type.rs
index a4db53225b..1ab0f72e27 100644
--- a/vm/src/builtins/type.rs
+++ b/vm/src/builtins/type.rs
@@ -868,11 +868,11 @@ impl PyType {
                 })?;
         }
 
-        if let Some(initter) = typ.get_super_attr(identifier!(vm, __init_subclass__)) {
-            let initter = vm
-                .call_get_descriptor_specific(initter.clone(), None, Some(typ.clone().into()))
-                .unwrap_or(Ok(initter))?;
-            vm.invoke(&initter, kwargs)?;
+        if let Some(init_subclass) = typ.get_super_attr(identifier!(vm, __init_subclass__)) {
+            let init_subclass = vm
+                .call_get_descriptor_specific(init_subclass.clone(), None, Some(typ.clone().into()))
+                .unwrap_or(Ok(init_subclass))?;
+            vm.invoke(&init_subclass, kwargs)?;
         };
 
         Ok(typ.into())
@@ -1156,14 +1156,14 @@ fn take_next_base(bases: &mut [Vec<PyTypeRef>]) -> Option<PyTypeRef> {
 }
 
 fn linearise_mro(mut bases: Vec<Vec<PyTypeRef>>) -> Result<Vec<PyTypeRef>, String> {
-    vm_trace!("Linearising MRO: {:?}", bases);
+    vm_trace!("Linearise MRO: {:?}", bases);
     // Python requires that the class direct bases are kept in the same order.
     // This is called local precedence ordering.
     // This means we must verify that for classes A(), B(A) we must reject C(A, B) even though this
     // algorithm will allow the mro ordering of [C, B, A, object].
     // To verify this, we make sure non of the direct bases are in the mro of bases after them.
     for (i, base_mro) in bases.iter().enumerate() {
-        let base = &base_mro[0]; // Mros cannot be empty.
+        let base = &base_mro[0]; // MROs cannot be empty.
         for later_mro in &bases[i + 1..] {
             // We start at index 1 to skip direct bases.
             // This will not catch duplicate bases, but such a thing is already tested for.
diff --git a/whats_left.py b/whats_left.py
index 46517468db..0c1426bf96 100755
--- a/whats_left.py
+++ b/whats_left.py
@@ -441,7 +441,7 @@ def remove_one_indent(s):
 compare_src = inspect.getsourcelines(compare)[0][1:]
 output += "".join(remove_one_indent(line) for line in compare_src)
 
-with open(GENERATED_FILE, "w") as f:
+with open(GENERATED_FILE, "w", encoding='utf-8') as f:
     f.write(output + "\n")
 
 


Test patch: