1
0
mirror of https://github.com/exaloop/codon.git synced 2025-06-03 15:03:52 +08:00

Fix Python

This commit is contained in:
Ibrahim Numanagić 2024-01-18 11:53:57 -08:00
parent 9a1c2741ee
commit b1b75913ec
3 changed files with 6 additions and 4 deletions

View File

@ -28,7 +28,7 @@ Expr::Expr(const Expr &expr, bool clean) : Expr(expr) {
if (clean) {
type = nullptr;
done = false;
attributes = 0;
// attributes = 0;
}
}
void Expr::validate() const {}

View File

@ -82,7 +82,7 @@ void TypecheckVisitor::visit(TryStmt *stmt) {
N<DotExpr>(N<IdExpr>(pyVar), "pytype"), c->exc),
N<SuiteStmt>(c->suite, N<BreakStmt>()), nullptr);
pyCatchStmt->suite->getSuite()->stmts.push_back(c->suite);
} else if (c->exc && c->exc->type->is("std.internal.types.error.PyError")) {
} else if (c->exc && c->exc->type->is("std.internal.python.PyError.0")) {
// Transform PyExc exceptions
if (!c->var.empty()) {
c->suite =
@ -104,11 +104,12 @@ void TypecheckVisitor::visit(TryStmt *stmt) {
}
if (!pyCatchStmt->suite->getSuite()->stmts.empty()) {
// Process PyError catches
auto exc = NT<IdExpr>("std.internal.types.error.PyError");
auto exc = NT<IdExpr>("std.internal.python.PyError.0");
pyCatchStmt->suite->getSuite()->stmts.push_back(N<ThrowStmt>(nullptr));
auto c = std::make_shared<TryStmt::Catch>(pyVar, transformType(exc), pyCatchStmt);
auto val = ctx->addVar(pyVar, pyVar, c->exc->getType());
auto val =
ctx->addVar(pyVar, pyVar, std::make_shared<types::LinkType>(c->exc->getType()));
unify(val->type, c->exc->getType());
ctx->blockLevel++;
transform(c->suite);

View File

@ -46,6 +46,7 @@ from internal.file import File, gzFile, open, gzopen
from pickle import pickle, unpickle
from internal.dlopen import dlsym as _dlsym
import internal.python
from internal.python import PyError
# if __py_numerics__:
# import internal.pynumerics