UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position

  • Thread starter Îίκος
  • Start date
Î

Îίκος

I just started to have this error without changing nothing

in my index.html(template) and metrites.py(which ipen the template)

[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Original
exception was:
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Traceback
(most recent call last):
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] File
"/home/nikos/public_html/cgi-bin/metrites.py", line 19, in <module>
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] host =
socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or 'UnResolved'
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97]
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Premature end
of script headers: metrites.py


Why cant it decode the starting byte? what starting byte is that?
 
U

Ulrich Eckhardt

Am 04.07.2013 10:37, schrieb Îίκος:
I just started to have this error without changing nothing

Well, undo the nothing that you didn't change. ;)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Premature end
of script headers: metrites.py

Why cant it decode the starting byte? what starting byte is that?

It's the 0xb6 but it's expecting the starting byte of a UTF-8 sequence.
Please do some research on UTF-8, that should clear it up. You could
also search for common causes of that error.

Uli
 
D

Dave Angel

I just started to have this error without changing nothing

in my index.html(template) and metrites.py(which ipen the template)

[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Original
exception was: [Thu Jul 04 11:35:14 2013] [error] [client
108.162.229.97] Traceback (most recent call last): [Thu Jul 04
11:35:14 2013] [error] [client 108.162.229.97] File
"/home/nikos/public_html/cgi-bin/metrites.py", line 19, in <module>
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] host =
socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or
'UnResolved' [Thu Jul 04 11:35:14 2013] [error] [client
108.162.229.97] UnicodeDecodeError: 'utf-8' codec can't decode byte
0xb6 in position 0: invalid start byte [Thu Jul 04 11:35:14 2013]
[error] [client 108.162.229.97] Premature end of script headers:
metrites.py


Why cant it decode the starting byte? what starting byte is that?

The error message means that somebody is trying to decode a byte string
into Unicode, and using the utf-8 codec for it. Only certain sequences
are legal in utf-8, and the first byte of a character may not be 0xb6.
So it gives an error. The question is where does this string come from.


Well, the message shows the source line from metrites.py:

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

So the most likely candidate is the string in the environment named
"REMOTE_ADDR" Can you display that string? it should look like

"11.24.32.4"

or some other valid IP address.


I'm assuming Python 2.7. You should specify the python version when
starting a new thread, as we (or at least I) cannot keep track of what
version everyone's running.
 
Î

Îίκος

Στις 4/7/2013 12:59 μμ, ο/η Dave Angel έγÏαψε:
I just started to have this error without changing nothing

in my index.html(template) and metrites.py(which ipen the template)

[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Original
exception was: [Thu Jul 04 11:35:14 2013] [error] [client
108.162.229.97] Traceback (most recent call last): [Thu Jul 04
11:35:14 2013] [error] [client 108.162.229.97] File
"/home/nikos/public_html/cgi-bin/metrites.py", line 19, in <module>
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] host =
socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or
'UnResolved' [Thu Jul 04 11:35:14 2013] [error] [client
108.162.229.97] UnicodeDecodeError: 'utf-8' codec can't decode byte
0xb6 in position 0: invalid start byte [Thu Jul 04 11:35:14 2013]
[error] [client 108.162.229.97] Premature end of script headers:
metrites.py


Why cant it decode the starting byte? what starting byte is that?

The error message means that somebody is trying to decode a byte string
into Unicode, and using the utf-8 codec for it. Only certain sequences
are legal in utf-8, and the first byte of a character may not be 0xb6.
So it gives an error. The question is where does this string come from.


Well, the message shows the source line from metrites.py:

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

So the most likely candidate is the string in the environment named
"REMOTE_ADDR" Can you display that string? it should look like

"11.24.32.4"

or some other valid IP address.


I'm assuming Python 2.7. You should specify the python version when
starting a new thread, as we (or at least I) cannot keep track of what
version everyone's running.

Ima using Python v3.3.2 Dave

The host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or
'UnResolved' should not have give an error since i explicityl tell it
that if it cannot resolve dns the ip to hostname to set it as "unresolved"

The error appear ONLY when i CloudFlare superhost.gr

If i pause tthe domain form CloudFlare then my website loads properly.
 
D

Dave Angel

Στις 4/7/2013 12:59 μμ, ο/η Dave Angel έγÏαψε:
I just started to have this error without changing nothing

