Diaoul / babelfish

BabelFish is a Python library to work with countries and languages
BSD 3-Clause "New" or "Revised" License
25 stars 13 forks source link

Python 3.4 and inspect #16

Closed Toilal closed 9 years ago

Toilal commented 10 years ago

Calling some inspect functions with Python 3.4 on babelfish objects crash (maximum recursion depth exceeded). see https://github.com/wackou/guessit/issues/109

>>> from babelfish.language import Language
>>> from inspect import ismethoddescriptor
>>> lang = Language("fra")
>>> ismethoddescriptor(lang)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "D:\Python\x64\Python34\Lib\inspect.py", line 113, in ismethoddescriptor
    return hasattr(tp, "__get__") and not hasattr(tp, "__set__")
  File "D:\devel\workspace\babelfish\babelfish\language.py", line 55, in __getattr__
    return getattr(cls, name)
  File "D:\devel\workspace\babelfish\babelfish\language.py", line 55, in __getattr__
    return getattr(cls, name)
  File "D:\devel\workspace\babelfish\babelfish\language.py", line 55, in __getattr__
    return getattr(cls, name)
  File "D:\devel\workspace\babelfish\babelfish\language.py", line 55, in __getattr__
    return getattr(cls, name)
  File "D:\devel\workspace\babelfish\babelfish\language.py", line 55, in __getattr__
    return getattr(cls, name)
  File "D:\devel\workspace\babelfish\babelfish\language.py", line 55, in __getattr__
    return getattr(cls, name)
  File "D:\devel\workspace\babelfish\babelfish\language.py", line 55, in __getattr__
    return getattr(cls, name)
[....]
RuntimeError: maximum recursion depth exceeded while calling a Python object
Toilal commented 10 years ago

Same problem with this code, and with any python3 version. It's working on python 2.7

>>> from babelfish.language import Language
>>> lang = Language("fra")
>>> t = type(lang)
>>> hasattr(t, 'anyattr')
zentracker commented 10 years ago

Still getting what I believe is a related issue using Subliminal. Despite using the current master branch of Babelfish, if I do pickle.dumps on the output of 'subliminal.video.scan_video', when I pickle.loads the string object, I get: File "/usr/local/lib/python2.7/dist-packages/babelfish/language.py", line 139, in getattr alpha3 = self.alpha3 RuntimeError: maximum recursion depth exceeded while calling a Python object

Toilal commented 10 years ago

Are you really sure this is current master of babelfish ? When i read File "/usr/local/lib/python2.7/dist-packages/babelfish/language.py", i'm quite sure you are using actual version from pipy (0.5.1) which is not fixed. You'll have to wait for next babelfish release.

zentracker commented 10 years ago

Thanks for your comment. I installed it through the below commands - also I checked directly the local code and it does seem to have the commits fixing the issue:

sudo pip install git+https://github.com/Diaoul/babelfish.git@master Downloading/unpacking git+https://github.com/Diaoul/babelfish.git@master Cloning https://github.com/Diaoul/babelfish.git (to master) to /tmp/pip-9Yp0b9-build Running setup.py (path:/tmp/pip-9Yp0b9-build/setup.py) egg_info for package from git+https://github.com/Diaoul/babelfish.git@master

Installing collected packages: babelfish Running setup.py install for babelfish

Successfully installed babelfish Cleaning up...

wackou commented 10 years ago

I just released 0.5.2 on pypi which has the fix from Toilal. Could you check if that works for you?