1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

online-judge-toolsが急に動かなくなった話

Last updated at Posted at 2025-06-01

対象読者

発生したエラー

File "[your_python_path]/python3.11/site-packages/onlinejudge/service/atcoder.py", line 545, in _from_table_row
    assert False
           ^^^^^
AssertionError

解決方法

[your_python_path]/python3.11/site-packages/onlinejudge/service/atcoder.pyの545行目のif文に「MiB」を追加すると直る。

if tds[3].text.endswith(' KB'):
    memory_limit_byte = int(float(utils.remove_suffix(tds[3].text, ' KB')) * 1000)
elif tds[3].text.endswith(' MB'):
    memory_limit_byte = int(float(utils.remove_suffix(tds[3].text, ' MB')) * 1000 * 1000)  # TODO: confirm this is MB truly, not MiB
    
# ここから追加
elif tds[3].text.endswith(' MiB'):
    memory_limit_byte = int(float(utils.remove_suffix(tds[3].text, ' MiB')) * 1024 * 1024)
# ここまで追加

else:
    assert False

なぜ発生したのか

結論:サイトが少し変わったから

各問題下の「メモリ制限」の単位が、2025/05の第3週から2025/05の第4週の間に変わった模様。
それまでif文の選択肢になかった「MiB」により、assert Falseが発火してしまい、その時点でコードが止まってしまっていた。

MiB(メビバイト)ってなんだ?(not MB(メガバイト))

1MB = 1000KB = 1000 * 1000 B
1MiB = 1024KiB = 1024 * 1024 B

補足
数学の世界で、単位を1つ上げるのはルールがあります。
例えば、kmはmの1000倍です。そして、MBはKBの1000倍です。
ただ、コンピュータの世界では2進数で表すので、2^nで表せない1000というのはこの世界では曖昧なものになってしまいます。
そこで、2^10単位で繰り上がるようにしたのがKiBやMiBなどの「i」が入った単位たちです。

なんか単位が厳密になったんだね、と思えれば修正完了です

追記

早速issueが建てられていました。
https://github.com/online-judge-tools/api-client/issues/172

1
0
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?