in my index.html(template) and metrites.py(which ipen the template)

[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Original
exception was: [Thu Jul 04 11:35:14 2013] [error] [client
108.162.229.97] Traceback (most recent call last): [Thu Jul 04
11:35:14 2013] [error] [client 108.162.229.97] File
"/home/nikos/public_html/cgi-bin/metrites.py", line 19, in <module>
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] host =
socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or
'UnResolved' [Thu Jul 04 11:35:14 2013] [error] [client
108.162.229.97] UnicodeDecodeError: 'utf-8' codec can't decode byte
0xb6 in position 0: invalid start byte [Thu Jul 04 11:35:14 2013]
[error] [client 108.162.229.97] Premature end of script headers:
metrites.py


Why cant it decode the starting byte? what starting byte is that?

The error message means that somebody is trying to decode a byte string
into Unicode, and using the utf-8 codec for it. Only certain sequences
are legal in utf-8, and the first byte of a character may not be 0xb6.
So it gives an error. The question is where does this string come from.


Well, the message shows the source line from metrites.py:

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

So the most likely candidate is the string in the environment named
"REMOTE_ADDR" Can you display that string? it should look like

"11.24.32.4"

or some other valid IP address.


I'm assuming Python 2.7. You should specify the python version when
starting a new thread, as we (or at least I) cannot keep track of what
version everyone's running.

Ima using Python v3.3.2 Dave

The host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or
'UnResolved' should not have give an error since i explicityl tell it
that if it cannot resolve dns the ip to hostname to set it as "unresolved"

That's not true. The 'or' doesn't get executed until after the
gethostbyaddr() call has returned. So if something's wrong with that
call, and it throws an exception, the 'or "unresolved"' won't help.

I don't know that this is the problem, and I'm not all familiar with
these api's. But I cannot see anything else that could go wrong there
to give that particular exception. Unless the hostname it's going to
return is a byte string.
The error appear ONLY when i CloudFlare superhost.gr

If i pause tthe domain form CloudFlare then my website loads properly.

I don't really know what CloudFlare is, and have no idea what 'pausing
the form' will do. But since it has something to do with dns, perhaps
it's returning an invalid host name, one that isn't encoded in utf-8.
 
Î

Îίκος

-------- ΑÏχικό μήνυμα --------
Θέμα: Re: UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in
position 0: invalid start byte
ΗμεÏομηνία: Thu, 04 Jul 2013 06:29:25 -0400
Από: Dave Angel <[email protected]>
ΠÏος: (e-mail address removed)
Ομάδες συζήτησης: comp.lang.python
ΑναφοÏές: <[email protected]>
<[email protected]>
<[email protected]>

Στις 4/7/2013 12:59 μμ, ο/η Dave Angel έγÏαψε:
I just started to have this error without changing nothing

in my index.html(template) and metrites.py(which ipen the template)

[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Original
exception was: [Thu Jul 04 11:35:14 2013] [error] [client
108.162.229.97] Traceback (most recent call last): [Thu Jul 04
11:35:14 2013] [error] [client 108.162.229.97] File
"/home/nikos/public_html/cgi-bin/metrites.py", line 19, in <module>
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] host =
socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or
'UnResolved' [Thu Jul 04 11:35:14 2013] [error] [client
108.162.229.97] UnicodeDecodeError: 'utf-8' codec can't decode byte
0xb6 in position 0: invalid start byte [Thu Jul 04 11:35:14 2013]
[error] [client 108.162.229.97] Premature end of script headers:
metrites.py


Why cant it decode the starting byte? what starting byte is that?

The error message means that somebody is trying to decode a byte string
into Unicode, and using the utf-8 codec for it. Only certain sequences
are legal in utf-8, and the first byte of a character may not be 0xb6.
So it gives an error. The question is where does this string come from.


Well, the message shows the source line from metrites.py:

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

So the most likely candidate is the string in the environment named
"REMOTE_ADDR" Can you display that string? it should look like

"11.24.32.4"

or some other valid IP address.


I'm assuming Python 2.7. You should specify the python version when
starting a new thread, as we (or at least I) cannot keep track of what
version everyone's running.

Ima using Python v3.3.2 Dave

The host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] or
'UnResolved' should not have give an error since i explicityl tell it
that if it cannot resolve dns the ip to hostname to set it as "unresolved"

