elarivie / pyReaderWriterLock

Python 3 implementation of the Readers-writers problem

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError when importing on Python 3.5

JannKleen opened this issue · comments

Python 3.5. seems to have an issue with Optional[Type[BaseException]] in all the __exit__ methods. Using Python 3.7 (or removing Type in py3.5) worked fine.

  File "/usr/local/lib/python3.5/dist-packages/readerwriterlock/rwlock.py", line 14, in <module>
    class RWLockRead():
  File "/usr/local/lib/python3.5/dist-packages/readerwriterlock/rwlock.py", line 23, in RWLockRead
    class _aReader():
  File "/usr/local/lib/python3.5/dist-packages/readerwriterlock/rwlock.py", line 61, in _aReader
    def __exit__(self, exc_type: Optional[Type[BaseException]], exc_val: Optional[Exception], exc_tb: Optional[TracebackType]) -> bool:
  File "/usr/lib/python3.5/typing.py", line 649, in __getitem__
    return Union[arg, type(None)]
  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 "/usr/lib/python3.5/abc.py", line 225, in __subclasscheck__
    for scls in cls.__subclasses__():
TypeError: descriptor '__subclasses__' of 'type' object needs an argument

Hello @JannKleen,

Thank you for your issue report + investigation.

Strangely the Travis CI builds does not detect the error...
image

I personally use python 3.7 which is the default version on Ubuntu 19.04

The version 3.7 brings a lot of improvement related to typing.

With pyReaderWriterLock I don't plan to support any backward compatibility issue of python version <=3.7

So in your situation you can either update the python version to 3.7on your system or adjust the code to make it work with 3.5 by simply removing the problematic typing declaration.

sorry :(