GOZERBOT 0.99.0 RELEASED

2011-10-05 Thread Bart Thate
Hello world and everybody !

i'm pleased to announce the release of GOZERBOT 0.99.0, the first in a
series of releases that are supposed to lead to a proper 1.0 release
for GOZERBOT. The intention is to get a 1.0 version of GOZERBOT
available for users that still use this bot, got almost 2000 download
of 0.9.2 so its worth to support all those users with a release they
can build on. I dont have the intention to develop GOZERBOT any
further beyond that, that's what JSONBOT is all about, so keep in mind
these are pure maintenance releases.

2 major changes crept into this release, namely:

* no more seperate gozerplugs package, its all wrapped into 1 thing.
The gozerplugs package has find its way under the gplugs directory in
the main distro so no more seperate installing of plugins.
* SQLAlchemy is now optional, so GOZERBOT can run on older versions of
debian etc. Since this leads to less dependancies GOZERBOT is easier
to install.

note: there is not going to be a seperate all distro as those
dependancies are already included.

SQLAlchemy is made optional by providing plugins that use direct
queries on the database, this is the default. You can change
operations back to SA by setting db_driver = alchemy in gozerdata/
mainconfig.

The intention is to release a new version of GOZERBOT every week or
so, until its stable for a long period of time. When its time i'll cut
of the 1.0 release ;]

urls:

* download tar - http://code.google.com/p/gozerbot/downloads/list
* mercurial clone - hg clone https://gozerbot.googlecode.com/hg
mybot
* please report bugs at http://code.google.com/p/gozerbot/issues/entry
especially if you are already running a GOZERBOT and run into
problems.
* path to the futire - http://jsonbot.org

read the provided README for instructions on how to get the bot
running.

About GOZERBOT:

GOZERBOT is a channel bot supporting conversations in irc channels
and jabber conference rooms. It is mainly used to send notifications
(RSS,
nagios, etc.) and to have custom commands made for the channel. More
then
just a channel bot GOZERBOT aims to provide a platform for the user
to
program his own bot and make it into something thats usefull. This is
done
with a plugin structure that makes it easy to program your own
plugins.
GOZERBOT comes with some batteries included.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


PyScripter v2.4.3 released

2011-10-05 Thread pyscripter
A new version 2.4.3 of PyScripter, the Python IDE for Windows, is now available 
at http://pyscripter.googlecode.com. This new version implements major 
improvements in code completion and many other new features and bug fixes.  You 
can find more about this new version at http://pyscripter.blogspot.com.
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


Re: BaseHTTPServer ThreadMixIn not working

2011-10-05 Thread Gabriel Genellina

En Mon, 03 Oct 2011 12:03:18 -0300, amit wilson.a...@gmail.com escribió:


I am really stuck in a very simple problem and wanted to know if you
could take some time to check it out -

My code is simple. Using BaseHTTPServer and ThreadInMix I want to run
a python script (Script1.py) for every request made simultaneously.
[...]

If I open multiple tabs/pages in Chrome/Firefox/IE and give URL:
http://localhost:8080, the pages wait for previous page? This does not
imply threading? Any help? Thanks


Your code is fine, and Python behaves correctly. The browser is queuing  
all similar requests when it sees they all refer to the same URI. Had the  
first response contained an Expires: header in the future, there would be  
no need to ask again for the same object; the ETag: and Last-Modified:  
headers may play a role too. So, only after the first response is  
completely read, Chrome/Firefox/IE sees it is invalid and knows she cannot  
re-use the received body and has to issue the second request and waits  
again and ...


Try with different URLs for each request:
http://localhost:8080/a
http://localhost:8080/b
http://localhost:8080/c
and you'll see they all are processed in parallel.


--
Gabriel Genellina

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


Re: Is exec() also not used in python 2.7.1 anymore?

2011-10-05 Thread Gabriel Genellina
En Tue, 04 Oct 2011 07:32:41 -0300, Wong Wah Meng-R32813  
r32...@freescale.com escribió:


Haha... yeah I reviewed the code, it is supposed to exposed some remote  
methods locally (RMI proxy usage). However, I am not sure why what it  
does is merely a pass.


I commented out this code and haven't seen any negative implication. I  
will look into this again if I am convinced the next error I see is due  
to I commented out this code.



  exec('def %s(self, *args, **kw): pass'%methodStrName)


In case you convince yourself that defining this dynamic but empty  
function is really needed, you can avoid exec this way:


  def some_function(...)

...
# instead of exec('def ...' % methodStrName)
def empty_function(self, *args, **kw): pass
empty_function.func_name = methodStrName
...
# presumably methodStrName is referred somehow in
# the remaining code block, or perhaps locals();
# modify accordingly


--
Gabriel Genellina

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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Gregory Ewing

alex23 wrote:


But on the gripping hand, it is a clear triumph of Explicit is better
than implicit. ;)


I think we may have found the long-lost 20th principle
of the Zen: If it results in eye-bleedingly horrible
code, it might be a bad idea.

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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Chris Angelico
On Wed, Oct 5, 2011 at 12:22 PM, Alan Meyer amey...@yahoo.com wrote:
 Of course you'll need to be fair in evaluating the students comparisons.
  Some bright students are likely to come up with good reasons for using
 globals in some situations, and they might even be right.  Or if they're not
 completely right, they might nevertheless be partly right.  They should get
 high marks for that.


Definitely. There's always a right time to do the wrong thing, just as
much as there's a wrong time to do the right thing. Even the
much-maligned goto has its place.

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


ImportError: No module named _sha256

2011-10-05 Thread Wong Wah Meng-R32813
Hello there,

In migrating my application from python 1.5.2 to 2.7.1, I encountered an issue 
modules which utilizes _sha256 cannot be loaded. This includes hashlib, random 
and tempfile.

I think this should be related to the build of my python 64-bit on HP11.31 
using HP-UX compiler. I have tried including the header files of openSSL and 
library of openSSL during the build however the binary generated still unable 
to load those modules.

Can anyone advise?

$ python
Python 2.7.1 (r271:86832, Sep 30 2011, 17:07:25) [C] on hp-ux11
Type help, copyright, credits or license for more information.
 import hashlib
Traceback (most recent call last):
  File stdin, line 1, in module
  File 
/home/r32813/genesis/GEN_DEV_271/Enablers/Python/lib/python2.7/hashlib.py, 
line 136, in module
globals()[__func_name] = __get_hash(__func_name)
  File 
/home/r32813/genesis/GEN_DEV_271/Enablers/Python/lib/python2.7/hashlib.py, 
line 74, in __get_builtin_constructor
import _sha256
ImportError: No module named _sha256


Regards,
Wah Meng

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


issue with pexpect

2011-10-05 Thread Daniel
Hello,
For about week i am experiencing a problem with pexpect that's why i
hope you can help me :).
Following is my code which tries to remove some files from the root dir
and the code works on linux debian and freebsd but with no success on
linux fedora .. any idea why this happen only in fedora ?

#!/usr/bin/env python
from __future__ import print_function
import sys
import pexpect
import time

spa=pexpect.spawn('su root')
spa.expect('.*')
print(spa.after)
spa.sendline('abc')
spa.expect('.*')
print(spa.after)
spa.sendline('rm -rf /root/py/pe*')
spa.expect('.*')
print(spa.after)
spa.close()


this is the output in Fedora linux  it looks that the script can't
authenticate as root

python]$ ./sk64.py 
Password: 


rm -rf /root/py/pe*


i appreciate any help thanks in advance

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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Ben Finney
Steven D'Aprano steve+comp.lang.pyt...@pearwood.info writes:

 import the module called 'math' into the current namespace and bind
 that module to the name 'math' in the current namespace

 bind the name 'x' in the current namespace to the return result of
 calling the attribute named 'sin' in the object currently bound to the
 name 'math' in the current namespace using the float literal 1.2345 as
 the argument

This mocking is hurtful to people who identify too strongly with COBOL.
I wonder whether that means it's intentionally hurtful.

