pgsql-io / multicorn2

http://multicorn2.org
Other
83 stars 17 forks source link

Support for Python 3.10 w suggested fix #6

Closed luss closed 2 years ago

luss commented 2 years ago

Hey my friend,

thanks so much for creating the economy of Postgres extensions.

Im getting an error when using Postgresql 14 and Python 3.10. After my fix it worked. When I load the extension:

    CREATE EXTENSION multicorn;

I get this error:

 2022-05-09 18:58:49.386 CEST [7957] DETAIL:  Traceback (most recent

call last):

 File

"/usr/lib/python3.10/site-packages/multicorn-2.2-py3.10-linux-x86_64.egg/multicorn/init.py", line 543, in get_class module = import_module(module_name)

 File

"/usr/lib/python3.10/site-packages/multicorn-2.2-py3.10-linux-x86_64.egg/multicorn/init.py", line 523, in import_module import(name)

 File

"/usr/lib/python3.10/site-packages/multicorn-2.2-py3.10-linux-x86_64.egg/multicorn/fsfdw/init.py", line 109, in from multicorn.fsfdw.structuredfs import StructuredDirectory

 File

"/usr/lib/python3.10/site-packages/multicorn-2.2-py3.10-linux-x86_64.egg/multicorn/fsfdw/structuredfs.py", line 169, in class Item(collections.Mapping):

 AttributeError: module 'collections' has no attribute 'Mapping'

 2022-05-09 18:58:49.386 CEST [7957] ANWEISUNG:  CREATE EXTENSION

multicorn;

The fix (makes multicorn2 incompatible with Python 2): In multicorn2/python/multicorn/fsfdw/structuredfs.py change the import of collections to collections.abc and the inheritance of class Item(collections.Mapping) to (collections.abc.Mapping)

 import collections.abc
 ...
 class Item(collections.abc.Mapping):
 ...

It would also be possible to do the following fix instead to ensure compatibility with Python 2. That introduces the dependency six. But that fix faulted with ImportError: cannot import name 'colletions_abc' from 'six.moves' (unknown location) on my setup.

 from six.moves import collections_abc
 ...
 class Item(collections_abc.Mapping):
 ...

Sorry for not writing a pull request. Github is too extemely annyoing to use as a mammal. I created a new account on Github but it got instantly banned from public. Even my issue is not visible publicly. Maybe you could host repos on git.pgsql.io haha.

<3333333 Best f

luss commented 2 years ago

I will look into applying this in the near future for version 2.3. Since Multicorn2 is only purporting to work with Python 3.6+, I'll opt to keep-it-simple and not introduce a dependency on six.

luss commented 2 years ago

I checked in the suggested fix, but, haven't tested it yet.

luss commented 2 years ago

it works