You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@qpid.apache.org by "Jiri Daněk (Jira)" <ji...@apache.org> on 2023/04/10 14:27:00 UTC
[jira] [Created] (QPID-8632) [python client] Circular imports in mllib and qpid.connection, qpid.delegates
Jiri Daněk created QPID-8632:
--------------------------------
Summary: [python client] Circular imports in mllib and qpid.connection, qpid.delegates
Key: QPID-8632
URL: https://issues.apache.org/jira/browse/QPID-8632
Project: Qpid
Issue Type: Bug
Components: Python Client
Affects Versions: qpid-python-1.38.0
Reporter: Jiri Daněk
Circular imports in Python actually do work, and break only when one makes a change that trips this potential minefield. One such change is Python 2/3 compatibility.
What triggers the problem is the situation when two modules import each other, _and_ the other module needs to be evaluated for the first import (when evaluating the first module) to complete. See https://stackoverflow.com/questions/744373/what-happens-when-using-mutual-or-circular-cyclic-imports for discussion and examples.
Picking solution that is compatible with Python 2 as well as Python 3 in the future (QPID-8631) is tricky.
{noformat}
Traceback (most recent call last):
File "./qpid-python-test", line 29, in <module>
from qpid.harness import Skipped
File "/home/runner/work/qpid-python/qpid-python/qpid/__init__.py", line 20, in <module>
from . import connection
File "/home/runner/work/qpid-python/qpid-python/qpid/connection.py", line 29, in <module>
from . import delegates
File "/home/runner/work/qpid-python/qpid-python/qpid/delegates.py", line 21, in <module>
from . import connection, session
ImportError: cannot import name connection
{noformat}
{noformat}
Traceback (most recent call last):
File "./qpid-python-test", line 30, in <module>
from qpid.harness import Skipped
File "/home/runner/work/qpid-python/qpid-python/qpid/__init__.py", line 21, in <module>
from . import connection
File "/home/runner/work/qpid-python/qpid-python/qpid/connection.py", line 21, in <module>
from . import datatypes, session
File "/home/runner/work/qpid-python/qpid-python/qpid/session.py", line 22, in <module>
from .generator import command_invoker
File "/home/runner/work/qpid-python/qpid-python/qpid/generator.py", line 23, in <module>
from .ops import *
File "/home/runner/work/qpid-python/qpid-python/qpid/ops.py", line 21, in <module>
import os, mllib, sys
File "/home/runner/work/qpid-python/qpid-python/mllib/__init__.py", line 27, in <module>
from . import dom, transforms, parsers
File "/home/runner/work/qpid-python/qpid-python/mllib/dom.py", line 34, in <module>
from . import transforms
File "/home/runner/work/qpid-python/qpid-python/mllib/transforms.py", line 25, in <module>
from . import dom
ImportError: cannot import name dom
{noformat}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@qpid.apache.org
For additional commands, e-mail: dev-help@qpid.apache.org