-- 
 \   “The long-term solution to mountains of waste is not more |
  `\  landfill sites but fewer shopping centres.” —Clive Hamilton, |
_o__)_Affluenza_, 2005 |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


socket.getsockname is returning junk!!

2011-10-05 Thread Wong Wah Meng-R32813
Hello guys,

I am migrating my application from python 1.5.2 to 2.7.1. One of the existing 
code breaks. The getsockname method from socket object somehow returns me with 
some number which I deem as junk, rather than the listening port as I would 
have expected in the older python. Has anyone seen the same thing or is it due 
to my python is built with some corrupted library or something?


$ python
Python 2.7.1 (r271:86832, Oct  5 2011, 18:34:15) [C] on hp-ux11
Type help, copyright, credits or license for more information.
 import socket
 sock = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
 sock.setsockopt( socket.SOL_SOCKET, socket.SO_REUSEADDR, 1 )
 sock.setsockopt( socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1 )
 sock.setsockopt( socket.IPPROTO_TCP, 1, 1 )
 server_address=('zmy02hp3', 1)
 sock.bind(server_address)
 sock.getsockname()
(0, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')

In python 1.5.2
 server_address=('zmy02aix04', 1)
 sock.bind(server_address)
 sock.getsockname()
('10.228.51.41', 1)



Regards,
Wah Meng

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


issue with pexpect

2011-10-05 Thread Daniel
Hello,
For about week i am experiencing a problem with pexpect that's why i
hope you can help me :).
Following is my code which tries to remove some files from the root dir
and the code works on linux debian and freebsd but with no success on
linux fedora .. any idea why this happen only in fedora ?

#!/usr/bin/env python
from __future__ import print_function
import sys
import pexpect
import time

spa=pexpect.spawn('su root')
spa.expect('.*')
print(spa.after)
spa.sendline('abc')
spa.expect('.*')
print(spa.after)
spa.sendline('rm -rf /root/py/pe*')
spa.expect('.*')
print(spa.after)
spa.close()


this is the output in Fedora linux  it looks that the script can't
authenticate as root

python]$ ./sk64.py 
Password: 


rm -rf /root/py/pe*


i appreciate any help thanks in advance 

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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Roy Smith
In article mailman.1737.1317798109.27778.python-l...@python.org,
 Chris Angelico ros...@gmail.com wrote:

 Definitely. There's always a right time to do the wrong thing, just as
 much as there's a wrong time to do the right thing. Even the
 much-maligned goto has its place.

Not in python, it doesn't :-)

But, yes, I agree that in languages that support it, it can be useful.  
When I was writing C++ for a living, I must have written a goto at least 
once every couple of years.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Chris Angelico
On Wed, Oct 5, 2011 at 11:57 PM, Roy Smith r...@panix.com wrote:
 In article mailman.1737.1317798109.27778.python-l...@python.org,
  Chris Angelico ros...@gmail.com wrote:

 Definitely. There's always a right time to do the wrong thing, just as
 much as there's a wrong time to do the right thing. Even the
 much-maligned goto has its place.

 Not in python, it doesn't :-)

The absence from the language doesn't prove that. All it means is
that, on those rare occasions when a goto would have been correct, the
programmer had to make do with something else :-)

How often do you see a loop structure that exists solely so someone
can 'break' out of it? Or, worse, raising an exception? I haven't seen
it in Python, but frequently in C or C++ code where the programmer had
a fixation on avoiding gotos.

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


Re: recommend a graphics library for plotting by the pixel?

2011-10-05 Thread Adam Funk
On 2011-10-04, Derek Simkowiak wrote:

  If this is strictly for 2D pixel graphics, I recommend using PyGame 
 (aka SDL).  Why do you not think it's the way to go?  It was built for 
 this type of thing.

I only know PyGame because we did an exercise in recreating the old
breakout game and messing around with it at a local Python group.

I was under the mistaken impression from that exercise that you have
to maintain a set of all the objects on the screen and redraw them all
every time through the loop that ends with pygame.display.flip() ---
*but* I now see that the loop starts with these:

clock.tick(tick_rate)
screen.fill((0,0,0))
# comes from screen = pygame.display.set_mode((screen_width,screen_height))
# before the loop

and that I was then deleting hit bricks, calculating the new positions
of the balls, and then redrawing everything that was left on the
secondary screen because things were moving around and disappearing.

I guess if I don't clear the screen at the beginning of the loop but
just blit pixels onto it, when I call display.flip(), it will add the
new blittings to what was already there?  If that's true, this will be
much easier than I thought.

The only buttons I have in mind are pause, step, go, and quit,
and I can just as easily do those with keypresses.
-- 
http://mail.python.org/mailman/listinfo/python-list


httplib2 download forbidden

2011-10-05 Thread Mauro Zaccariotto
Hi! does anyone know what's happening here http://code.google.com/p/httplib2/
? I get this:
403. That’s an error.
Your client does not have permission to get URL /p/httplib2/ from this
server. That’s all we know.
It seems like the httplib2 googlecode project is preventing from
accessing the project web page and downloading httplib2 library
package. I'm in extreme need of using httplib2!
thanks
-- 
http://mail.python.org/mailman/listinfo/python-list


A tuple in order to pass returned values ?

2011-10-05 Thread faucheuse
Hi, (new to python and first message here \o/)

I was wondering something :
when you do : return value1, value2, value3
It returns a tuple.

So if I want to pass these value to a function, the function have to
look like :
def function(self,(value1, value2, value3)) #self because i'm working
with classes

I tried it, and it works perfectly, but I was wondering if it's a good
choice to do so, if there is a problem by coding like that.

So my question is : Is there a problem doig so ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: issue with pexpect

2011-10-05 Thread Daniel
there is no such implementation in fedora you can su as a root .. i can
su from regular user to root with no problems 
the problem come when i use the pexpect module

On Wed, 2011-10-05 at 14:47 +0200, Nizamov Shawkat wrote:
 2011/10/5 Daniel 5960...@gmail.com:
  Hello,
  For about week i am experiencing a problem with pexpect that's why i
  hope you can help me :).
  Following is my code which tries to remove some files from the root dir
  and the code works on linux debian and freebsd but with no success on
  linux fedora .. any idea why this happen only in fedora ?
 
  #!/usr/bin/env python
  from __future__ import print_function
  import sys
  import pexpect
  import time
 
  spa=pexpect.spawn('su root')
  spa.expect('.*')
  print(spa.after)
  spa.sendline('abc')
  spa.expect('.*')
  print(spa.after)
  spa.sendline('rm -rf /root/py/pe*')
  spa.expect('.*')
  print(spa.after)
  spa.close()
 
 
  this is the output in Fedora linux  it looks that the script can't
  authenticate as root
 
 
 Hi!
 
 The problem may be that root user is disabled. This was introduced in
 Ubuntu long ago and I believe that later this was also accepted in
 Fedora. That means that you simply can not su to root, no matter
 what password you supply. This is the way how your OS operates and is
 not connected in any way to python or pexpect. Therefore, either use
 sudo (generally recommended) or enable root user (insecure!).
 
 Hope it helps,
 S.Nizamov


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


Re: eggbasket

2011-10-05 Thread Andrea Crotti
Well it was easy, apparently sqlalchemy.exceptions doesn't exist but 
sqlalchemy.exc does,

and that's the correct one, maybe a version problem...

I get another problem right after
  File 
/home/andrea/PSI_refactor/test_local_pypi/lib/python2.7/site-packages/EggBasket-0.6.1b-py2.7.egg/eggbasket/commands.py, 
line 82, in init_database

model.User.query().filter_by(user_name=u'admin').one()
TypeError: 'Query' object is not callable

so I might try chishop or anything else...

Actually do I really need to have a local pypi server to be able to use 
easy_install?
If I have a whole directory full of directory eggs isn't there any way 
to use that?

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


Re: A tuple in order to pass returned values ?

2011-10-05 Thread Daniel Dorani
this feature has been removed in python3 in accordance to the PEP 3113 
(http://www.python.org/dev/peps/pep-3113/), you should consider using the * 
operator 
http://docs.python.org/tutorial/controlflow.html#unpacking-argument-lists . 
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: issue with pexpect

2011-10-05 Thread Daniel
Okey i figure it out how to do the job in fedora
i added slight delay before sending each command
either by the delaybeforesend attribute or by the time module
;)


cheers

On Wed, 2011-10-05 at 14:47 +0200, Nizamov Shawkat wrote:
 2011/10/5 Daniel 5960...@gmail.com:
  Hello,
  For about week i am experiencing a problem with pexpect that's why i
  hope you can help me :).
  Following is my code which tries to remove some files from the root dir
  and the code works on linux debian and freebsd but with no success on
  linux fedora .. any idea why this happen only in fedora ?
 
  #!/usr/bin/env python
  from __future__ import print_function
  import sys
  import pexpect
  import time
 
  spa=pexpect.spawn('su root')
  spa.expect('.*')
  print(spa.after)
  spa.sendline('abc')
  spa.expect('.*')
  print(spa.after)
  spa.sendline('rm -rf /root/py/pe*')
  spa.expect('.*')
  print(spa.after)
  spa.close()
 
 
  this is the output in Fedora linux  it looks that the script can't
  authenticate as root
 
 
 Hi!
 
 The problem may be that root user is disabled. This was introduced in
 Ubuntu long ago and I believe that later this was also accepted in
 Fedora. That means that you simply can not su to root, no matter
 what password you supply. This is the way how your OS operates and is
 not connected in any way to python or pexpect. Therefore, either use
 sudo (generally recommended) or enable root user (insecure!).
 
 Hope it helps,
 S.Nizamov


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


Re: A tuple in order to pass returned values ?

2011-10-05 Thread Dave Angel

On 01/-10/-28163 02:59 PM, faucheuse wrote:

Hi, (new to python and first message here \o/)

I was wondering something :
when you do : return value1, value2, value3
It returns a tuple.

So if I want to pass these value to a function, the function have to
look like :
def function(self,(value1, value2, value3)) #self because i'm working
with classes

I tried it, and it works perfectly, but I was wondering if it's a good
choice to do so, if there is a problem by coding like that.

So my question is : Is there a problem doig so ?

In the abstract, no.  There's no relationship between the two, except 
they happen to use the same name in their respective local namespaces.


In practice, I wouldn't do it.  If the three values really comprise one 
thing then it makes sense for a function to expect a single thing, and 
that thing needs a name.  So I'd define the function as


   def function(self, mything):
interesting, useful, related = mything
...  work on them

But it's certainly possible that the writer of the first function really 
had three independent things to return, and if the second method is 
expecting those same three independent things, he should define the 
method as:


 def function(self, this, that, theother):

Python does have magic syntax to make this sort of thing easier to work 
with, using * and **.  But I seldom use them unless forced to by 
meta-concerns, such as passing unknown arguments through one method to a 
method of a superclass.


DaveA

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


Re: A tuple in order to pass returned values ?

2011-10-05 Thread Ulrich Eckhardt

Am 05.10.2011 15:33, schrieb faucheuse:

I was wondering something :
when you do : return value1, value2, value3
It returns a tuple.


Right.


So if I want to pass these value to a function, the function have to
look like :
def function(self,(value1, value2, value3))

[...]

No, you don't have to, but you can:

# example functions
def fni():
return 1, 2
def fno(v1, v2):
pass

# store result in a tuple and unpack tuple for function call
t = fni()
fno(*fni)

# store results in individual values
v1, v2 = fni()
fno(v1, v2)


Note that the first variant can be written in a single line, too. A 
completely different alternative is passing a tuple to the function as a 
single parameter. You can then access the elements using normal tuple 
indexing. That said, I don't see a problem with your syntax, except that 
it's a bit unusual.



Welcome to Python!

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


A tuple in order to pass returned values ?

2011-10-05 Thread faucheuse
Hi, (new to python and first message here \o/)

I was wondering something :
when you do : return value1, value2, value3
It returns a tuple.

So if I want to pass these value to a function, the function have to
look like :
def function(self,(value1, value2, value3)) #self because i'm working
with classes

I tried it, and it works perfectly, but I was wondering if it's a good
choice to do so, if there is a problem by coding like that.

So my question is : Is there a problem doig so ?
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing file out to another machine

2011-10-05 Thread John Gordon
In 0d795922-d946-480d-8f41-95656e56f...@g23g2000vbz.googlegroups.com RVince 
rvinc...@gmail.com writes:

 I have a project whereby I need it to write out a file to a different
 server (that the originating server has write access to). So, say I
 need to write out from myserver1, where my app is running, onto, say
 S:/IT/tmp how can I specify/do this? Thanks, RVince

scp file host:/some/location

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Westley Martínez
On Tue, Oct 04, 2011 at 08:20:34PM -0700, alex23 wrote:
 Steven D'Aprano steve+comp.lang.pyt...@pearwood.info wrote:
  Imported modules are variables like any other, and as they usually exist
  in the global scope, so they will all need to be explicitly referenced as
  global. This will get tiresome very quickly, and is a cure far worse than
  the disease, and alone is enough to disqualify this suggestion from
  serious consideration.
 
 But on the gripping hand, it is a clear triumph of Explicit is better
 than implicit. ;)


Simple is better than complex.
Readability counts.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: recommend a graphics library for plotting by the pixel?

2011-10-05 Thread Westley Martínez
On Wed, Oct 05, 2011 at 02:29:38PM +0100, Adam Funk wrote:
 On 2011-10-04, Derek Simkowiak wrote:
 
   If this is strictly for 2D pixel graphics, I recommend using PyGame 
  (aka SDL).  Why do you not think it's the way to go?  It was built for 
  this type of thing.
 
 I only know PyGame because we did an exercise in recreating the old
 breakout game and messing around with it at a local Python group.
 
 I was under the mistaken impression from that exercise that you have
 to maintain a set of all the objects on the screen and redraw them all
 every time through the loop that ends with pygame.display.flip() ---
 *but* I now see that the loop starts with these:
 
 clock.tick(tick_rate)
 screen.fill((0,0,0))
 # comes from screen = 
 pygame.display.set_mode((screen_width,screen_height))
 # before the loop
 
 and that I was then deleting hit bricks, calculating the new positions
 of the balls, and then redrawing everything that was left on the
 secondary screen because things were moving around and disappearing.
 
 I guess if I don't clear the screen at the beginning of the loop but
 just blit pixels onto it, when I call display.flip(), it will add the
 new blittings to what was already there?  If that's true, this will be
 much easier than I thought.
 
 The only buttons I have in mind are pause, step, go, and quit,
 and I can just as easily do those with keypresses.

Yep.  Blitting is replacing the old colors with new colors.  It doesn't
replace colors unless you tell it to.
-- 
http://mail.python.org/mailman/listinfo/python-list


Convenient filtering in for cycles

2011-10-05 Thread Stefano Maggiolo
Dear all,

I would like to know if there is a (more) convenient way of doing this
structure:

===(1)===
for x in l:
if P(x):
do_stuff(x)
==

Let's say that my dream syntax would be

===(2)===
for x in l if P(x):
do_stuff(x)
==

as if it was the second part of a list comprehension. But sadly it is
not in the language. Obvious alternatives are

===(3)===
for x in (x for x in l if P(x)):
do_stuff(x)
==

===(4)===
for x in l:
if not P(x):
continue
do_stuff(x)
==

===(5)===
[do_stuff(x) for x in l if P(x)]
==

As I see it, every syntax-valid solution has its drawbacks:
(1) adds an indentation level;
(3) adds an unnatural repetition of variable names and for;
(4) has the masked goto continue (even if it is quite easy to
understand what happens);
(5) is good but not usable when do_stuff is what it usually is, that
is a list of instructions.

Is there some better and valid construction I missed? If not, is there
a reason why (2) is not in the language?

Pardon my boldness, but I am asking this because there are two invalid
construct that I keep writing when I don't pay attention: one is (2),
and the other is list comprehensions as in

===(6)===
for x in (x in l if P(x)):
do_stuff(x)
==

which accidentally would be a better solution than (1), (3), (4), (5),
though not as good as (2).

Thank you for your attention,
Stefano Maggiolo
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convenient filtering in for cycles

2011-10-05 Thread Ian Kelly
On Wed, Oct 5, 2011 at 10:55 AM, Stefano Maggiolo s.maggi...@gmail.com wrote:
 Dear all,

 I would like to know if there is a (more) convenient way of doing this
 structure:

 ===(1)===
 for x in l:
    if P(x):
        do_stuff(x)
 ==

 Let's say that my dream syntax would be

 ===(2)===
 for x in l if P(x):
    do_stuff(x)
 ==

for x in filter(P, l):
do_stuff(x)

This works nicely if P is a function but can be a bit unwieldy if you
want to use an arbitrary expression, since you would need to put it in
a lambda.

 Is there some better and valid construction I missed? If not, is there
 a reason why (2) is not in the language?

I guess because, as you helpfully enumerated, there are already plenty
of options for iterating with a condition.  Syntax isn't added without
a strong reason, and avoiding an extra line or an extra indentation
level isn't enough.

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convenient filtering in for cycles

2011-10-05 Thread Ian Kelly
On Wed, Oct 5, 2011 at 11:24 AM, Ian Kelly ian.g.ke...@gmail.com wrote:
 Is there some better and valid construction I missed? If not, is there
 a reason why (2) is not in the language?

 I guess because, as you helpfully enumerated, there are already plenty
 of options for iterating with a condition.  Syntax isn't added without
 a strong reason, and avoiding an extra line or an extra indentation
 level isn't enough.

Also, see these older threads:

http://groups.google.com/group/comp.lang.python/browse_thread/thread/ef807313aa47efc/4f4269a7b566cb87
http://groups.google.com/group/python-ideas/browse_thread/thread/87eee156ac2c3a24/61621e7779b5b255
http://groups.google.com/group/python-ideas/browse_thread/thread/e2d076fe35ece873/862674672b4de683

Cheers,
Ian
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Convenient filtering in for cycles

2011-10-05 Thread Stefano Maggiolo
Dear Ian,

thank you for you kind response. I was pretty confident the issue had
already been discussed, but I was unable to look it up.

I suppose your filter syntax is the best given the options (I always
forget about map and filter...) and definitely I see that the work
needed to add such a feature is hardly worth the convenience.

Still, I think it is sad that generators/list comprehensions and for
cycles do not share the same syntax. Unfortunately, this example from
one of your links convinces that anyway it is too late:

(x for x in (l1 if c else l2)) # valid
(x for x in l1 if c else l2) # SyntaxError
for x in l1 if c else l2 # valid

Cheers,
Stefano
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: syntax enhancement

2011-10-05 Thread Tim Chase

On 10/04/11 20:45, Terry Reedy wrote:

On 10/4/2011 9:50 AM, Valiev Sergey wrote:


- `[]` - used for list comprehension,
- `()` - used for generators,
- `[start:stop]` / `[start:stop:step]` - used for slices.
The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy
evaluated' slices (like itertools.islice).
What do you think about it?


a(b) is already used for function calls. Making a(b:c) be something
unreleated does not seem like a good idea to me. At present, a[b:c] ==
a[slice(b,c)]. However, a(slice(b,c)) is already a function call and
could not equal a(b:c).


I'm very -1 on the initial proposal with parens, but I wouldn't 
object to generators growing a method (__getitem__?) to do slices 
via itertools, something like


  gen = (a for a in iterator if test(a))
  for thing in gen[4::2]:
do_something(thing)

acting something like

  gen = (a for a in iterator if test(a))
  for thing in itertools.islice(gen, start=4, step=2):
do_something(thing)

-tkc




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


Re: syntax enhancement

2011-10-05 Thread Terry Reedy

On 10/5/2011 2:31 PM, Tim Chase wrote:

On 10/04/11 20:45, Terry Reedy wrote:

On 10/4/2011 9:50 AM, Valiev Sergey wrote:


- `[]` - used for list comprehension,
- `()` - used for generators,
- `[start:stop]` / `[start:stop:step]` - used for slices.
The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy
evaluated' slices (like itertools.islice).
What do you think about it?


a(b) is already used for function calls. Making a(b:c) be something
unreleated does not seem like a good idea to me. At present, a[b:c] ==
a[slice(b,c)]. However, a(slice(b,c)) is already a function call and
could not equal a(b:c).


I'm very -1 on the initial proposal with parens, but I wouldn't object
to generators growing a method (__getitem__?) to do slices via
itertools, something like

gen = (a for a in iterator if test(a))
for thing in gen[4::2]:
do_something(thing)

acting something like

gen = (a for a in iterator if test(a))
for thing in itertools.islice(gen, start=4, step=2):


'end' arg is required


do_something(thing)


islice(gen,4,None,2) is 11 more characters than
gen[4::2]

If you start with 'from itertools import islice as sl', then each use is 
7 more chars. In the normal case with an 'end' arg, the difference would 
be 4 chars less:


sl(gen,4,100,2)  # 3 extra chars to type ;=)
gen[4:100:2]

This would complicate the language and make generators more different 
from other iterators without adding new functionality


--
Terry Jan Reedy

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


Re: Writing file out to another machine

2011-10-05 Thread Terry Reedy

On 10/5/2011 10:34 AM, RVince wrote:

I have a project whereby I need it to write out a file to a different
server (that the originating server has write access to). So, say I
need to write out from myserver1, where my app is running, onto, say
S:/IT/tmp how can I specify/do this? Thanks, RVince


open('S:/IT/tmp','w')  ??

--
Terry Jan Reedy

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


Re: Writing file out to another machine

2011-10-05 Thread John Gordon
In mailman.1758.1317845707.27778.python-l...@python.org Terry Reedy 
tjre...@udel.edu writes:

 On 10/5/2011 10:34 AM, RVince wrote:
  I have a project whereby I need it to write out a file to a different
  server (that the originating server has write access to). So, say I
  need to write out from myserver1, where my app is running, onto, say
  S:/IT/tmp how can I specify/do this? Thanks, RVince

 open('S:/IT/tmp','w')  ??

I assume he intended S: to indicate a remote server.

-- 
John Gordon   A is for Amy, who fell down the stairs
gor...@panix.com  B is for Basil, assaulted by bears
-- Edward Gorey, The Gashlycrumb Tinies

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


Re: syntax enhancement

2011-10-05 Thread Westley Martínez
On Wed, Oct 05, 2011 at 01:31:41PM -0500, Tim Chase wrote:
 On 10/04/11 20:45, Terry Reedy wrote:
 On 10/4/2011 9:50 AM, Valiev Sergey wrote:
 
 - `[]` - used for list comprehension,
 - `()` - used for generators,
 - `[start:stop]` / `[start:stop:step]` - used for slices.
 The idea is to use `(start:stop)` / `(start:stop:step)` as 'lazy
 evaluated' slices (like itertools.islice).
 What do you think about it?
 
 a(b) is already used for function calls. Making a(b:c) be something
 unreleated does not seem like a good idea to me. At present, a[b:c] ==
 a[slice(b,c)]. However, a(slice(b,c)) is already a function call and
 could not equal a(b:c).
 
 I'm very -1 on the initial proposal with parens, but I wouldn't
 object to generators growing a method (__getitem__?) to do slices
 via itertools, something like
 
   gen = (a for a in iterator if test(a))
   for thing in gen[4::2]:
 do_something(thing)
 
 acting something like
 
   gen = (a for a in iterator if test(a))
   for thing in itertools.islice(gen, start=4, step=2):
 do_something(thing)
 
 -tkc
 
 
 


Wait, how would this work fundamentally?  A list can be sliced because
all the values are there.  A generator does not have all its value at
once (it generates each value as requested).  I don't like change so I
look at these kinds of suggestions with lots of scrutiny and biased
criticism.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Writing file out to another machine

2011-10-05 Thread Chris Angelico
On Thu, Oct 6, 2011 at 8:22 AM, John Gordon gor...@panix.com wrote:
 I assume he intended S: to indicate a remote server.


The most obvious understanding of it is a drive letter (ie Windows
box). But if not, more clarification is needed.

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


Re: syntax enhancement

2011-10-05 Thread Ian Kelly
On Wed, Oct 5, 2011 at 3:28 PM, Westley Martínez aniko...@gmail.com wrote:
 Wait, how would this work fundamentally?  A list can be sliced because
 all the values are there.  A generator does not have all its value at
 once (it generates each value as requested).  I don't like change so I
 look at these kinds of suggestions with lots of scrutiny and biased
 criticism.

Like islice, it would return an iterator that lazily pulls values from
the generator as they are requested, discarding unneeded values as
necessary.
-- 
http://mail.python.org/mailman/listinfo/python-list


encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Greg
Hi, I am having some encoding problems when I first parse stuff from a
non-english website using BeautifulSoup and then write the results to
a txt file.

I have the text both as a normal (text) and as a unicode string
(utext):
print repr(text)
'Branie zak\xc2\xb3adnik\xc3\xb3w'

print repr(utext)
u'Branie zak\xb3adnik\xf3w'

print text or print utext (fileSoup.prettify() also shows 'wrong'
symbols):
Branie zak³adników


Now I am trying to save this to a file but I never get the encoding
right. Here is what I tried (+ lot's of different things with encode,
decode...):
outFile=open(filePath,w)
outFile.write(text)
outFile.close()

outFile=codecs.open( filePath, w, UTF8 )
outFile.write(utext)
outFile.close()

Thanks!!





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


Re: Writing file out to another machine

2011-10-05 Thread Terry Reedy

On 10/5/2011 5:31 PM, Chris Angelico wrote:

On Thu, Oct 6, 2011 at 8:22 AM, John Gordongor...@panix.com  wrote:

I assume he intended S: to indicate a remote server.



The most obvious understanding of it is a drive letter (ie Windows
box).


More exactly, a remote server filesystem 'mounted' (not sure of the 
Windows' term) as a local drive. I am pretty sure I have read of this 
being done.


 But if not, more clarification is needed.

Definitely.

--
Terry Jan Reedy

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


Re: syntax enhancement

2011-10-05 Thread Steven D'Aprano
On Wed, 05 Oct 2011 13:31:41 -0500, Tim Chase wrote:

 I'm very -1 on the initial proposal with parens, but I wouldn't object
 to generators growing a method (__getitem__?) to do slices via
 itertools, something like
 
gen = (a for a in iterator if test(a))
for thing in gen[4::2]:
  do_something(thing)
 
 acting something like
 
gen = (a for a in iterator if test(a))
for thing in itertools.islice(gen, start=4, step=2):
  do_something(thing)


The problem is that adding slicing to iterators is that it requires ALL 
iterators to support slicing, whether appropriate or not, and regardless 
of the implementation.

Just use islice. Not everything needs to be a built-in.



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


Re: Convenient filtering in for cycles

2011-10-05 Thread Steven D'Aprano
On Wed, 05 Oct 2011 18:55:53 +0200, Stefano Maggiolo wrote:

 Dear all,
 
 I would like to know if there is a (more) convenient way of doing this
 structure:
 
 ===(1)===
 for x in l:
 if P(x):
 do_stuff(x)
 ==

That seems pretty convenient to me. It's simple, obvious and readable.


 
 Let's say that my dream syntax would be
 
 ===(2)===
 for x in l if P(x):
 do_stuff(x)
 ==

That is exactly the same as #1 above, except it takes one extra line 
(trivial) and one extra indent level (almost always trivial). So what's 
the problem with #1?

If you have so many indent levels that one more level causes you grief, 
then consider that Nature's way of telling you that you have too much 
code in one chunk and that you should refactor some of it into functions.



 as if it was the second part of a list comprehension. But sadly it is
 not in the language. Obvious alternatives are
 
 ===(3)===
 for x in (x for x in l if P(x)):
 do_stuff(x)
 ==

A hard to read mess. Best avoided.



 ===(4)===
 for x in l:
 if not P(x):
 continue
 do_stuff(x)
 ==

Saves an indent level, otherwise virtually identical to #1.


 
 ===(5)===
 [do_stuff(x) for x in l if P(x)]
 ==

Only appropriate if you care about the return results of do_stuff. If you 
are using a list comprehension solely for the side-effects, don't.



 As I see it, every syntax-valid solution has its drawbacks: (1) adds an
 indentation level;

This shouldn't be a drawback. This should be an advantage. It's an extra 
indentation level because it represents a block of code.


 (3) adds an unnatural repetition of variable names and for; (4) has
 the masked goto continue (even if it is quite easy to understand what
 happens);

While it is true that goto is harmful, it is possible to take the 
hatred of goto to ridiculous levels. 

Calling a function is a masked goto. For-loops and while loops are 
masked gotos. That doesn't make them bad things.

There is nothing inherently wrong with continue and break for flow 
control, although of course you can write bad code with any construct.


 (5) is good but not usable when do_stuff is what it usually is, that is
 a list of instructions.
 
 Is there some better and valid construction I missed? If not, is there a
 reason why (2) is not in the language?

Because it complicates the language for very little benefit. That makes 
the language harder to learn and read and the compiler harder to 
maintain. Unless there is a concrete gain from the feature, why bother?



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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread alex23
Ben Finney ben+pyt...@benfinney.id.au wrote:
 This mocking is hurtful to people who identify too strongly with COBOL.
 I wonder whether that means it's intentionally hurtful.

Far, _far_ less hurtful than COBOL itself...

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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread alex23
On Oct 5, 11:10 pm, Chris Angelico ros...@gmail.com wrote:
 The absence from the language doesn't prove that. All it means is
 that, on those rare occasions when a goto would have been correct, the
 programmer had to make do with something else :-)

Like the goto module? :)

http://entrian.com/goto/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Cameron Simpson
On 03Oct2011 13:10, rantingrick rantingr...@gmail.com wrote:
| Also for scoping.
| 
| py count = 0
| py def foo():
| ... global.count += 1
| py print count
| 1
| 
| Why? Well because many times i find myself wondering if this or that
| variable is local or global -- and when i say global i am speaking
| of module scope! The globalDOT cures the ill.

I must admit I rarely have this concern. My own module globals are
almost entirely CONSTANT type names. (Excluding function and class
names.) 

What's the common ambifuity case for you?
-- 
Cameron Simpson c...@zip.com.au DoD#743
http://www.cskk.ezoshosting.com/cs/

Generally, these things are dreadful, but I saw a clip the other night on tv
of someone who had built a scorpion costume for their spaniel, complete with
legs and a stinger.  It was quite impressive.  Made me want to run out and
buy a dog and a some foam rubber.   - David Farley
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Steven D'Aprano
On Wed, 05 Oct 2011 16:35:59 -0700, Greg wrote:

 Hi, I am having some encoding problems when I first parse stuff from a
 non-english website using BeautifulSoup and then write the results to a
 txt file.

If you haven't already read this, you should do so:

http://www.joelonsoftware.com/articles/Unicode.html



 I have the text both as a normal (text) and as a unicode string (utext):
 print repr(text)
 'Branie zak\xc2\xb3adnik\xc3\xb3w'

This is pretty much meaningless, because we don't know how you got the 
text and what it actually is. You're showing us a bunch of bytes, with no 
clue as to whether they are the right bytes or not. Considering that your 
Unicode text is also incorrect, I would say it is *not* right and your 
description of the problem is 100% backwards: the problem is not 
*writing* the text, but *reading* the bytes and decoding it.


You should do something like this:

(1) Inspect the web page to find out what encoding is actually used.

(2) If the web page doesn't know what encoding it uses, or if it uses 
bits and pieces of different encodings, then the source is broken and you 
shouldn't expect much better results. You could try guessing, but you 
should expect mojibake in your results.

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

(3) Decode the web page into Unicode text, using the correct encoding.

(4) Do all your processing in Unicode, not bytes.

(5) Encode the text into bytes using UTF-8 encoding.

(6) Write the bytes to a file.


[...]
 Now I am trying to save this to a file but I never get the encoding
 right. Here is what I tried (+ lot's of different things with encode,
 decode...):

 outFile=codecs.open( filePath, w, UTF8 ) 
 outFile.write(utext)
 outFile.close()

That's the correct approach, but it won't help you if utext contains the 
wrong characters in the first place. The critical step is taking the 
bytes in the web page and turning them into text.

How are you generating utext?



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


Re: Convenient filtering in for cycles

2011-10-05 Thread alex23
On Oct 6, 2:55 am, Stefano Maggiolo s.maggi...@gmail.com wrote:
 I would like to know if there is a (more) convenient way of doing this
 structure:

 ===(1)===
 for x in l:
     if P(x):
         do_stuff(x)
 ==

map(do_stuff, filter(P, l))
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: recommend a graphics library for plotting by the pixel?

2011-10-05 Thread Alec Taylor
Hehe, sure, why not?

:P

On Wed, Oct 5, 2011 at 2:24 PM, alex23 wuwe...@gmail.com wrote:
 On Oct 5, 12:53 am, Alec Taylor alec.tayl...@gmail.com wrote:
 Sounds like a job for Processing...

 Don't you mean PyProcessing? :)

 http://code.google.com/p/pyprocessing/
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Westley Martínez
On Thu, Oct 06, 2011 at 02:44:33PM +1100, Cameron Simpson wrote:
 On 03Oct2011 13:10, rantingrick rantingr...@gmail.com wrote:
 | Also for scoping.
 | 
 | py count = 0
 | py def foo():
 | ... global.count += 1
 | py print count
 | 1
 | 
 | Why? Well because many times i find myself wondering if this or that
 | variable is local or global -- and when i say global i am speaking
 | of module scope! The globalDOT cures the ill.
 
 I must admit I rarely have this concern. My own module globals are
 almost entirely CONSTANT type names. (Excluding function and class
 names.) 
 
 What's the common ambifuity case for you?

I never have this concern either.  Python's functions and classes are
powerful enough to avoid globals entirely.  In C I have a few sometimes
and in Fortran and the like they're everywhere.  Global variables are
POWERFUL and USEFUL but there's a certain paradigm that goes with them,
and Python works better with an object-oriented w/ functional elements
approach.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Greg
Brilliant! It worked. Thanks!

Here is the final code for those who are struggling with similar
problems:

## open and decode file
# In this case, the encoding comes from the charset argument in a meta
tag
# e.g. meta charset=iso-8859-2
fileObj = open(filePath,r).read()
fileContent = fileObj.decode(iso-8859-2)
fileSoup = BeautifulSoup(fileContent)

## Do some BeautifulSoup magic and preserve unicode, presume result is
saved in 'text' ##

## write extracted text to file
f = open(outFilePath, 'w')
f.write(text.encode('utf-8'))
f.close()



On Oct 5, 11:40 pm, Steven D'Aprano steve
+comp.lang.pyt...@pearwood.info wrote:
 On Wed, 05 Oct 2011 16:35:59 -0700, Greg wrote:
  Hi, I am having some encoding problems when I first parse stuff from a
  non-english website using BeautifulSoup and then write the results to a
  txt file.

 If you haven't already read this, you should do so:

 http://www.joelonsoftware.com/articles/Unicode.html

  I have the text both as a normal (text) and as a unicode string (utext):
  print repr(text)
  'Branie zak\xc2\xb3adnik\xc3\xb3w'

 This is pretty much meaningless, because we don't know how you got the
 text and what it actually is. You're showing us a bunch of bytes, with no
 clue as to whether they are the right bytes or not. Considering that your
 Unicode text is also incorrect, I would say it is *not* right and your
 description of the problem is 100% backwards: the problem is not
 *writing* the text, but *reading* the bytes and decoding it.

 You should do something like this:

 (1) Inspect the web page to find out what encoding is actually used.

 (2) If the web page doesn't know what encoding it uses, or if it uses
 bits and pieces of different encodings, then the source is broken and you
 shouldn't expect much better results. You could try guessing, but you
 should expect mojibake in your results.

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

 (3) Decode the web page into Unicode text, using the correct encoding.

 (4) Do all your processing in Unicode, not bytes.

 (5) Encode the text into bytes using UTF-8 encoding.

 (6) Write the bytes to a file.

 [...]

  Now I am trying to save this to a file but I never get the encoding
  right. Here is what I tried (+ lot's of different things with encode,
  decode...):
  outFile=codecs.open( filePath, w, UTF8 )
  outFile.write(utext)
  outFile.close()

 That's the correct approach, but it won't help you if utext contains the
 wrong characters in the first place. The critical step is taking the
 bytes in the web page and turning them into text.

 How are you generating utext?

 --
 Steven

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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Chris Angelico
On Thu, Oct 6, 2011 at 2:36 PM, alex23 wuwe...@gmail.com wrote:
 On Oct 5, 11:10 pm, Chris Angelico ros...@gmail.com wrote:
 The absence from the language doesn't prove that. All it means is
 that, on those rare occasions when a goto would have been correct, the
 programmer had to make do with something else :-)

 Like the goto module? :)

 http://entrian.com/goto/

Yes. That module is extremely valuable and needs to be brought into
the main trunk. Rick, can this go on your Python 4000 list?

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


Re: encoding problem with BeautifulSoup - problem when writing parsed text to file

2011-10-05 Thread Chris Angelico
On Thu, Oct 6, 2011 at 3:39 PM, Greg gregor.hochsch...@googlemail.com wrote:
 Brilliant! It worked. Thanks!

 Here is the final code for those who are struggling with similar
 problems:

 ## open and decode file
 # In this case, the encoding comes from the charset argument in a meta
 tag
 # e.g. meta charset=iso-8859-2
 fileContent = fileObj.decode(iso-8859-2)
 f.write(text.encode('utf-8'))

In other words, when you decode correctly into Unicode and encode
correctly onto the disk, it works!

This is why encodings are so important :)

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


selenium pyvirtualdisplay script on remote server

2011-10-05 Thread sajuptpm
Hi Friends,

Here the isuue is i can't find the li element. that is because that
element is out of display, so i adjust scroll bar or do focus around
that area to get that element via find_element_by_id(loc_opt)

I already tested with scroll bar and focus and its working fine in my
laptop.
But when i run this script on Remote Server, it can't find that
element.??

Note: Here i am using pyvirtualdisplay, Xvfb and Xephyr, because
server don't have Xserver.
Its also working fine with pyvirtualdisplay in my laptop. but the
issue is in Remote Server.

Has anyone faced this problem before ?

Please suggest a solution.

class Search:
def __init__(self):


self.display = Display(visible=0, size=(800, 600))
self.display.start()
self.url ='http://www.google.com'
self.search_url = None
self.driver  = webdriver().Firefox()

def search(self, search_query, search_location=None):


if search_query:
self.search_url = %s/search?q=%s %(self.url, 
search_query)
print \nURL : , self.search_url
self.driver.get(self.search_url)
self.submit_search()

#self.driver.execute_script(window.scrollBy(0,200))

self.driver.execute_script(document.getElementById('tbpi').focus();)
more_search_tools_link = 
self.driver.find_element_by_id(tbpi)
more_search_tools_link.click()
self.driver.execute_script(window.scrollBy(0,200))
loc_li = self.driver.find_element_by_id(loc_opt)

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


Re: Is it possible to create C-style main function in Python? (for teaching purposes)

2011-10-05 Thread Hansmeet Singh
REMEMBER STEVE

On Wed, Oct 5, 2011 at 9:58 PM, Chris Angelico ros...@gmail.com wrote:

 On Thu, Oct 6, 2011 at 2:36 PM, alex23 wuwe...@gmail.com wrote:
  On Oct 5, 11:10 pm, Chris Angelico ros...@gmail.com wrote:
  The absence from the language doesn't prove that. All it means is
  that, on those rare occasions when a goto would have been correct, the
  programmer had to make do with something else :-)
 
  Like the goto module? :)
 
  http://entrian.com/goto/

 Yes. That module is extremely valuable and needs to be brought into
 the main trunk. Rick, can this go on your Python 4000 list?

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

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


[issue6715] xz compressor support

2011-10-05 Thread Jesús Cea Avión

Jesús Cea Avión j...@jcea.es added the comment:

I agree with Martin here. We should *NOT* have first and second class OS 
support, if we can avoid it.

That said, I wonder what happens in Windows with the BZ2 module, for instance 
:-?. Do we include the BZ2 sourcecode to compile it under windows?.

I know, for instance, that Windows 2.* builds include Berkeley DB.

--

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



[issue6715] xz compressor support

2011-10-05 Thread Antoine Pitrou

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

 I agree with Martin here. We should *NOT* have first and second class
 OS support, if we can avoid it.

The key word being if we can avoid it.
Jesus, if you are a Windows expert, your contribution is welcome.

--

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



[issue6715] xz compressor support

2011-10-05 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

For bz2, Tools/buildbot/external-common.bat has code to download bz2 source, 
and PCbuild/_bz2.vcproj include and compile these files together with _bz2.pyd.

The _ssl module does a similar thing, except that libeay32.lib and 
libssleay32.lib are built in a separate step.

--

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



[issue6715] xz compressor support

2011-10-05 Thread Martin v . Löwis

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

 That said, I wonder what happens in Windows with the BZ2 module, for instance 
 :-?.

External code currently lives at 
http://svn.python.org/projects/external/. The build process gets it from 
there, and we may
have local modifications to libraries where necessary.

--

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



[issue11638] pysetup un sdist crashes with weird trace if version is unicode by accident

2011-10-05 Thread Jens Diemer

Changes by Jens Diemer bugs.python@jensdiemer.de:


--
nosy: +jens

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



[issue6715] xz compressor support

2011-10-05 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 I agree with Martin here. We should *NOT* have first
 and second class OS support, if we can avoid it.

Ok but who will do the job? If nobody is motivated to fix compiler issues, it 
would be a pity to not add the module for that.

--
nosy: +haypo

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



[issue11638] pysetup un sdist crashes with weird trace if version is unicode by accident

2011-10-05 Thread Jens Diemer

Jens Diemer bugs.python@jensdiemer.de added the comment:

I have the same problem, using distutils (and not distutils2):


Traceback (most recent call last):
  File ./setup.py, line 60, in module
test_suite=creole.tests.run_all_tests,
  File /usr/lib/python2.7/distutils/core.py, line 152, in setup
dist.run_commands()
  File /usr/lib/python2.7/distutils/dist.py, line 953, in run_commands
self.run_command(cmd)
  File /usr/lib/python2.7/distutils/dist.py, line 972, in run_command
cmd_obj.run()
  File 
/home/jens/python2creole_env/local/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg/setuptools/command/sdist.py,
 line 147, in run
  File /usr/lib/python2.7/distutils/command/sdist.py, line 448, in 
make_distribution
owner=self.owner, group=self.group)
  File /usr/lib/python2.7/distutils/cmd.py, line 392, in make_archive
owner=owner, group=group)
  File /usr/lib/python2.7/distutils/archive_util.py, line 237, in make_archive
filename = func(base_name, base_dir, **kwargs)
  File /usr/lib/python2.7/distutils/archive_util.py, line 101, in make_tarball
tar = tarfile.open(archive_name, 'w|%s' % tar_compression[compress])
  File /usr/lib/python2.7/tarfile.py, line 1687, in open
_Stream(name, filemode, comptype, fileobj, bufsize),
  File /usr/lib/python2.7/tarfile.py, line 431, in __init__
self._init_write_gz()
  File /usr/lib/python2.7/tarfile.py, line 459, in _init_write_gz
self.__write(self.name + NUL)
  File /usr/lib/python2.7/tarfile.py, line 475, in __write
self.buf += s
UnicodeDecodeError: 'ascii' codec can't decode byte 0x8b in position 1: ordinal 
not in range(128)


The Problem seems that tarfile._Stream() can't handle 'name' as unicode. With 
this changes, it works:

class _Stream:
...
def __init__(self, name, mode, comptype, fileobj, bufsize):
...
self.name = str(name) or 
+

Don't know it this is related to the usage of: from __future__ import 
unicode_literals ?

--
components: +Distutils

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



[issue13073] message_body argument of HTTPConnection.endheaders is undocumented

2011-10-05 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

The 2.7 documentation should mention the version in which the argument was 
added. I believe it was 2.7.

--
resolution: fixed - 
status: closed - open

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



[issue13073] message_body argument of HTTPConnection.endheaders is undocumented

2011-10-05 Thread Ezio Melotti

Ezio Melotti ezio.melo...@gmail.com added the comment:

I also left some comments on the review page that should be addressed.

--
nosy: +ezio.melotti

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



[issue6715] xz compressor support

2011-10-05 Thread Jesús Cea Avión

Jesús Cea Avión j...@jcea.es added the comment:

Antoine, I am a Linux/Solaris/Illumos guy. I only use Windows (virtualized) to 
sync my iPhone with iTunes :)

--

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



[issue13107] Text width in optparse.py can become negative

2011-10-05 Thread Adam Byrtek

New submission from Adam Byrtek adambyr...@gmail.com:

Code snippet from optparse.py:

   344 self.help_position = min(max_len + 2, self.max_help_position)
   345 self.help_width = self.width - self.help_position

Where self.width is initialized with the COLUMNS environment variable. On 
narrow terminals it can happen that self.help_position  self.width, leading to 
an exception in textwrap.py:

raise ValueError(invalid width %r (must be  0) % self.width)
ValueError: invalid width -15 (must be  0)

A reasonable workaround would be to trim part of the help text instead of 
causing an exception.

--
components: Library (Lib)
messages: 144947
nosy: adambyrtek
priority: normal
severity: normal
status: open
title: Text width in optparse.py can become negative
type: behavior

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



[issue13103] copy of an asyncore dispatcher causes infinite recursion

2011-10-05 Thread Xavier de Gaye

Xavier de Gaye xdeg...@gmail.com added the comment:

The infinite recursion occurs also when running python 3.2 with the
extension modules copy, copyreg and asyncore from python 3.1. So it
seems this regression is not caused by a modification in these
modules.

Anyway, the bug is in asyncore. The attached patch fixes it and is
more robust than adding the __getstate__ and __setstate__ methods to
dispatcher.

The patch includes a test case.

--
keywords: +patch
Added file: http://bugs.python.org/file23317/infinite_recursion_asyncore.patch

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



[issue13106] Incorrect pool.py distributed with Python 2.7 windows 32bit

2011-10-05 Thread Aaron Staley

Aaron Staley usaa...@gmail.com added the comment:

Never mind; looks like this functionality was moved to handle_workers. I had 
inadvertently been testing under a modified pool.py.

Sorry for the inconvenience!

--
resolution:  - invalid
status: open - closed

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



[issue13106] Incorrect pool.py distributed with Python 2.7 windows 32bit

2011-10-05 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
stage: test needed - committed/rejected

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



[issue3163] module struct support for ssize_t and size_t

2011-10-05 Thread Antoine Pitrou

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

Thanks for the comments. Here is an updated patch.

--
Added file: http://bugs.python.org/file23318/struct_nn4.patch

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



[issue3163] module struct support for ssize_t and size_t

2011-10-05 Thread Mark Dickinson

Changes by Mark Dickinson dicki...@gmail.com:


--
assignee: mark.dickinson - 

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



[issue13073] message_body argument of HTTPConnection.endheaders is undocumented

2011-10-05 Thread Roundup Robot

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

New changeset befa7b926aad by Senthil Kumaran in branch '3.2':
Issue  #13073 - Address the review comments made by Ezio.
http://hg.python.org/cpython/rev/befa7b926aad

New changeset a7b7ba225de7 by Senthil Kumaran in branch 'default':
merge from 3.2. Issue  #13073 - Address the review comments made by Ezio.
http://hg.python.org/cpython/rev/a7b7ba225de7

--
nosy: +python-dev

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



[issue13073] message_body argument of HTTPConnection.endheaders is undocumented

2011-10-05 Thread Roundup Robot

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

New changeset 64fae6f7b64c by Senthil Kumaran in branch '2.7':
Issue13073 - Address review comments and add versionchanged information in the 
docs.
http://hg.python.org/cpython/rev/64fae6f7b64c

--

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



[issue13073] message_body argument of HTTPConnection.endheaders is undocumented

2011-10-05 Thread Senthil Kumaran

Senthil Kumaran sent...@uthcode.com added the comment:

I believe, I have addressed all the comments. Closing this report.

--
resolution:  - fixed
status: open - closed

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



[issue13103] copy of an asyncore dispatcher causes infinite recursion

2011-10-05 Thread Xavier de Gaye

Xavier de Gaye xdeg...@gmail.com added the comment:

About why the asyncore bug shows up in python 3.2:

The simple test below is ok with python 3.1 but triggers a
RuntimeError: maximum recursion depth exceeded... with python 3.2:

$ python3.1
Python 3.1.2 (r312:79147, Apr  4 2010, 17:46:48) 
[GCC 4.3.2] on linux2
Type help, copyright, credits or license for more information.
 class C:
...   def __getattr__(self, attr):
... return getattr(self.foo, attr)
... 
 c = C()
 hasattr(c, 'bar')
False
 

For the reasoning behind this change made in python 3.2, see issue
9666 and the mail
http://mail.python.org/pipermail/python-dev/2010-August/103178.html

--

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



[issue13070] segmentation fault in pure-python multi-threaded server

2011-10-05 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

Sorry, forgot about this issue...
Updated patch (I'm not really satisfied with the error message, don't
hesitate if you can think of a better wording).

--
Added file: http://bugs.python.org/file23319/buffered_closed_gc-3.diff

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13070
___diff --git a/Lib/test/test_io.py b/Lib/test/test_io.py
--- a/Lib/test/test_io.py
+++ b/Lib/test/test_io.py
@@ -2421,6 +2421,20 @@
 with self.open(support.TESTFN, rb) as f:
 self.assertEqual(f.read(), b456def)
 
+def test_rwpair_cleared_before_textio(self):
+# Issue 13070: TextIOWrapper's finalization would crash when called
+# after the reference to the underlying BufferedRWPair got cleared.
+for i in range(1000):
+b1 = self.BufferedRWPair(self.MockRawIO(), self.MockRawIO())
+t1 = self.TextIOWrapper(b1, encoding=ascii)
+b2 = self.BufferedRWPair(self.MockRawIO(), self.MockRawIO())
+t2 = self.TextIOWrapper(b2, encoding=ascii)
+# circular references
+t1.buddy = t2
+t2.buddy = t1
+support.gc_collect()
+
+
 class PyTextIOWrapperTest(TextIOWrapperTest):
 pass
 
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -2307,6 +2307,10 @@
 static PyObject *
 bufferedrwpair_closed_get(rwpair *self, void *context)
 {
+if (self-writer == NULL) {
+PyErr_SetString(PyExc_RuntimeError, the writer object has been 
cleared);
+return NULL;
+}
 return PyObject_GetAttr((PyObject *) self-writer, _PyIO_str_closed);
 }
 
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue13104] urllib.request.thishost() returns a garbage value

2011-10-05 Thread Roundup Robot

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

New changeset 805a0a1e3c2b by Senthil Kumaran in branch '3.2':
Issue13104 - Fix urllib.request.thishost() utility function.
http://hg.python.org/cpython/rev/805a0a1e3c2b

New changeset a228e59ad693 by Senthil Kumaran in branch 'default':
merge from 3.2.  Issue13104 - Fix urllib.request.thishost() utility function.
http://hg.python.org/cpython/rev/a228e59ad693

--
nosy: +python-dev

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



[issue13104] urllib.request.thishost() returns a garbage value

2011-10-05 Thread Senthil Kumaran

Senthil Kumaran sent...@uthcode.com added the comment:

Thanks for the report. This is fixed now. I hope in 3.3 I remove this old 
utility functions. (real soon).

--
assignee:  - orsenthil
resolution:  - fixed
status: open - closed

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



[issue13045] socket.getsockopt may require custom buffer contents

2011-10-05 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

 I've attached an update for the previous patch. Now there's no more
 overloading for the third argument and socket.getsockopt accepts one more
 optional argument -- a buffer to use as an input to kernel.

Remarks:

+   length.  If *buffer* is absent and *buflen* is an integer, then *buflen*
[...]
+   this buffer is returned as a bytes object.  If *buflen* is absent,
an integer

There's a problem here, the first buflen part should probably be removed.

Also, you might want to specify that if a custom buffer is provided,
the length argument will be ignored.

 By the way, I don't really think that any POSIX-compliant UNIX out there
 would treat the buffer given to getsockopt in any way different from what
 Linux does. It is very easy to copy the buffer from user to kernel and back,
 and it is so inconvenient to prevent kernel from reading it prior to
 modification, that I bet no one has ever bothered to do this.

Me neither, I don't expect the syscall to return EINVAL: the goal is
just to test the correct passing of the input buffer, and the length
computation.

If we can't test this easily within test_socket, it's ok, I guess the
following should be enough:
- try supplying a non-buffer argument as fourth parameter (e.g. and
int), and check that you get a ValueError
- supply a buffer with a size == sizeof(int) (SIZEOF_INT is defined in
Lib/test/test_socket.py), and call getsockopt(socket.SOL_SOCKET,
socket.SO_REUSEADDR, 0, buffer): this should normally succeed, and
return a buffer (check the return type)

--

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



[issue10141] SocketCan support

2011-10-05 Thread Charles-François Natali

Changes by Charles-François Natali neolo...@free.fr:


--
nosy: +pitrou

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



[issue11956] 3.3 : test_import.py causes 'make test' to fail

2011-10-05 Thread Charles-François Natali

Changes by Charles-François Natali neolo...@free.fr:


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

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



[issue10141] SocketCan support

2011-10-05 Thread Antoine Pitrou

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

I don't have much to say about the patch, given that I don't know anything 
about CAN and my system doesn't appear to have a vcan0 interface. I think 
it's ok to commit and refine later if something turns out insufficient.

--

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



[issue10141] SocketCan support

2011-10-05 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

 I don't have much to say about the patch, given that I don't know
 anything about CAN and my system doesn't appear to have a vcan0
 interface.

I had never heard about it before this issue, but the protocol is really simple.

If you want to try it out (just for fun :-), you just have to do the following:
# modprobe vcan
# ip link add dev vcan0 type vcan
# ifconfig vcan0 up

--

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



[issue10141] SocketCan support

2011-10-05 Thread Antoine Pitrou

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

 I had never heard about it before this issue, but the protocol is really 
 simple.
 
 If you want to try it out (just for fun :-), you just have to do the 
 following:
 # modprobe vcan
 # ip link add dev vcan0 type vcan
 # ifconfig vcan0 up

Ah, thanks! Can you add a comment about that in test_socket.py?
I can confirm that all tests pass ok on my Linux system (kernel
2.6.38.8-desktop-5.mga).

--

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



[issue13103] copy of an asyncore dispatcher causes infinite recursion

2011-10-05 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

So, in 3.1 hasattr(y, '__setstate__') *did* recurse and hit the limit, but the 
exception was caught and hasattr returned False?

I think I prefer the new behavior...
The patch looks good, I would simply have raised AttributeError(name) though.

--
nosy: +amaury.forgeotdarc

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



[issue13070] segmentation fault in pure-python multi-threaded server

2011-10-05 Thread Antoine Pitrou

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

The latest patch looks good to me.
As for the error message, how about the BufferedRWPair object is being 
garbage-collected.

--

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



[issue13103] copy of an asyncore dispatcher causes infinite recursion

2011-10-05 Thread Giampaolo Rodola'

Giampaolo Rodola' g.rod...@gmail.com added the comment:

IMO, patch should only be applied to Python 3.2.
For 3.3 we finally have the chance to get rid of the dispatcher.__getattr__ 
aberration (see issue 8483) so I say let's just remove it and fix this issue as 
a consequence.

--

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



[issue13070] segmentation fault in pure-python multi-threaded server

2011-10-05 Thread Roundup Robot

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

New changeset d60c00015f01 by Charles-François Natali in branch '3.2':
Issue #13070: Fix a crash when a TextIOWrapper caught in a reference cycle
http://hg.python.org/cpython/rev/d60c00015f01

New changeset 7defc1e5d13a by Charles-François Natali in branch 'default':
Issue #13070: Fix a crash when a TextIOWrapper caught in a reference cycle
http://hg.python.org/cpython/rev/7defc1e5d13a

--
nosy: +python-dev

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



[issue13081] Crash in Windows with unknown cause

2011-10-05 Thread Amorilia

Amorilia amorilia.game...@gmail.com added the comment:

Thanks for also trying it out, Brian.

I feel there's little more I can do. I guess the multiprocessing module could 
be documented a bit better that join() ought to be called before the pool is 
deleted? Currently, the docs merely say:

Wait for the worker processes to exit. One must call close() or terminate() 
before using join(). 
(http://docs.python.org/library/multiprocessing.html#multiprocessing.pool.multiprocessing.Pool.join)

Something along the following lines could be added:

You must call join() when you no longer need the pool; otherwise, zombie 
processes may keep running.

I'm happy to provide a patch, if needed.

--

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



[issue13070] segmentation fault in pure-python multi-threaded server

2011-10-05 Thread Charles-François Natali

Charles-François Natali neolo...@free.fr added the comment:

Committed to 3.2 and default.

Victor, thanks for the report!

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

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



[issue13070] segmentation fault in pure-python multi-threaded server

2011-10-05 Thread Victor Semionov

Victor Semionov vsemio...@gmail.com added the comment:

Great, thanks to you too, for fixing it!

--

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



[issue8813] SSLContext doesn't support loading a CRL

2011-10-05 Thread David Andrzejewski

Changes by David Andrzejewski site+python@davidandrzejewski.com:


--
nosy: +dandrzejewski

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



[issue13103] copy of an asyncore dispatcher causes infinite recursion

2011-10-05 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

Let's add the test to 3.3 nonetheless.

--

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



[issue13103] copy of an asyncore dispatcher causes infinite recursion

2011-10-05 Thread Xavier de Gaye

Xavier de Gaye xdeg...@gmail.com added the comment:

 So, in 3.1 hasattr(y, '__setstate__') *did* recurse and hit the limit,
 but the exception was caught and hasattr returned False?

This is right.


 I think I prefer the new behavior...
 The patch looks good, I would simply have raised AttributeError(name)
 though.

It is fine with me to raise AttributeError(name).
Note that when raising AttributeError('socket'), the user gets
notified of the exceptions on both 'socket' and 'name'.
For example with the patch applied:

$ python3
Python 3.2 (r32:88445, Jun 18 2011, 20:30:18) 
[GCC 4.3.2] on linux2
Type help, copyright, credits or license for more information.
 import asyncore
 a = asyncore.dispatcher()
 del a.socket
 a.foo
Traceback (most recent call last):
  File asyncore.py, line 415, in __getattr__
retattr = getattr(self.socket, attr)
  File asyncore.py, line 413, in __getattr__
% self.__class__.__name__)
AttributeError: dispatcher instance has no attribute 'socket'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File stdin, line 1, in module
  File asyncore.py, line 418, in __getattr__
%(self.__class__.__name__, attr))
AttributeError: dispatcher instance has no attribute 'foo'

--

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



[issue13108] test_urllib: buildbot failure

2011-10-05 Thread Stefan Krah

New submission from Stefan Krah stefan-use...@bytereef.org:

The FreeBSD-amd64 and Fedora buildbots are recently failing with: 

==
ERROR: test_thishost (test.test_urllib.Utility_Tests)
Test the urllib.request.thishost utility function returns a tuple
--
Traceback (most recent call last):
  File 
/home/buildbot/buildarea/3.x.krah-fedora/build/Lib/test/test_urllib.py, line 
1063, in test_thishost
self.assertIsInstance(urllib.request.thishost(), tuple)
  File /home/buildbot/buildarea/3.x.krah-fedora/build/Lib/urllib/request.py, 
line 2128, in thishost
_thishost = tuple(socket.gethostbyname_ex(socket.gethostname())[2])
socket.gaierror: [Errno -2] Name or service not known

--

--
components: Tests
messages: 144971
nosy: skrah
priority: normal
severity: normal
status: open
title: test_urllib: buildbot failure
versions: Python 3.3

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



[issue13109] telnetlib insensitive to connection loss

2011-10-05 Thread xy zzy

New submission from xy zzy the.stuffd...@gmail.com:

Using python's telnetlib I can connect and communicate with a device.

While the telnet session is active I can disconnect the network cable of the 
device.

At this point, I would expect read_until() with a timeout to throw a 
socket.error, EOFError or perhaps an IOError, but what I actually get is a null 
string.

Because I'm reading in a loop, when the cable is reconnected the device will 
resume communicating, and the program will continue.

My best guess ts that read_until() or perhaps everything except open() is 
insensitive to the loss of a connection.

--
components: IO
messages: 144972
nosy: xy.zzy
priority: normal
severity: normal
status: open
title: telnetlib insensitive to connection loss
type: behavior

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



[issue13109] telnetlib insensitive to connection loss

2011-10-05 Thread Eric V. Smith

Eric V. Smith e...@trueblade.com added the comment:

Can you post some example code?

I would not expect disconnecting the network cable to close any TCP 
connections, unless you are transmitting data and/or you have keepalives turned 
on.

--
nosy: +eric.smith

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



[issue13110] test_socket.py failures on ARM

2011-10-05 Thread Barry A. Warsaw

New submission from Barry A. Warsaw ba...@python.org:

Initial results from warsaw-ubuntu-arm buildbot indicates two failures in 
test_socket.py

==
ERROR: test_create_connection_timeout 
(test.test_socket.NetworkConnectionNoServer)
--
Traceback (most recent call last):
  File 
/var/lib/buildbot/buildarea/2.7.warsaw-ubuntu-arm/build/Lib/test/test_socket.py,
 line 1198, in test_create_connection_timeout
socket.create_connection((HOST, 1234))
  File /var/lib/buildbot/buildarea/2.7.warsaw-ubuntu-arm/build/Lib/socket.py, 
line 571, in create_connection
raise err
error: [Errno 97] Address family not supported by protocol

==
FAIL: test_create_connection (test.test_socket.NetworkConnectionNoServer)
--
Traceback (most recent call last):
  File 
/var/lib/buildbot/buildarea/2.7.warsaw-ubuntu-arm/build/Lib/test/test_socket.py,
 line 1191, in test_create_connection
self.assertEqual(cm.exception.errno, errno.ECONNREFUSED)
AssertionError: 97 != 111

--

I'm still investigating, but wanted to file the bug now so there's an issue 
number to reference.

--
components: Tests
messages: 144974
nosy: barry
priority: normal
severity: normal
status: open
title: test_socket.py failures on ARM
versions: Python 3.3

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



[issue13110] test_socket.py failures on ARM

2011-10-05 Thread Barry A. Warsaw

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


--
versions: +Python 2.7, Python 3.2

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



[issue13111] Error 2203 when installing Python/Perl?

2011-10-05 Thread MA S

New submission from MA S matthewsotou...@gmail.com:

I can't install Python or Strawberry Perl on the Windows 8 Developer Preview :( 
I keep getting installer error 2203; the log file's attached. I really don't 
know what's wrong...

--
components: Windows
files: python.log
messages: 144975
nosy: MA.S
priority: normal
severity: normal
status: open
title: Error 2203 when installing Python/Perl?
type: crash
versions: Python 2.7
Added file: http://bugs.python.org/file23320/python.log

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



[issue13112] backreferences in comprehensions

2011-10-05 Thread yoch

New submission from yoch yoch.me...@gmail.com:

Hi,

I would like to use backreferences in list comprehensions (or other 
comprehensions), such as :

[[elt for elt in lst if elt] for lst in matrix if \{1}]
# \{1} is back reference to [elt for elt in lst if elt] 
# to filter the result of the first comprehension

It would be possible to do this ?

Thanks

--
messages: 144976
nosy: yoch.melka
priority: normal
severity: normal
status: open
title: backreferences in comprehensions
type: feature request

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



[issue7732] imp.find_module crashes Python if there exists a directory named __init__.py

2011-10-05 Thread Antoine Pitrou

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

This broke the Windows buildbots in Python 2.7.

--
assignee:  - haypo

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



  1   2   >