Re: [Python-Dev] 'text' mode rears its ugly head again

2007-09-17 Thread Nick Coghlan
Bill Janssen wrote:
> I've checked in the asyncore SSL patch, and the Windows buildbots are
> failing on the HTTPS test.  I believe it's due to this insane
> differentiation between between text files and binary files, a bad
> idea introduced by Windows and perpetuated (apparently) by Python.  I
> can't believe this wasn't eliminated in py3k!

The binary/text distinction is being increased in Py3k rather than 
reduced (the API for binary files uses bytes, the API for text files 
uses Unicode strings).

Cheers,
Nick.

-- 
Nick Coghlan   |   [EMAIL PROTECTED]   |   Brisbane, Australia
---
 http://www.boredomandlaziness.org
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] IPv6 hostname resolution using socket.getaddrinfo()

2007-09-17 Thread O.R.Senthil Kumaran
To get the hostname, I can use socket.gethostbyname() but that has an
inherent limitation wherein does it not support IPv6 name resolution, and
getaddrinfo() should be used instead.

Looking up the socket.getaddrinfo() documentation, I come to know that

The getaddrinfo() function returns a list of 5-tuples with the following
structure:

(family, socktype, proto, canonname, sockaddr)

family, socktype, proto are all integer and are meant to be passed to
the socket() function. canonname is a string representing the canonical
name of the host. It can be a numeric IPv4/v6 address when AI_CANONNAME
is specified for a numeric host.

With this information, if I try something like this:

>>> for res in socket.getaddrinfo('goofy.goofy.com', None,
socket.AI_CANONNAME):

print res

(2, 1, 6, '', ('10.98.1.6', 0))
(2, 2, 17, '', ('10.98.1.6', 0))
(2, 3, 0, '', ('10.98.1.6', 0))

In the output, I see the cannoname to be always blank ''. I am not
getting the IPv4 or IPv6 address as a result of using getaddrinfo().

Am I making any mistake?

What i am trying is a replacement function for
socket.gethostbyname(hostname) which will work for both IPv4 and IPv6 (and make 
changes in urllib2 to support that)

# return hostbyname for either IPv4 or IPv6 address. Common function.

def ipv6_gethostbyname(hostname):
for res in socket.getaddrinfo(hostname,None,
socket.AI_CANONNAME):
fa, socktype, proto, canonname, sa = res
return cannoname

The above function does not seem to work. It returns blank value only.

Any help/ pointers? 

-- 
O.R.Senthil Kumaran
http://uthcode.sarovar.org
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] 'text' mode rears its ugly head again

2007-09-17 Thread Bill Janssen
> > differentiation between between text files and binary files, a bad
> > idea introduced by Windows and perpetuated (apparently) by Python.  I
> > can't believe this wasn't eliminated in py3k!
> 
> The binary/text distinction is being increased in Py3k rather than 
> reduced (the API for binary files uses bytes, the API for text files 
> uses Unicode strings).

Actually, it's not so much the differentiation that bothers me, as it
is the default of assuming "text".  I think the default should be
"binary", and getting the file in "text" mode should require extra
effort.  It should be 'rt', not 'rb' -- an extra qualifier for text
mode, not for binary mode.  That would eliminate a lot of the little
bugs like this one that crop up in ports to the ineffable assemblage
that is Windows.

Bill
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] IPv6 hostname resolution using socket.getaddrinfo()

2007-09-17 Thread skip

Senthil> To get the hostname, I can use socket.gethostbyname() but that
Senthil> has an inherent limitation wherein does it not support IPv6
Senthil> name resolution, and getaddrinfo() should be used instead.
...

For those who would ask Senthil to take this to comp.lang.python, he already
did and got no response.  He's working on fixes to urllib2, so this seems to
me to be a python-dev question and I suggested he post here.  I tried it
with 2.5, 2.6 and 3.0 and got blanks for the canonical name as well.
Hopefully someone with more network-fu can steer him in the right direction.

Skip
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Hash to longs, and Decimal

2007-09-17 Thread Guido van Rossum
Seems a fine idea. I don't have the time for a code review but I'll
leave that up to you all.

--Guido

On 9/17/07, Facundo Batista <[EMAIL PROTECTED]> wrote:
> Hi everybody!
>
> In the Tracker Issue...
>
>   http://bugs.python.org/issue1772851
>
> ... Mark Dickinson came with a patch that alters in a very corner case
> how the hash is calculated to a long integer.
>
> This allows changes in Decimal that lead to a better hashing behaviour
> for big, big, really big numbers.
>
> The patch applies cleanly, all the tests pass ok (Mark also provided
> more tests for the hash function).
>
> I won't commit this right now; I'll delay the change for a couple of
> days in case somebody wants to take a look at it.
>
> Thanks!
>
> --
> .Facundo
>
> Blog: http://www.taniquetil.com.ar/plog/
> PyAr: http://www.python.org/ar/
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe: 
> http://mail.python.org/mailman/options/python-dev/guido%40python.org
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] Hash to longs, and Decimal

2007-09-17 Thread Facundo Batista
Hi everybody!

In the Tracker Issue...

  http://bugs.python.org/issue1772851

... Mark Dickinson came with a patch that alters in a very corner case
how the hash is calculated to a long integer.