That's not true. The 'or' doesn't get executed until after the
gethostbyaddr() call has returned. So if something's wrong with that
call, and it throws an exception, the 'or "unresolved"' won't help.

So how do you propose to write the above statement?
I was under the i impression then if for any reason the gethostbyaddr
failed then or's argument will be returned instead.
The error appear ONLY when i CloudFlare superhost.gr

If i pause tthe domain form CloudFlare then my website loads properly.

I don't really know what CloudFlare is, and have no idea what 'pausing
the form' will do. But since it has something to do with dns, perhaps
it's returning an invalid host name, one that isn't encoded in utf-8.

I think so too.
 
Î

Îίκος

Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγÏαψε:
Am 04.07.2013 10:37, schrieb Îίκος:
I just started to have this error without changing nothing

Well, undo the nothing that you didn't change. ;)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Premature end
of script headers: metrites.py

Why cant it decode the starting byte? what starting byte is that?

It's the 0xb6 but it's expecting the starting byte of a UTF-8 sequence.
Please do some research on UTF-8, that should clear it up. You could
also search for common causes of that error.

So you are also suggesting that what gesthostbyaddr() returns is not
utf-8 encoded too?

What character is 0xb6 anyways?
 
M

MRAB

Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγÏαψε:
Am 04.07.2013 10:37, schrieb Îίκος:
I just started to have this error without changing nothing

Well, undo the nothing that you didn't change. ;)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Premature end
of script headers: metrites.py

Why cant it decode the starting byte? what starting byte is that?

It's the 0xb6 but it's expecting the starting byte of a UTF-8 sequence.
Please do some research on UTF-8, that should clear it up. You could
also search for common causes of that error.

So you are also suggesting that what gesthostbyaddr() returns is not
utf-8 encoded too?

What character is 0xb6 anyways?
Well, it's from a bytestring, so you'll have to specify what encoding
you're using! (It clearly isn't UTF-8.)

If it's ISO-8859-7 (what you've previously referred to as "greek-iso"),
then:
'GREEK CAPITAL LETTER ALPHA WITH TONOS'

You'll need to find out where that bytestring is coming from.
 
Î

Îίκος

Στις 4/7/2013 2:06 μμ, ο/η MRAB έγÏαψε:
Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγÏαψε:
Am 04.07.2013 10:37, schrieb Îίκος:
I just started to have this error without changing nothing

Well, undo the nothing that you didn't change. ;)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Premature
end
of script headers: metrites.py

Why cant it decode the starting byte? what starting byte is that?

It's the 0xb6 but it's expecting the starting byte of a UTF-8 sequence.
Please do some research on UTF-8, that should clear it up. You could
also search for common causes of that error.

So you are also suggesting that what gesthostbyaddr() returns is not
utf-8 encoded too?

What character is 0xb6 anyways?
Well, it's from a bytestring, so you'll have to specify what encoding
you're using! (It clearly isn't UTF-8.)

If it's ISO-8859-7 (what you've previously referred to as "greek-iso"),
then:
'GREEK CAPITAL LETTER ALPHA WITH TONOS'

You'll need to find out where that bytestring is coming from.

Right.
But nowhere in my script(metrites.py) i use an 'Ά' so i really have no
clue where this is coming from.

And you are right if it was a byte came from an utf-8 encoding scheme
then it would be automatically decoded.

The only thing i can say for use is that this problem a[[ear only when i
cloudflare my domain "superhost.gr"

If i un-cloudlflare it it cease to display errors.

Can you tell me hpw to write the following properly:

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

so even if the function fails "unresolved" to be returned back?
Somehow i need to capture the error.

Or it dosnt have to do it the or operand will be returned?
 
M

MRAB

Στις 4/7/2013 1:54 μμ, ο/η Chris Angelico έγÏαψε:

Well in case of utf-8 encoding for the first 127 codepoing we can safely
say that a character equals a byte :)
Equals? No. Bytes are not characters. (Strictly speaking, they're
codepoints, not characters.)

And anyway, it's the first _128_ codepoints.
 
Î

Îίκος

Στις 4/7/2013 2:52 μμ, ο/η MRAB έγÏαψε:
Equals? No. Bytes are not characters. (Strictly speaking, they're
codepoints, not characters.)

And anyway, it's the first _128_ codepoints.

Yes 0-127 = 128, i knew that!

Well the relationship between characters and bytes is that:

A [0-127] Unicode codepoints(characters) need 1-byte to be stored in
utf-8 encoding.

I think its also correct to say that the byte in the above situation is
the representation of our character.
 
M

MRAB

Στις 4/7/2013 2:06 μμ, ο/η MRAB έγÏαψε:
Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγÏαψε:
Am 04.07.2013 10:37, schrieb Îίκος:
I just started to have this error without changing nothing

Well, undo the nothing that you didn't change. ;)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in position 0:
invalid start byte
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Premature
end
of script headers: metrites.py

Why cant it decode the starting byte? what starting byte is that?

It's the 0xb6 but it's expecting the starting byte of a UTF-8 sequence.
Please do some research on UTF-8, that should clear it up. You could
also search for common causes of that error.

So you are also suggesting that what gesthostbyaddr() returns is not
utf-8 encoded too?

What character is 0xb6 anyways?
Well, it's from a bytestring, so you'll have to specify what encoding
you're using! (It clearly isn't UTF-8.)

If it's ISO-8859-7 (what you've previously referred to as "greek-iso"),
then:
import unicodedata
unicodedata.name(b"\xb6".decode("ISO-8859-7"))
'GREEK CAPITAL LETTER ALPHA WITH TONOS'

You'll need to find out where that bytestring is coming from.

Right.
But nowhere in my script(metrites.py) i use an 'Ά' so i really have no
clue where this is coming from.

And you are right if it was a byte came from an utf-8 encoding scheme
then it would be automatically decoded.

The only thing i can say for use is that this problem a[[ear only when i
cloudflare my domain "superhost.gr"

If i un-cloudlflare it it cease to display errors.

Can you tell me hpw to write the following properly:

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

so even if the function fails "unresolved" to be returned back?
Somehow i need to capture the error.

Or it dosnt have to do it the or operand will be returned?
If gethostbyaddr fails, it raises socket.gaierror, (which, from Python
3.3 onwards, is a subclass of OSError), so try catching that, setting
'host' to 'UnResolved' if it's raised.

Also, try printing out ascii(os.environ['REMOTE_ADDR']).
 
C

Chris Angelico

Equals? No. Bytes are not characters. (Strictly speaking, they're
codepoints, not characters.)

And anyway, it's the first _128_ codepoints.

As MRAB says, even if there's a 1:1 correspondence between bytes,
codepoints, and characters, they're still not the same thing. Plus,
0xb6 is not in the first 128, so your statement is false and your
question has no answer. Do you understand why I gave you that link? If
not, go read the page linked to.

ChrisA
 
Î

Îίκος

Στις 4/7/2013 3:07 μμ, ο/η MRAB έγÏαψε:
Στις 4/7/2013 2:06 μμ, ο/η MRAB έγÏαψε:
On 04/07/2013 11:38, Îίκος wrote:
Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγÏαψε:
Am 04.07.2013 10:37, schrieb Îίκος:
I just started to have this error without changing nothing

Well, undo the nothing that you didn't change. ;)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in
position 0:
invalid start byte
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Premature
end
of script headers: metrites.py

Why cant it decode the starting byte? what starting byte is that?

It's the 0xb6 but it's expecting the starting byte of a UTF-8
sequence.
Please do some research on UTF-8, that should clear it up. You could
also search for common causes of that error.

So you are also suggesting that what gesthostbyaddr() returns is not
utf-8 encoded too?

What character is 0xb6 anyways?

Well, it's from a bytestring, so you'll have to specify what encoding
you're using! (It clearly isn't UTF-8.)

If it's ISO-8859-7 (what you've previously referred to as "greek-iso"),
then:

import unicodedata
unicodedata.name(b"\xb6".decode("ISO-8859-7"))
'GREEK CAPITAL LETTER ALPHA WITH TONOS'

You'll need to find out where that bytestring is coming from.

Right.
But nowhere in my script(metrites.py) i use an 'Ά' so i really have no
clue where this is coming from.

And you are right if it was a byte came from an utf-8 encoding scheme
then it would be automatically decoded.

