GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Add CO_ITERABLE_COROUTINE flag and fix types tests · RustPython/RustPython@38ff638

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • Lib
    • test
      • test_types.py
    • types.py
  • crates
    • compiler-core/src
      • bytecode.rs
    • vm/src
      • frame.rs
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎Lib/test/test_types.py‎

Copy file name to clipboardExpand all lines: Lib/test/test_types.py
-2Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2174,7 +2174,6 @@ def foo():
21742174
foo = types.coroutine(foo)
21752175
self.assertIs(aw, foo())
21762176

2177-
@unittest.expectedFailure # TODO: RUSTPYTHON
21782177
def test_async_def(self):
21792178
# Test that types.coroutine passes 'async def' coroutines
21802179
# without modification
@@ -2431,7 +2430,6 @@ def foo():
24312430
foo = types.coroutine(foo)
24322431
self.assertIs(foo(), gencoro)
24332432

2434-
@unittest.expectedFailure # TODO: RUSTPYTHON
24352433
def test_genfunc(self):
24362434
def gen(): yield
24372435
self.assertIs(types.coroutine(gen), gen)
Collapse file

‎Lib/types.py‎

Copy file name to clipboardExpand all lines: Lib/types.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,7 @@ def coroutine(func):
292292
if not callable(func):
293293
raise TypeError('types.coroutine() expects a callable')
294294

295-
# XXX RUSTPYTHON TODO: iterable coroutine
296-
if (False and func.__class__ is FunctionType and
295+
if (func.__class__ is FunctionType and
297296
getattr(func, '__code__', None).__class__ is CodeType):
298297

299298
co_flags = func.__code__.co_flags
Collapse file

‎crates/compiler-core/src/bytecode.rs‎

Copy file name to clipboardExpand all lines: crates/compiler-core/src/bytecode.rs
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ bitflags! {
297297
const VARKEYWORDS = 0x0008;
298298
const GENERATOR = 0x0020;
299299
const COROUTINE = 0x0080;
300+
const ITERABLE_COROUTINE = 0x0100;
300301
/// If a code object represents a function and has a docstring,
301302
/// this bit is set and the first item in co_consts is the docstring.
302303
const HAS_DOCSTRING = 0x4000000;
Collapse file

‎crates/vm/src/frame.rs‎

Copy file name to clipboardExpand all lines: crates/vm/src/frame.rs
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1051,7 +1051,7 @@ impl ExecutingFrame<'_> {
10511051
let iterable = self.pop_value();
10521052
let iter = if iterable.class().is(vm.ctx.types.coroutine_type) {
10531053
// Coroutine requires CO_COROUTINE or CO_ITERABLE_COROUTINE flag
1054-
if !self.code.flags.intersects(bytecode::CodeFlags::COROUTINE) {
1054+
if !self.code.flags.intersects(bytecode::CodeFlags::COROUTINE | bytecode::CodeFlags::ITERABLE_COROUTINE) {
10551055
return Err(vm.new_type_error(
10561056
"cannot 'yield from' a coroutine object in a non-coroutine generator"
10571057
.to_owned(),

0 commit comments

Comments
0 (0)
You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.