Issue 21 in iniparse: circular imports make python3 unhappy

0 views
Skip to first unread message

inip...@googlecode.com

unread,
May 5, 2010, 5:27:34 AM5/5/10
to iniparse...@googlegroups.com
Status: Accepted
Owner: tim.lauridsen
Labels: Type-Defect Priority-Medium

New issue 21 by tim.lauridsen: circular imports make python3 unhappy
http://code.google.com/p/iniparse/issues/detail?id=21


I have been playing around with python3 and iniparse and have build some
fedora packages, there make a python3 version of iniparse using the 2to3
tool from python3.
But i run into an issue when importing iniparse

Python 3.1.2 (r312:79147, Apr 1 2010, 03:31:01)
[GCC 4.4.3 20100226 (Red Hat 4.4.3-8)] on linux2
>>> import iniparse
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.1/site-packages/iniparse/__init__.py", line 6, in
<module>
from .ini import INIConfig, tidy, change_comment_syntax
File "/usr/lib/python3.1/site-packages/iniparse/ini.py", line 48, in
<module>
from . import compat
File "/usr/lib/python3.1/site-packages/iniparse/compat.py", line 27, in
<module>
from . import ini
ImportError: cannot import name ini

This is cause by ini.py has a

from . import compat

and compat.py has a

from . import ini

The compat import in ini.py is only used by the newly added tidy().

One way to solve it is to move the tidy() to a separate .py file, so the
compat import can be skipped from ini.py.

What do you think ?

Tim









--
To post to this group, send email to iniparse...@googlegroups.com
To unsubscribe from this group, send email to iniparse-commi...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/iniparse-commits?hl=en

inip...@googlecode.com

unread,
May 5, 2010, 5:37:39 AM5/5/10
to iniparse...@googlegroups.com

Comment #1 on issue 21 by tim.lauridsen: circular imports make python3
unhappy
http://code.google.com/p/iniparse/issues/detail?id=21

(No comment was entered for this change.)

Attachments:
python3.diff 13.9 KB

inip...@googlecode.com

unread,
May 5, 2010, 5:41:40 AM5/5/10
to iniparse...@googlegroups.com

Comment #2 on issue 21 by tim.lauridsen: circular imports make python3
unhappy
http://code.google.com/p/iniparse/issues/detail?id=21

I have added a diff file to see the changes made to the code by the 2to3
tool.

inip...@googlecode.com

unread,
May 6, 2010, 10:22:09 PM5/6/10
to iniparse...@googlegroups.com

Comment #3 on issue 21 by psoberoi: circular imports make python3 unhappy
http://code.google.com/p/iniparse/issues/detail?id=21

Yeah - create a iniparse.utils module and move tidy to it. Also, change the
corresponding lines in iniparse/__init__.py

inip...@googlecode.com

unread,
May 6, 2010, 10:32:14 PM5/6/10
to iniparse...@googlegroups.com

Comment #4 on issue 21 by psoberoi: circular imports make python3 unhappy
http://code.google.com/p/iniparse/issues/detail?id=21

Based on a 1-minute look at the diff, the 2to3 changes look mostly sane,
except for a
few extra list creations that I think could be avoided (in the
iterkeys/itervalues/iteritems functions).

I think these changes are sufficient if we want iniparse to work with files
opened in
text mode. However, currently iniparse supports both byte and unicode
strings. If
we want to preserve that functionality, we'll probably have to make more
changes.

inip...@googlecode.com

unread,
May 8, 2010, 3:11:16 AM5/8/10
to iniparse...@googlegroups.com

Comment #5 on issue 21 by tim.lauridsen: circular imports make python3
unhappy
http://code.google.com/p/iniparse/issues/detail?id=21

ok, I have commited the changes for moving tidy

http://code.google.com/p/iniparse/source/detail?r=139

I was not my plan to add the 2to3 diff to upstream at this point in time, i
will
modify the rpm build spec file to build both a python 2.x version and
python 3.x one
by running 2to3 on the sources before the build. So no need to convert
upstream
sources at this point in time.

inip...@googlecode.com

unread,
May 8, 2010, 3:09:38 PM5/8/10
to iniparse...@googlegroups.com
Updates:
Status: Fixed

Comment #6 on issue 21 by psoberoi: circular imports make python3 unhappy
http://code.google.com/p/iniparse/issues/detail?id=21

sounds good.
Reply all
Reply to author
Forward
0 new messages