This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: minidom.py -- TypeError: object doesn't support slice assig
Type: behavior Stage: needs patch
Components: XML Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: akuchling Nosy List: BreamoreBoy, akuchling, fdrake, leshmark, loewis
Priority: normal Keywords:

Created on 2003-07-26 00:22 by leshmark, last changed 2022-04-10 16:10 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
dom-test.py akuchling, 2005-11-22 21:21 Small test case
Messages (7)
msg17358 - (view) Author: Mark Lesh (leshmark) Date: 2003-07-26 00:22
Got the following traceback after upgrading to 2.3c1

Traceback (most recent call last):
  File
"/root/alchemy/scripts/cvs/alchemy/alchemy_menu.py",
line 178, in menu_system
    a=alchemy.Alchemy(name=name,step='alchemy')
  File "/root/alchemy/scripts/cvs/alchemy/alchemy.py",
line 89, in __init__
   
self.traverseNodes([self.start_node],exclude_tags=["evaporate","info"])
  File "/root/alchemy/scripts/cvs/alchemy/alchemy.py",
line 786, in traverseNodes
    self.traverseNodes(node.childNodes,exclude_tags)
  File "/root/alchemy/scripts/cvs/alchemy/alchemy.py",
line 786, in traverseNodes
    self.traverseNodes(node.childNodes,exclude_tags)
  File "/root/alchemy/scripts/cvs/alchemy/alchemy.py",
line 786, in traverseNodes
    self.traverseNodes(node.childNodes,exclude_tags)
  File "/root/alchemy/scripts/cvs/alchemy/alchemy.py",
line 786, in traverseNodes
    self.traverseNodes(node.childNodes,exclude_tags)
  File "/root/alchemy/scripts/cvs/alchemy/alchemy.py",
line 786, in traverseNodes
    self.traverseNodes(node.childNodes,exclude_tags)
  File "/root/alchemy/scripts/cvs/alchemy/alchemy.py",
line 786, in traverseNodes
    self.traverseNodes(node.childNodes,exclude_tags)
  File "/root/alchemy/scripts/cvs/alchemy/alchemy.py",
line 766, in traverseNodes
    node.normalize()
  File "/usr/lib/python2.3/xml/dom/minidom.py", line
208, in normalize
    self.childNodes[:] = L
TypeError: object doesn't support slice assignment
msg17359 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-07-27 11:10
Logged In: YES 
user_id=21627

Are you sure this is a bug in Python, and not in Alchemy?
msg17360 - (view) Author: Mark Lesh (leshmark) Date: 2003-08-01 06:20
Logged In: YES 
user_id=76540

The code worked again after I downgraded to Python 2.2.3. If
you like I can replicate in a shorter and includable code
snippet (I'd need to pop 2.3 back on my box first though)
msg17361 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2003-08-01 07:00
Logged In: YES 
user_id=21627

It would definitely help if you could provide more detail on
the nature of the failure. E.g. where did the DOM tree come
from that Alchemy tries to invoke .normalize on, and what is
self.childnodes in the place of the error. 

If you could instead submit a small example that allows
reproduction of the error, that would help as well.
msg17362 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2005-11-22 21:21
Logged In: YES 
user_id=11375

I can trigger this exception by calling the normalize()
method on a childless DOM node such as Text.  A little
script is attached. 

The question is: what should normalize() do for a class such
as Text?  Looking at the DOM Level 1 specification,
.normalize() is actually part of the Element interface, not
Node, so things like Text.normalize() wouldn't work at all.

One solution: move normalize() onto the Element class. 
Possibly backwards-incompatible.

Another solution: add a normalize() method to the Childless
mix-in that raises an exception.
msg111539 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2010-07-25 12:57
This is still an issue with all Python versions, is there anybody who could take this on please?
msg111581 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2010-07-25 23:50
Well, we certainly can't going making any incompatible changes now, so I've opted to add an empty normalize() method to the Childless mix-in.  This makes minidom a little more liberal than other DOM implementations, but I think that's OK.

Committed to trunk in rev83152, and backported to 2.7 in rev83153.
History
Date User Action Args
2022-04-10 16:10:14adminsetgithub: 38935
2010-07-25 23:50:16akuchlingsetstatus: open -> closed
resolution: fixed
messages: + msg111581
2010-07-25 12:57:11BreamoreBoysetnosy: + BreamoreBoy
messages: + msg111539
2009-07-04 02:37:05ezio.melottisettype: behavior
stage: needs patch
2008-01-20 01:16:23akuchlingsetassignee: fdrake -> akuchling
2003-07-26 00:22:23leshmarkcreate