Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #49827 > unrolled thread
| Started by | Νίκος <nikos@superhost.gr> |
|---|---|
| First post | 2013-07-04 11:37 +0300 |
| Last post | 2013-09-06 16:17 -0700 |
| Articles | 8 on this page of 68 — 16 participants |
Back to article view | Back to comp.lang.python
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος <nikos@superhost.gr> - 2013-07-04 11:37 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Dave Angel <davea@davea.name> - 2013-07-04 05:59 -0400
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος <nikos@superhost.gr> - 2013-07-04 13:03 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Dave Angel <davea@davea.name> - 2013-07-04 06:29 -0400
Fwd: Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος <nikos@superhost.gr> - 2013-07-04 13:36 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-07-04 11:50 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος <nikos@superhost.gr> - 2013-07-04 13:38 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Chris Angelico <rosuav@gmail.com> - 2013-07-04 20:54 +1000
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος <nikos@superhost.gr> - 2013-07-04 14:29 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte MRAB <python@mrabarnett.plus.com> - 2013-07-04 12:52 +0100
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος <nikos@superhost.gr> - 2013-07-04 15:06 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Chris Angelico <rosuav@gmail.com> - 2013-07-04 22:37 +1000
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte MRAB <python@mrabarnett.plus.com> - 2013-07-04 12:06 +0100
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος <nikos@superhost.gr> - 2013-07-04 14:36 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte MRAB <python@mrabarnett.plus.com> - 2013-07-04 13:07 +0100
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος <nikos@superhost.gr> - 2013-07-04 15:47 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte MRAB <python@mrabarnett.plus.com> - 2013-07-04 14:34 +0100
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Γκρ33κ <nikos@superhost.gr> - 2013-07-04 16:38 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte MRAB <python@mrabarnett.plus.com> - 2013-07-04 16:10 +0100
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Γκρ33κ <nikos@superhost.gr> - 2013-07-04 18:56 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Wayne Werner <wayne@waynewerner.com> - 2013-07-12 06:47 -0500
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Ferrous Cranus <nikos@superhost.gr> - 2013-07-12 14:56 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Dave Angel <davea@davea.name> - 2013-07-12 11:46 -0400
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος <nikos@superhost.gr> - 2013-07-04 15:52 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte MRAB <python@mrabarnett.plus.com> - 2013-07-04 14:34 +0100
Fwd: Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Γκρ33κ <nikos@superhost.gr> - 2013-07-04 17:48 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Ulrich Eckhardt <ulrich.eckhardt@dominolaser.com> - 2013-07-04 15:07 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Γκρ33κ <nikos@superhost.gr> - 2013-07-04 16:26 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-07-04 16:08 -0400
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Ferrous Cranus <nikos@superhost.gr> - 2013-07-04 23:25 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Lele Gaifax <lele@metapensiero.it> - 2013-07-04 22:44 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Michael Torrie <torriem@gmail.com> - 2013-07-04 14:53 -0600
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Nobody <nobody@nowhere.com> - 2013-07-05 01:06 +0100
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Ferrous Cranus <nikos@superhost.gr> - 2013-07-05 09:07 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Lele Gaifax <lele@metapensiero.it> - 2013-07-05 08:55 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 10:10 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 09:51 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Lele Gaifax <lele@metapensiero.it> - 2013-07-05 09:06 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 10:13 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Dave Angel <davea@davea.name> - 2013-07-05 04:27 -0400
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 12:01 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Benjamin Kaplan <benjamin.kaplan@case.edu> - 2013-07-05 00:21 -0700
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Dave Angel <davea@davea.name> - 2013-07-05 03:50 -0400
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 11:00 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Dave Angel <davea@davea.name> - 2013-07-05 04:35 -0400
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 11:49 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Dave Angel <davea@davea.name> - 2013-07-05 05:21 -0400
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 12:25 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Lele Gaifax <lele@metapensiero.it> - 2013-07-05 12:24 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 13:28 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 13:26 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Lele Gaifax <lele@metapensiero.it> - 2013-07-05 12:36 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 13:42 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Lele Gaifax <lele@metapensiero.it> - 2013-07-05 12:59 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 14:05 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 14:16 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Lele Gaifax <lele@metapensiero.it> - 2013-07-05 13:16 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 14:27 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte feedthetroll@gmx.de - 2013-07-05 05:06 -0700
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 13:33 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte feedthetroll@gmx.de - 2013-07-05 04:56 -0700
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte feedthetroll@gmx.de - 2013-07-05 05:14 -0700
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Dave Angel <davea@davea.name> - 2013-07-05 09:05 -0400
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Lele Gaifax <lele@metapensiero.it> - 2013-07-05 16:11 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Νίκος Gr33k <nikos@superhost.gr> - 2013-07-05 17:27 +0300
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte feedthetroll@gmx.de - 2013-07-05 01:44 -0700
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte Lele Gaifax <lele@metapensiero.it> - 2013-07-05 12:16 +0200
Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0: invalid start byte roggero.n@gmail.com - 2013-09-06 16:17 -0700
Page 4 of 4 — ← Prev page 1 2 3 [4]
| From | feedthetroll@gmx.de |
|---|---|
| Date | 2013-07-05 04:56 -0700 |
| Message-ID | <bbb8bae1-3299-4e1d-ae6d-82d25419c01e@googlegroups.com> |
| In reply to | #49965 |
Am Freitag, 5. Juli 2013 12:33:05 UTC+2 schrieb Νίκος Gr33k:
> ...
> Wait!
> Are you saying that the ip address is being returned as a byte string
> which then i have to decode with something like:
>
> host = socket.gethostbyaddr( os.environ['REMOTE_HOST'].decode('utf-8') )[0]
Wait!
I get a decode error when python tries to automatically decode a bytestring assuming it to be utf-8 encoded.
I am sure the error will disappear, when I try to decode it explicit using utf-8. Heureka! I got it!
Or in other words:
If a big stone falls on my foot accidently it hurts.
But I am sure it will not hurt, if take that same stone and throw it on my foot.
Heureka! I got it!
P.S.:
Am 14.06.2013 10:35, schrieb Fábio Santos:
> Also you have been shown this link and I feel you really need to read it.
> http://slash7.com/2006/12/22/vampires/
[toc] | [prev] | [next] | [standalone]
| From | feedthetroll@gmx.de |
|---|---|
| Date | 2013-07-05 05:14 -0700 |
| Message-ID | <9d1589fa-1372-4164-a33a-c96aab89a17e@googlegroups.com> |
| In reply to | #49974 |
Am Freitag, 5. Juli 2013 12:33:05 UTC+2 schrieb Νίκος Gr33k:
> ...
> Wait!
> Are you saying that the ip address is being returned as a byte string
> which then i have to decode with something like:
>
> host = socket.gethostbyaddr( os.environ['REMOTE_HOST'].decode('utf-8') )[0]
Wait!
I get a decode error when python tries to automatically decode a bytestring
assuming it to be utf-8 encoded.
I am sure the error will disappear, when I try to decode it explicit using
utf-8. Heureka! I got it!
Or in other words:
If a big stone falls on my foot accidently, it hurts.
------------------------------------------^
But I am sure it will not hurt, if take that same stone and throw it on my foot.
Heureka! I got it!
P.S.:
Am 14.06.2013 10:35, schrieb Fábio Santos:
> Also you have been shown this link and I feel you really need to read it.
> http://slash7.com/2006/12/22/vampires/
[toc] | [prev] | [next] | [standalone]
| From | Dave Angel <davea@davea.name> |
|---|---|
| Date | 2013-07-05 09:05 -0400 |
| Message-ID | <mailman.4295.1373029556.3114.python-list@python.org> |
| In reply to | #49965 |
On 07/05/2013 06:33 AM, Νίκος Gr33k wrote:
> Στις 5/7/2013 12:21 μμ, ο/η Dave Angel έγραψε:
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "/usr/local/lib/python3.3/os.py", line 669, in __getitem__
>> value = self._data[self.encodekey(key)]
>> KeyError: b'REMOTE_ADDR
>
>
> Wait!
> Are you saying that the ip address is being returned as a byte string
> which then i have to decode with something like:
>
> host = socket.gethostbyaddr( os.environ['REMOTE_HOST'].decode('utf-8') )[0]
>
Don't fix the problem till you understand it. Figure out who is dealing
with a byte string here, and where that byte string came from. Adding a
decode, especially one that's going to do the same decode as your
original error message, is very premature.
You're quoting from my error output, and that's caused because I don't
have such an environment variable. But you do. So why aren't you in
there debugging it? And why on earth are you using the complex
expression instead of a refactored one which might be simple enough for
you to figure out what's wrong with it.
There is definitely something strange going on with that os.environ
reference (NOT call). So have you yet succeeded in running the factored
lines? If you can't get them to run, at least up to the point that you
get that unicode error, then you'll make progress only by guessing.
Get to that interactive debug session, and enter the lines till you get
an error. Then at least you know which line is causing the error.
xxx = os.environ['REMOTE_HOST']
yyy = socket.gethostbyaddr(xxx)
host = yyy[0]
I'll bet the real problem is you're using some greek characters in the
name of the environment variable, rather than "REMOTE_HOST" So
everything you show us is laboriously retyped, hiding the real problems
underneath.
--
DaveA
[toc] | [prev] | [next] | [standalone]
| From | Lele Gaifax <lele@metapensiero.it> |
|---|---|
| Date | 2013-07-05 16:11 +0200 |
| Message-ID | <mailman.4298.1373033487.3114.python-list@python.org> |
| In reply to | #49965 |
Dave Angel <davea@davea.name> writes: > You're quoting from my error output, and that's caused because I don't > have such an environment variable. But you do. Dave, maybe you already know, but that variable is "injected" by the CGI mechanism, is not coming from the OP shell environment. As Νίκος discovered, when he "cloudfare" (whatever that means) his site, the REMOTE_HOST envvar contains some (I guess) latin-greek encoded string, and the remote address is carried by a different envvar... ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.
[toc] | [prev] | [next] | [standalone]
| From | Νίκος Gr33k <nikos@superhost.gr> |
|---|---|
| Date | 2013-07-05 17:27 +0300 |
| Message-ID | <kr6l4l$7aa$1@news.grnet.gr> |
| In reply to | #49986 |
Στις 5/7/2013 5:11 μμ, ο/η Lele Gaifax έγραψε: > Dave Angel <davea@davea.name> writes: > >> You're quoting from my error output, and that's caused because I don't >> have such an environment variable. But you do. > > Dave, maybe you already know, but that variable is "injected" by the CGI > mechanism, is not coming from the OP shell environment. > > As Νίκος discovered, when he "cloudfare" (whatever that means) his site, > the REMOTE_HOST envvar contains some (I guess) latin-greek encoded > string, and the remote address is carried by a different envvar... Exactly only when i CloudFlare(www.cloudflare.com) the domain the hostname cannot be retrieved. At least i managed to solve this by: try: host = socket.gethostbyaddr( os.environ['HTTP_CF_CONNECTING_IP'] )[0] except Exception as e: host = repr(e) Seems like when you cloudflare a domain you can no longer have the originates ip address of the visitor but you have to read the above environmental variable to be bale to retrieve it! -- What is now proved was at first only imagined!
[toc] | [prev] | [next] | [standalone]
| From | feedthetroll@gmx.de |
|---|---|
| Date | 2013-07-05 01:44 -0700 |
| Message-ID | <06a3bc9c-3f0f-49fd-a489-b66cee64e976@googlegroups.com> |
| In reply to | #49944 |
Am Freitag, 5. Juli 2013 10:00:21 UTC+2 schrieb Νίκος Gr33k:
> ...
> I'am not sure how iam supposed to write this: i just tried this:
> try:
> remadd = os.environ('REMOVE_ADDR')
> tuple3 = socket.gethostbyaddr(remadd)
> host = tuple3[0]
> except:
> host = type(remadd) + " : " + repr(remadd)
Hey, if no one told you before:
You are allowed to read what other people suggest you to do, think about it and so correct obvious typos: 'REMO*V*E_ADDR'
By the way, my i cite:
Am Donnerstag, 4. Juli 2013 14:52:59 UTC+2 schrieb Νίκος Gr33k:
> ...
> '108.162.229.97' is the result of:
> print( ascii(os.environ['REMOTE_ADDR']) )
Am Donnerstag, 4. Juli 2013 16:48 UTC+2 schrieb Νίκος Gr33k:
> For me, socket.gethostbyaddr('108.162.229.97') raises socket.herror,
> which is also a subclass of OSError from Python 3.3 onwards.
[toc] | [prev] | [next] | [standalone]
| From | Lele Gaifax <lele@metapensiero.it> |
|---|---|
| Date | 2013-07-05 12:16 +0200 |
| Message-ID | <mailman.4289.1373019362.3114.python-list@python.org> |
| In reply to | #49928 |
Benjamin Kaplan <benjamin.kaplan@case.edu> writes: >> FYI, your code above is (almost) exactly equivalent to the simpler > > They aren't equivalent. "except Exception" won't catch KeyboardInterrupt or > SystemExit or a few others that you really don't want to catch in a generic > error handler. You should almost never have a bare except. I know, that's why I added "(almost)", I was just trying to explain why he wasn't able to see the problem. Thanks for pointing out the difference, ciao, lele. -- nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia. lele@metapensiero.it | -- Fortunato Depero, 1929.
[toc] | [prev] | [next] | [standalone]
| From | roggero.n@gmail.com |
|---|---|
| Date | 2013-09-06 16:17 -0700 |
| Message-ID | <481dce27-9615-440c-858f-2ad0529f192f@googlegroups.com> |
| In reply to | #49827 |
shut off the HD, start the SO form an USB and shut on again the HD
[toc] | [prev] | [standalone]
Page 4 of 4 — ← Prev page 1 2 3 [4]
Back to top | Article view | comp.lang.python
csiph-web