mirror of
				https://github.com/python/cpython.git
				synced 2025-11-04 03:44:55 +00:00 
			
		
		
		
	SF#1534630
ignore data that arrives before the opening start tag
This commit is contained in:
		
							parent
							
								
									574cfea993
								
							
						
					
					
						commit
						dc075b9ddd
					
				
					 2 changed files with 16 additions and 1 deletions
				
			
		| 
						 | 
					@ -204,6 +204,17 @@ def check_encoding(encoding):
 | 
				
			||||||
        "<?xml version='1.0' encoding='%s'?><xml />" % encoding
 | 
					        "<?xml version='1.0' encoding='%s'?><xml />" % encoding
 | 
				
			||||||
        )
 | 
					        )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def bug_1534630():
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    >>> bob = ET.TreeBuilder()
 | 
				
			||||||
 | 
					    >>> e = bob.data("data")
 | 
				
			||||||
 | 
					    >>> e = bob.start("tag", {})
 | 
				
			||||||
 | 
					    >>> e = bob.end("tag")
 | 
				
			||||||
 | 
					    >>> e = bob.close()
 | 
				
			||||||
 | 
					    >>> serialize(ET, e)
 | 
				
			||||||
 | 
					    '<tag />'
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def test_main():
 | 
					def test_main():
 | 
				
			||||||
    from test import test_xml_etree_c
 | 
					    from test import test_xml_etree_c
 | 
				
			||||||
    test_support.run_doctest(test_xml_etree_c, verbosity=True)
 | 
					    test_support.run_doctest(test_xml_etree_c, verbosity=True)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -48,7 +48,7 @@
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#include "Python.h"
 | 
					#include "Python.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#define VERSION "1.0.6-snapshot"
 | 
					#define VERSION "1.0.6"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/* -------------------------------------------------------------------- */
 | 
					/* -------------------------------------------------------------------- */
 | 
				
			||||||
/* configuration */
 | 
					/* configuration */
 | 
				
			||||||
| 
						 | 
					@ -1599,6 +1599,10 @@ LOCAL(PyObject*)
 | 
				
			||||||
treebuilder_handle_data(TreeBuilderObject* self, PyObject* data)
 | 
					treebuilder_handle_data(TreeBuilderObject* self, PyObject* data)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    if (!self->data) {
 | 
					    if (!self->data) {
 | 
				
			||||||
 | 
					        if (self->last == (ElementObject*) Py_None) {
 | 
				
			||||||
 | 
					            /* ignore calls to data before the first call to start */
 | 
				
			||||||
 | 
					            Py_RETURN_NONE;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        /* store the first item as is */
 | 
					        /* store the first item as is */
 | 
				
			||||||
        Py_INCREF(data); self->data = data;
 | 
					        Py_INCREF(data); self->data = data;
 | 
				
			||||||
    } else {
 | 
					    } else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue