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: Crash when importing encoded file
Type: Stage:
Components: Unicode Versions: Python 2.3
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: loewis Nosy List: jneb, lemburg, loewis
Priority: normal Keywords:

Created on 2004-07-14 09:05 by jneb, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg21571 - (view) Author: Jurjen N.E. Bos (jneb) * Date: 2004-07-14 09:05
Python crashes (!) when it meets a non-ascii character in a file with 
encoding in use.

For example:
<file foo.py>
# encoding: mac-roman

...

<square root character>


<in Python>
>>> import user #so we can import 
>>> import foo
Parser/tokenizer.c:366: failed assertion `strlen(str) < (size_t)size'
Abort

When debugging, I found the StreamReader.readline() routine in 
codecs.py. It self.calls decode, which does return well; then readline 
returns, and then the inevitable happens.
Readline is called straight from the toplevel (from the viewpoint of 
the debugger), which probably means calling readline is part of the 
import logic in C.
So the bug must somewhere in there...
- Jurjen
msg21572 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2004-07-23 10:13
Logged In: YES 
user_id=38388

Martin, could you have a look at this ? Thanks.
msg21573 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-08-25 11:31
Logged In: YES 
user_id=21627

Some time has passed, and now I fail to reproduce the
problem. It would have helped if you had attached the actual
file that causes the bug, and if you had stated the precise
Python version and platform on which this bug occurred.

So I'm closing this as "works for me". If you can provide
further details, and it hasn't been fixed in 2.4, please
submit a new report.
History
Date User Action Args
2022-04-11 14:56:05adminsetgithub: 40557
2004-07-14 09:05:00jnebcreate