Honor generator close, throw context, and docs (#8701) · RustPython/RustPython@80eddfc · GitHub
Skip to content

Commit 80eddfc

Browse files
authored
Honor generator close, throw context, and docs (#8701)
* Honor close unraisable and deallocator messages A failed close lookup on a yield-from target is unraisable. Ignored GeneratorExit from finalize gets a traceback and the closing-generator err_msg. __del__ uses the deallocator message. Assisted-by: Grok:grok-4.6 * address review: claim, ag_running, frame steal Keep the running claim through close() cleanup. ag_running reads running_async. aclose ignore-yield does not mark the generator closed. Steal the frame slot before uniqueness and expose it with try_to_owned. Assisted-by: Grok:grok-4.6 * Honor wrapper docs, yield assign, throw context method-wrapper exposes the slot __doc__. Parenthesized yield assignment uses the invalid-target messages. throw() restores without overwriting __context__, then chains only from the generator's own exc_info slot. Assisted-by: Grok:grok-4.6 * Remove passing expectedFailure markers method-wrapper docs, deallocator messages, and help pager output now match, so drop the leftover markers. Assisted-by: Grok:grok-4.6 * Honor wrapper signatures and assignment diagnostics Slot docs include text signatures. method-wrapper compares and hashes by identity. Keyword genexp and if/while assignment use the invalid-target messages. Assisted-by: Grok:grok-4.6 * address review: aclose, unraisable, frame publish aclose ignore-yield does not close the generator. Format unraisable object is None. close() leaves traceback to the caller; finalize attaches the generator frame. Publish the iframe before the lock-free slot. Assisted-by: Grok:grok-4.6 * Honor member descriptors and wrapper annotations Assisted-by: Grok:grok-4.6 * address review: getitem, bool doc, if assign Assisted-by: Grok:grok-4.6 * Honor eval-mode assignment invalid syntax Assisted-by: Grok:grok-4.6 * Supply getset and member docs from rustpython-doc Assisted-by: Grok:grok-4.6 * Enable rustls SSL on WASI targets Compile the rustls _ssl module for WASI and stub socket waits plus the native certificate store. Assisted-by: Grok:grok-4.6 * Add browser TLS _ssl in rustpython-wasm Register rustls _ssl and a MemoryBIO-oriented _socket from rustpython-wasm. Use rustls-rustcrypto because ring cannot compile for wasm32-unknown-unknown. Assisted-by: Grok:grok-4.6 * Define SSL protocol and cert constants as enums Keep OpenSSL bitmask defines as integer constants. Assisted-by: Grok:grok-4.6 * Ignore rustls deps cargo-shear cannot see The rustpython-wasm _ssl sources are compiled through a symlink, so shear does not count their crate uses. Assisted-by: Grok:grok-4.6 * Replace wasm ssl symlink with a BIO module Drop the stdlib ssl.rs link and keep a rustpython-wasm _ssl that only covers MemoryBIO wrap_bio TLS. Assisted-by: Grok:grok-4.6
1 parent 39b7030 commit 80eddfc

46 files changed

Lines changed: 3329 additions & 455 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 701 additions & 61 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Lib/test/test_contextlib.py

Lines changed: 0 additions & 1 deletion

Lib/test/test_descr.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,7 +1553,6 @@ class B(A1, A2):
15531553
else:
15541554
self.fail("finding the most derived metaclass should have failed")
15551555

1556-
@unittest.expectedFailure # TODO: RUSTPYTHON
15571556
def test_classmethods(self):
15581557
# Testing class methods...
15591558
class C(object):
@@ -1615,7 +1614,6 @@ def f(cls, arg):
16151614
del cm.x
16161615
self.assertNotHasAttr(cm, "x")
16171616

1618-
@unittest.expectedFailure # TODO: RUSTPYTHON
16191617
def test_classmethod_staticmethod_annotations(self):
16201618
for deco in (classmethod, staticmethod):
16211619
@deco
@@ -2355,7 +2353,6 @@ class Weak(object):
23552353
self.assertEqual(r(), None)
23562354
del r
23572355

2358-
@unittest.expectedFailure # TODO: RUSTPYTHON
23592356
def test_properties(self):
23602357
# Testing property...
23612358
class C(object):
@@ -3329,7 +3326,6 @@ def __ge__(self, other):
33293326
eval("x %s y" % op),
33303327
"x=%d, y=%d" % (x, y))
33313328

3332-
@unittest.expectedFailure # TODO: RUSTPYTHON
33333329
def test_descrdoc(self):
33343330
# Testing descriptor doc strings...
33353331
from _io import FileIO
@@ -4084,7 +4080,6 @@ def test_ipow_exception_text(self):
40844080
y = x ** 2
40854081
self.assertIn('unsupported operand type(s) for **', str(cm.exception))
40864082

4087-
@unittest.expectedFailure # TODO: RUSTPYTHON
40884083
def test_pow_wrapper_error_messages(self):
40894084
self.assertRaisesRegex(TypeError,
40904085
'expected 1 or 2 arguments, got 0',
@@ -4654,7 +4649,6 @@ def assertNotOrderable(self, a, b):
46544649
with self.assertRaises(TypeError):
46554650
a >= b
46564651

4657-
@unittest.expectedFailure # TODO: RUSTPYTHON
46584652
def test_method_wrapper(self):
46594653
# Testing method-wrapper objects...
46604654
# <type 'method-wrapper'> did not support any reflection before 2.5
@@ -4981,7 +4975,6 @@ class X:
49814975
self.assertIn("cannot delete '__doc__' attribute of immutable type 'X'", str(cm.exception))
49824976
self.assertEqual(X.__doc__, "banana")
49834977

4984-
@unittest.expectedFailure # TODO: RUSTPYTHON
49854978
def test_qualname(self):
49864979
descriptors = [str.lower, complex.real, float.real, int.__add__]
49874980
types = ['method', 'member', 'getset', 'wrapper']

Lib/test/test_exceptions.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,6 @@ def test_errno_ENOTDIR(self):
17241724
os.listdir(__file__)
17251725
self.assertEqual(cm.exception.errno, errno.ENOTDIR, cm.exception)
17261726

1727-
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: None != 'Exception ignored while calling dealloca[83 chars]200>'
17281727
def test_unraisable(self):
17291728
# Issue #22836: PyErr_WriteUnraisable() should give sensible reports
17301729
class BrokenDel:

Lib/test/test_generators.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ def b():
13691369
>>> [s for s in dir(i) if not s.startswith('_')]
13701370
['close', 'gi_code', 'gi_frame', 'gi_running', 'gi_suspended', 'gi_yieldfrom', 'send', 'throw']
13711371
>>> from test.support import HAVE_DOCSTRINGS
1372-
>>> print(i.__next__.__doc__ if HAVE_DOCSTRINGS else 'Implement next(self).') # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
1372+
>>> print(i.__next__.__doc__ if HAVE_DOCSTRINGS else 'Implement next(self).')
13731373
Implement next(self).
13741374
>>> iter(i) is i
13751375
True
@@ -2526,12 +2526,12 @@ def printsolution(self, x):
25262526
...
25272527
SyntaxError: assignment to yield expression not possible
25282528
2529-
>>> def f(): (yield bar) = y # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
2529+
>>> def f(): (yield bar) = y
25302530
Traceback (most recent call last):
25312531
...
25322532
SyntaxError: cannot assign to yield expression here. Maybe you meant '==' instead of '='?
25332533
2534-
>>> def f(): (yield bar) += y # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
2534+
>>> def f(): (yield bar) += y
25352535
Traceback (most recent call last):
25362536
...
25372537
SyntaxError: 'yield expression' is an illegal expression for augmented assignment
@@ -2727,7 +2727,7 @@ def printsolution(self, x):
27272727
27282728
Our ill-behaved code should be invoked during GC:
27292729
2730-
>>> with support.catch_unraisable_exception() as cm: # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
2730+
>>> with support.catch_unraisable_exception() as cm:
27312731
... g = f()
27322732
... next(g)
27332733
... gen_repr = repr(g)
@@ -2845,7 +2845,7 @@ def printsolution(self, x):
28452845
... raise RuntimeError(message)
28462846
... invoke("del failed")
28472847
...
2848-
>>> with support.catch_unraisable_exception() as cm: # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
2848+
>>> with support.catch_unraisable_exception() as cm:
28492849
... leaker = Leaker()
28502850
... del_repr = repr(type(leaker).__del__)
28512851
... del leaker

Lib/test/test_genexps.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@
105105
106106
Verify that parenthesis are required when used as a keyword argument value
107107
108-
>>> dict(a = i for i in range(10)) # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
108+
>>> dict(a = i for i in range(10))
109109
Traceback (most recent call last):
110110
...
111111
SyntaxError: invalid syntax. Maybe you meant '==' or ':=' instead of '='?
@@ -242,7 +242,7 @@
242242
True
243243
244244
>>> from test.support import HAVE_DOCSTRINGS
245-
>>> print(g.__next__.__doc__ if HAVE_DOCSTRINGS else 'Implement next(self).') # TODO: RUSTPYTHON # doctest: +EXPECTED_FAILURE
245+
>>> print(g.__next__.__doc__ if HAVE_DOCSTRINGS else 'Implement next(self).')
246246
Implement next(self).
247247
>>> import types
248248
>>> isinstance(g, types.GeneratorType)

Lib/test/test_inspect/test_inspect.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3954,7 +3954,6 @@ def wrapped_foo_call():
39543954
('b', ..., ..., "positional_or_keyword")),
39553955
...))
39563956

3957-
@unittest.expectedFailure # TODO: RUSTPYTHON
39583957
def test_signature_on_class(self):
39593958
class C:
39603959
def __init__(self, a):

Lib/test/test_pydoc/test_pydoc.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,6 @@ def run_pydoc_for_request(request, expected_text_part):
787787
run_pydoc_for_request(pydoc.Helper.help, 'Help on function help in module pydoc:')
788788
# test for pydoc.Helper() instance skipped because it is always meant to be interactive
789789

790-
@unittest.expectedFailure # TODO: RUSTPYTHON
791790
@unittest.skipIf(hasattr(sys, 'gettrace') and sys.gettrace(),
792791
'trace function introduces __locals__ unexpectedly')
793792
@requires_docstrings

Lib/test/test_struct.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ def test_format_attr(self):
730730
s2 = struct.Struct(s.format.encode())
731731
self.assertEqual(s2.format, s.format)
732732

733-
@unittest.expectedFailure # TODO: RUSTPYTHON
734733
def test_struct_cleans_up_at_runtime_shutdown(self):
735734
code = """if 1:
736735
import struct

Lib/test/test_syntax.py

Lines changed: 10 additions & 10 deletions

0 commit comments

Comments
 (0)