[issue16726] expat ParseFile expects bytes, not string

2021-11-28 Thread Irit Katriel


Irit Katriel  added the comment:

Reproduced on 3.11.

--
components: +Library (Lib)
nosy: +iritkatriel
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16726] expat ParseFile expects bytes, not string

2019-04-26 Thread Mark Lawrence


Change by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16726] expat ParseFile expects bytes, not string

2014-10-14 Thread Sebastien Bardeau

Sebastien Bardeau added the comment:

Same problem here with:
Python 3.4.1 (default, Jul 30 2014, 14:02:54)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-3)] on linux

What is unclear to me if this is a bug or a feature. In particular, as 
described here 
http://stackoverflow.com/questions/1179305/expat-parsing-in-python-3, one can 
open the xml file as binary to solve the issue. But is this /really/ intended? 
Opening standard ASCII xml files as binaries!?

--
nosy: +sbardeau

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16726] expat ParseFile expects bytes, not string

2014-07-13 Thread Mark Lawrence

Mark Lawrence added the comment:

@Michiel I'm sorry about the delay in replying to you.  I can confirm the same 
behaviour in 3.4.1 on 3.5.0a0 on Windows 7.

--
nosy: +BreamoreBoy, christian.heimes
versions: +Python 3.4, Python 3.5 -Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16726] expat ParseFile expects bytes, not string

2012-12-19 Thread Wibowo Arindrarto

Changes by Wibowo Arindrarto :


--
nosy: +bow

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16726] expat ParseFile expects bytes, not string

2012-12-19 Thread Michiel de Hoon

New submission from Michiel de Hoon:

The expat parser in xml.parsers.expat has a Parse method and a ParseFile 
method. The Parse method parses a string, however the ParseFile method wants 
bytes.

This is a minimal example of the Parse method:

>>> import xml.parsers.expat
>>> p = xml.parsers.expat.ParserCreate()
>>> p.Parse('')

which runs fine. Note that argument to p.Parse is a string, not bytes.

This is the corresponding example of ParseFile:

>>> import xml.parsers.expat
>>> handle = open("test.xml")
>>> p = xml.parsers.expat.ParserCreate()
>>> p.ParseFile(handle)

where the file test.xml only contains 
This gives an error:

Traceback (most recent call last):
  File "", line 1, in 
TypeError: read() did not return a bytes object (type=str)

Opening the file test.xml in binary raises an Error:

>>> import xml.parsers.expat
>>> handle = open("test.xml", "rb")
>>> p = xml.parsers.expat.ParserCreate()
>>> p.ParseFile(handle)
Traceback (most recent call last):
  File "", line 1, in 
xml.parsers.expat.ExpatError: no element found: line 2, column 0

suggesting that in reality, the expat Parser needs a string, not bytes.
(the same error appears with a more meaningful XML file).

I would expect that both Parse and ParseFile accept strings, but not bytes.

--
messages: 177733
nosy: mdehoon
priority: normal
severity: normal
status: open
title: expat ParseFile expects bytes, not string
type: behavior
versions: Python 3.3

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com