Multiple class definitions in the same file raise error "invalid syntax"
- 主要言語
- Go
- スター
- 1k
- フォーク
- 105
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Hey, there. It seems like it's not possible to define multiple classes in a single Python file with `py.RunSrc()`, unless I'm misunderstanding something...? It works with `py.RunFile()`, though.
Go:
```go
context := py.NewContext(py.DefaultContextOpts())
data, _ := fs.ReadFile(g.FS, "math_stuff.py")
_, err := py.RunSrc(context, string(data), "run", nil)
log.Println(err)
```
`math_stuff.py`
```python
class A:
pass
class B:
pass
```
Gives me the error:
```
2026/07/02 15:06:16
File "run", line 5, offset 5
class B:
SyntaxError: 'invalid syntax'
```
I'm testing with the latest commit.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
調査の方向性
Start by reproducing the issue with py.RunSrc and the two-class math_stuff.py example, then compare its handling with py.RunFile. Trace the parser or source-loading path reached by py.RunSrc and add a regression test for multiple class definitions; done means the example runs without the invalid syntax error.
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- go, python
- 領域
- compilers
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 静か
- 明瞭さ
- おおむね明確
- 初心者へのやさしさ
- 65/100