Unicode issue with Python v3.3

Discussion in 'Python' started by Íßêïò Ãêñ33ê, Apr 9, 2013.

  1. 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.
     
    Íßêïò Ãêñ33ê, Apr 9, 2013
    #1
    1. Advertising

  2. Íßêïò Ãêñ33ê

    Ian Kelly Guest

    On Tue, Apr 9, 2013 at 3:10 PM, Íßêïò Ãêñ33ê <> 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?
     
    Ian Kelly, Apr 9, 2013
    #2
    1. Advertising

  3. Íßêïò Ãêñ33ê

    Guest

    Τη ΤετάÏτη, 10 ΑπÏιλίου 2013 12:34:25 Ï€.μ. UTC+3, ο χÏήστης Ian έγÏαψε:
    > On Tue, Apr 9, 2013 at 3:10 PM, Îίκος ΓκÏ33κ <> 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.
     
    , Apr 10, 2013
    #3
  4. Íßêïò Ãêñ33ê

    Guest

    Τη ΤετάÏτη, 10 ΑπÏιλίου 2013 12:34:25 Ï€.μ. UTC+3, ο χÏήστης Ian έγÏαψε:
    > On Tue, Apr 9, 2013 at 3:10 PM, Îίκος ΓκÏ33κ <> 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.
     
    , Apr 10, 2013
    #4
  5. 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κ <>
    >> 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
     
    Steven D'Aprano, Apr 10, 2013
    #5
  6. On Wed, Apr 10, 2013 at 2:25 PM, Steven D'Aprano
    <> 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ê <>
    >>> 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
     
    Chris Angelico, Apr 10, 2013
    #6
  7. Íßêïò Ãêñ33ê

    rusi Guest

    An interesting case of two threads:

    On Apr 10, 9:46 am, Chris Angelico <> 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
     
    rusi, Apr 10, 2013
    #7
  8. Íßêïò Ãêñ33ê

    rusi Guest

    On Apr 10, 10:06 am, rusi <> wrote:
    > An interesting case of two threads:
    >
    > On Apr 10, 9:46 am, Chris Angelico <> 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.
     
    rusi, Apr 10, 2013
    #8
  9. 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.
     
    Antoine Pitrou, Apr 10, 2013
    #9
  10. Íßêïò Ãêñ33ê

    Guest

    Τη ΤετάÏτη, 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'

    -->
     
    , Apr 10, 2013
    #10
  11. 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.
     
    Íßêïò Ãêñ33ê, Apr 10, 2013
    #11
  12. On Tue, 09 Apr 2013 23:04:35 -0700, rusi wrote:

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



    --
    Steven
     
    Steven D'Aprano, Apr 10, 2013
    #12
  13. People in the python community [was Re: Unicode issue with Pythonv3.3]

    On Wed, 10 Apr 2013 08:28:55 +0000, Steven D'Aprano wrote:

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



    --
    Steven
     
    Steven D'Aprano, Apr 10, 2013
    #13
  14. Re: People in the python community [was Re: Unicode issue with Pythonv3.3]

    On 10/04/2013 09:34, Steven D'Aprano wrote:
    >
    > 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.

    --
    If you're using GoogleCrap™ please read this
    http://wiki.python.org/moin/GoogleGroupsPython.

    Mark Lawrence
     
    Mark Lawrence, Apr 10, 2013
    #14
  15. Re: People in the python community [was Re: Unicode issue with Python v3.3]

    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ê, Apr 10, 2013
    #15
  16. Re: People in the python community [was Re: Unicode issue with Pythonv3.3]

    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ê, Apr 10, 2013
    #16
  17. Re: People in the python community [was Re: Unicode issue with Python v3.3]

    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ê, Apr 10, 2013
    #17
  18. Re: People in the python community [was Re: Unicode issue with Pythonv3.3]

    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ê, Apr 10, 2013
    #18
  19. Íßêïò Ãêñ33ê

    Peter Otten Guest

    Re: People in the python community [was Re: Unicode issue with Pythonv3.3]

    Steven D'Aprano wrote:

    > On Wed, 10 Apr 2013 08:28:55 +0000, Steven D'Aprano wrote:
    >
    >> 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 :)
     
    Peter Otten, Apr 10, 2013
    #19
  20. Íßêïò Ãêñ33ê

    Peter Otten Guest

    Re: People in the python community [was Re: Unicode issue with Pythonv3.3]

    Mark Lawrence wrote:

    > On 10/04/2013 09:34, Steven D'Aprano wrote:
    >>
    >> 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.


    You're invited as a speaker to my funeral ;)
     
    Peter Otten, Apr 10, 2013
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Robert Mark Bram
    Replies:
    0
    Views:
    4,052
    Robert Mark Bram
    Sep 28, 2003
  2. ygao

    unicode wrap unicode object?

    ygao, Apr 8, 2006, in forum: Python
    Replies:
    6
    Views:
    591
    =?ISO-8859-1?Q?=22Martin_v=2E_L=F6wis=22?=
    Apr 8, 2006
  3. Gabriele *darkbard* Farina

    Unicode digit to unicode string

    Gabriele *darkbard* Farina, May 16, 2006, in forum: Python
    Replies:
    2
    Views:
    566
    Gabriele *darkbard* Farina
    May 16, 2006
  4. Grzegorz ¦liwiñski
    Replies:
    2
    Views:
    1,030
    Grzegorz ¦liwiñski
    Jan 19, 2011
  5. Terry Reedy
    Replies:
    0
    Views:
    94
    Terry Reedy
    Jan 7, 2014
Loading...

Share This Page