The only thing i can say for use is that this problem a[[ear only when i
cloudflare my domain "superhost.gr"

If i un-cloudlflare it it cease to display errors.

Can you tell me hpw to write the following properly:

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

so even if the function fails "unresolved" to be returned back?
Somehow i need to capture the error.

Or it dosnt have to do it the or operand will be returned?
If gethostbyaddr fails, it raises socket.gaierror, (which, from Python
3.3 onwards, is a subclass of OSError), so try catching that, setting
'host' to 'UnResolved' if it's raised.

Also, try printing out ascii(os.environ['REMOTE_ADDR']).

I have followed your suggestion by trying this:

try:
host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
except socket.gaierror:
host = "UnResolved"

and then re-cloudlflared "superhost.gr" domain

http://superhost.gr/ gives internal server error.
 
Î

Îίκος

Στις 4/7/2013 3:07 μμ, ο/η MRAB έγÏαψε:
Also, try printing out ascii(os.environ['REMOTE_ADDR']).

'108.162.229.97' is the result of:

print( ascii(os.environ['REMOTE_ADDR']) )

Seems perfectly valid. and also have a PTR record, so that leaved us
clueless about the internal server error.
 
U

Ulrich Eckhardt

Am 04.07.2013 12:38, schrieb Îίκος:
Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγÏαψε:

So you are also suggesting that what gesthostbyaddr() returns is not
utf-8 encoded too?

I never said that. And do some research yourself, you were given plenty
of hints.

Uli
 
Î

Îίκος ΓκÏ33κ

Στις 4/7/2013 4:07 μμ, ο/η Ulrich Eckhardt έγÏαψε:
Am 04.07.2013 12:38, schrieb Îίκος:

I never said that. And do some research yourself, you were given plenty
of hints.

Uli
Yes and as you can see form my responses i have tried any suggestion so
far and the problem still remains unresolved.

What you said implied that the string returned by the function cannot be
decoded as utf-8.
 
M

MRAB

Στις 4/7/2013 3:07 μμ, ο/η MRAB έγÏαψε:
Στις 4/7/2013 2:06 μμ, ο/η MRAB έγÏαψε:
On 04/07/2013 11:38, Îίκος wrote:
Στις 4/7/2013 12:50 μμ, ο/η Ulrich Eckhardt έγÏαψε:
Am 04.07.2013 10:37, schrieb Îίκος:
I just started to have this error without changing nothing

Well, undo the nothing that you didn't change. ;)

UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb6 in
position 0:
invalid start byte
[Thu Jul 04 11:35:14 2013] [error] [client 108.162.229.97] Premature
end
of script headers: metrites.py

Why cant it decode the starting byte? what starting byte is that?

It's the 0xb6 but it's expecting the starting byte of a UTF-8
sequence.
Please do some research on UTF-8, that should clear it up. You could
also search for common causes of that error.

So you are also suggesting that what gesthostbyaddr() returns is not
utf-8 encoded too?

What character is 0xb6 anyways?

Well, it's from a bytestring, so you'll have to specify what encoding
you're using! (It clearly isn't UTF-8.)

If it's ISO-8859-7 (what you've previously referred to as "greek-iso"),
then:

import unicodedata
unicodedata.name(b"\xb6".decode("ISO-8859-7"))
'GREEK CAPITAL LETTER ALPHA WITH TONOS'

You'll need to find out where that bytestring is coming from.

Right.
But nowhere in my script(metrites.py) i use an 'Ά' so i really have no
clue where this is coming from.

And you are right if it was a byte came from an utf-8 encoding scheme
then it would be automatically decoded.

The only thing i can say for use is that this problem a[[ear only when i
cloudflare my domain "superhost.gr"

If i un-cloudlflare it it cease to display errors.

Can you tell me hpw to write the following properly:

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

so even if the function fails "unresolved" to be returned back?
Somehow i need to capture the error.

Or it dosnt have to do it the or operand will be returned?
If gethostbyaddr fails, it raises socket.gaierror, (which, from Python
3.3 onwards, is a subclass of OSError), so try catching that, setting
'host' to 'UnResolved' if it's raised.

Also, try printing out ascii(os.environ['REMOTE_ADDR']).

I have followed your suggestion by trying this:

try:
host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0]
except socket.gaierror:
host = "UnResolved"

and then re-cloudlflared "superhost.gr" domain

http://superhost.gr/ gives internal server error.
Try catching OSError instead. (As I said, from Python 3.3,
socket.gaierror is a subclass of it.)
 

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

Forum statistics

Threads
474,056
Messages
2,570,443
Members
47,091
Latest member
IsaacLuna

Latest Threads

Top