Re: How to generate java .properties files in python

2011-12-04 Thread Arnaud Delobelle
On 3 December 2011 23:51, Peter Otten __pete...@web.de wrote:
 Arnaud Delobelle wrote:

 I need to generate some java .properties files in Python (2.6 / 2.7).
 It's a simple format to store key/value pairs e.g.

 blue=bleu
 green=vert
 red=rouge

 The key/value are unicode strings.  The annoying thing is that the
 file is encoded in ISO 8859-1, with all non Latin1 characters escaped
 in the form \u (same as how unicode characters are escaped in
 Python).

 I thought I could use the unicode_escape codec.  But it doesn't work
 because it escapes Latin1 characters with escape sequences of the form
 \xHH, which is not valid in a java .properties file.

 Is there a simple way to achieve this? I could do something like this:

 def encode(u):
     encode a unicode string in .properties format
     return u.join(u\\u%04x % ord(c) if ord(c)  0xFF else c for c
 in u).encode(latin_1)

 but it would be quite inefficient as I have many to generate.

 class D(dict):
 ...     def __missing__(self, key):
 ...             result = self[key] = u\\u%04x % key
 ...             return result
 ...
 d = D(enumerate(map(unichr, range(256
 uähnlich üblich nötig ΦΧΨ
 u'\xe4hnlich \xfcblich n\xf6tig \u03a6\u03a7\u03a8'
 uähnlich üblich nötig ΦΧΨ.translate(d)
 u'\xe4hnlich \xfcblich n\xf6tig \\u03a6\\u03a7\\u03a8'
 uähnlich üblich nötig ΦΧΨ.translate(d).encode(latin1)
 '\xe4hnlich \xfcblich n\xf6tig \\u03a6\\u03a7\\u03a8'

A very nice solution - thanks, Peter.

-- 
Arnaud
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to generate java .properties files in python

2011-12-04 Thread Peter Otten
Arnaud Delobelle wrote:

 On 3 December 2011 23:51, Peter Otten __pete...@web.de wrote:
 Arnaud Delobelle wrote:

 I need to generate some java .properties files in Python (2.6 / 2.7).
 It's a simple format to store key/value pairs e.g.

 blue=bleu
 green=vert
 red=rouge

 The key/value are unicode strings.  The annoying thing is that the
 file is encoded in ISO 8859-1, with all non Latin1 characters escaped
 in the form \u (same as how unicode characters are escaped in
 Python).

 I thought I could use the unicode_escape codec.  But it doesn't work
 because it escapes Latin1 characters with escape sequences of the form
 \xHH, which is not valid in a java .properties file.

 Is there a simple way to achieve this? I could do something like this:

 def encode(u):
 encode a unicode string in .properties format
 return u.join(u\\u%04x % ord(c) if ord(c)  0xFF else c for c
 in u).encode(latin_1)

 but it would be quite inefficient as I have many to generate.

 class D(dict):
 ... def __missing__(self, key):
 ... result = self[key] = u\\u%04x % key
 ... return result
 ...
 d = D(enumerate(map(unichr, range(256
 uähnlich üblich nötig ΦΧΨ
 u'\xe4hnlich \xfcblich n\xf6tig \u03a6\u03a7\u03a8'
 uähnlich üblich nötig ΦΧΨ.translate(d)
 u'\xe4hnlich \xfcblich n\xf6tig \\u03a6\\u03a7\\u03a8'
 uähnlich üblich nötig ΦΧΨ.translate(d).encode(latin1)
 '\xe4hnlich \xfcblich n\xf6tig \\u03a6\\u03a7\\u03a8'
 
 A very nice solution - thanks, Peter.

I found another one:

 uäöü ΦΧΨ.encode(latin1, backslashreplace)
'\xe4\xf6\xfc \\u03a6\\u03a7\\u03a8'


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Lie Ryan

On 12/02/2011 03:29 PM, 8 Dihedral wrote:


I clear my point a hash is a collection of (key, value) pairs that have
well defined methods and behavior to be used in programming.

The basic operations of a hash normally includes the following:

1. insertion of a (key, value) pair  into the hash
2. deletion of a (key, value) from the hash
3. inquiring  a hash by a key to retrieve the value if the (key, value)
pair available in the hash. If no key matched, the hash will return
a not found result.

The hash can grow with (k,v) pairs accumulated in the run time.
An auto memory management mechanism is required for a hash of a non-fixed size 
of (k,v) pairs.

Some implementations of a hash might pose some restrictions of k and v
for some reasons. But in object programming k and v can be objects
to be manipulated by the programmer.


Strictly speaking, what you're describing is just a dictionary/mapping 
abstract data type (ADT), not a hashtable. Hashtable is a particular way 
to implement the dictionary/mapping ADT. Python's dictionary is 
implemented as hashtable, but there are other ways to implement a 
dictionary/mapping, such as using a sorted tree.


For a data structure to be considered a Hashtable, in addition to having 
the properties of a dictionary that you described, the data structure 
must also uses a hashing function to encode the dictionary's keys into 
integer that will be used to calculate the index for the corresponding 
value in its internal array. A hashtable also must provide mechanism to 
deal with hash collisions to maintains its invariants as a dictionary.


--
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Lie Ryan

On 12/02/2011 04:48 PM, 8 Dihedral wrote:

On Friday, December 2, 2011 1:00:10 PM UTC+8, Chris Angelico wrote:

On Fri, Dec 2, 2011 at 3:29 PM, 8 Dihedral
dihedr...@googlemail.com  wrote:

I clear my point a hash is a collection of (key, value) pairs that have
well defined methods and behavior to be used in programming.

The basic operations of a hash normally includes the following:

1. insertion of a (key, value) pair  into the hash
2. deletion of a (key, value) from the hash
3. inquiring  a hash by a key to retrieve the value if the (key, value)
pair available in the hash. If no key matched, the hash will return
a not found result.

The hash can grow with (k,v) pairs accumulated in the run time.
An auto memory management mechanism is required for a hash of a non-fixed size 
of (k,v) pairs.


That's a hash table - think of a Python dictionary:

On Fri, Dec 2, 2011 at 3:33 PM, Steven D'Aprano
steve+comp@pearwood.info  wrote:

Python dicts are hash tables.


Although strictly speaking, isn't that Python dicts are implemented
as hash tables in CPython? Or is the hashtable implementation
mandated? Anyway, near enough.





Cryptography and data verification use hashing too (look at the
various historic hashing algorithms - CRC, MD5, SHA, etc). The concept
of a hash is a number (usually of a fixed size) that is calculated
from a string or other large data type, such that hashing the same
input will always give the same output, but hashing different input
will usually give different output. It's then possible to identify a
large object solely by its hash, as is done in git, for instance; or
to transmit both the data and the hash, as is done in message
protection schemes (many archiving programs/formats include a hash of
the uncompressed data). These have nothing to do with (key,value)
pairs, but are important uses of hashes.

ChrisA


If one tries to insert a (k,v1) and then a (k,v2) pair into a
hash with v1 not equals V2, what could happen in your understanding of
a hash?


Don't try to argue, in English, `hash != hash` is true; it's just a 
typical occurence of homonyms. Just because they have the same name 
doesn't mean hash (function) has to have somewhat similar properties to 
hash (table).



A hash function is different from a hash or so called a hash table in
my post.


Indeed.


If the hash collision rate is not specified, then  it is  trivial to write a 
hash function with the conditions you specified. A hash function applied to a 
set of data items only  is of very limited use at all.


It's trivial indeed, but a hashtable couldn't exist without hash 
function. And without a good hash function, a hash table's performance 
may degrade into O(n) access/insertion/deletion.



A hash stores (k,v) pairs specified in the run time with auto memory
management build in is not a simple hash function to produce data signatures 
only clearly in my post.

What I said a hash which is lifted as a basic type in python  is called a 
dictionary in python.

It is called a map in c++'s generics library.


Putting aside all these, it's pretty obvious from the beginning that OP 
was referring to hash functions, not hash tables.


--
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Roel Schroeven
Op 2011-12-02 6:48, 8 Dihedral schreef:
 A hash stores (k,v) pairs specified in the run time with auto memory 
 management build in is not a simple hash function to produce data
 signatures only clearly in my post.
 
 What I said a hash which is lifted as a basic type in python  is
 called a dictionary in python.
 
 It is called a map in c++'s generics library.

Not exactly: a C++ std::map uses a tree structure (which is why it keeps
the keys sorted). C++ STL also has std::hash_map which, as the name
implies, does use a hash table implementation.

-- 
The saddest aspect of life right now is that science gathers knowledge
faster than society gathers wisdom.
  -- Isaac Asimov

Roel Schroeven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Hrvoje Niksic
Terry Reedy tjre...@udel.edu writes:

 [Hashing is] pretty much mandated because of the __hash__ protocol.

 Lib Ref 4.8. Mapping Types — dict
 A mapping object maps hashable values to arbitrary objects.

 This does not say that the mapping has to *use* the hash value ;-).
 Even if it does, it could use a tree structure instead of a hash
 table.

An arbitrary mapping doesn't, but reference to the hash protocol was in
the context of implementation constraints for dicts themselves (my
response quotes the relevant part of Chris's message).  If a Python
implementation tried to implement dict as a tree, instances of classes
that define only __eq__ and __hash__ would not be correctly inserted in
such a dict.  This would be a major source of incompatibility with
Python code, both in the standard library and at large.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Chris Angelico
2011/12/5 Hrvoje Niksic hnik...@xemacs.org:
 If a Python
 implementation tried to implement dict as a tree, instances of classes
 that define only __eq__ and __hash__ would not be correctly inserted in
 such a dict.

Couldn't you just make a tree of hash values? Okay, that's probably
not the most useful way to do things, but technically it'd comply with
the spec.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


struct calcsize discrepency?

2011-12-04 Thread Glen Rice
In IPython:
import struct
struct.calcsize('4s')
4
struct.calcsize('Q')
8
struct.calcsize('4sQ')
16

This doesn't make sense to me.  Can anyone explain?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: How to generate java .properties files in python

2011-12-04 Thread Arnaud Delobelle
On 4 December 2011 10:22, Peter Otten __pete...@web.de wrote:

 I found another one:

 uäöü ΦΧΨ.encode(latin1, backslashreplace)
 '\xe4\xf6\xfc \\u03a6\\u03a7\\u03a8'

That's it!  I was hoping for a built-in solution and this is it. FTR,
the 'backslashreplace' argument tells the encoder to replace any
character that it can't encode with a backslash escape sequence.
Which is exactly what I needed, only I hadn't realised it.  Thanks!

-- 
Arnaud
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: struct calcsize discrepency?

2011-12-04 Thread Chris Angelico
On Mon, Dec 5, 2011 at 1:25 AM, Glen Rice glen.rice.n...@gmail.com wrote:
 In IPython:
import struct
struct.calcsize('4s')
 4
struct.calcsize('Q')
 8
struct.calcsize('4sQ')
 16

 This doesn't make sense to me.  Can anyone explain?

Same thing happens in CPython, and it looks to be the result of alignment.

 struct.calcsize(4sQ)
16
 struct.calcsize(Q4s)
12

The eight-byte integer is aligned on an eight-byte boundary, so when
it follows a four-byte string, you get four padding bytes inserted.
Put them in the other order, and the padding disappears.

(Caveat: I don't use the struct module much, this is based on conjecture.)

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: struct calcsize discrepency?

2011-12-04 Thread Duncan Booth
Glen Rice glen.rice.n...@gmail.com wrote:

 In IPython:
import struct
struct.calcsize('4s')
 4
struct.calcsize('Q')
 8
struct.calcsize('4sQ')
 16
 
 This doesn't make sense to me.  Can anyone explain?
 
When you mix different types in a struct there can be padding inserted 
between the items. In this case the 8 byte unsigned long long must always 
start on an 8 byte boundary so 4 padding bytes are inserted.

See http://docs.python.org/library/struct.html?highlight=struct#byte-order-
size-and-alignment in particular the first sentence:

By default, C types are represented in the machine’s native format and 
byte order, and properly aligned by skipping pad bytes if necessary 
(according to the rules used by the C compiler).

-- 
Duncan Booth http://kupuguy.blogspot.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: struct calcsize discrepency?

2011-12-04 Thread Dave Angel

On 12/04/2011 09:35 AM, Chris Angelico wrote:

On Mon, Dec 5, 2011 at 1:25 AM, Glen Riceglen.rice.n...@gmail.com  wrote:

In IPython:

import struct
struct.calcsize('4s')

4

struct.calcsize('Q')

8

struct.calcsize('4sQ')

16

This doesn't make sense to me.  Can anyone explain?

Same thing happens in CPython, and it looks to be the result of alignment.


struct.calcsize(4sQ)

16

struct.calcsize(Q4s)

12

The eight-byte integer is aligned on an eight-byte boundary, so when
it follows a four-byte string, you get four padding bytes inserted.
Put them in the other order, and the padding disappears.

NOT disappears.  In C, the padding to the largest alignment occurs at 
the end of a structure as well as between items.  Otherwise, an array of 
the struct would not be safely aligned.  if you have an 8byte item 
followed by a 4 byte item, the total size is 16.

(Caveat: I don't use the struct module much, this is based on conjecture.)

ChrisA



--

DaveA

--
http://mail.python.org/mailman/listinfo/python-list


Re: struct calcsize discrepency?

2011-12-04 Thread Peter Otten
Glen Rice wrote:

 In IPython:
import struct
struct.calcsize('4s')
 4
struct.calcsize('Q')
 8
struct.calcsize('4sQ')
 16
 
 This doesn't make sense to me.  Can anyone explain?

A C compiler can insert padding bytes into a struct:

By default, the result of packing a given C struct includes pad bytes in 
order to maintain proper alignment for the C types involved; similarly, 
alignment is taken into account when unpacking. This behavior is chosen so 
that the bytes of a packed struct correspond exactly to the layout in memory 
of the corresponding C struct. To handle platform-independent data formats 
or omit implicit pad bytes, use standard size and alignment instead of 
native size and alignment: see Byte Order, Size, and Alignment for details.

 
http://docs.python.org/library/struct.html#struct-alignment

You can avoid this by specifying a non-native byte order (little endian, big 
endian, or network):

 struct.calcsize(4sQ)
16
 struct.calcsize(!4sQ)
12


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: struct calcsize discrepency?

2011-12-04 Thread Glen Rice
On Dec 4, 9:38 am, Duncan Booth duncan.bo...@invalid.invalid wrote:
 Glen Rice glen.rice.n...@gmail.com wrote:
  In IPython:
 import struct
 struct.calcsize('4s')
  4
 struct.calcsize('Q')
  8
 struct.calcsize('4sQ')
  16

  This doesn't make sense to me.  Can anyone explain?

 When you mix different types in a struct there can be padding inserted
 between the items. In this case the 8 byte unsigned long long must always
 start on an 8 byte boundary so 4 padding bytes are inserted.

 Seehttp://docs.python.org/library/struct.html?highlight=struct#byte-order-
 size-and-alignment in particular the first sentence:

 By default, C types are represented in the machine s native format and
 byte order, and properly aligned by skipping pad bytes if necessary
 (according to the rules used by the C compiler).

 --
 Duncan Boothhttp://kupuguy.blogspot.com

Chris / Duncan, Thanks. I missed that in the docs.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: struct calcsize discrepency?

2011-12-04 Thread Chris Angelico
On Mon, Dec 5, 2011 at 1:51 AM, Dave Angel d...@davea.name wrote:
 On 12/04/2011 09:35 AM, Chris Angelico wrote:

 struct.calcsize(4sQ)

 16

 struct.calcsize(Q4s)

 12

 The eight-byte integer is aligned on an eight-byte boundary, so when
 it follows a four-byte string, you get four padding bytes inserted.
 Put them in the other order, and the padding disappears.

 NOT disappears.  In C, the padding to the largest alignment occurs at the
 end of a structure as well as between items.  Otherwise, an array of the
 struct would not be safely aligned.  if you have an 8byte item followed by a
 4 byte item, the total size is 16.

That's padding of the array, not of the structure. But you're right in
that removing padding from inside the structure will in this case
result in padding outside the structure. However, in more realistic
scenarios, it's often possible to truly eliminate padding by ordering
members appropriately.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread 88888 Dihedral
On Sunday, December 4, 2011 9:41:19 PM UTC+8, Roel Schroeven wrote:
 Op 2011-12-02 6:48, 8 Dihedral schreef:
  A hash stores (k,v) pairs specified in the run time with auto memory 
  management build in is not a simple hash function to produce data
  signatures only clearly in my post.
  
  What I said a hash which is lifted as a basic type in python  is
  called a dictionary in python.
  
  It is called a map in c++'s generics library.
 
 Not exactly: a C++ std::map uses a tree structure (which is why it keeps
 the keys sorted). C++ STL also has std::hash_map which, as the name
 implies, does use a hash table implementation.
 
Thanks for your comments. Are we gonna talk about the way to implement a hash 
table or the use of a hash table in programming? 
-- 
http://mail.python.org/mailman/listinfo/python-list


SQLObject 1.2.1

2011-12-04 Thread Oleg Broytman
Hello!

I'm pleased to announce version 1.2.1, the first stable release of branch
1.2 of SQLObject.


What is SQLObject
=

SQLObject is an object-relational mapper.  Your database tables are described
as classes, and rows are instances of those classes.  SQLObject is meant to be
easy to use and quick to get started with.

SQLObject supports a number of backends: MySQL, PostgreSQL, SQLite,
Firebird, Sybase, MSSQL and MaxDB (also known as SAPDB).


Where is SQLObject
==

Site:
http://sqlobject.org

Development:
http://sqlobject.org/devel/

Mailing list:
https://lists.sourceforge.net/mailman/listinfo/sqlobject-discuss

Archives:
http://news.gmane.org/gmane.comp.python.sqlobject

Download:
http://pypi.python.org/pypi/SQLObject/1.2.1

News and changes:
http://sqlobject.org/News.html


What's New
==

* A bug was fixed in handling ``modulo`` operator - SQLite implements
  only ``%``, MySQL - only ``MOD()``, PostgreSQL implements both.

For a more complete list, please see the news:
http://sqlobject.org/News.html

Oleg.
-- 
 Oleg Broytmanhttp://phdru.name/p...@phdru.name
   Programmers don't die, they just GOSUB without RETURN.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Ian Kelly
On Sun, Dec 4, 2011 at 8:39 AM, 8 Dihedral
dihedral88...@googlemail.com wrote:
 Thanks for your comments. Are we gonna talk about the way to implement a hash
 table or the use of a hash table in programming?

Implementing a hash table is not very relevant on a list about Python,
which already has them built into the language; and any pure Python
implementation would be uselessly slow.

If you want to talk about ways to use dicts, please start a different
thread for it.  As has been pointed out several times now, it is
off-topic for this thread, which is about hash *functions*.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread 88888 Dihedral
A hash that can hash objects is not a trivial hash function  

On Monday, December 5, 2011 1:41:14 AM UTC+8, Ian wrote:
 On Sun, Dec 4, 2011 at 8:39 AM, 8 Dihedral
 dihedr...@googlemail.com wrote:
  Thanks for your comments. Are we gonna talk about the way to implement a 
  hash
  table or the use of a hash table in programming?
 
 Implementing a hash table is not very relevant on a list about Python,
 which already has them built into the language; and any pure Python
 implementation would be uselessly slow.
 
 If you want to talk about ways to use dicts, please start a different
 thread for it.  As has been pointed out several times now, it is
 off-topic for this thread, which is about hash *functions*.

A hash that can hash objects is not a hash function at all.
Are you miss-leading the power of true OOP ?
-- 
http://mail.python.org/mailman/listinfo/python-list


LinuxJournal Readers' Choice Awards 2011 Best {Programming, Scripting} Language

2011-12-04 Thread wesley chun
in recent news...

Python wins LinuxJournal's Readers' Choice Awards 2011 as Best
Programming Language:
http://www.linuxjournal.com/slideshow/readers-choice-2011?page=27

yee-haw!! it's even more amazing that Python has won this title 3
straight years. let's celebrate and get back to building great things.

wait, in other news...

Python wins LinuxJournal's Readers' Choice Awards 2011 as Best
Scripting Language:
http://www.linuxjournal.com/slideshow/readers-choice-2011?page=28

interestingly enough, this happened last year as well:
http://www.linuxjournal.com/content/readers-choice-awards-2010

in fact, Python has nearly won this one 6 straight years, from
2006-2011, except bash won in 2009. is it the same people who are
voting (practically) every year? :-)

cheers,
--wesley
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Core Python, Prentice Hall, (c)2007,2001
Python Fundamentals, Prentice Hall, (c)2009
    http://corepython.com

wesley.chun : wescpy-gmail.com : @wescpy
python training and technical consulting
cyberweb.consulting : silicon valley, ca
http://cyberwebconsulting.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Tim Chase

On 12/04/11 08:08, Chris Angelico wrote:

2011/12/5 Hrvoje Niksichnik...@xemacs.org:

If a Python
implementation tried to implement dict as a tree, instances of classes
that define only __eq__ and __hash__ would not be correctly inserted in
such a dict.


Couldn't you just make a tree of hash values? Okay, that's probably
not the most useful way to do things, but technically it'd comply with
the spec.


From an interface perspective, I suppose it would work.  However 
one of the main computer-science reasons for addressing by a hash 
is to get O(1) access to items (modulo pessimal hash 
structures/algorithms which can approach O(N) if everything 
hashes to the same value/bucket), rather than the O(logN) time 
you'd get from a tree. So folks reaching for a hash/map might be 
surprised if performance degraded with the size of the contents.


-tkc



--
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Ian Kelly
On Sun, Dec 4, 2011 at 11:06 AM, 8 Dihedral
dihedral88...@googlemail.com wrote:
 If you want to talk about ways to use dicts, please start a different
 thread for it.  As has been pointed out several times now, it is
 off-topic for this thread, which is about hash *functions*.

 A hash that can hash objects is not a hash function at all.

Please explain what you think a hash function is, then.  Per
Wikipedia, A hash function is any algorithm or subroutine that maps
large data sets to smaller data sets, called keys.

 Are you miss-leading the power of true OOP ?

I have no idea what you are suggesting.  I was not talking about OOP at all.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python 2 or 3

2011-12-04 Thread Zaphod
On Sat, 03 Dec 2011 05:54:19 +0200, Antti J Ylikoski wrote:

 I'm in the process of learning Python.  I already can code
 objet-oriented programs with the language.  I have in my hands the
 O'Reilly book by Mark Lutz, Programming Python, in two versions: the 2nd
 Edition, which covers Python 2, and the 4th edition, which covers Python
 3.

It doesn't matter that much which one you learn.  The differences aren't 
that big between the two.  You could easily use the 2nd edition but use 
python 3 and the biggest difference you will find is between print 
stuff vs print(stuff).  In fact, doing it this way will make you a 
better programmer.


 Cheers, Antti Andy Ylikoski
 Helsinki, Finland, the EU

ps: I quite like your Finnish Dudesons program.  They remind me of some 
of the rednecks I grew up with here on Vancouver Island (British 
Columbia, Canada)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread 88888 Dihedral
On Monday, December 5, 2011 4:13:01 AM UTC+8, Ian wrote:
 On Sun, Dec 4, 2011 at 11:06 AM, 8 Dihedral
 dihedr...@googlemail.com wrote:
  If you want to talk about ways to use dicts, please start a different
  thread for it.  As has been pointed out several times now, it is
  off-topic for this thread, which is about hash *functions*.
 
  A hash that can hash objects is not a hash function at all.
 
 Please explain what you think a hash function is, then.  Per
 Wikipedia, A hash function is any algorithm or subroutine that maps
 large data sets to smaller data sets, called keys.
 
  Are you miss-leading the power of true OOP ?
 
 I have no idea what you are suggesting.  I was not talking about OOP at all.

In python the (k,v) pair in a dictionary k and v can be  both an objects. 
v can be a tuple or a list.  There are some restrictions on k to be an
 hashable type in python's implementation. The key is used to compute the 
position of the pair to be stored in a  hash table. The hash function maps key 
k to the position in the hash table. If k1!=k2 are both  mapped to the same
position, then something has to be done to resolve this. 


  
 


-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Matt Joiner
Duh. What's the point you're trying to make?

On Mon, Dec 5, 2011 at 10:17 AM, 8 Dihedral
dihedral88...@googlemail.com wrote:
 On Monday, December 5, 2011 4:13:01 AM UTC+8, Ian wrote:
 On Sun, Dec 4, 2011 at 11:06 AM, 8 Dihedral
 dihedr...@googlemail.com wrote:
  If you want to talk about ways to use dicts, please start a different
  thread for it.  As has been pointed out several times now, it is
  off-topic for this thread, which is about hash *functions*.
 
  A hash that can hash objects is not a hash function at all.

 Please explain what you think a hash function is, then.  Per
 Wikipedia, A hash function is any algorithm or subroutine that maps
 large data sets to smaller data sets, called keys.

  Are you miss-leading the power of true OOP ?

 I have no idea what you are suggesting.  I was not talking about OOP at all.

 In python the (k,v) pair in a dictionary k and v can be  both an objects.
 v can be a tuple or a list.  There are some restrictions on k to be an
  hashable type in python's implementation. The key is used to compute the 
 position of the pair to be stored in a  hash table. The hash function maps 
 key k to the position in the hash table. If k1!=k2 are both  mapped to the 
 same
 position, then something has to be done to resolve this.






 --
 http://mail.python.org/mailman/listinfo/python-list



-- 
ಠ_ಠ
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Ian Kelly
On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral
dihedral88...@googlemail.com wrote:
 Please explain what you think a hash function is, then.  Per
 Wikipedia, A hash function is any algorithm or subroutine that maps
 large data sets to smaller data sets, called keys.

  Are you miss-leading the power of true OOP ?

 I have no idea what you are suggesting.  I was not talking about OOP at all.

 In python the (k,v) pair in a dictionary k and v can be  both an objects.
 v can be a tuple or a list.  There are some restrictions on k to be an
  hashable type in python's implementation. The key is used to compute the 
 position of the pair to be stored in a  hash table. The hash function maps 
 key k to the position in the hash table. If k1!=k2 are both  mapped to the 
 same
 position, then something has to be done to resolve this.

I understand how dicts / hash tables work.  I don't need you to
explain that to me.  What you haven't explained is why you stated that
a hash function that operates on objects is not a hash function, or
what you meant by misleading the power of true OOP.
-- 
http://mail.python.org/mailman/listinfo/python-list


SSL connection issue with Windows CPython

2011-12-04 Thread Blairo
Hi all,

I've written a Python API for the Windows Azure Service Management web-
service. Requests against the web-service are HTTPS with a client
certificate used for authentication. This works fine with CPython
(tested with 2.6 and 2.7) on Linux, but something is amiss with the
SSL connection with vanilla python.org CPython (again 2.6 and 2.7) on
Windows. I've managed to boil it down to a simple test case, which
should return a list of Azure data-centre locations (requires an Azure
account):

Python 2.7.1 (r271:86832, Nov 27 2010, 17:19:03) [MSC v.1500 64 bit
(AMD64)] on win32
Type copyright, credits or license() for more information.
 sub_id = '506...-...-...-...-...'
 cert = 'c:\\users\\blair\\...\\azure.pem'
 import socket,ssl
 s = ssl.wrap_socket(socket.socket(), certfile=cert)
 s.connect(('management.core.windows.net',443))
 s.send(GET /%s/locations HTTP/1.1\r\nAccept-Encoding: 
 identity\r\nX-Ms-Version: 2011-10-01\r\nHost: 
 management.core.windows.net\r\nConnection: close\r\nUser-Agent: 
 Python-urllib/2.7\r\n\r\n % sub_id)
202
 s.read(2048)

Traceback (most recent call last):
  File pyshell#8, line 1, in module
s.read(2048)
  File C:\Python27\lib\ssl.py, line 138, in read
return self._sslobj.read(len)
error: [Errno 10054] An existing connection was forcibly closed by the
remote host


What's interesting is that the exact same code works with ActivePython
(2.6 and 2.7), output omitted here for brevity. There is more detail
on a (currently unanswered) stackoverflow post:
http://stackoverflow.com/questions/8342714/python-https-against-azure-service-management-api-fails-on-windows
.

I'm not sure where/what the difference is. My best guess so far is
that ActivePython bundles a newer version of OpenSSL then the
python.org version and that the problem must be there. Any further
insight would be appreciated.

TIA,
~Blair
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Terry Reedy

On 12/4/2011 6:17 PM, 8 Dihedral wrote:


In python the (k,v) pair in a dictionary k and v can be  both an objects.
v can be a tuple or a list.


In Python, everything is an object. *tuple* and *list* are subclasses of 
*object*. The value v for a dict can be any object, and must be an object.


--
Terry Jan Reedy

--
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread 88888 Dihedral
On Monday, December 5, 2011 7:24:49 AM UTC+8, Ian wrote:
 On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral
 dihedr...@googlemail.com wrote:
  Please explain what you think a hash function is, then.  Per
  Wikipedia, A hash function is any algorithm or subroutine that maps
  large data sets to smaller data sets, called keys.
 
   Are you miss-leading the power of true OOP ?
 
  I have no idea what you are suggesting.  I was not talking about OOP at 
  all.
 
  In python the (k,v) pair in a dictionary k and v can be  both an objects.
  v can be a tuple or a list.  There are some restrictions on k to be an
   hashable type in python's implementation. The key is used to compute the 
  position of the pair to be stored in a  hash table. The hash function maps 
  key k to the position in the hash table. If k1!=k2 are both  mapped to the 
  same
  position, then something has to be done to resolve this.
 
 I understand how dicts / hash tables work.  I don't need you to
 explain that to me.  What you haven't explained is why you stated that
 a hash function that operates on objects is not a hash function, or
 what you meant by misleading the power of true OOP.

If v is a tuple or a list then a dictionary in python can replace a 
bi-directional list or a tree under the assumption that the hash which  
accesses values stored in a  much faster way  when well implemented.  
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Lie Ryan

On 12/05/2011 11:52 AM, 8 Dihedral wrote:

On Monday, December 5, 2011 7:24:49 AM UTC+8, Ian wrote:

On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral
dihedr...@googlemail.com  wrote:

Please explain what you think a hash function is, then.  Per
Wikipedia, A hash function is any algorithm or subroutine that maps
large data sets to smaller data sets, called keys.


Are you miss-leading the power of true OOP ?


I have no idea what you are suggesting.  I was not talking about OOP at all.


In python the (k,v) pair in a dictionary k and v can be  both an objects.
v can be a tuple or a list.  There are some restrictions on k to be an
  hashable type in python's implementation. The key is used to compute the 
position of the pair to be stored in a  hash table. The hash function maps key 
k to the position in the hash table. If k1!=k2 are both  mapped to the same
position, then something has to be done to resolve this.


I understand how dicts / hash tables work.  I don't need you to
explain that to me.  What you haven't explained is why you stated that
a hash function that operates on objects is not a hash function, or
what you meant by misleading the power of true OOP.


If v is a tuple or a list then a dictionary in python can replace a 
bi-directional list or a tree under the assumption that the hash which  
accesses values stored in a  much faster way  when well implemented.


trying not to be rude, but the more you talk, the more Im convince that 
you're trolling. Welcome to my killfile.


--
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Steven D'Aprano
Dihedral, you're back to double posting. Please stop. Send to the mailing 
list, or to the newsgroup, it doesn't matter. But don't send to both.

Further comments below.


On Sun, 04 Dec 2011 16:52:14 -0800, 8 Dihedral wrote:

 If v is a tuple or a list then a dictionary in python can replace a
 bi-directional list or a tree under the assumption that the hash which 
 accesses values stored in a  much faster way  when well implemented.

No it can't.

The keys in a hash tables are unordered. You get an order when you 
iterate over them, but that order is arbitrary.

Keys in a list or tree are ordered. E.g. collections.OrderedDict 
remembers the order that keys are added. If Python were to replace 
OrderedDicts with dicts, it would break code.


-- 
Steven
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Ethan Furman

Lie Ryan wrote:

On 12/05/2011 11:52 AM, 8 Dihedral wrote:

On Monday, December 5, 2011 7:24:49 AM UTC+8, Ian wrote:

On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral
dihedr...@googlemail.com  wrote:

Please explain what you think a hash function is, then.  Per
Wikipedia, A hash function is any algorithm or subroutine that maps
large data sets to smaller data sets, called keys.


Are you miss-leading the power of true OOP ?


I have no idea what you are suggesting.  I was not talking about 
OOP at all.


In python the (k,v) pair in a dictionary k and v can be  both an 
objects.

v can be a tuple or a list.  There are some restrictions on k to be an
  hashable type in python's implementation. The key is used to 
compute the position of the pair to be stored in a  hash table. The 
hash function maps key k to the position in the hash table. If 
k1!=k2 are both  mapped to the same

position, then something has to be done to resolve this.


I understand how dicts / hash tables work.  I don't need you to
explain that to me.  What you haven't explained is why you stated that
a hash function that operates on objects is not a hash function, or
what you meant by misleading the power of true OOP.


If v is a tuple or a list then a dictionary in python can replace a 
bi-directional list or a tree under the assumption that the hash 
which  accesses values stored in a  much faster way  when well 
implemented.


trying not to be rude, but the more you talk, the more Im convince that 
you're trolling. Welcome to my killfile.


I think he's a bot, and he's been in my killfile for a while now.

~Ethan~
--
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Matt Joiner
Yes. I sent a mail earlier asking such and it was bounced. I'm one
email from also blocking this fellow.

On Mon, Dec 5, 2011 at 12:59 PM, Lie Ryan lie.1...@gmail.com wrote:
 On 12/05/2011 11:52 AM, 8 Dihedral wrote:

 On Monday, December 5, 2011 7:24:49 AM UTC+8, Ian wrote:

 On Sun, Dec 4, 2011 at 4:17 PM, 8 Dihedral
 dihedr...@googlemail.com  wrote:

 Please explain what you think a hash function is, then.  Per
 Wikipedia, A hash function is any algorithm or subroutine that maps
 large data sets to smaller data sets, called keys.

 Are you miss-leading the power of true OOP ?


 I have no idea what you are suggesting.  I was not talking about OOP at
 all.


 In python the (k,v) pair in a dictionary k and v can be  both an
 objects.
 v can be a tuple or a list.  There are some restrictions on k to be an
  hashable type in python's implementation. The key is used to compute
 the position of the pair to be stored in a  hash table. The hash function
 maps key k to the position in the hash table. If k1!=k2 are both  mapped to
 the same
 position, then something has to be done to resolve this.


 I understand how dicts / hash tables work.  I don't need you to
 explain that to me.  What you haven't explained is why you stated that
 a hash function that operates on objects is not a hash function, or
 what you meant by misleading the power of true OOP.


 If v is a tuple or a list then a dictionary in python can replace a
 bi-directional list or a tree under the assumption that the hash which
  accesses values stored in a  much faster way  when well implemented.


 trying not to be rude, but the more you talk, the more Im convince that
 you're trolling. Welcome to my killfile.

 --
 http://mail.python.org/mailman/listinfo/python-list



-- 
ಠ_ಠ
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Ben Finney
Ethan Furman et...@stoneleaf.us writes:

 Lie Ryan wrote:

  trying not to be rude, but the more you talk, the more Im convince
  that you're trolling. Welcome to my killfile.

 I think he's a bot, and he's been in my killfile for a while now.

Having a ludicrous name doesn't help, and is part of what dropped them
into my kill file.

Maybe when they give a human-friendly name, and drop the insistence on
being right rather than learning something, they can emerge from some of
our kill files.

-- 
 \   “We jealously reserve the right to be mistaken in our view of |
  `\  what exists, given that theories often change under pressure |
_o__)  from further investigation.” —Thomas W. Clark, 2009 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: order independent hash?

2011-12-04 Thread Dan Stromberg
Two methods:
1) If you need your hash only once in an infrequent while, then save
the elements in a list, appending as needed, and sort prior to
hashing, as needed

2) If you need your hash more often, you could keep your elements in a
treap or red-black tree; these will maintain sortedness throughout the
life of the datastructure.

3) If A bunch of log(n) or n or nlog(n) operations doesn't sound
appealing, then you might try this one: Create some sort of mapping
from your elements to the integers.  Then just use a sum.  This won't
scatter things nearly as well as a cryptographic hash, but it's very
fast, because you don't need to reevaluate some of your members as you
go.

HTH

On 11/30/11, Neal Becker ndbeck...@gmail.com wrote:
 I like to hash a list of words (actually, the command line args of my
 program)
 in such a way that different words will create different hash, but not
 sensitive
 to the order of the words.  Any ideas?

 --
 http://mail.python.org/mailman/listinfo/python-list

-- 
http://mail.python.org/mailman/listinfo/python-list


class print method...

2011-12-04 Thread Suresh Sharma
Hello All,
I am new to python and i have stuck up on a particular issue with classes,
i understand this might be a very dumb question but please help me out.

I have created two classes and whenever i try to print the objects i get
this message but not the data,  __main__.cards instance at (memory
location) i even tried using __str__ but calling it also produces the same
result. Can anyone please help me how to get my objects printed. I googled
a lot but could not find anything relevant.

thanks in advance

regards
suresh
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: class print method...

2011-12-04 Thread Dave Angel

On 12/05/2011 02:11 AM, Suresh Sharma wrote:

Hello All,
I am new to python and i have stuck up on a particular issue with classes,
i understand this might be a very dumb question but please help me out.

I have created two classes and whenever i try to print the objects i get
this message but not the data,  __main__.cards instance at (memory
location) i even tried using __str__ but calling it also produces the same
result. Can anyone please help me how to get my objects printed. I googled
a lot but could not find anything relevant.

thanks in advance

regards
suresh

You were close, but you have it backward.  You don't call __str__() to 
print an object, you implement __str__() in your object.


If you write a class without also writing __str__(), then print won't 
know what to do with it.


--

DaveA

--
http://mail.python.org/mailman/listinfo/python-list


[issue13526] Deprecate the old Unicode API

2011-12-04 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

I agree with Benjamin.

--
nosy: +georg.brandl

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12555] PEP 3151 implementation

2011-12-04 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

 Is the following change in behavior caused by the fix for this issue?
 
 $ python3.2 -c $'class A(IOError):\n  def __init__(self, arg): pass\nA(arg=1)'
 $ python3.3 -c $'class A(IOError):\n  def __init__(self, arg): pass\nA(arg=1)'
 Traceback (most recent call last):
   File string, line 3, in module
 TypeError: A does not take keyword arguments

It must be because IOError now has a significant __new__ method.
I could change it to accept arbitrary arguments but I'm not sure that's
the right solution.
Another approach would be:
- if IOError is instantiated, initialize stuff in IOError.__new__
- otherwise, initialize stuff in IOError.__init__

What do you think?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12555
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13464] HTTPResponse is missing an implementation of readinto

2011-12-04 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Hello Jon, and thanks for the patch. I have a couple of comments:

- readinto() shouldn't return None but 0 when there is nothing to read (this 
corresponds to read() returning b)

- I see _read_chunked() is only ever called with amt=None, so perhaps it can be 
simplified?

Also, a nitpick: the doc entry needs a versionadded tag.

--
stage:  - patch review

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13464
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12555] PEP 3151 implementation

2011-12-04 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

  Is the following change in behavior caused by the fix for this issue?
  
  $ python3.2 -c $'class A(IOError):\n  def __init__(self, arg): 
  pass\nA(arg=1)'
  $ python3.3 -c $'class A(IOError):\n  def __init__(self, arg): 
  pass\nA(arg=1)'
  Traceback (most recent call last):
File string, line 3, in module
  TypeError: A does not take keyword arguments
 
 It must be because IOError now has a significant __new__ method.
 I could change it to accept arbitrary arguments but I'm not sure that's
 the right solution.
 Another approach would be:
 - if IOError is instantiated, initialize stuff in IOError.__new__
 - otherwise, initialize stuff in IOError.__init__

To make things clearer, IOError.__new__ would detect if a subclass is
asked for, and then defer initialization until __init__ is called so
that argument checking is done in __init__.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12555
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13526] Deprecate the old Unicode API

2011-12-04 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

Closing this as rejected, for the reasons given.

--
resolution:  - rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13526
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue12555] PEP 3151 implementation

2011-12-04 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

There's a fairly sophisticated tapdance in object.__new__ that deals with this 
problem at that level.

See: http://hg.python.org/cpython/file/default/Objects/typeobject.c#l2869

The new IOError may require something similarly sophisticated to cope with 
subclasses that only override __init__.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue12555
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue9420] gdbm with /usr/include/ndbm.h

2011-12-04 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
versions: +Python 3.2, Python 3.3

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue9420
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13524] critical error with import tempfile

2011-12-04 Thread Tim Golden

Tim Golden m...@timgolden.me.uk added the comment:

OK, the long and short is that spwaning a process without passing
in SystemRoot is asking for trouble. There's a blog post here
which gives an example:

http://jpassing.com/2009/12/28/the-hidden-danger-of-forgetting-to-specify-systemroot-in-a-custom-environment-block/

And, certainly this works:

import os
import subprocess
subprocess.Popen(
 notepad.exe,
 env={SystemRoot : os.environ['SystemRoot']}
)

I'm not quite sure what approach we should take in the subprocess
module. Is it a docs warning? Should we refuse to proceed if there's
no SystemRoot? Is it the caller's responsibility?
I'll ask on python-dev to gather opinions.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13524
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13211] urllib2.HTTPError does not have 'reason' attribute.

2011-12-04 Thread Jason R. Coombs

Jason R. Coombs jar...@jaraco.com added the comment:

After yet another commit, the build bots are green again:

http://hg.python.org/cpython/rev/8fa1dc66de5d

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13211
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13464] HTTPResponse is missing an implementation of readinto

2011-12-04 Thread Jon Kuhn

Jon Kuhn jonk...@gmail.com added the comment:

Thanks for the comments.  Attached is an updated patch.

In the RawIOBase docs it says If the object is in non-blocking mode and no 
bytes are available, None is returned.  So I wasn't sure if that meant any 
time no bytes were available or just when no bytes are available and EOF has 
not been reached.  -- I updated it to return 0 instead of None.

I simplified _read_chunked() and renamed it to _readall_chunked() since that is 
all it does.  

I added the versionadded tag specifying that it was added in 3.3 since the 
patch is for the default branch.

--
Added file: http://bugs.python.org/file23850/issue13464_r1.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13464
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13528] Rework performance FAQ

2011-12-04 Thread Antoine Pitrou

New submission from Antoine Pitrou pit...@free.fr:

This is a slimmed down rewrite of the performance question in the FAQ (also 
moved around to a dedicated subheader).

--
assignee: docs@python
components: Documentation
files: perffaq.patch
keywords: patch
messages: 148853
nosy: docs@python, pitrou, rhettinger
priority: normal
severity: normal
stage: patch review
status: open
title: Rework performance FAQ
versions: Python 3.2, Python 3.3
Added file: http://bugs.python.org/file23851/perffaq.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13528
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13503] improved efficiency of bytearray pickling by using bytes type instead of str

2011-12-04 Thread Irmen de Jong

Irmen de Jong ir...@razorvine.net added the comment:

Added new patch that only does the new reduction when protocol is 3 or higher.

--
Added file: http://bugs.python.org/file23852/bytearray3x_reduceex.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13503
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13529] Segfault inside of gc/weakref

2011-12-04 Thread Alex Gaynor

New submission from Alex Gaynor alex.gay...@gmail.com:

I don't have a particularly minimal test case for this, however I am able to 
reproduce it consistently (so far reproduced on multiple machines, 32-bit and 
64-bit on 2.6 and 2.7), using these steps:

First get a checkout of the PyPy repository:

hg clone ssh://h...@bitbucket.org/pypy/pypy

Next, get to the correct revision:

hg up -C 82e1fc9c253c

Finally, attempt to run the tests:

./pytest.py pypy/module/micronumpy/ -x

At this point you should have a segfault that appears to be because of a bad 
address for a weakref (but I could be horrifically wrong).

--
components: Interpreter Core
messages: 148855
nosy: alex
priority: normal
severity: normal
status: open
title: Segfault inside of gc/weakref
versions: Python 2.6, Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13529
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13529] Segfault inside of gc/weakref

2011-12-04 Thread Alex Gaynor

Alex Gaynor alex.gay...@gmail.com added the comment:

Antoine asked for a gdb bt, here's the last couple of useful frames:


#0  _PyWeakref_ClearRef (self=0x4000) at Objects/weakrefobject.c:97
#1  0x004d4c66 in handle_weakrefs (old=0x78a2b0, 
unreachable=0x7fff87b0) at Modules/gcmodule.c:595
#2  collect (generation=0) at Modules/gcmodule.c:924
#3  0x004d5640 in collect_generations () at Modules/gcmodule.c:996
#4  _PyObject_GC_Malloc (basicsize=optimized out) at Modules/gcmodule.c:1457
#5  0x00466ba9 in PyType_GenericAlloc (type=0x31d05e0, nitems=0) at 
Objects/typeobject.c:753
#6  0x0046ad83 in type_call (type=0x31d05e0, args=(257, None, [], 8, 
51), kwds=0x0) at Objects/typeobject.c:721
#7  0x0041ebc7 in PyObject_Call (func=type at remote 0x31d05e0, 
arg=optimized out, kw=optimized out) at Objects/abstract.c:2529
#8  0x0049b152 in do_call (nk=optimized out, na=optimized out, 
pp_stack=0x7fff89b0, func=type at remote 0x31d05e0)
at Python/ceval.c:4239
#9  call_function (oparg=optimized out, pp_stack=0x7fff89b0) at 
Python/ceval.c:4044
#10 PyEval_EvalFrameEx (f=optimized out, throwflag=optimized out) at 
Python/ceval.c:2666

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13529
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1660009] continuing problem with httplib multiple set-cookie headers

2011-12-04 Thread Piotr Dobrogost

Changes by Piotr Dobrogost p...@python.dobrogost.net:


--
nosy: +piotr.dobrogost

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue1660009
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13529] Segfault inside of gc/weakref

2011-12-04 Thread Alex Gaynor

Alex Gaynor alex.gay...@gmail.com added the comment:

Turns out this was a subtle bug in some raw memory manipulation code, which 
amaury spotted.

--
resolution:  - invalid
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13529
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue3276] httplib.HTTPConnection._send_request should not blindly assume dicts for headers

2011-12-04 Thread Piotr Dobrogost

Changes by Piotr Dobrogost p...@python.dobrogost.net:


--
nosy: +piotr.dobrogost
status: pending - open

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue3276
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13527] Remove obsolete mentions in the GUIs page

2011-12-04 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 2111bf7e5bca by Antoine Pitrou in branch '3.2':
Issue #13527: remove mention of Python megawidgets and Tkinter3000 WCK
http://hg.python.org/cpython/rev/2111bf7e5bca

New changeset f0008683585c by Antoine Pitrou in branch 'default':
Issue #13527: remove mention of Python megawidgets and Tkinter3000 WCK
http://hg.python.org/cpython/rev/f0008683585c

New changeset 478b4e9551fa by Antoine Pitrou in branch '2.7':
Issue #13527: remove mention of Python megawidgets and Tkinter3000 WCK
http://hg.python.org/cpython/rev/478b4e9551fa

--
nosy: +python-dev

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13527] Remove obsolete mentions in the GUIs page

2011-12-04 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13527
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-12-04 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
hgrepos:  -93

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-12-04 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


--
hgrepos: +94

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-12-04 Thread Nick Coghlan

Changes by Nick Coghlan ncogh...@gmail.com:


Added file: http://bugs.python.org/file23853/5ce60675e572.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11816] Refactor the dis module to provide better building blocks for bytecode analysis

2011-12-04 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

MvL pointed out I hadn't updated the Hg repo reference when I moved my sandbox 
over to BitBucket - the diff it was generating was from the last time I updated 
my pydotorg sandbox in order to try something on the buildbots.

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11816
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue5364] documentation in epub format

2011-12-04 Thread James Polley

James Polley jamezpol...@gmail.com added the comment:

So http://bitbucket.org/birkenfeld/sphinx/issue/140/ has now been closed; 
sphinx happily builds epub.

However, the python docs are still not available for download in epub format 
from http://docs.python.org/download.html, which was the original request in 
this issue.

--
nosy: +James.Polley

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue5364
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13530] Docs for os.lseek neglect to mention what it returns

2011-12-04 Thread Ned Batchelder

New submission from Ned Batchelder n...@nedbatchelder.com:

The docs for os.lseek don't make any mention of its return value.  I believe 
it's the new offset in the file, but I'm not sure if there are other subtleties 
to be mentioned.

--
assignee: docs@python
components: Documentation
messages: 148861
nosy: docs@python, nedbat
priority: normal
severity: normal
status: open
title: Docs for os.lseek neglect to mention what it returns
versions: Python 2.7, Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13530
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13506] IDLE sys.path does not contain Current Working Directory

2011-12-04 Thread Marco Scataglini

Marco Scataglini atlant...@gmx.com added the comment:

At first I did no see the difference on preserving the existing correct 
behavior and fixing the issue between the two patches... and I thought less is 
more, so mine was better...

But, I checked again and by:
... running a python script will have sys.path include the absolute path to 
the script... (Roger meant) instead of CWD ().

I can see the reasoning for it and since that IS the standard Python behavior 
it should be also transposed to IDLE.

So yes, Roger (serwy) patch presents a more accurate correction.

+1

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13506
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13530] Docs for os.lseek neglect to mention what it returns

2011-12-04 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

The only subtlety is that the result is the offset from the beginning, 
independent of the how value. It may also raise exceptions.

--
nosy: +loewis

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13530
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13495] IDLE: Regression - Two ColorDelegator instances loaded

2011-12-04 Thread Roger Serwy

Roger Serwy roger.se...@gmail.com added the comment:

I attached a better patch that preserves the goals of the original code while 
not creating two color delegators.

I traced down when the regression occurred (2007-09-06):
(a4bd8a4805a8) 1. Fail gracefully if the file fails to decode when loaded.

This patch (2008-02-16) modified parts of the last patch, as well adds 
ResetColorizer to the filename_change_hook.
(7c4c46342137) Merged revisions 
60481,60485,60489-60492,60494-60496,60498-60499,60501-60503,605

--
nosy: +christian.heimes, kbk -ned.deily
Added file: http://bugs.python.org/file23854/issue13495.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13495
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com