Unicode issue with Python v3.3

  • Thread starter Íßêïò Ãêñ33ê
  • Start date
Í

Íßêïò Ãêñ33ê

Hello, iam still trying to alter the code form python 2.6 => 3.3

Everyrging its setup except that unicode error that you can see if you go to http://superhost.gr

Can anyone help with this?
I even tried to change print() with sys.stdout.buffer() but still i get the same unicode issue.

I don't know what to try anymore.
 
I

Ian Kelly

Hello, iam still trying to alter the code form python 2.6 => 3.3

Everyrging its setup except that unicode error that you can see if you goto http://superhost.gr

Can anyone help with this?
I even tried to change print() with sys.stdout.buffer() but still i get the same unicode issue.

I don't know what to try anymore.

It seems to be failing on the line:

host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]

So the obvious question to ask is: what are the contents of
os.environ['REMOTE_ADDR'] when this line is reached?

And why are you still trying to solve these sorts of problems on your
production website? Do you not have a development or staging
environment?
 
N

nagia.retsina

Τη ΤετάÏτη, 10 ΑπÏιλίου 2013 12:34:25 Ï€.μ. UTC+3, ο χÏήστης Ian έγÏαψε:
Hello, iam still trying to alter the code form python 2.6 => 3.3

Everyrging its setup except that unicode error that you can see if you go to http://superhost.gr

Can anyone help with this?
I even tried to change print() with sys.stdout.buffer() but still i getthe same unicode issue.

I don't know what to try anymore.



It seems to be failing on the line:



host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]



So the obvious question to ask is: what are the contents of

os.environ['REMOTE_ADDR'] when this line is reached?



And why are you still trying to solve these sorts of problems on your

production website? Do you not have a development or staging

environment?

No forget this line. this is not the problem.
No i don't have a testing enviroment, i altered all the code form 2.6 to 3..3 in the live enviromtnt.

i strongly believe there is somethign goind wrong with the prints(). Thoeseare causing the unicode isu es much like as thes changes from:

quote = random.choice( list( open( "/home/nikos/www/data/private/quotes.txt", ) ) )

quote = random.choice( list( open( "/home/nikos/www/data/private/quotes.txt", encoding="utf-8" ) ) )

in order for the open() to work.
 
N

nagia.retsina

Τη ΤετάÏτη, 10 ΑπÏιλίου 2013 12:34:25 Ï€.μ. UTC+3, ο χÏήστης Ian έγÏαψε:
Hello, iam still trying to alter the code form python 2.6 => 3.3

Everyrging its setup except that unicode error that you can see if you go to http://superhost.gr

Can anyone help with this?
I even tried to change print() with sys.stdout.buffer() but still i getthe same unicode issue.

I don't know what to try anymore.



It seems to be failing on the line:



host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]



So the obvious question to ask is: what are the contents of

os.environ['REMOTE_ADDR'] when this line is reached?



And why are you still trying to solve these sorts of problems on your

production website? Do you not have a development or staging

environment?

No forget this line. this is not the problem.
No i don't have a testing enviroment, i altered all the code form 2.6 to 3..3 in the live enviromtnt.

i strongly believe there is somethign goind wrong with the prints(). Thoeseare causing the unicode isu es much like as thes changes from:

quote = random.choice( list( open( "/home/nikos/www/data/private/quotes.txt", ) ) )

quote = random.choice( list( open( "/home/nikos/www/data/private/quotes.txt", encoding="utf-8" ) ) )

in order for the open() to work.
 
S

Steven D'Aprano

Τη ΤετάÏτη, 10 ΑπÏιλίου 2013 12:34:25 Ï€.μ. UTC+3, ο χÏήστης Ian έγÏαψε:
Hello, iam still trying to alter the code form python 2.6 => 3.3

Everyrging its setup except that unicode error that you can see if
you go to http://superhost.gr

Can anyone help with this?
I even tried to change print() with sys.stdout.buffer() but still i
get the same unicode issue.

I don't know what to try anymore.



It seems to be failing on the line:

host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]

So the obvious question to ask is: what are the contents of

os.environ['REMOTE_ADDR'] when this line is reached?
[...]

No forget this line. this is not the problem. No i don't have a testing
enviroment, i altered all the code form 2.6 to 3.3 in the live
enviromtnt.

i strongly believe there is somethign goind wrong with the prints().


Obviously you know what the problem is much better than the Python
interpreter.

I suggest you open a bug report:

