Another (simple) unicode question

R

Rustom Mody

Construct http://construct.wikispaces.com/ is a kick-ass binary file
structurer (written by a 21 year old!)
I thought of trying to port it to python3 but it barfs on some unicode
related stuff (after running 2to3) which I am unable to wrap my head
around.

Can anyone direct me to what I should read to try to understand this?
 
J

John Machin

Constructhttp://construct.wikispaces.com/is a kick-ass binary file
structurer (written by a 21 year old!)
I thought of trying to port it to python3 but it barfs on some unicode
related stuff (after running 2to3) which I am unable to wrap my head
around.

Can anyone direct me to what I should read to try to understand this?

"unicode related stuff" is rather vague. Have you read the Python
Unicode HOWTO? Joel Spolsky's article?

http://www.amk.ca/python/howto/unicode
http://www.joelonsoftware.com/articles/Unicode.html

In any case, it's a debugging problem, isn't it? Could you possibly
consider telling us the error message, the traceback, a few lines of
the 3.x code around where the problem is, and the corresponding 2.x
lines? Are you using 3.1.1 and 2.6.4? Does your test work in 2.6?
 
C

Carl Banks

Constructhttp://construct.wikispaces.com/is a kick-ass binary file
structurer (written by a 21 year old!)
I thought of trying to port it to python3 but it barfs on some unicode
related stuff (after running 2to3) which I am unable to wrap my head
around.

2to3 isn't a general Python 2 to Python 3 translator. You can't pass
any old Python 2.x code through 2to3 and expect it to work. Rather,
you have to write the Python 2.x code in a subset of Python that I
call "transitional dialect". In order to port to Python 3 using 2to3,
you first have to port it to this transitional dialect.

If Unicode is the issue, one thing you should do to explicitly
classify all strings as binary or text in Python 2.x. This means to
change str() to unicode() or bytes(), whichever is appropriate, and to
change "" to u"" or b"".


Carl Banks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,184
Messages
2,570,978
Members
47,561
Latest member
gjsign

Latest Threads

Top