🕌

atcoder-toolsでsubmit時に「AttributeError」が出る対策

2021/11/30に公開

概要

atcoder-toolsでpython3コードのsubmit時に「AttributeError: 'NoneType' object has no attribute 'get'」というエラーが出た場合の対策です。
atcoder-tools gen でも出るかもしれません。

Traceback (most recent call last):
  File "/usr/local/bin/atcoder-tools", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/atcodertools/atcoder_tools.py", line 64, in main
    exit_program(submit_main(prog, args))
  File "/usr/local/lib/python3.7/site-packages/atcodertools/tools/submit.py", line 174, in main
    metadata.problem.contest, metadata.problem, metadata.lang, source)
  File "/usr/local/lib/python3.7/site-packages/atcodertools/client/atcoder.py", line 179, in submit_source_code
    "option", text=lang_option_pattern).get("value")
AttributeError: 'NoneType' object has no attribute 'get'

手順

  1. atcoder-toolsのインストール先を特定
pip3 show atcoder-tools | grep Location
# -> Location: /usr/local/lib/python3.7/site-packages
  1. atcoder-toolsのソースコードを修正
    atcodertools -> common -> language.py をエディタで開き、以下の通り修正する
diff --git a/language.py b/language_old.py
index 2589016..4eb275d 100644
--- a/language.py
+++ b/language_old.py
@@ -124,7 +124,7 @@ PYTHON = Language(
     name="python",
     display_name="Python",
     extension="py",
-    submission_lang_pattern=re.compile(".*Python.*|^Python$"),
+    submission_lang_pattern=re.compile(".*Python3.*|^Python$"),
     default_code_generator=python.main,
     default_template_path=get_default_template_path('py'),
     compile_command="python3 -mpy_compile {filename}.py",
GitHubで編集を提案

Discussion