"Errors printing bytes are wrongly claimed to be socket errors"

and see what happens.

Or, you can listen to people who actually know what they are talking
about, and look at the actual error, which has NOTHING to do with print.

What does os.environ['REMOTE_ADDR'] give? Until you answer that question,
you won't make any progress.
 
C

Chris Angelico

Ôç ÔåôÜñôç, 10 Áðñéëßïõ 2013 12:34:25 ð.ì. UTC+3, ï ÷ñÞóôçò Ian Ýãñáøå:
Hello, iam still trying to alter the code form python 2.6 => 3.3

Everyrging its setup except that unicode error that you can see if
you go to http://superhost.gr

Can anyone help with this?

I even tried to change print() with sys.stdout.buffer() but still i
get the same unicode issue.

I don't know what to try anymore.



It seems to be failing on the line:

host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]

So the obvious question to ask is: what are the contents of

os.environ['REMOTE_ADDR'] when this line is reached?
[...]

No forget this line. this is not the problem. No i don't have a testing
enviroment, i altered all the code form 2.6 to 3.3 in the live
enviromtnt.

i strongly believe there is somethign goind wrong with the prints().


Obviously you know what the problem is much better than the Python
interpreter.

I just went to the page and it started playing sound. Between that and
this arrogant refusal to believe either the interpreter or the people
who are freely donating time to assist, I'm done. No more looking at
Nikos's home page to try to figure out his problems. Have fun, Nikos.

ChrisA
 
R

rusi

An interesting case of two threads:

I just went to the page and it started playing sound. Between that and
this arrogant refusal to believe either the interpreter or the people
who are freely donating time to assist, I'm done. No more looking at
Nikos's home page to try to figure out his problems. Have fun, Nikos.

ChrisA

Some swans are black
Some homo sapiens have negative IQ
 
R

rusi

An interesting case of two threads:





Some swans are black
Some homo sapiens have negative IQ

Hmm I see some cut-paste goofup on my part.
I was meaning to juxtapose this thread where we put up with inordinate
amount of nonsense from OP
along with the recent thread in which a newcomer who thinks he has
found a bug in pdb is made fun of.

Then thought better of it and deleted the stuff.
However I did not do a good delete-job so I better now say what I
avoided saying:

If those who habitually post rubbish are given much of our time and
effort,
whereas newcomers and first-timers are treated rudely, the list begins
to smell like a club of old farts.
 
A

Antoine Pitrou

rusi said:
Hmm I see some cut-paste goofup on my part.
I was meaning to juxtapose this thread where we put up with inordinate
amount of nonsense from OP
along with the recent thread in which a newcomer who thinks he has
found a bug in pdb is made fun of.

Then thought better of it and deleted the stuff.
However I did not do a good delete-job so I better now say what I
avoided saying:

If those who habitually post rubbish are given much of our time and
effort,
whereas newcomers and first-timers are treated rudely, the list begins
to smell like a club of old farts.

+1. If you think you have something intelligent to say to jmfauth,
you might as well start a private discussion with him.

As far as I'm concerned, python-list is *already* of club of old
farts. Many regular posters are more interested in "being right on the
Internet" rather than helping people out.

(this is where the StackOverflow mechanics probably work better, sadly)

Regards

Antoine.
 
N

nagia.retsina

Τη ΤετάÏτη, 10 ΑπÏιλίου 2013 7:25:21 Ï€.μ. UTC+3, οχÏήστης Steven D'Aprano έγÏαψε:
What does os.environ['REMOTE_ADDR'] give? Until you answer that question,
you won't make any progress.

I insists stevv.

Look at what 'python3 metrites.py' gives me

<!-- The above is a description of an error in a Python program, formatted
for a Web browser because the 'cgitb' module was enabled. In case you
are not reading this in a Web browser, here is the original traceback:

Traceback (most recent call last):
File "metrites.py", line 34, in &lt;module&gt;
userinfo = os.environ['HTTP_USER_AGENT']
File "/root/.local/lib/python2.7/lib/python3.3/os.py", line 669, in __getitem__
value = self._data[self.encodekey(key)]
KeyError: b'HTTP_USER_AGENT'

-->
 
Í

Íßêïò Ãêñ33ê

Here is the whole code for metrites.py in case someone wants to take allok.

Everything is correct after altering it to meet python 3.3, everythign aprt from the weird unicode error thing.

http://pastebin.com/5Mpjx5Fd

please take a look.
Thank you.
 
