Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Unicode issue with Python v3.3

Reply
Thread Tools

Unicode issue with Python v3.3

 
 
33
Guest
Posts: n/a
 
      04-09-2013
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.
 
Reply With Quote
 
 
 
 
Ian Kelly
Guest
Posts: n/a
 
      04-09-2013
On Tue, Apr 9, 2013 at 3:10 PM, 33 <(E-Mail Removed)> wrote:
> 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?
 
Reply With Quote
 
 
 
 
nagia.retsina@gmail.com
Guest
Posts: n/a
 
      04-10-2013
Τη Τετάρτη, 10 Απριλίου 2013 12:34:25 π.μ. UTC+3, ο χρήστης Ian *γραψε:
> On Tue, Apr 9, 2013 at 3:10 PM, Νίκος Γκρ33κ <(E-Mail Removed)> wrote:
>
> > 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.
 
Reply With Quote
 
nagia.retsina@gmail.com
Guest
Posts: n/a
 
      04-10-2013
Τη Τετάρτη, 10 Απριλίου 2013 12:34:25 π.μ. UTC+3, ο χρήστης Ian *γραψε:
> On Tue, Apr 9, 2013 at 3:10 PM, Νίκος Γκρ33κ <(E-Mail Removed)> wrote:
>
> > 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.
 
Reply With Quote
 
Steven D'Aprano
Guest
Posts: n/a
 
      04-10-2013
On Tue, 09 Apr 2013 20:16:12 -0700, nagia.retsina wrote:

> Τη Τετάρτη, 10 Απριλίου 2013 12:34:25 π.μ. UTC+3, ο χρήστης Ian *γραψε:
>> On Tue, Apr 9, 2013 at 3:10 PM, Νίκος Γκρ33κ <(E-Mail Removed)>
>> wrote:
>>
>> > 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.



--
Steven
 
Reply With Quote
 
Chris Angelico
Guest
Posts: n/a
 
      04-10-2013
On Wed, Apr 10, 2013 at 2:25 PM, Steven D'Aprano
<(E-Mail Removed)> wrote:
> On Tue, 09 Apr 2013 20:16:12 -0700, nagia.retsina wrote:
>
>> , 10 2013 12:34:25 .. UTC+3, Ian :
>>> On Tue, Apr 9, 2013 at 3:10 PM, 33 <(E-Mail Removed)>
>>> wrote:
>>>
>>> > 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
 
Reply With Quote
 
rusi
Guest
Posts: n/a
 
      04-10-2013
An interesting case of two threads:

On Apr 10, 9:46*am, Chris Angelico <(E-Mail Removed)> wrote:
> On Wed, Apr 10, 2013 at 2:25 PM, Steven D'Aprano


> > 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


Some swans are black
Some homo sapiens have negative IQ
 
Reply With Quote
 
rusi
Guest
Posts: n/a
 
      04-10-2013
On Apr 10, 10:06*am, rusi <(E-Mail Removed)> wrote:
> An interesting case of two threads:
>
> On Apr 10, 9:46*am, Chris Angelico <(E-Mail Removed)> wrote:
>
> > On Wed, Apr 10, 2013 at 2:25 PM, Steven D'Aprano
> > > 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

>
> 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.
 
Reply With Quote
 
Antoine Pitrou
Guest
Posts: n/a
 
      04-10-2013
rusi <rustompmody <at> gmail.com> writes:
>
> 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.


 
Reply With Quote
 
nagia.retsina@gmail.com
Guest
Posts: n/a
 
      04-10-2013
Τη Τετάρτη, 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'

-->

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Python unicode utf-8 characters and MySQL unicode utf-8 characters Grzegorz liwiski Python 2 01-19-2011 07:31 AM
os.lisdir, gets unicode, returns unicode... USUALLY?!?!? gabor Python 13 11-18-2006 09:23 AM
Unicode digit to unicode string Gabriele *darkbard* Farina Python 2 05-16-2006 01:15 PM
unicode wrap unicode object? ygao Python 6 04-08-2006 09:54 AM
Unicode + jsp + mysql + tomcat = unicode still not displaying Robert Mark Bram Java 0 09-28-2003 05:37 AM



Advertisments