This allows changes in Decimal that lead to a better hashing behaviour
for big, big, really big numbers.

The patch applies cleanly, all the tests pass ok (Mark also provided
more tests for the hash function).

I won't commit this right now; I'll delay the change for a couple of
days in case somebody wants to take a look at it.

Thanks!

-- 
.Facundo

Blog: http://www.taniquetil.com.ar/plog/
PyAr: http://www.python.org/ar/
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Hash to longs, and Decimal

2007-09-17 Thread Mark Dickinson
On 9/17/07, Facundo Batista <[EMAIL PROTECTED]> wrote:
>
> In the Tracker Issue...
>
>   http://bugs.python.org/issue1772851
>
> ... Mark Dickinson came with a patch that alters in a very corner case
> how the hash is calculated to a long integer.
>

Much as I'd like this patch to be applied, I feel compelled to point out
that it does have a significant(?) downside:  it slows down hashing of large
integers to some degree.

On my machine (Dual Xeon 2.8Ghz/SuSE Linux 10.2/gcc 4.1 with -O3), using
timeit.timeit('hash(n)') to get timings, the new hash function takes 70%
more time for 1000 digit integers, 20% longer for 100 digit integers, but
has no measurable performance impact for small (int-sized) longs.  I don't
know how significant this performance hit is in the larger scheme of things.

Mark
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] IPv6 hostname resolution using socket.getaddrinfo()

2007-09-17 Thread Martin v. Löwis
> Any help/ pointers? 

Did you read the man page of getaddrinfo, or the RFC?

Regards,
Martin
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Daily Windows Installers

2007-09-17 Thread David Bolen
On 9/17/07, Trent Mick <[EMAIL PROTECTED]> wrote:

> How do you tell Windows to do that?

Via the SetErrorMode call.

Since the Windows buildbot already uses the win32 extensions, I just
used the existing win32api wrapper (although through ctypes is very
easy too).  In my case I just surrounded the reactor.spawnProcess call
in buildbot/slave/commands.py with:

old_err_mode = win32api.SetErrorMode(7)
and
win32api.SetErrorMode(old_err_mode)

I suppose I should really tweak that to 0x8007 rather than just 7 to
include missing file dialogs (like when a removeable device is not
available).

Since the error mode is inherited by child processes (unless
explicitly overridden in the CreateProcess call), this effectively
covers the primary child process and any others it may spawn during
execution, so it works even though buildbot uses an intermediate
command interpreter to execute whatever command is requested.

We had a bit of discussion about this recently on the py3k devel list,
in regards to failures in the python buildbot tests, in regards to
more local changes within Python itself.

-- David
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] Daily Windows Installers

2007-09-17 Thread Trent Mick
David Bolen wrote:
> I hit it with a sledge-hammer and modified my build slave to disable
> error boxes for anything it runs, so we'll get the 3.0 MSI now but
> with a bad chm until it gets figured out.

How do you tell Windows to do that?

Trent

-- 
Trent Mick
trentm at activestate.com
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] IPv6 hostname resolution using socket.getaddrinfo()

2007-09-17 Thread Blinston_Fernandes
On python2.4.1

>>> socket.getaddrinfo('www.python.org', None, socket.AF_INET,
socket.SOCK_DGRAM, socket.IPPROTO_IP, socket.AI_CANONNAME)
[(2, 2, 17, 'dinsdale.python.org', ('82.94.237.218', 0))]
>>>

Blinston.

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On
Behalf Of O.R.Senthil Kumaran
Sent: Monday, September 17, 2007 10:08 PM
To: [email protected]
Subject: [Python-Dev] IPv6 hostname resolution using
socket.getaddrinfo()

To get the hostname, I can use socket.gethostbyname() but that has an
inherent limitation wherein does it not support IPv6 name resolution,
and
getaddrinfo() should be used instead.

Looking up the socket.getaddrinfo() documentation, I come to know that

The getaddrinfo() function returns a list of 5-tuples with the following
structure:

(family, socktype, proto, canonname, sockaddr)

family, socktype, proto are all integer and are meant to be passed to
the socket() function. canonname is a string representing the canonical
name of the host. It can be a numeric IPv4/v6 address when AI_CANONNAME
is specified for a numeric host.

With this information, if I try something like this:

>>> for res in socket.getaddrinfo('goofy.goofy.com', None,
socket.AI_CANONNAME):

print res

(2, 1, 6, '', ('10.98.1.6', 0))
(2, 2, 17, '', ('10.98.1.6', 0))
(2, 3, 0, '', ('10.98.1.6', 0))

In the output, I see the cannoname to be always blank ''. I am not
getting the IPv4 or IPv6 address as a result of using getaddrinfo().

Am I making any mistake?

What i am trying is a replacement function for
socket.gethostbyname(hostname) which will work for both IPv4 and IPv6
(and make changes in urllib2 to support that)

# return hostbyname for either IPv4 or IPv6 address. Common function.

def ipv6_gethostbyname(hostname):
for res in socket.getaddrinfo(hostname,None,
socket.AI_CANONNAME):
fa, socktype, proto, canonname, sa = res
return cannoname

The above function does not seem to work. It returns blank value only.

Any help/ pointers? 

--
O.R.Senthil Kumaran
http://uthcode.sarovar.org
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/blinston_fernandes%40d
ell.com
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com