Don't require _testcapi and _testinternalcapi for test_monitoring.py#152311
Don't require _testcapi and _testinternalcapi for test_monitoring.py#152311ShaharNaveh wants to merge 5 commits into
_testcapi and _testinternalcapi for test_monitoring.py#152311Conversation
261c9bd to
2f281f9
Compare
2f281f9 to
d043654
Compare
StanFromIreland
left a comment
There was a problem hiding this comment.
Do you know if there any more tests with the same issues (I'm not familiar with RustPython, so I don't know where to even try finding a list)? I'd rather get them all done in one go.
|
|
||
|
|
||
| class TestCApiEventGeneration(MonitoringTestBase, unittest.TestCase): | ||
| _testcapi = import_helper.import_module("_testcapi") |
There was a problem hiding this comment.
This'll be executed at import time, so it will skip test_monitoring defeating the whole point of this PR. You can move it to a setUpClass.
We are copying the tests from CPython directly into Lib/test, this structure might look familiar:) Anyway, I've gathered a list using a small script:
I've looked at each of those tests, all but Script used for findingsimport ast
import pathlib
ROOT = pathlib.Path(__file__).parent
TEST_DIR = ROOT / "Lib/test"
class Visitor(ast.NodeVisitor):
def __init__(self):
self.found = False
def visit_Call(self, node):
func = node.func
if not isinstance(func, ast.Attribute):
return
if func.attr != "import_module":
return
args = node.args
if len(args) != 1:
return
arg = args[0]
if not isinstance(arg, ast.Constant):
return
value = arg.value
self.found = value in ("_testcapi", "_testinternalcapi")
def visit_ClassDef(self, node):
for bnode in node.body:
if isinstance(bnode, ast.Assign):
return self.generic_visit(bnode)
def visit_FuncionDef(self, node):
return
def visit_AsyncFunctionDef(self, node):
return
bad = set()
for child in TEST_DIR.glob("**/*.py"):
if "test_capi" in child.parts:
continue
rchild = child.relative_to(ROOT)
try:
source = child.read_text(encoding="utf-8")
mod = ast.parse(source)
except:
bad.add(rchild)
continue
visitor = Visitor()
visitor.visit(mod)
if visitor.found:
print(rchild)
# print("\ncould not parse:\n" + "\n".join(map(str, bad))) |
|
Interestingly this uncovers UB in |
I see that it just crashes without any information:/ Anway, I've subscribed to #152376 so I'll update the PR once it's merged. puting on draft for now |
See the "Display logs" step, which has the UBSan output. |
same as #152171 and #152185