classification
Title: xml.sax.expatreader is missing
Type: Stage:
Components: XML Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: calvin, fdrake, loewis, zseil
Priority: critical Keywords:

Created on 2006-06-23 18:14 by calvin, last changed 2006-07-29 17:07 by fdrake. This issue is now closed.

Files
File name Uploaded Description Edit
pyconfig.h calvin, 2006-06-26 18:15
Messages (6)
msg28877 - (view) Author: Bastian Kleineidam (calvin) Date: 2006-06-23 18:14
Hi,

when testing the new Python 2.5 subversion tree I
encountered this behaviour:
$ python2.5
Python 2.5b1 (trunk:47065, Jun 22 2006, 20:56:23) 
[GCC 4.1.2 20060613 (prerelease) (Debian 4.1.1-5)] on
linux2
Type "help", "copyright", "credits" or "license" for
more information.
>>> import xml.sax.expatreader
>>> print xml.sax.expatreader
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute
'expatreader'
>>> 

So the import went ok, but using the attribute gave an
error. This is very strange. Python 2.4 did not have
this behaviour.
msg28878 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2006-06-24 10:39
Logged In: YES 
user_id=21627

How precisely did you test it? What configure options did
you set up, what commands did you provide to build Python?
msg28879 - (view) Author: Bastian Kleineidam (calvin) Date: 2006-06-26 18:15
Logged In: YES 
user_id=9205

I built Python directly from the SVN trunk repository with
$ ./configure && make altinstall
I attached the pyconfig.h that was generated. If you need
more info, feel free to ask.

After building and installing, I started up python2.5 and
executed "import xml.sax.expatreader" and then "print
xml.sax.expatreader", and nothing else.

Another thing I tried is "import from", which works.
But importing xml.sax.expatreader directly, as noted above,
does not work.

Here is the log with the "import from" test:
Python 2.5b1 (trunk:47090, Jun 25 2006, 09:59:02) 
[GCC 4.1.2 20060613 (prerelease) (Debian 4.1.1-5)] on linux2
Type "help", "copyright", "credits" or "license" for more
information.
>>> from xml.sax import expatreader
>>> print expatreader
<module 'xml.sax.expatreader' from
'/usr/local/lib/python2.5/xmlcore/sax/expatreader.pyc'>
>>> print xml.sax.expatreader
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'expatreader'
msg28880 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2006-06-26 22:52
Logged In: YES 
user_id=1326842

I see the same behaviour with the official Python 2.5
beta 1 Windows installer. The interesting thing is that
the expatreader module is present in sys.modules:

Python 2.5b1 (r25b1:47027, Jun 20 2006, 09:31:33)
[MSC v.1310 32 bit (Intel)] on win32
...
>>> import xml.sax.expatreader
>>> xml.sax.expatreader
Traceback (most recent call last):
  ...
AttributeError: 'module' object has no attribute 'expatreader'
>>> import sys
>>> sys.modules['xml.sax.expatreader']
<module 'xml.sax.expatreader' from
'...\lib\xmlcore\sax\expatreader.pyc'>

All of the other modules in xml package can be imported
without any trouble.
I don't understand what is the real problem here,
but it goes away if you import xmlcore.sax package
before expatreader:

[restart python]
>>> import xmlcore.sax
>>> import xml.sax.expatreader
>>> xml.sax.expatreader
<module 'xml.sax.expatreader' from
'...\lib\xmlcore\sax\expatreader.pyc'>

The simplest fix would be to use at least one absolute
import in ...\lib\xmlcore\sax\__init__.py, for example
you could change line 22:

from xmlreader import InputSource

to:

from xmlcore.sax.xmlreader import InputSource

but that might just hide the real bug.
msg28881 - (view) Author: Ziga Seilnacht (zseil) * (Python committer) Date: 2006-07-10 07:38
Logged In: YES 
user_id=1326842

See patch #1519796:
http://python.org/sf/1519796
msg28882 - (view) Author: Fred L. Drake, Jr. (fdrake) (Python committer) Date: 2006-07-29 17:07
Logged In: YES 
user_id=3066

The xmlcore package has been renamed back to the original
xml as of revision 50941.

A test for this condition has been added as part of that change.
History
Date User Action Args
2006-06-23 18:14:05calvincreate