S

Steven D'Aprano

Hmm I see some cut-paste goofup on my part. I was meaning to juxtapose
this thread where we put up with inordinate amount of nonsense from OP
along with the recent thread in which a newcomer who thinks he has found
a bug in pdb is made fun of.

Curious. Is this making fun of the newcomer?

If you are able to supply more details, we might be able to
follow up on the registration problem. And, as someone else
suggested, you could post the details of the pdb problem here.
Note, there are already a number of currently open issues with
pdb reported on the bug tracker. If you haven't already, you
could search for "pdb" and see if your problem has been reported.
Thanks for bringing the problem(s) up!


Or perhaps this is making fun of them?

Post the 10-line program here, so others can verify whether it is a bug.


I think it is quite unfair of you to mischaracterise the entire community
response in this way. One person made a light-hearted, silly, unhelpful
response. (As sarcasm, I'm afraid it missed the target.) Two people made
good, sensible responses -- and you were not either of them.

If you want to be helpful, how about leading by example and taking on
some of the less coherent newbie questions, instead of just bitching that
others don't? It's easy, and a pleasure, to give good answers to well-
written, carefully thought out questions. It's much harder to do the same
for those questions which are... shall we say... less optimal. We could
do with a few more people who make an effort to be helpful and friendly,
instead of scolds who just tell us off when we stumble.


Then thought better of it and deleted the stuff. However I did not do a
good delete-job so I better now say what I avoided saying:

If those who habitually post rubbish are given much of our time and
effort,
whereas newcomers and first-timers are treated rudely, the list begins
to smell like a club of old farts.


It's often the newcomers who are posting rubbish. Should we ignore them
for posting rubbish, or welcome them for being newcomers?
 
S

Steven D'Aprano

If you want to be helpful, how about leading by example and taking on
some of the less coherent newbie questions
[...]


On that note, I think I'll take the opportunity to give thanks to Peter
Otten, who (if I remember correctly) has been here for longer than I
have, and I've been here for a long time. In all that time, I don't think
I've ever seen him snap at or be rude to anyone, not even those who
deserved it, and he doesn't shy away from answering even the most poorly
written questions.


Peter, I don't know how you do it, but you're doing a fantastic job.
 
M

Mark Lawrence

On that note, I think I'll take the opportunity to give thanks to Peter
Otten, who (if I remember correctly) has been here for longer than I
have, and I've been here for a long time. In all that time, I don't think
I've ever seen him snap at or be rude to anyone, not even those who
deserved it, and he doesn't shy away from answering even the most poorly
written questions.


Peter, I don't know how you do it, but you're doing a fantastic job.

Seconded. For those who don't know Peter is always responding to
queries on the tutor mailing list as well. Definite case of the
patience of a saint.
 
Í

Íßêïò Ãêñ33ê

os.environ['HTTP_USER_AGENT'] is only set when running from browser.

so i faked it by using:

userinfo = os.environ.get('HTTP_USER_AGENT', 'some default')

but the encoding issues are still there.
 
Í

Íßêïò Ãêñ33ê

os.environ['HTTP_USER_AGENT'] is only set when running from browser.

so i faked it by using:

userinfo = os.environ.get('HTTP_USER_AGENT', 'some default')

but the encoding issues are still there.
 
Í

Íßêïò Ãêñ33ê

Thank you just altered it but i still get the same encoding issues.

please its only a matter of simple alternation that iam not able to see.

When you have the time plz take a look.

Thank you!
 
Í

Íßêïò Ãêñ33ê

Thank you just altered it but i still get the same encoding issues.

please its only a matter of simple alternation that iam not able to see.

When you have the time plz take a look.

Thank you!
 
P

Peter Otten

Steven said:
If you want to be helpful, how about leading by example and taking on
some of the less coherent newbie questions
[...]


On that note, I think I'll take the opportunity to give thanks to Peter
Otten, who (if I remember correctly) has been here for longer than I
have, and I've been here for a long time. In all that time, I don't think
I've ever seen him snap at or be rude to anyone, not even those who
deserved it, and he doesn't shy away from answering even the most poorly
written questions.


Peter, I don't know how you do it, but you're doing a fantastic job.

Thank you :)
 
P

Peter Otten

Mark said:
Seconded. For those who don't know Peter is always responding to
queries on the tutor mailing list as well. Definite case of the
patience of a saint.

You're invited as a speaker to my funeral ;)
 

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

Similar Threads


Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top