Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime error on Python 3.5.2 #363

Closed
fukatani opened this issue Mar 8, 2019 · 9 comments · Fixed by #366
Closed

Runtime error on Python 3.5.2 #363

fukatani opened this issue Mar 8, 2019 · 9 comments · Fixed by #366
Labels

Comments

@fukatani
Copy link
Contributor

fukatani commented Mar 8, 2019

Python3.5.2 で実行したんですが、以下のようなエラーで、動作しないです。
(最近online-judge-toolsアップデートしてなかった。)

Traceback (most recent call last):
  File "/home/ryo/workspace/github/chainer-wind-env/bin/oj", line 6, in <module>
    exec(compile(open(__file__).read(), __file__, 'exec'))
  File "/home/ryo/workspace/github/online-judge-tools/oj", line 4, in <module>
    import onlinejudge._implementation.main
  File "/home/ryo/workspace/github/online-judge-tools/onlinejudge/__init__.py", line 3, in <module>
    import onlinejudge.service
  File "/home/ryo/workspace/github/online-judge-tools/onlinejudge/service/__init__.py", line 2, in <module>
    import onlinejudge.service.anarchygolf
  File "/home/ryo/workspace/github/online-judge-tools/onlinejudge/service/anarchygolf.py", line 14, in <module>
    import onlinejudge._implementation.testcase_zipper
  File "/home/ryo/workspace/github/online-judge-tools/onlinejudge/_implementation/testcase_zipper.py", line 9, in <module>
    import onlinejudge._implementation.format_utils
  File "/home/ryo/workspace/github/online-judge-tools/onlinejudge/_implementation/format_utils.py", line 11, in <module>
    import onlinejudge._implementation.utils as utils
  File "/home/ryo/workspace/github/online-judge-tools/onlinejudge/_implementation/utils.py", line 215, in <module>
    def getter_with_load_details(name: str, type: Union[str, Type]) -> Callable:
  File "/usr/lib/python3.5/typing.py", line 552, in __getitem__
    dict(self.__dict__), parameters, _root=True)
  File "/usr/lib/python3.5/typing.py", line 512, in __new__
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 512, in <genexpr>
    for t2 in all_params - {t1} if not isinstance(t2, TypeVar)):
  File "/usr/lib/python3.5/typing.py", line 1077, in __subclasscheck__
    if super().__subclasscheck__(cls):
  File "/home/ryo/workspace/github/chainer-wind-env/lib/python3.5/abc.py", line 225, in __subclasscheck__
    for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument

def getter_with_load_details(name: str, type: Union[str, Type]) -> Callable:の型アノテーション止めると動作します。(Unionの方)

@fukatani
Copy link
Contributor Author

fukatani commented Mar 8, 2019

Union[str, Any]にすると動作するようになります。Typeがよくない?

@kmyk kmyk added the bug label Mar 8, 2019
@kmyk
Copy link
Member

kmyk commented Mar 8, 2019

Type でなくて type にするのが適切な可能性があります。
https://docs.python.org/3/library/typing.html#typing.Type

@kmyk
Copy link
Member

kmyk commented Mar 8, 2019

ところでこれなぜCI上で再現しなかったのだろう?

@fukatani
Copy link
Contributor Author

fukatani commented Mar 8, 2019

たしかにtypeだと動きます。

@fukatani
Copy link
Contributor Author

fukatani commented Mar 8, 2019

Type[***]のように引数取らないといけないってことですかね。

@kmyk
Copy link
Member

kmyk commented Mar 8, 2019

そのようですね。

しかしドキュメントには 3.5 の段階で次のようにもあるので、本来は現状でも動くはずです。

Type[Any] is equivalent to Type which in turn is equivalent to type, which is the root of Python’s metaclass hierarchy.

@fukatani fukatani changed the title Runtime error on Python 3.5 Runtime error on Python 3.5.2 Mar 8, 2019
@kmyk
Copy link
Member

kmyk commented Mar 8, 2019

「Python 3.5 をサポート」と言っている以上は 3.5.x すべてで動いてほしいので、CIは 3.5.0 での動作を確認するのがよさそう?

kmyk added a commit that referenced this issue Mar 8, 2019
TypeError: descriptor '__subclasses__' of 'type' object needs an argument
@fukatani
Copy link
Contributor Author

fukatani commented Mar 8, 2019

あまりそこまでやっているリポジトリを見かけませんが、kmykさんがそうしたいなら私はOKです。
あるいは我々Python3.5.2ユーザーにアップデートを迫ってもらってもかまいません。

@kmyk
Copy link
Member

kmyk commented Mar 8, 2019

とりあえず 3.5.0 を指定する形でプルリクを出しました

kmyk added a commit that referenced this issue Mar 8, 2019
NOTE: once we did specify `3.5.0`, but CI fails to install this due to the too old setuptools.
fukatani added a commit that referenced this issue Mar 9, 2019
#363: fix the error on Python 3.5.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants