devpi-server-0.8.5: fixes, fewer dependencies for pypi caching server

2013-05-14 Thread holger krekel
Hi all,

just did a quick release of devpi-server 0.8.5, the pypi.python.org
caching server.  This should fix some cases of uninstallable packages 
and removes pip and virtualenv from its dependencies.  See

https://pypi.python.org/pypi/devpi-server

for details.  Thanks to Markus Zapke-Gruendemann for some help
and to everybody for reporting issues.

cheers,
holger

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

Support the Python Software Foundation:
http://www.python.org/psf/donations/


Re: Python for philosophers

2013-05-14 Thread Jake Angulo
On Tue, May 14, 2013 at 9:32 AM, Citizen Kant citizenk...@gmail.com wrote:
 Do I want to learn to program?
 I didn't say I've wanted to learn to program neither said the
 opposite. I've said that I wasn't sure.


H... i'd say you'll make very good business applications analyst.  In
fact i'd hazard to say you can make it to CIO.

Recommended reading:
* PERL for dummies by: Paul Hoffman
* Crime  Punishment by: Fyodor Dostoyevsky

With your natural philosophical talent, and just a little more
 supplementary knowledge you would Pwn  ruLZ!


Just...
pls...
dont do programming...
and Never do Python.


On Tue, May 14, 2013 at 9:32 AM, Citizen Kant citizenk...@gmail.com wrote:

 I'm amazed with your feedback, even when due to a lack of knowledge I'm
 not able to discuss some of them. I've been inspecting the stuff about
 rewriting and that drew my attention to my first intuition of Python being
 economic. Maybe could it support my impression about a thing thats behind
 the language and got to do with condensing expressions until their end
 point is reached. I'll absolutely read the book you recommended, coz looks
 perfect. The dis module thing sounds and looks perfect too. Then again
 something that was discussed here about Python being economic or not and
 how or in which sense also threw some light on my first impression about
 the language. Everything here is interesting and illustrative. Anyway, I
 think that maybe I'm missing the point and I'm not being capable of
 expressing the fundamentals of the reason why I'm here. I thought that the
 most convenient thing to do is trying to keep myself attached to the
 natural language I master (so to speak) and answer the a set of questions
 that has been formulated. Maybe with this I'm helping myself.

 Towards what purpose I'm just inspecting Python's environment?
 Towards what purpose one would be just inspecting Chess' environment.
 Eventually, I could end up playing; but that isn't told yet.

 Do I want to learn to program?
 I didn't say I've wanted to learn to program neither said the opposite.
 I've said that I wasn't sure. And I said that because it's true. I'm not
 sure. Sureness tends to proliferate at its highest rate when one is looking
 to know. I'm looking to understand this something called Python. I've came
 here as explorer. I know_about numbers of things that go_about a number of
 topics of various supposedly most separated sciences. Since I sometimes
 have the capacity for combining these knowledge units in a fancy way and
 realize a great deal of things, is that I use a lot the verb realize.
 These constant instantiations of mine are like well done objects of real
 true knowledge, made somehow by myself, by calling a method called
 understanding from the class that corresponds and apply to any number of
 memorized_data_objects that were previously instantiated in my mind coming
 from my senses. For me this seems to look like what follows:

  understanding(combination(a_set_of _memorized_data_objects))

  def real_knowledge
  understanding(a_set_of_memorized_data_objects)  # How does this
 look?

 I'm positive about that being told all the time about everything is pretty
 much an economic issue, it just saves time, which in this environment saves
 money, but at the cost of not playing with real knowledge that's verified
 by each self (checksummed so to speak). Monkeys didn't developed our actual
 brains just by being told about everything, but experiencing the phenomena,
 that now we humans are talking about.

 If not, then why do I care about Python programming?
 In part is like a gut_decision. Internet is plenty of information about
 one or another thing that one could be looking for, I've taken a look to
 Ruby and Java and C++, but was a set of Python characteristics that really
 matched with something inside of me. An entity named Python must be somehow
 as a serpent. Don't forget that I'm with the freeing up of my memory, now
 I'm not trying to follow the path of what's told but acting like the monkey
 and pushing with my finger against the skin of the snake. Could be the case
 that a stimulus_response method is being called inside of me. If that's the
 case, objects instantiated by the stimulus_response method are the first
 ones that can be considered scientific like, inside of me. Python also must
 be an entity that's able to swallow, doesn't matter that it's chicken
 object. Then it will throw whatever by its tail. For me that's interesting
 and, in me, interestingness use to call the understanding method. Then I
 realize that what's stated above implies that I can feed Python, and (here
 starts the magic) see what type of whatever throws back by its tail. Then
 I'll approach to smell any possible profit.

 What do I aim to get out of this exercise?
 Since actually I'm not running for programmer, my reason for understanding
 Python must be sui generis and it is.

 What do I think Python's core means?
 More than thinking I'm just 

weave and 64 bit issues

2013-05-14 Thread Jadhav, Alok
Hi everyone,

 

I am facing a strange problem using weave on 64 bit machine.
Specifically with weave's inline function. It has something to do with
weave's catalog. 

 

Similar issues I found in the past (very old)

 

http://mail.scipy.org/pipermail/scipy-dev/2006-June/005908.html

http://mail.scipy.org/pipermail/scipy-dev/2005-June/003042.html

 

 

I have a simple script to calculate moving average using weave's inline
function. 

 

 

 

File mvg.py

 

import numpy as np

import scipy.weave as weave

import distutils.sysconfig

import distutils.dir_util

import os

 

distutils.sysconfig._config_vars[LDSHARED]=-LC:\strawberry64\c\x86_64
-w64-mingw32\lib

 

 

def ExpMovAvg(data,time,lag):

if (data.size!=time.size):

print error in EMA, data and time have different size

return None

result=np.repeat(0.0,data.size)

code=

#line 66 basics.py

result(0)=data(0);

for (int i=0;idata.size()-1;i++)

{

//double alpha=1-(2.0/(lag+1)*(time(i)-time(i-1)));

double dt=time(i+1)-time(i);

double alpha=pow(0.13533, dt / lag);

if(alpha1)

{

alpha=10;

}

result(i+1)=(1-alpha)*data(i)+alpha*result(i);

}



 
weave.inline(code,[data,time,lag,result],type_converters=weave.c
onverters.blitz,headers=[math.h],compiler=gcc,verbose=2)

return result

 

 

file test.py

 

import string

import numpy as np

import mvg

 

print(mvg.ExpMovAvg(np.array(range(10)),np.array(range(10)),2))

 

 

 

Output:

 

 

Working output:

 

Y:\STMM\alpha\klse\PRODc:\python27\python.exe
s:\common\tools\python\python-2.7-64bit\test.py

[ 0.  0.  0.63212774  1.49679774  2.44701359  3.42869938
4.42196209  5.41948363  6.41857187  7.41823646]

 

Now if I keep running the script multiple times, sometimes I see correct
output... but suddenly sometimes I get below error.

 

Y:\STMM\alpha\klse\PRODc:\python27\python.exe
s:\common\tools\python\python-2.7-64bit\test.py

repairing catalog by removing key

weave: compiling

Looking for python27.dll

running build_ext

running build_src

build_src

building extension sc_44f3fe3c65d5c3feecb45d9269ac207f5 sources

build_src: building npy-pkg config files

Looking for python27.dll

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

Looking for python27.dll

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

building 'sc_44f3fe3c65d5c3feecb45d9269ac207f5' extension

compiling C++ sources

C compiler: g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall

 

compile options: '-Ic:\python27\lib\site-packages\scipy\weave
-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz

-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\python27\include
-Ic:\python27\PC -c' 

 g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall
-Ic:\python27\lib\site-packages\scipy\weave

-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz
-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\pytho

n27\include -Ic:\python27\PC -c
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_compiled\sc_44f3f
e3c65d5c3feecb45d9269ac207f5.cpp -o c:\users\ajadhav2\ap

pdata\local\temp\ajadhav2\python27_intermediate\compiler_2d3e1e2e4de6a91
419d2376b162e5342\Release\users\ajadhav2\appdata\local\temp\ajadhav2\pyt
hon27_compiled\s

c_44f3fe3c65d5c3feecb45d9269ac207f5.o

Found executable C:\strawberry\c\bin\g++.exe

g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall
-Ic:\python27\lib\site-packages\scipy\weave-Ic:\python27\lib\site-packag
es\scipy\weave\scxx -Ic:\python27\lib\site-packages

\scipy\weave\blitz -Ic:\python27\lib\site-packages\numpy\core\include
-Ic:\python27\include -Ic:\python27\PC -c
c:\python27\lib\site-packages\scipy\weave\scxx\w

eave_imp.cpp -o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4de6a91419d2376b162e5342\Release\python27\lib\site-packages

\scipy\weave\scxx\weave_imp.o

g++ -g -shared
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4de6a91419d2376b162e5342\Release\users\ajadhav2\appdata\loc
a

l\temp\ajadhav2\python27_compiled\sc_44f3fe3c65d5c3feecb45d9269ac207f5.o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4d

e6a91419d2376b162e5342\Release\python27\lib\site-packages\scipy\weave\sc
xx\weave_imp.o -Lc:\python27\libs -Lc:\python27\PCbuild\amd64 -lpython27
-lmsvcr90 -o c:

\users\ajadhav2\appdata\local\temp\ajadhav2\python27_compiled\sc_44f3fe3
c65d5c3feecb45d9269ac207f5.pyd

running scons

Traceback (most recent call last):

  File s:\common\tools\python\python-2.7-64bit\test.py, line 5, in
module

print(mvg.ExpMovAvg(np.array(range(10)),np.array(range(10)),2))

  File s:\common\tools\python\python-2.7-64bit\mvg.py, line 30, in
ExpMovAvg

 
weave.inline(code,[data,time,lag,result],type_converters=weave.c
onve


Re: Differences of != operator behavior in python3 and python2 [ bug? ]

2013-05-14 Thread Chris Angelico
On Tue, May 14, 2013 at 9:22 AM, Dave Angel da...@davea.name wrote:
 On 05/13/2013 06:53 PM, Mark Lawrence wrote:
 I much prefer the alternative  for != but some silly people insisted
 that this be removed from Python3.  Just how stupid can you get?


 So which special methods should the  operator call?  By rights it ought to
 call both __gt__ and __lt__ and return True if either of them is True.

Why do you think that? After all, the != operator doesn't call
__factorial__ and __assignment__ and return True if either is True,
does it?

ChrisA

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


Re: Writing a blog post on the new Enum.

2013-05-14 Thread Chris Angelico
On Tue, May 14, 2013 at 9:40 AM, Fábio Santos fabiosantos...@gmail.com wrote:
 Well I am thus defying the law and order of this world by publishing
 it on the internets!

 ---

 And here it is:
 http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html

class Text(unicode, Enum):
one = u'one'
two = u'two'
three = u'three'

That looks like Python 2 code. Are you backporting Enum to Py2
manually? AIUI the Python core won't be adding features like that to
2.7, and there won't be a 2.8, so PEP 435 will be Py3.4+ only. Or have
I misunderstood it?

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


Fwd: Python for philosophers

2013-05-14 Thread Citizen Kant
2013/5/14 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info

 On Tue, 14 May 2013 01:32:43 +0200, Citizen Kant wrote:

  An entity named Python must be somehow as a serpent. Don't forget that
  I'm with the freeing up of my memory, now I'm not trying to follow the
  path of what's told but acting like the monkey and pushing with my
  finger against the skin of the snake.

 Python is not named after the snake, but after Monty Python the British
 comedy troupe. And they picked their name because it sounded funny.

  http://en.wikipedia.org/wiki/Monty_Pythonhttp://en.wikipedia.org/wiki/Monty_Python




 I'm sorry to hear that. Mostly because, as an answer, seems to example
 very well the taken because I've been told how things are kind of
 actions, which is exactly the opposite of the point I'm trying to state.

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


Fwd: Python for philosophers

2013-05-14 Thread Citizen Kant
From: llanitedave llanited...@veawb.coop


On Monday, May 13, 2013 4:32:43 PM UTC-7, Citizen Kant wrote:

An entity named Python must be
 somehow as a serpent.


llanitedave wrote:

 Moe like a dead parrot, actually.


That's a good one! Even If doesn't lead to the fact that Python (so to
speak) use to give an answer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's sad, unimaginative Enum

2013-05-14 Thread Jean-Michel Pichavant
- Original Message -
 On Mon, 13 May 2013 13:00:36 +0200, Jean-Michel Pichavant wrote:
 
  - Original Message -
  That's the title of this little beast
  http://www.acooke.org/cute/Pythonssad0.html if anybody's
  interested.
  
  --
  If you're using GoogleCrap™ please read this
  http://wiki.python.org/moin/GoogleGroupsPython.
  
  Mark Lawrence
  
  --
  http://mail.python.org/mailman/listinfo/python-list
  
  
  python 2.5
  
  class Enum:
class __metaclass__(type):
  def __iter__(self):
for attr in sorted(dir(self)):
  if not attr.startswith(__):
yield getattr(self, attr)
  
  class Colours(Enum):
RED = red
GREEN = green
 
 py class Experience(Enum):
 ... NOVICE = 'novice'
 ... GREEN = 'green'
 ... EXPERIENCED = 'experienced'
 ... MASTER = 'master'
 ...
 py
 py Colours.GREEN == Experience.GREEN
 True
 
 
 Oops.
 
 
 It's very easy to make something which does a few things that enums
 should do, and call it an Enum. It's much harder to do a lot of
 things
 that enums should do.
 
 
 
 --
 Steven

I was just proposing a solution I've been using and found quite satisfactory. 
As for the perfect enumness of that solution, I don't know. To be honest, I'm 
not sure I know the exact definition of an enum, and whether or not the C enum 
fits 100% that definition. It does the job in python. Some people may find it 
useful, others may just ignore it.
Additionally, the bug you mentioned can be written in C as well, casts allow 
to compare apples and oranges:

(Colours::GREEN == (enum Coulours::Colour)Experiences::GREEN)


JM


-- IMPORTANT NOTICE: 

The contents of this email and any attachments are confidential and may also be 
privileged. If you are not the intended recipient, please notify the sender 
immediately and do not disclose the contents to any other person, use it for 
any purpose, or store or copy the information in any medium. Thank you.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's sad, unimaginative Enum

2013-05-14 Thread Fábio Santos
On 13 May 2013 12:05, Jean-Michel Pichavant jeanmic...@sequans.com
wrote:

 class Enum:
   class __metaclass__(type):

That's some cool metaclass fu! I didn't know that to be possible
-- 
http://mail.python.org/mailman/listinfo/python-list


Fwd: Python for philosophers

2013-05-14 Thread Citizen Kant
Case study (kind of)

Imagine that I use to explore with my mind a particular topic and I want to
map and model the mechanics of that exploration. That's mostly
metaphysical. I have a partner called Python with whom I must communicate
in Python. Which would be the basics that I must know in order to pass my
ideas to him properly. With this I mean using the units of my natural
language skills that match with his language, and using them in Python's
language context, in order to program at the highest level possible. It's
true that my program won't run yet but for me this is not an obstacle at
all, as when one writes a book one can start writing an index. For some
people, this index or highest level programming could look mostly like a
void thing coz lacks of the proper meat that a Python use to eat, and in a
sense they are right. But that's not the point. The point is that as soon
as I can I would start to dig deeper in that structure and build the proper
meat that my highest level labels are just naming. What if using my ability
to name what I actually think and recognize the path of whichever method I
call from my object of thinking, I'd like to start setting a context for
further immersion (inmersion with advanced mathematical notation an that?
Somebody commented about a couple of basic elements which I'm familiarized
with, like +, -, /, =, 1,2,3,4,5,6,7,8,9,0, (), etc. I know that Python has
a set of keywords, there's also a proper way in which one must express
wholes in Python, proper way which I'm not familiarized with but I'm able
to learn. Does this help?

For me, starting with Python is an affair of connecting with it. It's not
about including it in me or including me in it, but a kind of symbiotic
relationship. Unless for me, using my natural language as far as I can, but
constrained (formalized) by Python syntax in order to model using objects
and methods and classes that are still unable to run in Python (yet) seems
to be a good starting point for a symbiotic relationship. Understanding
might depend in our ability to set ourselves in the shoes of another.

Any clues? Since this is a real goal that I'm looking to accomplish, any
question that would clarify a bit more my states will be highly appreciated.
-- 
http://mail.python.org/mailman/listinfo/python-list


ssl proxy server

2013-05-14 Thread 23alagmy
ssl proxy server

http://natigtas7ab.blogspot.com/2013/05/ssl-proxy-server.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python for philosophers

2013-05-14 Thread Terry Jan Reedy



2013/5/14 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info
mailto:steve+comp.lang.pyt...@pearwood.info



 Python is not named after the snake, but after Monty Python the
British
 comedy troupe. And they picked their name because it sounded funny.


That does not mean they were unaware that Pythons are snakes.
requiring a slippery-sounding surname, they settled on Python


  http://en.wikipedia.org/wiki/Monty_Python
http://en.wikipedia.org/wiki/Monty_Python




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


Re: Writing a blog post on the new Enum.

2013-05-14 Thread Terry Jan Reedy

On 5/14/2013 3:52 AM, Chris Angelico wrote:

On Tue, May 14, 2013 at 9:40 AM, Fábio Santos fabiosantos...@gmail.com wrote:



http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html


 class Text(unicode, Enum):
 one = u'one'
 two = u'two'
 three = u'three'


Is this supposed to be a quote? or your rewrite? or did Santos rewrite 
after you posted? The blog currently has a 3.x version of that.



That looks like Python 2 code. Are you backporting Enum to Py2
manually? AIUI the Python core won't be adding features like that to
2.7, and there won't be a 2.8, so PEP 435 will be Py3.4+ only. Or have
I misunderstood it?


As far as official CPython goes, Enum is 3.4+ only. I believe the module 
will continue to work on earlier 3.x and will remain externally 
available as a 3rd party module. Ethan said he plans to backport to 2.7 
so 2  3 code can use enums.



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


Re: Debugging difficulty in python with __getattr__, decorated properties and AttributeError.

2013-05-14 Thread Mr. Joe
Sorry for digging this old topic back. I see that my 'property' does not
play well with polymorphic code comment generated some controversy. So
here's something in my defense:

Here's the link to stackoveflow topic I am talking about:

http://stackoverflow.com/questions/237432/python-properties-and-inheritance

The solution that fits my taste:
http://stackoverflow.com/a/14349742

A related blogpost:

http://requires-thinking.blogspot.com/2006/03/note-to-self-python-properties-are-non.html

Yes, I like decorators and descriptors. I also like the ability to create a
virtual property in a python class by binding a bunch of methods as
setter/getter. But I find the implementation of this virtual property
feature a bit awkward sometimes - every time I need to override a
getter/setter in a child class, I need to decorate them again. Some of you
may like this explicitness, but I don't.

To Steven D'Aprano: Seriously, what's all the bashing in your last reply
about? You dissected my thank-you reply more strictly than the python
interpreter checking for syntax errors. Not in a mood for fight, but I find
your opinions about bug finding time, hacks and stackoverflow quite
silly.
-- 
http://mail.python.org/mailman/listinfo/python-list


PDF generator decision

2013-05-14 Thread Christian Jurk
Hi folks,

This questions may be asked several times already, but the development of 
relevant software continues day-for-day. For some time now I've been using 
xhtml2pdf [1] to generate PDF documents from HTML templates (which are rendered 
through my Django-based web application. This have been working for some time 
now but I'm constantly adding new templates and they are not looking like I 
want it (sometimes bold text is bold, sometimes not, layout issues, etc). I'd 
like to use something else than xhtml2pdf.

So far I'd like to ask which is the (probably) best way to create PDFs in 
Python (3)? It is important for me that I am able to specify not only 
background graphics, paragaphs, tables and so on but also to specify page 
headers/footers. The reason is that I have a bunch of documents to be generated 
(including Invoice templates, Quotes - stuff like that).

Any advice is welcome. Thanks.

[1] https://github.com/chrisglass/xhtml2pdf
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PDF generator decision

2013-05-14 Thread Frank Miles
On Tue, 14 May 2013 08:05:53 -0700, Christian Jurk wrote:

 Hi folks,
 
 This questions may be asked several times already, but the development
 of relevant software continues day-for-day. For some time now I've been
 using xhtml2pdf [1] to generate PDF documents from HTML templates (which
 are rendered through my Django-based web application. This have been
 working for some time now but I'm constantly adding new templates and
 they are not looking like I want it (sometimes bold text is bold,
 sometimes not, layout issues, etc). I'd like to use something else than
 xhtml2pdf.
 
 So far I'd like to ask which is the (probably) best way to create PDFs
 in Python (3)? It is important for me that I am able to specify not only
 background graphics, paragaphs, tables and so on but also to specify
 page headers/footers. The reason is that I have a bunch of documents to
 be generated (including Invoice templates, Quotes - stuff like that).
 
 Any advice is welcome. Thanks.
 
 [1] https://github.com/chrisglass/xhtml2pdf

Reportlab works well in Python 2.x.  Their _next_ version is supposed to 
work with Python3... {yes, not much help there}
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing a blog post on the new Enum.

2013-05-14 Thread Chris Angelico
On Wed, May 15, 2013 at 1:07 AM, Terry Jan Reedy tjre...@udel.edu wrote:
 On 5/14/2013 3:52 AM, Chris Angelico wrote:

 On Tue, May 14, 2013 at 9:40 AM, Fábio Santos fabiosantos...@gmail.com
 wrote:

 http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html


  class Text(unicode, Enum):
  one = u'one'
  two = u'two'
  three = u'three'


 Is this supposed to be a quote? or your rewrite? or did Santos rewrite after
 you posted? The blog currently has a 3.x version of that.

It was a quote from the blog post as it had been when I posted it.
Presumably he edited the post subsequently, as I'm now seeing the same
thing you are, a 3.x-compat version. (The u'xx' prefixes wouldn't be a
problem, incidentally, so this could be dual-versionned just by going
unicode = str.)

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


First post

2013-05-14 Thread Carlos Nepomuceno
Hi guys! This is my first post on this list.

I'd like have your opinion on how to safely implement WSGI on a production 
server.

My benchmarks show no performance differences between our PHP and Python 
environments. I'm using mod_wsgi v3.4 with Apache 2.4.

Is that ok or can it get faster?

Thanks in advance.

Regards,

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


Re: Writing a blog post on the new Enum.

2013-05-14 Thread Fábio Santos
I corrected it indeed.

On Tue, May 14, 2013 at 4:36 PM, Chris Angelico ros...@gmail.com wrote:
 On Wed, May 15, 2013 at 1:07 AM, Terry Jan Reedy tjre...@udel.edu wrote:
 On 5/14/2013 3:52 AM, Chris Angelico wrote:

 On Tue, May 14, 2013 at 9:40 AM, Fábio Santos fabiosantos...@gmail.com
 wrote:

 http://fabiosantoscode.blogspot.pt/2013/05/pythons-new-enum-class.html


  class Text(unicode, Enum):
  one = u'one'
  two = u'two'
  three = u'three'


 Is this supposed to be a quote? or your rewrite? or did Santos rewrite after
 you posted? The blog currently has a 3.x version of that.

 It was a quote from the blog post as it had been when I posted it.
 Presumably he edited the post subsequently, as I'm now seeing the same
 thing you are, a 3.x-compat version. (The u'xx' prefixes wouldn't be a
 problem, incidentally, so this could be dual-versionned just by going
 unicode = str.)

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



-- 
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: PDF generator decision

2013-05-14 Thread jmfauth
On 14 mai, 17:05, Christian Jurk co...@commx.ws wrote:
 Hi folks,

 This questions may be asked several times already, but the development of 
 relevant software continues day-for-day. For some time now I've been using 
 xhtml2pdf [1] to generate PDF documents from HTML templates (which are 
 rendered through my Django-based web application. This have been working for 
 some time now but I'm constantly adding new templates and they are not 
 looking like I want it (sometimes bold text is bold, sometimes not, layout 
 issues, etc). I'd like to use something else than xhtml2pdf.

 So far I'd like to ask which is the (probably) best way to create PDFs in 
 Python (3)? It is important for me that I am able to specify not only 
 background graphics, paragaphs, tables and so on but also to specify page 
 headers/footers. The reason is that I have a bunch of documents to be 
 generated (including Invoice templates, Quotes - stuff like that).

 Any advice is welcome. Thanks.

 [1]https://github.com/chrisglass/xhtml2pdf

-

1) Use Python to collect your data (db, pictures, texts, ...)
and/or to create the material (text, graphics, ...) that will
be the contents (source) of your your pdf's.
2) Put this source in .tex file (a plain text file).
3) Let it compile with a TeX engine.

- I can not figure out something more versatile and basically
simple (writing a text file).
- Do not forget you are the only one who knows the content
and the layout of your document(s).

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


Re: ssl proxy server

2013-05-14 Thread Chris “Kwpolska” Warrick
On Tue, May 14, 2013 at 2:34 PM, 23alagmy hossamala...@gmail.com wrote:
 ssl proxy server

 hxxp://natigtas7ab.blogspot.com/2013/05/ssl-proxy-server.html
 --
 http://mail.python.org/mailman/listinfo/python-list

I have been seeing those mails for a long time.  Why didn’t anybody
ban that guy?  If it comes from Usenet (and headers say it does), and
you can’t destroy stuff easily there, maybe just put a ban on the
Mailman side of things, making the world much better for at least some
people?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-14 Thread Mark Janssen
On Sat, May 11, 2013 at 1:03 PM, Citizen Kant citizenk...@gmail.com wrote:
I'm making my way to Python (and
 OOP in general) from a philosophical perspective or point of view and try to
 set the more global definition of Python's core as an entity. In order to
 do that, and following Wittgenstein's indication about that the true meaning
 of words doesn't reside on dictionaries but in the use that we make of them,
 the starting question I make to myself about Python is: which is the single
 and most basic use of Python as the entity it is?

It is a way to form order from ideas, an *experimental* philosophy.
One can apply and implement a philosophy, taking it out of the realm
of ideas and simulate them in the machine.

 I mean, beside
 programming, what's the single and most basic result one can expect from
 interacting with it directly (interactive mode)?

A game of interactions.

 I roughly came to the
 idea that Python could be considered as an economic mirror for data, one
 that mainly mirrors the data the programmer types on its black surface,

That is called the editor window in our world that is displayed on
an electronic device called a computer display, but in Samael's world
it is a mirror into our world.  He misused it to rape the crown of the
Hebrew story (found in the Bible).

 So, would it be legal (true) to define Python's core as an entity that
 mirrors whatever data one presents to it (or feed it with) showing back the
 most shortened expression of that data?

No, that is me, Marcos.
-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Illegal seek error with seek() and os.lseek()

2013-05-14 Thread krishna2prasad
I am trying to use os.open() and os.lseek() methods to operate on a device file 
in Linux. My code goes something like this -

 # first, open the file as a plain binary
 try:
 self.file = open(/dev/relpcfpga, r+b, buffering=0)
 
 except IOError:
 raise IOError ('Failed to open.')

 # Figure out file size
  self.file.seek(0, 2)
  self.file_size = self.file.tell()
 

The method seek() complains OSError: [Errno 29] Illegal seek
The device relpcfpga is a char device.

The same code works with a normal text file.
I have tried to use os.open() and os.lseek() methods, but see the same error.
Is there a different method to operate on device files?


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


Re: Message passing syntax for objects | OOPv2

2013-05-14 Thread Mark Janssen
 Sounds a lot like reddit threads.

It's similar, but it goes a lot further.  Where every other site
without centralized editors, the thread mess on a simple flat page
doesn't scale after about a 100 interactions.  To sort out the mess,
it takes another dimension.  The project I'm working on uses a 3
dimensional visualization model that can scale and order millions of
nodes.

-- 
MarkJ
Tacoma, Washington
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ssl proxy server

2013-05-14 Thread Skip Montanaro
I haven't touched the SpamBayes setup for the usenet-to-mail gateway
in a long while.  For whatever reason, this message was either held
and then approved by the current list moderator(s), or (more likely)
slipped through unscathed.  No filter is perfect.

Skip

On Tue, May 14, 2013 at 1:40 PM, Chris “Kwpolska” Warrick
kwpol...@gmail.com wrote:
 On Tue, May 14, 2013 at 2:34 PM, 23alagmy hossamala...@gmail.com wrote:
 ssl proxy server

 hxxp://natigtas7ab.blogspot.com/2013/05/ssl-proxy-server.html
 --
 http://mail.python.org/mailman/listinfo/python-list

 I have been seeing those mails for a long time.  Why didn’t anybody
 ban that guy?  If it comes from Usenet (and headers say it does), and
 you can’t destroy stuff easily there, maybe just put a ban on the
 Mailman side of things, making the world much better for at least some
 people?
 --
 http://mail.python.org/mailman/listinfo/python-list
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Illegal seek error with seek() and os.lseek()

2013-05-14 Thread mar...@python.net
On Tue, May 14, 2013, at 03:00 PM, krishna2pra...@gmail.com wrote:
 I am trying to use os.open() and os.lseek() methods to operate on a
 device file in Linux. My code goes something like this -
 
  # first, open the file as a plain binary
  try:
  self.file = open(/dev/relpcfpga, r+b, buffering=0)
  
  except IOError:
  raise IOError ('Failed to open.')
 
  # Figure out file size
   self.file.seek(0, 2)
   self.file_size = self.file.tell()
  
 
 The method seek() complains OSError: [Errno 29] Illegal seek
 The device relpcfpga is a char device.
 
 The same code works with a normal text file.
 I have tried to use os.open() and os.lseek() methods, but see the same
 error.
 Is there a different method to operate on device files?

Some file streams are not seekable.  Specifically, some (all?) char
devices aren't seekable (because e.g. they can't be rewound or they have
no end).  You'd get the same error in C (well it would return -1).

See also: http://www.linuxintro.org/wiki/Device
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Illegal seek error with seek() and os.lseek()

2013-05-14 Thread Roy Smith
In article 50bf9366-46e0-4a7f-865b-3f7c7b0f6...@googlegroups.com,
 krishna2pra...@gmail.com wrote:

 I am trying to use os.open() and os.lseek() methods to operate on a device 
 file in Linux. My code goes something like this -
 
  # first, open the file as a plain binary
  try:
  self.file = open(/dev/relpcfpga, r+b, buffering=0)
  
  except IOError:
  raise IOError ('Failed to open.')
 
  # Figure out file size
   self.file.seek(0, 2)
   self.file_size = self.file.tell()
  
 
 The method seek() complains OSError: [Errno 29] Illegal seek
 The device relpcfpga is a char device.
 
 The same code works with a normal text file.
 I have tried to use os.open() and os.lseek() methods, but see the same error.
 Is there a different method to operate on device files?

In general, seek() works on special files, when it makes sense.  But, 
the in general part is critical.  Not all devices support the seek 
operation.  I have no idea what /dev/relpcfpga is (a google search for 
relpcfpga came up with exactly one hit -- your post!) so I can't tell 
you if it supports seek() or not.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Message passing syntax for objects | OOPv2

2013-05-14 Thread Fábio Santos
Impressive, I'd say.

On Tue, May 14, 2013 at 8:11 PM, Mark Janssen dreamingforw...@gmail.com wrote:
 Sounds a lot like reddit threads.

 It's similar, but it goes a lot further.  Where every other site
 without centralized editors, the thread mess on a simple flat page
 doesn't scale after about a 100 interactions.  To sort out the mess,
 it takes another dimension.  The project I'm working on uses a 3
 dimensional visualization model that can scale and order millions of
 nodes.

 --
 MarkJ
 Tacoma, Washington


--
Fábio Santos
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Illegal seek error with seek() and os.lseek()

2013-05-14 Thread Andreas Perstinger

On 14.05.2013 21:00, krishna2pra...@gmail.com wrote:

  # first, open the file as a plain binary
  try:
  self.file = open(/dev/relpcfpga, r+b, buffering=0)


Aren't you missing the quotes for /dev/relpcfpga?


The method seek() complains OSError: [Errno 29] Illegal seek
The device relpcfpga is a char device.


Are you sure that your device is seekable?
Try

f = open(/dev/relpcfpga, r+b, buffering=0)
print(f.seekable())

Bye, Andreas
--
http://mail.python.org/mailman/listinfo/python-list


Re: Fwd: Python for philosophers

2013-05-14 Thread DJC

On 14/05/13 09:34, Citizen Kant wrote:

2013/5/14 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info


On Tue, 14 May 2013 01:32:43 +0200, Citizen Kant wrote:


An entity named Python must be somehow as a serpent. Don't forget that
I'm with the freeing up of my memory, now I'm not trying to follow the
path of what's told but acting like the monkey and pushing with my
finger against the skin of the snake.



Python is not named after the snake, but after Monty Python the British
comedy troupe. And they picked their name because it sounded funny.



http://en.wikipedia.org/wiki/Monty_Pythonhttp://en.wikipedia.org/wiki/Monty_Python





I'm sorry to hear that. Mostly because, as an answer, seems to example
very well the taken because I've been told how things are kind of
actions, which is exactly the opposite of the point I'm trying to state.




Emanual Kant was a real piss ant
Who was very rarely stable
--
http://mail.python.org/mailman/listinfo/python-list


Re: Differences of != operator behavior in python3 and python2 [ bug? ]

2013-05-14 Thread Steven D'Aprano
On Tue, 14 May 2013 19:01:38 -0400, Dennis Lee Bieber wrote:

 On 14 May 2013 05:09:48 GMT, Steven D'Aprano
 steve+comp.lang.pyt...@pearwood.info declaimed the following in
 gmane.comp.python.general:

 The  operator comes from Pascal, where it was used as not equal
 since
 
   I thought it came from BASIC...
 http://en.wikipedia.org/wiki/Dartmouth_BASIC


Ah, well apparently BASIC used it earlier, but I don't know whether it 
was an influence on Pascal (except as what not to do).


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


weave in 64 bit strange behavior

2013-05-14 Thread Jadhav, Alok
Hi everyone,

 

I realize my previous post was quite unreadable, thanks to my email
client. I am going to report my question here, with slight enhancements.
Apologies for inconvenience caused and spamming your mailboxes.

 

I am facing a strange problem using weave on 64 bit machine.
Specifically with weave's inline function. It has something to do with
weave's catalog. 

 

Similar issues I found in the past (very old)

 

http://mail.scipy.org/pipermail/scipy-dev/2006-June/005908.html 

http://mail.scipy.org/pipermail/scipy-dev/2005-June/003042.html

 

Common things I have in my observation are:

 

-  Already working setup in 32 bit doesn't work in same manner
in 64 bit env

-  Weave recompiles inline code which does not require any
recompilation. This is random behavior.  Whenever weave recompiles I see
a notification repairing catalog by removing key in the output which
ends up in the error message ImportError: DLL load failed: Invalid
access to memory location

-  Sometimes gcc gets into an infinite loop printing error
message Looking for python27.dll. Even though the dll is on the path.
This process doesn't end. Had to kill it forcefully. G++ process became
ghost even after killing python process. 

 

Could someone advise what am I missing here. Is there any specific setup
that I need to do? Is there an issue with python 27 64 bit weave
implementation? 

 

Regards,

Alok

 

CODE

 

I have a simple script to calculate moving average using weave's inline
function. 

 

source mvg.py

 

import numpy as np

import scipy.weave as weave

import distutils.sysconfig

import distutils.dir_util

import os

 

distutils.sysconfig._config_vars[LDSHARED]=-LC:\strawberry\c\x86_64-w
64-mingw32\lib

 

def ExpMovAvg(data,time,lag):

if (data.size!=time.size):

print error in EMA, data and time have different size

return None

 

result=np.repeat(0.0,data.size)

code=

#line 66 basics.py

result(0)=data(0);

for (int i=0;idata.size()-1;i++)

{

//double alpha=1-(2.0/(lag+1)*(time(i)-time(i-1)));

double dt=time(i+1)-time(i);

double alpha=pow(0.13533, dt / lag);

if(alpha1)

{

alpha=10;

}

result(i+1)=(1-alpha)*data(i)+alpha*result(i);

}



 
weave.inline(code,[data,time,lag,result],type_converters=weave.c
onverters.blitz,headers=[math.h],compiler=gcc,verbose=2)

return result

 

source test.py

 

import string

import numpy as np

import mvg

 

print(mvg.ExpMovAvg(np.array(range(10)),np.array(range(10)),2))

 

 

Output:

 

Working output:

 

Y:\STMM\alpha\klse\PRODc:\python27\python.exe

s:\common\tools\python\python-2.7-64bit\test.py

 

[ 0.  0.  0.63212774  1.49679774  2.44701359  3.42869938

4.42196209  5.41948363  6.41857187  7.41823646]

 

Now if I keep running the script multiple times, sometimes I see correct

output... but suddenly sometimes I get below error.

 

Y:\STMM\alpha\klse\PRODc:\python27\python.exe
s:\common\tools\python\python-2.7-64bit\test.py

 

repairing catalog by removing key

weave: compiling

Looking for python27.dll

running build_ext

running build_src

build_src

building extension sc_44f3fe3c65d5c3feecb45d9269ac207f5 sources

build_src: building npy-pkg config files

Looking for python27.dll

 

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

Looking for python27.dll

customize Mingw32CCompiler

customize Mingw32CCompiler using build_ext

building 'sc_44f3fe3c65d5c3feecb45d9269ac207f5' extension

compiling C++ sources

C compiler: g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall

 

compile options: '-Ic:\python27\lib\site-packages\scipy\weave
-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz
-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\python27\include
-Ic:\python27\PC -c' 

g++ -g -DDEBUG -DMS_WIN64 -O0 -Wall
-Ic:\python27\lib\site-packages\scipy\weave
-Ic:\python27\lib\site-packages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz
-Ic:\python27\lib\site-packages\numpy\core\include -Ic:\python27\include
-Ic:\python27\PC -c
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_compiled\sc_44f3f
e3c65d5c3feecb45d9269ac207f5.cpp -o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp
iler_2d3e1e2e4de6a91419d2376b162e5342\Release\users\ajadhav2\appdata\loc
al\temp\ajadhav2\python27_compiled\sc_44f3fe3c65d5c3feecb45d9269ac207f5.
o

 

Found executable C:\strawberry\c\bin\g++.exe

g++ -g -DDEBUG -DMS_WIN64 -O0
-Wall-Ic:\python27\lib\site-packages\scipy\weave-Ic:\python27\lib\site-p
ackages\scipy\weave\scxx
-Ic:\python27\lib\site-packages\scipy\weave\blitz
-Ic:\python27\lib\site-packages\numpy\core\include-Ic:\python27\include
-Ic:\python27\PC -c
c:\python27\lib\site-packages\scipy\weave\scxx\weave_imp.cpp -o
c:\users\ajadhav2\appdata\local\temp\ajadhav2\python27_intermediate\comp

Re: Python's sad, unimaginative Enum

2013-05-14 Thread 88888 Dihedral
Chris Angelico於 2013年5月14日星期二UTC+8上午1時36分34秒寫道:
 On Mon, May 13, 2013 at 8:17 PM, Steven D'Aprano
 
 steve+comp.lang.pyt...@pearwood.info wrote:
 
  Let's look at his major criticisms:
 
 
 
  1) values aren't automatically generated.
 
 
 
  True. So what? That is the *least* important part of enums.
 
 
 
 I stopped following the -ideas threads about enums, but IIRC
 
 autogeneration of values was in quite a few of the specs early on. So
 
 you can probably find the arguments against it in the list archives.
 
 
 
 FWIW, though, I do like C's autogeneration of enum values - but use it
 
 in only a small proportion of my enums. It's not a terrible loss, but
 
 it is a loss.
 
 
 
 ChrisA

Because a hash table can replace the enums in other languages,
it is more pythonic to use a dictionary built first
to replace the enums.

I think it is the same style of programming  in perl and ruby.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python's sad, unimaginative Enum

2013-05-14 Thread rusi
On May 14, 2:24 pm, Jean-Michel Pichavant jeanmic...@sequans.com
wrote:
 - Original Message -
  On Mon, 13 May 2013 13:00:36 +0200, Jean-Michel Pichavant wrote:

   - Original Message -
   That's the title of this little beast
  http://www.acooke.org/cute/Pythonssad0.htmlif anybody's
   interested.

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

   Mark Lawrence

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

   python 2.5

   class Enum:
     class __metaclass__(type):
       def __iter__(self):
         for attr in sorted(dir(self)):
           if not attr.startswith(__):
             yield getattr(self, attr)

   class Colours(Enum):
     RED = red
     GREEN = green

  py class Experience(Enum):
  ...     NOVICE = 'novice'
  ...     GREEN = 'green'
  ...     EXPERIENCED = 'experienced'
  ...     MASTER = 'master'
  ...
  py
  py Colours.GREEN == Experience.GREEN
  True

  Oops.

  It's very easy to make something which does a few things that enums
  should do, and call it an Enum. It's much harder to do a lot of
  things
  that enums should do.

  --
  Steven

 I was just proposing a solution I've been using and found quite satisfactory. 
 As for the perfect enumness of that solution, I don't know. To be honest, 
 I'm not sure I know the exact definition of an enum, and whether or not the C 
 enum fits 100% that definition. It does the job in python. Some people may 
 find it useful, others may just ignore it.
 Additionally, the bug you mentioned can be written in C as well, casts 
 allow to compare apples and oranges:

 (Colours::GREEN == (enum Coulours::Colour)Experiences::GREEN)


Enums are like names.
And like names are impossible to do right:
http://www.kalzumeus.com/2010/06/17/falsehoods-programmers-believe-about-names/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python for philosophers

2013-05-14 Thread Ramchandra Apte
On Sunday, 12 May 2013 01:33:15 UTC+5:30, Citizen Kant  wrote:
 Hi,
 this could be seen as an extravagant subject but that is not my original 
 purpose. I still don't know if I want to become a programmer or not. At this 
 moment I'm just inspecting the environment. I'm making my way to Python (and 
 OOP in general) from a philosophical perspective or point of view and try to 
 set the more global definition of Python's core as an entity. In order to 
 do that, and following Wittgenstein's indication about that the true meaning 
 of words doesn't reside on dictionaries but in the use that we make of them, 
 the starting question I make to myself about Python is: which is the single 
 and most basic use of Python as the entity it is? I mean, beside programming, 
 what's the single and most basic result one can expect from interacting 
 with it directly (interactive mode)? I roughly came to the idea that Python 
 could be considered as an economic mirror for data, one that mainly mirrors 
 the data the programmer types on its black surface, not exactly as the 
 programmer 
 originally typed it, but expressed in the most economic way possible. That's 
to say, for example, if one types 1+1 Python reflects 2. When data 
appears between apostrophes, then the mirror reflects, again, the same but 
expressed in the most economic way possible (that's to say without the 
apostrophes).
 So, would it be legal (true) to define Python's core as an entity that 
 mirrors whatever data one presents to it (or feed it with) showing back the 
 most shortened expression of that data?
 Don't get me wrong. I can see the big picture and the amazing things that 
 programmers write on Python, it's just that my question points to the lowest 
 level of it's existence.
 Thanks a lot for your time.
I expected some spam but this actually makes some sense.

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


IndexError: pop index out of range

2013-05-14 Thread Andrew Z
hello,
 going fru some basic examples and can't figureout why the following errors
out. Help is very much appreciated:
code
def front_x(words):
  # +++your code here+++
print words passed : , words
list_xx = []
list_temp = words[:]
print list_temp -, list_temp
print words -, words
for idx, val in enumerate(words):
print val, idx
# str_idx = val.find('x',0,2)
if val[0] == 'x':
vl = list_temp.pop(idx)
list_xx.append(vl)

print appending list_xx, list_xx

list_xx.sort
list_temp.sort
print words sorted :  + str(words)
print list_temp sorted : , list_temp
list_xx.append(words)
print list_xx + str(list_xx)
return True

front_x
words passed : ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
list_temp - ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
words - ['bbb', 'ccc', 'axx', 'xzz', 'xaa']
bbb 0
ccc 1
axx 2
xzz 3
appending list_xx ['xzz']
xaa 4
Traceback (most recent call last):
  File
/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py,
line 119, in module
main()
  File
/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py,
line 100, in main
test(front_x(['bbb', 'ccc', 'axx', 'xzz', 'xaa']),
  File
/home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py,
line 55, in front_x
vl = list_temp.pop(idx)
IndexError: pop index out of range

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


RE: IndexError: pop index out of range

2013-05-14 Thread Carlos Nepomuceno
Your for idx, val in enumerate(words): is running on words not list_temp.
As you remove from list_temp and keeps parsing words you get the IndexError.

 From: form...@gmail.com 
 Date: Wed, 15 May 2013 00:22:05 -0400 
 Subject: IndexError: pop index out of range 
 To: python-list@python.org 
  
 hello, 
   going fru some basic examples and can't figureout why the following  
 errors out. Help is very much appreciated: 
 code 
 def front_x(words): 
# +++your code here+++ 
  print words passed : , words 
  list_xx = [] 
  list_temp = words[:] 
  print list_temp -, list_temp 
  print words -, words 
  for idx, val in enumerate(words): 
  print val, idx 
  # str_idx = val.find('x',0,2) 
  if val[0] == 'x': 
  vl = list_temp.pop(idx) 
  list_xx.append(vl) 
  
  print appending list_xx, list_xx 
  
  list_xx.sort 
  list_temp.sort 
  print words sorted :  + str(words) 
  print list_temp sorted : , list_temp 
  list_xx.append(words) 
  print list_xx + str(list_xx) 
  return True 
  
 front_x 
 words passed : ['bbb', 'ccc', 'axx', 'xzz', 'xaa'] 
 list_temp - ['bbb', 'ccc', 'axx', 'xzz', 'xaa'] 
 words - ['bbb', 'ccc', 'axx', 'xzz', 'xaa'] 
 bbb 0 
 ccc 1 
 axx 2 
 xzz 3 
 appending list_xx ['xzz'] 
 xaa 4 
 Traceback (most recent call last): 
File  
 /home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py,  
 line 119, in module 
  main() 
File  
 /home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py,  
 line 100, in main 
  test(front_x(['bbb', 'ccc', 'axx', 'xzz', 'xaa']), 
File  
 /home/az/work/Python/Google_Course/google-python-exercises/basic/list1.py,  
 line 55, in front_x 
  vl = list_temp.pop(idx) 
 IndexError: pop index out of range 
  
 /code 
  
 -- http://mail.python.org/mailman/listinfo/python-list
   
-- 
http://mail.python.org/mailman/listinfo/python-list


[issue9338] argparse optionals with nargs='?', '*' or '+' can't be followed by positionals

2013-05-14 Thread paul j3

paul j3 added the comment:

I need to make one correction to my last post:

'-x 1 2 -w 3 4 5 6',   # w:3, x:[1,2], y:4, z:[5,6] +
   # w:3, x:[1], y:2, z:[4,5,6] -

The second solution is only possible if 'z' is not consumed when 'y' is being 
processed.  In current version, if consume_positionals() is called with a 
'AO' pattern, 'y' will match the first 'A', and 'z' will match ''.  That 
means '4 5 6' will be left over.

It's only when I use the patch in http://bugs.python.org/issue14191#msg187051
(argparse doesn't allow optionals within positionals)
that the processing 'z' is delayed, so it can get [4,5,6].

So at least with the 4 arguments in this example, bethard's idea only seems to 
make a difference in the case of '-w 1 -x 2 3 4 5', where 'y' lays claim to the 
last string, and '-x' gets the rest.

--

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



[issue17973] '+=' on a list inside tuple both succeeds and raises an exception

2013-05-14 Thread Andy Chugunov

New submission from Andy Chugunov:

At the same time append() succeeds silently, while simple '+' fails.

Here's an example:
 a = ([1],)
 a[0].append(2)
 a
([1, 2],)
 a[0] += [3]
Traceback (most recent call last):
  File pyshell#47, line 1, in module
a[0] += [3]
TypeError: 'tuple' object does not support item assignment
 a
([1, 2, 3],)
 a[0] = a[0] + [4]
Traceback (most recent call last):
  File pyshell#49, line 1, in module
a[0] = a[0] + [4]
TypeError: 'tuple' object does not support item assignment
 a
([1, 2, 3],)
 

Looks like a self-contradictory behavior. Unfortunately, I'm not yet advanced 
enough to figure out where the problem might be and submit a fix.

Tested with v3.3.1 on Windows 7 (64-bit), and v3.2.3 and v2.7.3 on Debian 7 
(also 64-bit).

--
messages: 189201
nosy: andy.chugunov
priority: normal
severity: normal
status: open
title: '+=' on a list inside tuple both succeeds and raises an exception
type: behavior
versions: Python 2.7, Python 3.3

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



[issue17973] '+=' on a list inside tuple both succeeds and raises an exception

2013-05-14 Thread Ronald Oussoren

Changes by Ronald Oussoren ronaldousso...@mac.com:


--
assignee:  - ronaldoussoren

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



[issue17973] '+=' on a list inside tuple both succeeds and raises an exception

2013-05-14 Thread Ronald Oussoren

Ronald Oussoren added the comment:

This is a side effect to the way the in place operators work.

Basically a[0] += [3] is evaluated as:

a[0] = a[0].__iadd__([3])

The call to __iadd__ succeeds, which is why the list is updated, but you get an 
exception when the interpreter tries to update item 0 of the tuple.

--
nosy: +ronaldoussoren

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



[issue17973] '+=' on a list inside tuple both succeeds and raises an exception

2013-05-14 Thread Ronald Oussoren

Ronald Oussoren added the comment:

I'm closing this issue as rejected because the current behavior is intentional, 
although it is confusing (IMO).

--
resolution:  - rejected
status: open - closed

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



[issue17973] '+=' on a list inside tuple both succeeds and raises an exception

2013-05-14 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
nosy: +flox

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



[issue17128] OS X system openssl deprecated - installer should build local libssl

2013-05-14 Thread Ronald Oussoren

Ronald Oussoren added the comment:

The RVM issue is wrong, ML still includes OpenSSL. Apple has deprecated the use 
of the system install of OpenSSL, but the library and include files are still 
there.

There are two paths for avoiding the deprecated library: either ship your own 
build of OpenSSL, or (and that's probably what Apple would prefer) use the 
Apple specific frameworks (common crypto and/or security transforms). 

The latter has the advantage of using the security infrastructure, such as the 
CA chain, as provided by Apple, but would require significant code changes in 
Python, might take even more work to get to work properly on OSX 10.6 or 
earlier (and cannot work on 10.4), and might cause problems with scripts that 
use os.fork() because a number of core Apple frameworks won't work properly in 
the child process and cause a hard crash when they were initialized in the 
parent and then used in a child.

All in all it would be better to ship a recent version of OpenSSL with the 
binary installers on OSX.

--

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



[issue16531] Allow IPNetwork to take a tuple

2013-05-14 Thread Kiyoshi Aman

Kiyoshi Aman added the comment:

I would instead suggest a cidr or netmask kwarg, rather than accepting a tuple 
as first argument.

--
nosy: +Kiyoshi.Aman

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



[issue17969] multiprocessing crash on exit

2013-05-14 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Catching regressions is what we have the regression tests for.  If it is not in 
caught by the regression tests, then it is not a regression, by definition.
Bug fix mode is for fixing bugs, IMHO.
Yes, I have patched my local version.  The reason I am here having this 
discussion is that I want to contribute to help others that are using 2.7 for 
multiprocessing.  Others will have the same problem, and probably have, already.

Anyway, I cannot easily reproduce the problem, it happens regularly in a live 
production environment.  My patch is a conjecture based patch.

But I actually had a different thought about how to handle this.
The particular manifestation of this error occurs because an exception state is 
being cleared from the system dict.  The dict contains a frame and there is 
where the connection object is being held.
The problem can be avoided, by clearing the exception right at the start of the 
PyInterpreterState_Clear(), thus flushing out most side effects right at the 
start.

I'll prepare a patch for you to review.

--

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



[issue17950] Dynamic classes contain non-breakable reference cycles

2013-05-14 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Thanks Guido.
The current patch provides the property you ask for.  I will see if I can make 
the fiddling of the internal tuple less magical.

I have one other question for you:  The standard mro puts the class in the 
0th position.
But apparently, there is a mechanism for a custom mro, by calling an mro() 
function on the type (as far as I understand).
However, the order of objects in the returned tuple is not verified, only the 
types of the objects therein (this is in mro_internal())
Yet there is code that manually skips the 0th element, e.g. this code 

/* Initialize tp_dict properly */
bases = type-tp_mro;
assert(bases != NULL);
assert(PyTuple_Check(bases));
n = PyTuple_GET_SIZE(bases);
for (i = 1; i  n; i++) {
PyObject *b = PyTuple_GET_ITEM(bases, i);
if (PyType_Check(b))
inherit_slots(type, (PyTypeObject *)b);
}
(from PyType_Ready())

I'm not familiar with the mro() function.  What kind of black magic is it 
supposed to provide?  And how can we make sure that its free-form return value 
is reconciled with the 1-based loop above?

--

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



[issue17969] multiprocessing crash on exit

2013-05-14 Thread Richard Oudkerk

Richard Oudkerk added the comment:

Kristjan, could you confirm whether joining the pool explicitly before shutdown 
(in the way I suggested earlier) fixes the problem.  I think it should -- at 
shutdown you won't switch to a thread if it has already been joined.

--

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



[issue17969] multiprocessing crash on exit

2013-05-14 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Catching regressions is what we have the regression tests for.  If it
 is not in caught by the regression tests, then it is not a
 regression, by definition.

Call it what you want :-) The bottom line is that we'll release a
2.7.5 soon because of breakage introduced in 2.7.4. Whether or not
it's a regression according to some platonic definition isn't
very important here.

 The problem can be avoided, by clearing the exception right at the
 start of the PyInterpreterState_Clear(), thus flushing out most side
 effects right at the start.
 
 I'll prepare a patch for you to review.

I think this kind of stuff is too tricky to risk breaking 2.7
once again with it.
If 3.x has the same issue, then a patch is helpful, otherwise not IMHO.

--

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



[issue1772673] Replacing char* with const char*

2013-05-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

In C++ we may overload functions for backward compatibility:

PyAPI_FUNC(int) PyArg_ParseTupleAndKeywords(PyObject *, PyObject *,
const char *, const char * const *, ...);
PyAPI_FUNC(int) PyArg_VaParseTupleAndKeywords(PyObject *, PyObject *,
const char *, const char * const *, va_list va);
...
#ifdef __cplusplus
inline int
PyArg_ParseTupleAndKeywords(PyObject *args, PyObject *keywords,
const char *format, char * const *kwlist, ...)
{
int retval;
va_list va;
va_start(va, kwlist);
retval = PyArg_ParseTupleAndKeywords(args, keywords, format,
(const char * const *)kwlist, va_start);
va_end(va);
return retval;
}
#endif

--
nosy: +serhiy.storchaka

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



[issue17969] multiprocessing crash on exit

2013-05-14 Thread Charles-François Natali

Charles-François Natali added the comment:

 Catching regressions is what we have the regression tests for.  If it is not 
 in caught by the regression tests, then it is not a regression, by definition.

You do realize this sentence doesn't make sense, do you?

--

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



[issue17974] Migrate unittest to argparse

2013-05-14 Thread Antoine Pitrou

New submission from Antoine Pitrou:

Attached patch migrates unittest to argparse.
This doesn't make discover handling much saner, given the awful way it's 
originally implemented.

--
components: Library (Lib)
files: unittest_argparse.patch
keywords: patch
messages: 189212
nosy: ezio.melotti, michael.foord, pitrou
priority: normal
severity: normal
stage: patch review
status: open
title: Migrate unittest to argparse
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file30256/unittest_argparse.patch

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



[issue17974] Migrate unittest to argparse

2013-05-14 Thread Michael Foord

Michael Foord added the comment:

What's the benefit of this change?

--

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



[issue14596] struct.unpack memory leak

2013-05-14 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't think Serhiy's patch should be blocked by a larger issue. I suppose you 
could rebase easily over his changes.

--
versions: +Python 3.4 -Python 2.7, Python 3.2, Python 3.3

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



[issue17974] Migrate unittest to argparse

2013-05-14 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I was considering making it possible to customize command-line options, as 
requested by Guido, and it's better to expose the modern API rather than the 
more obsolete one.

--

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



[issue16024] Doc cleanup regarding path=fd, dir_fd, follow_symlinks, etc

2013-05-14 Thread A.M. Kuchling

A.M. Kuchling added the comment:

Kaleb Robertson's changes look good.  Larry, do you want to go ahead and commit 
this?

--

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



[issue17974] Migrate unittest to argparse

2013-05-14 Thread Michael Foord

Michael Foord added the comment:

Ok, feel free to reimplement discovery command line handling if it can be done 
in a compatible-but-less-horrible way. Anyway, the patch looks fine and a 
couple of minor cleanups in there.

--

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



[issue17974] Migrate unittest to argparse

2013-05-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I don't see much sense in this modernization, while the code does not use the 
capabilities of argparse (and even optparse). Why 
USAGE_AS_MAIN/USAGE_FROM_MODULE/etc exist, why help is not generated 
automatically? Why -v/-q store boolean flags instead of changing the numerical 
level of verbosity?

--
nosy: +serhiy.storchaka

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



[issue17969] multiprocessing crash on exit

2013-05-14 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Richard, I'll review implement your change.  It is a bit tricky to test this, 
since I can only tell after a few days if the particular (rare) problem has 
been fixed.  The crash is a rare one but consistently happens with some 
probability we use multiprocessing to perform certain batch processing.

About regressions:  The term means that problems, previously fixed, become 
broken again.  All fixes should reasonably have appropriate tests in the 
regression test suite.

I don't know what particular regressions you have been battling since 2.7.4.  
I hope they are all testable by now.
I only know that there is a exit problem with multiprocessing that 
statistically happens and is problemematic.  It caused use to stop using 
multiprocessing and parallel jobs until I could diagnose the problem.  I have 
suggested several fixes to this particular problem.

I have two favorites, which would also help in the general case:
1) calling sys.exc_clear() at the beginning of the python finalize part, to 
throw out any lingering traceback and frame objects.  This will cause side 
effects such as gil-twiddling to happen early, and without consequence.  
sys.exc_clear() is a safe api and used throughout the code, an extra call just 
prior to exit should be a very safe operation.
2) Turn off multi-threading at the start of python exit, by setting 
interpreter_lock to NULL.  Again, this is a no-brainer, since the NULL value is 
already well defined and works well.  It will cause all subsequent GIL releases 
to be no-ops.

I personally favor the second one.  It makes no sense to allow other threads to 
run after finalization has started and forcing them to stay dead is only 
prudent.

2.7 is not frozen, and it is in bug fix mode.  If a solid bug fix to an actual 
problem is proposed, we should embrace it, and deal with any eventual fallout 
appropriate as the price of doing business.  2.7 is a product that is alive and 
well, used by millions of people and thousands of businesses and will remain so 
for quite some time.  I know that most of the core devs have moved on to 
greener pastures, but I for one would like to stay loyal to this workhorse of a 
product and continue to make necessary improvements to it.

--

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



[issue17974] Migrate unittest to argparse

2013-05-14 Thread Michael Foord

Michael Foord added the comment:

Test discovery and new options (buffer, failfast etc) were bolted onto an old 
and ugly design. Yes the code could use an overhaul and rebuilding from scratch 
- but doing that whilst remaining fully compatible with all the existing usage 
patterns is difficult.

--

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



[issue17974] Migrate unittest to argparse

2013-05-14 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
nosy: +barry

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



[issue17969] multiprocessing crash on exit

2013-05-14 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Richard, reading the multiprocessing.py code, it appears that your suggestion 
of closign and joining the Pool() object should also do the trick.  Doing that 
will certainly also fix this particular case.  I'll implement that in our local 
application code.

I'm still not happy that 2.7 has a potential exit crash if a daemon thread is 
left hanging :(

--

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



[issue17955] Minor updates to Functional HOWTO

2013-05-14 Thread A.M. Kuchling

A.M. Kuchling added the comment:

Updated version of the patch:

* uses 'r' instead of 'N'.
* removes the old outline and some notes at the end.
* minor rewriting.

--
Added file: http://bugs.python.org/file30257/functional.txt

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



[issue11245] Implementation of IMAP IDLE in imaplib?

2013-05-14 Thread Dmitry Shachnev

Changes by Dmitry Shachnev mity...@gmail.com:


--
nosy: +mitya57

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



[issue17975] libpython3.so conflicts between $VERSIONs

2013-05-14 Thread Patrick Welche

New submission from Patrick Welche:

I currently have python 2.7 and 3.2 installed concurrently. I just tried to 
install 3.3 as well, but a file conflicts between 3.2 and 3.3. It is 
libpython3.so.

Given that we go out of our way e.g. with

$(INSTALL_DATA) Misc/python.pc $(DESTDIR)$(LIBPC)/python-$(VERSION).pc

to avoid clashes, what should be done about PY3LIBRARY?

--
components: Build
messages: 189223
nosy: prlw1
priority: normal
severity: normal
status: open
title: libpython3.so conflicts between $VERSIONs
type: behavior
versions: Python 3.3

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



[issue17927] Argument copied into cell still referenced by frame

2013-05-14 Thread Guido van Rossum

Guido van Rossum added the comment:

Would you mind doing the backport then?

--

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



[issue17970] Mutlithread XML parsing cause segfault

2013-05-14 Thread Christian Heimes

Christian Heimes added the comment:

In my opinion it's fine to document Python's XML parser as not thread-safe and 
leave locking to the user. Any fancy locking or tracking is going to make it 
slower for users. Any it takes a lot of effort to implement the feature, too. 
lxml offers a faster XML parser with multi-threading support.

--
nosy: +christian.heimes

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



[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Jaakko Moisio

New submission from Jaakko Moisio:

file.write doesn't sometimes raise IOError when it should, e.g. writing to 
/dev/full in line buffered mode:

jaakko@jm-laptop:~$ python
Python 2.7.5+ (2.7:a32a3b79f5e8, May 14 2013, 14:20:11) 
[GCC 4.7.2] on linux2
Type help, copyright, credits or license for more information.
 f=open('/dev/full','w',1)
 f.write('hello\n')
Traceback (most recent call last):
  File stdin, line 1, in module
IOError: [Errno 28] No space left on device
 f.close()
 f=open('/dev/full','w',1)
 f.write('hello')
 f.write('\n')
 f.close()
 # No IOError!
... 
 

The current implementation of file.write relies on comparing the return value 
of fwrite to the expected number of bytes written to detect errors. I haven't 
dug deep enough into the C standard to know for sure if fwrite return value == 
expected should always imply no error, but in my example it clearly doesn't (I 
assume my glibc and fwrite aren't broken though). However using ferror to 
detect the error works fine and IOError was raised as expected.

Python3 and io module use different implementation where this is no longer an 
issue. For us still using Python 2.7 I suggest the attached simple patch to fix 
the issue.

--
components: Interpreter Core
files: fileobject-fix.patch
keywords: patch
messages: 189226
nosy: jasujm
priority: normal
severity: normal
status: open
title: file.write doesn't raise IOError when it should
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file30258/fileobject-fix.patch

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



[issue17922] Crash in clear_weakref

2013-05-14 Thread Jan Safranek

Jan Safranek added the comment:

On 05/09/2013 09:07 AM, Jan Safranek wrote:
 
 Jan Safranek added the comment:
 
 On 05/07/2013 05:32 PM, Antoine Pitrou wrote:
 Jan, one possibility would be for Pegasus to stop unloading Python,
 it seems.
 
 It is always possibility. Actually, Pegasus plugin is just a shared
 object (.so) and the .so is linked with Python. Pegasus calls dlopen()
 and dlclose() on it. After dlclose(), the plugin is removed from
 memory. Unfortunately, libpython2.7.so stays loaded, at least
 /proc/XXX/mems says so. If there was a way to unload libpython2.7.so
 from memory too...

libpython2.7.so is not unloaded because python extensions, e.g.
/usr/lib64/python2.7/lib-dynload/_heapq.so depend on it. And _heapq.so
was dlopenened by Python and it was not dlclosed - glibc does not
unload it.

It seems that Py_Finalize() does not even close opened shared objects.
Isn't it a bug?

Jan

--

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



[issue17977] urllib.request.urlopen() cadefault argument is documented with wrong default value

2013-05-14 Thread Barry A. Warsaw

New submission from Barry A. Warsaw:

The docs[1] say:

.. function:: urlopen(url, data=None[, timeout], *, cafile=None, capath=None, 
cadefault=True)

The code[2] says:

def urlopen(url, data=None, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
*, cafile=None, capath=None, cadefault=False):

Obviously, the code cannot be changed in a stable release, and whether the 
default should be changed for 3.4 is a separate discussion.  For now, the docs 
should be fixed to reflect the code.

[1] Doc/library/urllib.request.rst
[2] Lib/urllib/request.py

--
assignee: barry
components: Documentation
messages: 189228
nosy: barry
priority: normal
severity: normal
status: open
title: urllib.request.urlopen() cadefault argument is documented with wrong 
default value
type: behavior
versions: Python 3.3, Python 3.4

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



[issue17977] urllib.request.urlopen() cadefault argument is documented with wrong default value

2013-05-14 Thread Roundup Robot

Roundup Robot added the comment:

New changeset e2288953e9f1 by Barry Warsaw in branch '3.3':
- Issue #17977: The documentation for the cadefault argument's default value
http://hg.python.org/cpython/rev/e2288953e9f1

New changeset 85ecc4761a6c by Barry Warsaw in branch 'default':
- Issue #17977: The documentation for the cadefault argument's default value
http://hg.python.org/cpython/rev/85ecc4761a6c

--
nosy: +python-dev

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



[issue17977] urllib.request.urlopen() cadefault argument is documented with wrong default value

2013-05-14 Thread Barry A. Warsaw

Changes by Barry A. Warsaw ba...@python.org:


--
resolution:  - fixed
status: open - closed

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



[issue17936] O(n**2) behaviour when adding/removing classes

2013-05-14 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Yes, thanks for pointing that out, Antoine, I have made the change locally.

--

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



[issue17950] Dynamic classes contain non-breakable reference cycles

2013-05-14 Thread Armin Rigo

Armin Rigo added the comment:

Well, adding weak references left and right to break cycles is going to subtly 
change or break people's code and hasn't been done so far, but that's only my 
opinion.  Anyway, I want to correct what you say about tp_subclasses: yes, 
tp_subclasses is a list of weakrefs, but the reason is not (as I think you 
mean) to avoid cycles.  The reason is simply that if it were strong references, 
then all classes ever created would stay alive.

--
nosy: +arigo

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



[issue17970] Mutlithread XML parsing cause segfault

2013-05-14 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

In my opinion it's not fine to let Python crash.
The implementation could be similar to the one in bufferedio.c, it's quite 
lightweight.

--

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



[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Charles-François Natali

Charles-François Natali added the comment:

 I assume my glibc and fwrite aren't broken though

Actually, it's a glibc bug when the last character is a '\n':

$ python -c f = open('/dev/full', 'w', 1); f.write('hello'); f.close()
Traceback (most recent call last):
  File string, line 1, in module
IOError: [Errno 28] No space left on device

Normal.

Now, you add a trailing newline:
$ strace -e write python -c f = open('/dev/full', 'w', 1); f.write('hello'); 
f.write('\n'); f.close()
write(3, hello\n, 6)  = -1 ENOSPC (No space left on device)

write() still returns ENOSPC, but it gets ignored by fwrite().

I've had a quick look at the source, and I think the culprit is here:
http://sourceware.org/git/?p=glibc.git;a=blob;f=libio/fileops.c#l1270

1336   if (do_write)
1337 {
1338   count = new_do_write (f, s, do_write);
1339   to_do -= count;
1340   if (count  do_write)
1341 return n - to_do;
1342 }

It looks like there's a check missing here for count  0.

--
nosy: +neologix

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



[issue14596] struct.unpack memory leak

2013-05-14 Thread Meador Inge

Meador Inge added the comment:

 I don't think Serhiy's patch should be blocked by a larger issue.
 I suppose you could rebase easily over his changes.

Where rebase=undo, sure.  The changes for issue3132 are pretty
extensive (the basic data structures are changed).  And as mentioned
in msg165892, msg188840, and msg125617 I have already proposed and
implemented this optimization many months back.

If we feel that this optimization is really critical, then I agree
let's not hold it up and I will just work around it with my patch for
issue3132.  I don't see it as that critical, but I understand that the
PEP 3118 changes are dragging on and this optimization might be important
for some now.

--

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



[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Indeed, fwrite() can return expected number of items and set errno. Here is a 
simple example on C. An output is:

setvbuf 0 0
fwrite 5 0
fwrite 1 28
fwrite 1 28

On writing \n fwrite returns 1 and set errno to ENOSPC.

--
nosy: +serhiy.storchaka
Added file: http://bugs.python.org/file30259/fullwrite.c

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



[issue17974] Migrate unittest to argparse

2013-05-14 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Ok, feel free to reimplement discovery command line handling if it can
 be done in a compatible-but-less-horrible way.

I don't think it's possible. Best way forward would be to provide a
pytest utility that does discovery automatically, and leave python -m
unittest as the lesser, undocumented option.

--

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



[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Charles-François Natali

Charles-François Natali added the comment:

 Indeed, fwrite() can return expected number of items and set errno. Here is a 
 simple example on C. An output is:

Yeah, who's volunteering to report it to the glibc?

That's not a python bug, but I feel bad ignoring it.

Note that ferror() isn't reliable (not on my box at least), so we have to use 
errno directly.
And of course keep the check that the value returned by fwrite matches.

--
nosy: +pitrou

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



[issue17950] Dynamic classes contain non-breakable reference cycles

2013-05-14 Thread Guido van Rossum

Guido van Rossum added the comment:

Kristjan, it seems you're in over your head. :-)

The mro() function is documented here:
http://docs.python.org/3/library/stdtypes.html?highlight=mro#class.mro
It exists to be called instead of using __mro__ directly; a metaclass can then 
override what it returns.  (Though I don't know if anyone has ever done this.)

The code you quote is in PyType_Ready() and skips bases[0] because bases[0] has 
already been used as the basic template for the C-level layout of the 
instances.  This particular loop adds additional slots to the layout and (most 
importantly) verifies that no bases are in conflict with the layout enforced by 
bases[0].  (This is required because we don't actually implement virtual 
slots at this level -- the C-level layout can only extend the first base 
class's layout.)

BTW, Armin is also right about the reason for using weak references in the 
__subclasses__ list.

As for replacing references with weak references, I would be much more 
concerned if you were proposing this for e.g. bound methods or instances, but 
that doesn't mean I'm completely unconcerned...

In addition to worrying about breaking (obscure) code that might depend on 
those references, I worry that it is trying to optimize for an unusual case 
(dynamically created classes in a world where you don't want to call 
gc.collect()) but slowing down the common case (access of the class from the 
descriptor every time a descriptor is used).

Specifically about your patch, I'm pretty sure there are some calls in there 
that don't expect a NULL pointer, as d_type is never NULL; but adding the weak 
reference makes it possible that your macro will return a NULL pointer.

--

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



[issue14596] struct.unpack memory leak

2013-05-14 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Le mardi 14 mai 2013 à 16:37 +, Meador Inge a écrit :
 If we feel that this optimization is really critical, then I agree
 let's not hold it up and I will just work around it with my patch for
 issue3132.  I don't see it as that critical, but I understand that the
 PEP 3118 changes are dragging on and this optimization might be important
 for some now.

Are you sure the PEP 3118 changes will land in 3.4? It would be a pity
to lose a simple improvement because it was deferred to a bigger change.

--

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



[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Yuck. We can of course workaround this (the glibc is commonly used :-)). Why is 
ferror() not reliable?

--
priority: normal - low
stage:  - needs patch

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



[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Charles-François Natali

Charles-François Natali added the comment:

 Why is ferror() not reliable?

Because the glibc doesn't check the errno return code after the
write() syscall, and thus doesn't set the file's stream error flag
(ferror() just checks this flag).

That's what I saw from the code.

I was a little surprised when Jaako says that ferror() is enough to
detect this, so I modified Serhiy code to print ferror(), and actually
ferror() reports an error for subsequent writes, not for the first one
(probably because the error goes unnoticed only when the buffer is in
a particular state).

So in short, errno is the only reliable way to check for errors :-(

--

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



[issue17807] Generator cleanup without tp_del

2013-05-14 Thread Roundup Robot

Roundup Robot added the comment:

New changeset edefd3450834 by Antoine Pitrou in branch 'default':
Backout c89febab4648 following private feedback by Guido.
http://hg.python.org/cpython/rev/edefd3450834

--

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



[issue17807] Generator cleanup without tp_del

2013-05-14 Thread Antoine Pitrou

Antoine Pitrou added the comment:

After getting some private feedback from Guido, I'm convinced this patch isn't 
ready for consumption. Objects visible from the frame when it is finalized can 
be in a weird, incomplete state (Guido reports failing to get the __class__ of 
an object, for instance).

I'm keeping the issue open for now and will try to find further ways to solve 
the underlying problem.

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

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



[issue17128] OS X system openssl deprecated - installer should build local libssl

2013-05-14 Thread Ronald Oussoren

Ronald Oussoren added the comment:

The one difference between the system openssl and a separately compiled one is 
that the former can use the CA root from the KeyChain (and uses a private API 
to do that, as noted earlier).

I just stumbled across a utility that can sync the KeyChain to an OpenSSL CA 
file: 
https://svn.macports.org/repository/macports/trunk/dports/security/certsync/files/certsync.m,
 and a blog message at 
http://landonf.bikemonkey.org/code/macosx/certsync.20130514.html

--

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



[issue17922] Crash in clear_weakref

2013-05-14 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Le mardi 14 mai 2013 à 15:28 +, Jan Safranek a écrit :
 libpython2.7.so is not unloaded because python extensions, e.g.
 /usr/lib64/python2.7/lib-dynload/_heapq.so depend on it. And _heapq.so
 was dlopenened by Python and it was not dlclosed - glibc does not
 unload it.
 
 It seems that Py_Finalize() does not even close opened shared objects.
 Isn't it a bug?

What do you call shared objects in this context? .so files?
Indeed they are not closed, because usually extension modules are not
reload-safe: therefore, their basic structures are kept eternally once
initialized.

--

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



[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Jaakko Moisio

Jaakko Moisio added the comment:

Thank you for your comments.

 I was a little surprised when Jaako says that ferror() is enough to
 detect this, so I modified Serhiy code to print ferror(), and actually
 ferror() reports an error for subsequent writes, not for the first one
 (probably because the error goes unnoticed only when the buffer is in
 a particular state).

Strange. I too modified Serchiy's code and my version of glibc (2.15) set the 
error flag at the same fwrite call as errno was set:

setvbuf 0 0 0
fwrite 5 0 0
fwrite 1 28 1
fwrite 1 28 1

(the last column being the return value of ferror after each fwrite call)

I've trusted ferror until now but I'm not an expert on the subject. It's a good 
point that errno is set by the underlying system call and is thus more 
reliable. So would checking errno be sufficient (in addition to checking that 
the lengths agree)? It can only serve to make file_write more robust.

--
Added file: http://bugs.python.org/file30260/fileobject-fix2.patch

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



[issue17950] Dynamic classes contain non-breakable reference cycles

2013-05-14 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Armin:  Of course you are right.  This is what weak references are for, in a gc 
world, although their convenience to avoid cycles and enable reference counting 
to work always makes me forget.

I have another ongoing issue regarding tp_subclasses, btw, in issue #17936.

Guido: Yes, it is complicated.  The reason I am doing this is because I'm 
working to incorporate these changes in our stackless 2.7 branch.  I figured 
this might be useful to Python at large, hence this submission.  relying on gc 
is not an option when using python in a performance sensitive environment.  
there are a few places in the core that cause cycles and I'm always keen to try 
to remove those.  Of course we can avoid the dynamic creation of classes, which 
is perhaps somewhat exotic.  But it is a simpler problem than the reference 
cylcle inherent in recursive closures.  I had a crack at that a week ago and 
ran in to a wall, so I thought I'd set myself an easier target :)

Thanks for clarifying mro().  What I was driving at was that without mro(), 
then type == type-tp_mro[0].  and knowing this, it is easy to put a None in 
tp_mro[0].  With a custom mro(), this restriction is no longer valid.  But my 
patch deals with this by verifying the assumption.  So, there is no big problem 
there.

I hear you worry a bit about performance for descriptors.  Performance is 
indeed a valid concern, but Im not sure that an extra C indirection will show 
up on any readings, given that the next thing that happens is typically the 
creation of a bound method or the like, with all the stuff that entails.

I am not too worried about possibly returning NULL.  That's a technical detail 
that is fixable.
A much better question is whether this is worth doing at all because the 
practice I'm trying to optimize is probably a rare practice as you point out.  
When do you truly need to create throwaway classes?  Most places that do are 
simply defining classes in a function scope as a means of name scoping, not 
realizing that each function invocation will create a unique metaclass instance 
and cost a non-trivial amount of cpu.

So, after this interesting sojourn into the bowels of typeobject.c, and these 
most enlightening discussions with you (Armin, Guido, Antoine) I don't think 
I'll pursue this any further.

Cheers!

--

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



[issue17950] Dynamic classes contain non-breakable reference cycles

2013-05-14 Thread Guido van Rossum

Guido van Rossum added the comment:

Good call. I think it's perfectly fine for you to do this in your custom 2.7 
branch. It feels too fragile to adopt the same approach for Python 3.4 though.

--
status: open - closed

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



[issue14596] struct.unpack memory leak

2013-05-14 Thread Meador Inge

Meador Inge added the comment:

 Are you sure the PEP 3118 changes will land in 3.4? It would be a pity
 to lose a simple improvement because it was deferred to a bigger
 change.

No, I am not sure.  That is why I said that I understand if others felt
this bug was critical to fix now since the PEP 3118 changes were dragging
on.  In that case I will just rework my patch.

I am not trying to stand in the way of this patch.  I just wanted folks
to be aware that this approach was implemented in the PEP 3118 work.

--

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



[issue17978] Python crashes if Py_Initialize/Py_Finalize are called multiple times

2013-05-14 Thread Romulo A. Ceccon

New submission from Romulo A. Ceccon:

I have patched (see attachment) Python 2.7.4 (as available for download at 
python.org/download) to disable initialization of Unicode (an embeded system 
requirement) and now it segfaults with the following program:

#include Python.h

int main(int argc, char** argv)
{
  int i;
  Py_NoSiteFlag = 1;

  Py_SetProgramName(argv[0]);

  for (i = 0; i  3; i++)
  {
printf(run no. %d\n, i);

Py_Initialize();
Py_Finalize();
  }

  return 0;
}

The problem appears to be related with the reference count of the empty tuple. 
I've also applied the following patch in Objects/tupleobject.c to help diagnose 
the problem:

@@ -928,6 +928,8 @@ PyTuple_Fini(void)
 #if PyTuple_MAXSAVESIZE  0
 /* empty tuples are used all over the place and applications may
  * rely on the fact that an empty tuple is a singleton. */
+printf(free_list[0]-ob_refcnt before XDECREF: %d\n,
+free_list[0]-ob_refcnt);
 Py_XDECREF(free_list[0]);
 free_list[0] = NULL;

*Without* the patch for Python/pythonrun.c the program produces the following 
results under Ubuntu 13.04 x64:

run no. 0
free_list[0]-ob_refcnt before XDECREF: 58
run no. 1
free_list[0]-ob_refcnt before XDECREF: 57
run no. 2
free_list[0]-ob_refcnt before XDECREF: 57

Note the strange ref count of the empty tuple (free_list[0]). Now, *with* the 
patch, the application will not hold so many references to the empty tuple and 
the finalization code ends up trying to deallocate it (what, from my limited 
understading of the code, is not supposed to happen):

run no. 0
free_list[0]-ob_refcnt before XDECREF: 2
run no. 1
free_list[0]-ob_refcnt before XDECREF: 1
Segmentation fault (core dumped)

The actual patch I'm using is much more complicated. This is just the minimal 
patch able to reproduce the problem. I tried undefining Py_USING_UNICODE but 
then the build doesn't succeed.

--
components: Interpreter Core
files: pythonrun.c.patch
keywords: patch
messages: 189250
nosy: Romulo A. Ceccon
priority: normal
severity: normal
status: open
title: Python crashes if Py_Initialize/Py_Finalize are called multiple times
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file30261/pythonrun.c.patch

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



[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Charles-François Natali

Charles-François Natali added the comment:

 Strange. I too modified Serchiy's code and my version of glibc (2.15) set the 
 error flag at the same fwrite call as errno was set:

 setvbuf 0 0 0
 fwrite 5 0 0
 fwrite 1 28 1
 fwrite 1 28 1

 (the last column being the return value of ferror after each fwrite call)

Hum, you're right, I just re-ran the test, and I'm finding the same
thing as you (I must have been dreaming).

I just re-checked the glibc code, and indeed the write() error is
checked, and the error flag is set:
http://sourceware.org/git/?p=glibc.git;a=blob;f=libio/fileops.c#l1255
1241 _IO_ssize_t
1242 _IO_new_file_write (f, data, n)
[...]
1251   count = (__builtin_expect (f-_flags2
1252   _IO_FLAGS2_NOTCANCEL, 0)
1253? write_not_cancel (f-_fileno, data, to_do)
1254: write (f-_fileno, data, to_do));
1255   if (count  0)
1256 {
1257   f-_flags |= _IO_ERR_SEEN;
1258   break;
1259 }

But then this value is returned, and depending on the position in the
buffer, this -1 ends up being incremented to what's left to write, and
can result in returning exactly the same size that was requested.

That's definitely a bug, and a bad one since you can get silent
corruption (fclose() won't even return an error in most cases).

Anyway, this means that ferror() should be enough - in addition to
checking that the returned value matches.

 I've trusted ferror until now but I'm not an expert on the subject. It's a 
 good point that errno is set by the underlying system call and is thus more 
 reliable. So would checking errno be sufficient (in addition to checking that 
 the lengths agree)? It can only serve to make file_write more robust.

Yeah, would you like to write a patch?

--

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



[issue16611] multiple problems with Cookie.py

2013-05-14 Thread Éric Araujo

Éric Araujo added the comment:

I have just been bitten by a bug (haven’t checked if it’s covered by the added 
tests) where Cookies uses string.translate incorrectly:

  File /usr/lib/python2.7/Cookie.py, line 323, in _quote
if  == translate(str, idmap, LegalChars):
  File /usr/lib/python2.7/string.py, line 493, in translate
return s.translate(table, deletions)
TypeError: translate() takes exactly one argument (2 given)

The state of the Cookie module is quite embarrassing.

--
nosy: +eric.araujo

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



[issue17976] file.write doesn't raise IOError when it should

2013-05-14 Thread Jaakko Moisio

Jaakko Moisio added the comment:

 Yeah, would you like to write a patch?

Yes. It's fileobject-fix3.patch attached to this issue record.

--
Added file: http://bugs.python.org/file30262/fileobject-fix3.patch

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



[issue17974] Migrate unittest to argparse

2013-05-14 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch which reimplement discovery command line handling in a 
i-hope-in-compatible-but-less-horrible way (and fixes some bugs). It is 
horrible still, but I doubt how many changes can I do without breaking 
compatibility. If _do_discovery() used only in tests, I can clean the code more.

I suppose discovery mode doesn't make sense when unittest.main() is called from 
a test module (i.e. ./python Lib/test/test_bisect.py discover). At least 
USAGE_FROM_MODULE did not mention this mode.

--
Added file: 
http://bugs.python.org/file30263/unittest_argparse_less_horrible.patch

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



[issue17979] Cannot build 2.7 with --enable-unicode=no

2013-05-14 Thread Amaury Forgeot d'Arc

New submission from Amaury Forgeot d'Arc:

python2.7 can't be compiled with --enable-unicode=no
Because of a crash in the re module. It's a regression from 2.7.3.

$ ./python -c 'import re; re.compile(([a-zA-Z][a-zA-Z0-9_]+)\s*=\s*(.*))'
Traceback (most recent call last):
  File string, line 1, in module
  File /home/amauryfa/python/cpython2.7/Lib/re.py, line 190, in compile
return _compile(pattern, flags)
  File /home/amauryfa/python/cpython2.7/Lib/re.py, line 240, in _compile
p = sre_compile.compile(pattern, flags)
  File /home/amauryfa/python/cpython2.7/Lib/sre_compile.py, line 533, in 
compile
groupindex, indexgroup
RuntimeError: invalid SRE code


The cause is in sre.h: when Py_USING_UNICODE is false, SRE_CODE is defined as 
unsigned long instead of unsigned short!

When this is fixed, the following modules did not compile:
_io _json _sqlite3 _ssl _testcapi
Which modules are supposed to work without unicode?

--
assignee: serhiy.storchaka
messages: 189255
nosy: amaury.forgeotdarc, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Cannot build 2.7 with --enable-unicode=no
versions: Python 2.7

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



[issue17978] Python crashes if Py_Initialize/Py_Finalize are called multiple times

2013-05-14 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

The official way to build without unicode is
  ./configure --enable-unicode=no
But see issue17979.

--
nosy: +amaury.forgeotdarc

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




[issue17977] urllib.request.urlopen() cadefault argument is documented with wrong default value

2013-05-14 Thread Senthil Kumaran

Senthil Kumaran added the comment:

OMG. That's a glaring mistake. Thanks for fixing it.

--
nosy: +orsenthil

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



  1   2   >