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

Workaround an error to import "range" from "kafka.vendor.six.moves" #2376

Closed
wants to merge 1 commit into from

Conversation

hiwakaba
Copy link
Contributor

@hiwakaba hiwakaba commented Jul 13, 2023

Hello, Please check my patch. In my environment of Python3.12, an error occurs when importing range class from kafka.vendor.six.moves module.

Python 3.12.0b3 (main, Jun 21 2023, 00:00:00) [GCC 13.1.1 20230614 (Red Hat 13.1.1-4)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> sys.path.append('.')
>>> from kafka.client_async import KafkaClient, IdleConnectionManager
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/build/dev/fedora_packaging/python-kafka/tmp/kafka-python-2.0.2/kafka/__init__.py", line 23, in <module>
    from kafka.consumer import KafkaConsumer
  File "/home/build/dev/fedora_packaging/python-kafka/tmp/kafka-python-2.0.2/kafka/consumer/__init__.py", line 3, in <module>
    from kafka.consumer.group import KafkaConsumer
  File "/home/build/dev/fedora_packaging/python-kafka/tmp/kafka-python-2.0.2/kafka/consumer/group.py", line 13, in <module>
    from kafka.consumer.fetcher import Fetcher
  File "/home/build/dev/fedora_packaging/python-kafka/tmp/kafka-python-2.0.2/kafka/consumer/fetcher.py", line 19, in <module>
    from kafka.record import MemoryRecords
  File "/home/build/dev/fedora_packaging/python-kafka/tmp/kafka-python-2.0.2/kafka/record/__init__.py", line 1, in <module>
    from kafka.record.memory_records import MemoryRecords, MemoryRecordsBuilder
  File "/home/build/dev/fedora_packaging/python-kafka/tmp/kafka-python-2.0.2/kafka/record/memory_records.py", line 27, in <module>
    from kafka.record.legacy_records import LegacyRecordBatch, LegacyRecordBatchBuilder
  File "/home/build/dev/fedora_packaging/python-kafka/tmp/kafka-python-2.0.2/kafka/record/legacy_records.py", line 50, in <module>
    from kafka.codec import (
  File "/home/build/dev/fedora_packaging/python-kafka/tmp/kafka-python-2.0.2/kafka/codec.py", line 9, in <module>
    from kafka.vendor.six.moves import range
ModuleNotFoundError: No module named 'kafka.vendor.six.moves'
>>>

I do not know a good way to solve this isseu but here is my workaround that calls the range class using moves.range after import moves module.

>>> from kafka.vendor.six import moves
>>> moves.range
<class 'range'>

Thanks in advance,
Hirotaka


This change is Reviewable

@cdce8p cdce8p mentioned this pull request Jul 20, 2023
32 tasks
@wbarnha wbarnha self-requested a review August 6, 2023 01:54
Copy link
Collaborator

@wbarnha wbarnha left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Future support for Python 2.7 is undergoing debate at the moment, so I'm not sure if this PR is the right move for us. Personally, if we're moving support to 3.8+ (since all previous versions are EOL'ed), I think it makes sense to remove kafka.vendor.six and use regular function calls.

Regardless, thanks for the PR. I created support for 3.12 in workflows and I was perplexed at why 3.12 wouldn't work.

@wbarnha
Copy link
Collaborator

wbarnha commented Nov 3, 2023

The issue is now patched, we can close this for now. Thank you for your PR,

@wbarnha wbarnha closed this Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants