pdb++ 0.6: a drop-in replacement for pdb

2010-12-11 Thread Antonio Cuni
Hi,
I finally released pdb++ (which got some attention due to a lightning
talk at last europython).  It starts from version 0.6, since it has
been around for years now and it is stable enough to be used during
normal devlopment.

https://bitbucket.org/antocuni/pdb/src

From the README:

This module is an extension of the pdb module of the standard library.
It is meant to be fully compatible with its predecessor, yet it
introduces a number of new features to make your debugging experience
as nice as possible.

pdb++ features include:

* colorful TAB completion of Python expressions (through
fancycompleter)
* optional syntax highlighting of code listings (through
pygments)
* sticky mode
* several new commands to be used from the interactive (Pdb++)
prompt
* smart command parsing (hint: have you ever typed r or c at
the prompt to print the value of some variable?)
* additional convenience functions in the pdb module, to be
used from your program

pdb++ is meant to be a drop-in replacement for pdb. If you find some
unexpected behavior, please report it as a bug.

Enjoy,
Antonio Cuni
-- 
http://mail.python.org/mailman/listinfo/python-announce-list

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


ANN: ActivePython 3.1.3.5 is now available

2010-12-11 Thread Sridhar Ratnakumar
ActiveState is pleased to announce ActivePython 3.1.3.5, a complete, 
ready-to-install binary distribution of Python 3.1.

http://www.activestate.com/activepython/downloads

What's New in ActivePython-3.1.3.5
==

*Release date: 6-Dec-2010*

New Features  Upgrades
---

- Upgrade to Python 3.1.3 (`release notes
  http://svn.python.org/projects/python/tags/r313/Misc/NEWS`__)
- Upgrade to Tcl/Tk 8.5.9 (`changes http://wiki.tcl.tk/26961`_)
- Security upgrade to openssl-0.9.8q
- [MacOSX] Tkinter now requires ActiveTcl 8.5 64-bit (not Apple's Tcl/Tk 8.5 on
  OSX)
- Upgrade to PyPM 1.2.6; noteworthy changes:

  - New command 'pypm log' to view log entries for last operation

- Upgraded the following packages:

  - SQLAlchemy-0.6.5
  - virtualenv5-1.3.4.5

Noteworthy Changes  Bug Fixes
--

- [MacOSX] Include missing architecture binaries - Bug #88876
- PyPM bug fixes:

  - depgraph: Fix a bug with missing extra in install_requires - Bug #88825
  - depgraph: Fix a bug with double-marking a package for upgrade 
  - Bug #88664: handle cyclic dependencies in the depgraph algorithm
  - Ignore comments (starting with #) in the requirements file
  - Fix: ignore empty lines in requirements.txt
  - Bug #2: Fix pickle incompatability (sqlite) on Python 3.x


What is ActivePython?
=

ActivePython is ActiveState's binary distribution of Python. Builds for 
Windows, Mac OS X, Linux are made freely available. Solaris, HP-UX and AIX 
builds, and access to older versions are available in ActivePython Business, 
Enterprise and OEM editions:

http://www.activestate.com/python

ActivePython includes the Python core and the many core extensions: zlib and 
bzip2 for data compression, the Berkeley DB (bsddb) and SQLite (sqlite3) 
database libraries, OpenSSL bindings for HTTPS support, the Tix GUI widgets for 
Tkinter, ElementTree for XML processing, ctypes (on supported platforms) for 
low-level library access, and others. The Windows distribution ships with 
PyWin32 -- a suite of Windows tools developed by Mark Hammond, including 
bindings to the Win32 API and Windows COM.

ActivePython 2.6, 2.7 and 3.1 also include a binary package manager for Python 
(PyPM) that can be used to install packages much easily. For example:

  C:\pypm install mysql-python
  [...]

  C:\python
   import MySQLdb
  

See this page for full details:

http://docs.activestate.com/activepython/3.1/whatsincluded.html

As well, ActivePython ships with a wealth of documentation for both new and 
experienced Python programmers. In addition to the core Python docs, 
ActivePython includes the What's New in Python series, Dive into Python, 
the Python FAQs  HOWTOs, and the Python Enhancement Proposals (PEPs).

An online version of the docs can be found here:

http://docs.activestate.com/activepython/3.1/

We would welcome any and all feedback to:

activepython-feedb...@activestate.com

Please file bugs against ActivePython at:

http://bugs.activestate.com/enter_bug.cgi?product=ActivePython

Supported Platforms
===

ActivePython is available for the following platforms:

- Windows   (x86 and x64)
- Mac OS X  (x86 and x86_64; 10.5+)
- Linux (x86 and x86_64)

- Solaris/SPARC (32-bit and 64-bit) (Business, Enterprise or OEM edition only)
- Solaris/x86   (32-bit)(Business, Enterprise or OEM edition only)
- HP-UX/PA-RISC (32-bit)(Business, Enterprise or OEM edition only)
- HP-UX/IA-64   (32-bit and 64-bit) (Enterprise or OEM edition only)
- AIX/PowerPC   (32-bit and 64-bit) (Business, Enterprise or OEM edition only)

More information about the Business Edition can be found here:

http://www.activestate.com/business-edition

Custom builds are available in the Enterprise Edition:

http://www.activestate.com/enterprise-edition

Thanks, and enjoy!

The Python Team

--
Sridhar Ratnakumar
Python Developer
ActiveState, The Dynamic Language Experts

sridh...@activestate.com
http://www.activestate.com

Get insights on Open Source and Dynamic Languages at 
www.activestate.com/blog

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

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


Re: Python critique

2010-12-11 Thread Octavian Rasnita
From: Steven D'Aprano steve+comp.lang.pyt...@pearwood.info
...
 Can you please tell me how to write the following program in Python?
 
 my $n = 1;
 
 {
   my $n = 2;
   print $n\n;
 }
 
 print $n\n;
 
 If this program if ran in Perl, it prints: 
 2
 1
 
 Lots of ways. Here's one:
 
 
 n = 1
 
 class Scope:
n = 2
print n
 
 print n
 
 
 
 Here's another:
 
 n = 1
 print (lambda n=2: n)()
 print n
 
 
 
 Here's a third:
 
 n = 1
 
 def scope():
n = 2
print n
 
 scope()
 print n
 
 
 Here's a fourth:
 
 import sys
 n = 1
 (sys.stdout.write(%d\n % n) for n in (2,)).next()
 print n
 
 
 In Python 3, this can be written more simply:
 
 n = 1
 [print(n) for n in (2,)]
 print n
 
 
 
 I have tried to write it, but I don't know how I can create that block
 because it tells that there is an unexpected indent.
 
 Functions, closures, classes and modules are scopes in Python. If you 
 want a new scope, create one of those.
 
 
 
 -- 
 Steven


Hi Steven,

Thank you for your message. It is very helpful for me.
I don't fully understand the syntax of all these variants yet, but I can see 
that there are more scopes in Python than I thought, and this is very good.

Octavian

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


Re: run a function in another processor in python

2010-12-11 Thread Peter Otten
Astan Chee wrote:

 Sorry about that, here is a summary of my complete code. I haven't cleaned
 it up much or anything, but this is what it does:
 
 import time
 import multiprocessing
 
 test_constx =0
 test_consty =0
 
 def functionTester(x):
   global test_constx

You don't need to declare a variable as global unless you want to rebind 
(assign to) it.

   global test_consty
   print constx  + str(test_constx)
   print consty  + str(test_consty)
   return (test_constx*x[0]-x[1]+test_consty*x[0]+x[2])
 
 def functionTesterMain(constx,consty):
   global test_constx
   global test_consty
   test_constx = constx
   test_consty = consty
   num_args =
 [(61,12,1),(61,12,2),(61,12,3),(61,11,4),(61,12,4),(62,33,4),(7,12,4),
(16,19,4),(35,36,4),(37,38,3),(55,56,3),(57,63,3)]
   num_processes = multiprocessing.cpu_count()
   pool = multiprocessing.Pool(num_processes)

I think you need to create the pool outside the function; in the current 
configuration you get three not one Pool instance.

   rs = []
   start = time.time()
   rs = pool.map(functionTester,num_args)
   end = time.time()
   elapsed= end - start
   min = elapsed/60
   print Took, elapsed, seconds to run, which is the same as, min,
 minutes
   pos = 0
   high = 0
   n = None
   for r in rs:
 if r  high:
   n = num_args[pos]
   high = r
 pos+=1
   print high  + str(high)
   print n  + str(n)
 
   return high,n
 
 if __name__ == '__main__':
   for i in range(1,4):
 a,b = functionTesterMain(i,7)
 print ---
 print a  + str(a)
 print b  + str(a)
 
 
   Which doesn't seem to work because the functionTester() needs to be
 simpler and not use global variables.
 I'm using global variables because I'm also trying to pass a few other
 variables and I tried using a class but that just gave me a unpickleable
 error. I tried using zip but I'm confused with how I can get to pass the
 data.

A simple approach would be to pass an index into a list

const_data = zip(range(1, 4), [7]*3)

 I know I can probably combine the data into tuples but that means that
 there is alot of data duplication, especially if the constx and consty are
 large dictionaries (or even custom objects), which might happen later.
 So it seems that map doesn't quite like functions like these. Anyway, I'll
 try and see if threads or something can substitute. I'd appriciate any 
help. Thanks

Your code, slightly modified and cleaned up (yes, four-space indent improves 
readability):

import time
import multiprocessing

const_data = zip(range(1, 4), [7]*3)
num_args = [(61, 12, 1), (61, 12, 2), (61, 12, 3), (61, 11, 4), 
(61, 12, 4), (62, 33, 4), (7, 12, 4), (16, 19, 4), 
(35, 36, 4), (37, 38, 3), (55, 56, 3), (57, 63, 3)]

def functionTester(args):
i, x, y, z = args
constx, consty = const_data[i]

print constx, constx
print consty, consty
return constx*x - y + consty*x + z

def functionTesterMain(pool, index):
start = time.time()
rs = pool.map(functionTester, (((index, ) + x) for x in num_args))
end = time.time()
elapsed = end - start
min = elapsed/60
print Took, elapsed, 
print seconds to run, which is the same as, min, minutes
return max(zip(rs, num_args))

if __name__ == '__main__':
num_processes = multiprocessing.cpu_count()
pool = multiprocessing.Pool(num_processes)
for i, _ in enumerate(const_data):
a, b = functionTesterMain(pool, i)
print ---
print a, a
print b, b


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


how to read o/p of telenet (python) ?!

2010-12-11 Thread Darshak Bavishi
hi experts ,

i have code to telnet remote machine (unix)
i am using port 5400 to telnet but o/p is not in visible format when i run
random commands or run

when i give as read_some() it displays some lines but in case of read_all()
it gets hang !!

In actual i want to get some string from o/p and process pls help


[code]

import getpass
import sys
import telnetlib
import time
HOST = hostname
#user = raw_input(Enter your remote account: )
#password = getpass.getpass()


user = hostname
password = ABC


tn = telnetlib.Telnet(HOST , 5400)
print 1

print 2
tn.write(user + \n)
print 3
if password:
tn.read_until(Password: )
tn.write(password + \n)

print 4
tn.write(set alarm = off + \n)
tn.write(set event = off + \n)

print 5
tn.write(Cd /Office-Parameters/ + \n)

print 6

tn.write(\n)
tn.write(\n)

tn.write(vlrsubquery msisdn=*** + \n)
tn.write(\n)

print tn.read_all()

tn.write(exit + \n)

tn.close()
-- 
BR
Darshak Bavishi
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python critique

2010-12-11 Thread Lie Ryan
On 12/11/10 11:37, Dan Stromberg wrote:
 On Fri, Dec 10, 2010 at 3:51 PM, John Nagle na...@animats.com wrote:
 On 12/10/2010 3:25 PM, Stefan Behnel wrote:
 Benjamin Kaplan, 11.12.2010 00:13:
 On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote:
 The only scopes Python has are module and function.

 There's more.  Both a lambda, and in Python 3.x,
 list comprehensions, introduce a new scope.
 
 And classes and methods.

Also, class scope and instance scope, though similar, are distinct
scopes. Python also have the hidden interpreter-level scope (the
__builtins__).
-- 
http://mail.python.org/mailman/listinfo/python-list


Python distribution recommendation?

2010-12-11 Thread Octavian Rasnita
Hi,

Is there a recommended Python distribution for Windows XP?

I know about the one that can be downloaded from python.org (which I am using 
for the moment) and the one offered by ActiveState but I don't know which one 
is better for a beginner nor if there are other distributions available.

I am especially interested in creating MS Windows apps with Python.

Thanks.

Octavian

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


Re: Python distribution recommendation?

2010-12-11 Thread Katie T
On Sat, Dec 11, 2010 at 12:43 PM, Octavian Rasnita orasn...@gmail.com wrote:
 Hi,

 Is there a recommended Python distribution for Windows XP?

Either will work, although the python.org one is the more popular and
is likely the one used by most tutorials and beginners guides. The
ActiveState one bundles PyQT if  you want to build apps with GUIs
using QT (although it's fairly trivial to install with the regular
Python as well).

Katie
--
CoderStack
http://www.coderstack.co.uk
The Software Developer Job Board
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python distribution recommendation?

2010-12-11 Thread Lie Ryan
On 12/11/10 23:43, Octavian Rasnita wrote:
 Hi,
 
 Is there a recommended Python distribution for Windows XP?
 
 I know about the one that can be downloaded from python.org (which I am using 
 for the moment) and the one offered by ActiveState but I don't know which one 
 is better for a beginner nor if there are other distributions available.
 
 I am especially interested in creating MS Windows apps with Python.
 

ActiveState comes with more third party libraries, if you're developing
python and do not want to install those libraries yourself, they're the
way to go to. However, if you only need to use standard libraries, or
want to target the broadest possible platforms with very little
dependencies, then you should use python.org's version.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python distribution recommendation?

2010-12-11 Thread Godson Gera
On Sat, Dec 11, 2010 at 6:13 PM, Octavian Rasnita orasn...@gmail.comwrote:



 I am especially interested in creating MS Windows apps with Python.


If you want to access win32api and do some COM programming then ActiveState
comes bundled with pywin32. Where in vanilla python distro you have to
install those packages separately by downloading them.  ActiveState is the
same python with additional batteries included.

-- 
Python Consultant India http://godson.in
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: instance has no __call__ method

2010-12-11 Thread Steve Holden
On 12/10/2010 5:20 AM, frank cui wrote:
 Hi all,
 
 I'm a novice learner of python and get caught in the following trouble
 and hope experienced users can help me solve it:)
 
 Code:
 ---
 $ cat Muffle_ZeroDivision.py
 #!/usr/bin/env python
 
 class MuffledCalculator:
 muffled = False
 def clac(self,expr):
 try:
 return eval(expr)
 except:
 if self.muffled:
 print 'Division by zero is illegal'
 else:
 raise
 --
 
 $ python
 Python 2.7 (r27:82500, Sep 16 2010, 18:03:06)
 [GCC 4.5.1 20100907 (Red Hat 4.5.1-3)] on linux2
 Type help, copyright, credits or license for more information.
 import Muffle_ZeroDivision
 calc = Muffle_ZeroDivision.MuffledCalculator()
 calc = ('10/2')
 calc = Muffle_ZeroDivision.MuffledCalculator()
 calc('10/2')
 Traceback (most recent call last):
   File stdin, line 1, in module
 AttributeError: MuffledCalculator instance has no __call__ method
 
 
 
 There is an AttributeError that this instance doesn't have the __call__
 method, so how to add this kind of method to my instance?
 
 Thanks a lot in advance.
 
 Regards
 Frank.Cui
 
Try renaming your .calc() method to .__call__(). That way the method
will be called when you perform a function call on an instance.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Python distribution recommendation?

2010-12-11 Thread Octavian Rasnita
Ok, thank you all for your recommendations.

I think I will install ActivePython because it seems that it offers more 
features for Windows programming than the other distro (by default, which is 
important for a beginner).

I will use WxPython and not other GUIS like QT, Tk or GTK because they are not 
accessible for screen readers, so I will also need to install WxPython if 
ActiveState's Python doesn't include it.

Octavian

- Original Message - 
From: Godson Gera godso...@gmail.com
To: Octavian Rasnita orasn...@gmail.com
Cc: python-list@python.org
Sent: Saturday, December 11, 2010 4:02 PM
Subject: Re: Python distribution recommendation?


 On Sat, Dec 11, 2010 at 6:13 PM, Octavian Rasnita orasn...@gmail.comwrote:
 


 I am especially interested in creating MS Windows apps with Python.

 
 If you want to access win32api and do some COM programming then ActiveState
 comes bundled with pywin32. Where in vanilla python distro you have to
 install those packages separately by downloading them.  ActiveState is the
 same python with additional batteries included.
 
 -- 
 Python Consultant India http://godson.in

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


Re: 64 bit memory usage

2010-12-11 Thread Steve Holden
On 12/10/2010 2:03 PM, Rob Randall wrote:
 I manged to get my python app past 3GB on a smaller 64 bit machine.
 On a test to check memory usage with gc disabled only an extra 6MB was
 used.
 The figures were 1693MB to 1687MB.
 
 This is great.
 
 Thanks again for the help.

Do remember, though, that with the GC turned off you will lose memory
if you accidentally create cyclic data structures, since they will never
be reclaimed. It doesn't sound like this is an issue, but I wanted this
to act as a warning to others who might come across your solution but
have programmed less carefully.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Integrating doctest with unittest

2010-12-11 Thread Steven D'Aprano
I have a module with doctests, and a module that performs unit testing 
for it. The test module looks like this:


import doctest
import unittest

import module_to_test

# ...
# many test suites
# ...

if __name__ == '__main__':
doctest.testmod(module_to_test)
unittest.main()



but now I'd like to integrate the doctests with the unittests. I thought 
I could follow the instructions here:

http://docs.python.org/py3k/library/doctest.html#unittest-api


so I added a line:


doc_test_suite = doctest.DocTestSuite(module=module_to_test)


expecting that it would be found by unittest.main(), but it is not. I 
imagine this is because DocTestSuite returns a TestSuite instance, while 
the unittest test finder only looks for classes.

I realise that I could manually run the doc_test_suite with this:

unittest.TextTestRunner().run(doc_test_suite)

but this leads to two test outputs:

Ran 100 tests in 3.037s
OK

Ran 10 tests in 0.012s
OK


instead of combining them:

Ran 110 tests in 3.049s
OK


Is there a way to have unittest.main() find and run doc_test_suite 
together with the other test suites?



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


python-parser running Beautiful Soup needs to be reviewed

2010-12-11 Thread Martin Kaspar
Hello commnity

i am new to Python and to Beatiful Soup also!
It is told to be a great tool to parse and extract content. So here i
am...:

I want to take the content of a td-tag of a table in a html
document. For example, i have this table

table class=bp_ergebnis_tab_info
tr
td
 This is a sample text
/td

td
 This is the second sample text
/td
/tr
/table

How can i use beautifulsoup to take the text This is a sample text?

Should i make use
soup.findAll('table' ,attrs={'class':'bp_ergebnis_tab_info'}) to get
the whole table.

See the target 
http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=799.601437941842SchulAdresseMapDO=142323

Well - what have we to do first:

The first thing is t o find the table:

i do this with Using find rather than findall returns the first item
in the list
(rather than returning a list of all finds - in which case we'd have
to add an extra [0]
to take the first element of the list):


table = soup.find('table' ,attrs={'class':'bp_ergebnis_tab_info'})

Then use find again to find the first td:

first_td = soup.find('td')

Then we have to use renderContents() to extract the textual contents:

text = first_td.renderContents()

... and the job is done (though we may also want to use strip() to
remove leading and trailing spaces:

trimmed_text = text.strip()

This should give us:


print trimmed_text
This is a sample text

as desired.


What do you think about the code? I love to hear from you!?

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


Re: python-parser running Beautiful Soup needs to be reviewed

2010-12-11 Thread Nitin Pawar
try using lxml ... its very useful

On Sat, Dec 11, 2010 at 11:24 AM, Martin Kaspar martin.kas...@campus-24.com
 wrote:

 Hello commnity

 i am new to Python and to Beatiful Soup also!
 It is told to be a great tool to parse and extract content. So here i
 am...:

 I want to take the content of a td-tag of a table in a html
 document. For example, i have this table

 table class=bp_ergebnis_tab_info
tr
td
 This is a sample text
/td

td
 This is the second sample text
/td
/tr
 /table

 How can i use beautifulsoup to take the text This is a sample text?

 Should i make use
 soup.findAll('table' ,attrs={'class':'bp_ergebnis_tab_info'}) to get
 the whole table.

 See the target
 http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=799.601437941842SchulAdresseMapDO=142323

 Well - what have we to do first:

 The first thing is t o find the table:

 i do this with Using find rather than findall returns the first item
 in the list
 (rather than returning a list of all finds - in which case we'd have
 to add an extra [0]
 to take the first element of the list):


 table = soup.find('table' ,attrs={'class':'bp_ergebnis_tab_info'})

 Then use find again to find the first td:

 first_td = soup.find('td')

 Then we have to use renderContents() to extract the textual contents:

 text = first_td.renderContents()

 ... and the job is done (though we may also want to use strip() to
 remove leading and trailing spaces:

 trimmed_text = text.strip()

 This should give us:


 print trimmed_text
 This is a sample text

 as desired.


 What do you think about the code? I love to hear from you!?

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




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


Making os.unlink() act like rm -f

2010-12-11 Thread Roy Smith
I just wrote an annoying little piece of code:

try:
os.unlink(file)
except OSError:
   pass

The point being I want to make sure the file is gone, but am not sure if 
it exists currently.  Essentially, I want to do what rm -f does in the 
unix shell.

In fact, what I did doesn't even do that.  By catching OSError, I catch 
No such file or directory (which is what I want), but I also catch 
lots of things I want to know about, like Permission denied.  I could 
do:

if os.access(file, os.F_OK):
   os.unlink(file)

but that's annoying too.  What would people think about a patch to 
os.unlink() to add an optional second parameter which says to ignore 
attempts to remove non-existent files (just like rm -f)?  Then you 
could do:

os.unlink(file, ignore=True)
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Making os.unlink() act like rm -f

2010-12-11 Thread Christian Heimes
Am 11.12.2010 18:04, schrieb Roy Smith:
 if os.access(file, os.F_OK):
os.unlink(file)
 
 but that's annoying too.  What would people think about a patch to 
 os.unlink() to add an optional second parameter which says to ignore 
 attempts to remove non-existent files (just like rm -f)?  Then you 
 could do:

-1

os.unlink is a small wrapper around the unlink(2) function.

You want to ignore the ENOENT error number and re-raise the exception
for other errors:

try:
   os.unlink(file)
except OSError, e:
   if e.errno != errno.ENOENT:
  raise

You may be interested in EISDIR, too. unlink() doesn't remove directories.

Christian

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


Re: Making os.unlink() act like rm -f

2010-12-11 Thread Nobody
On Sat, 11 Dec 2010 12:04:01 -0500, Roy Smith wrote:

 I just wrote an annoying little piece of code:
 
 try:
 os.unlink(file)
 except OSError:
pass
 
 The point being I want to make sure the file is gone, but am not sure if
 it exists currently.  Essentially, I want to do what rm -f does in the
 unix shell.
 
 In fact, what I did doesn't even do that.  By catching OSError, I catch
 No such file or directory (which is what I want), but I also catch lots
 of things I want to know about, like Permission denied.

import errno
try:
os.unlink(file)
except OSError as e:
if e.errno != errno.ENOENT:
raise

 I could do:
 
 if os.access(file, os.F_OK):
os.unlink(file)
 
 but that's annoying too.

It also has a race condition. EAFP is the right approach here.

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


Re: Making os.unlink() act like rm -f

2010-12-11 Thread Godson Gera
On Sat, Dec 11, 2010 at 10:34 PM, Roy Smith r...@panix.com wrote:

 os.unlink(file, ignore=True)
 --
 http://mail.python.org/mailman/listinfo/python-list


Take a look at shutil.rmtree
http://docs.python.org/library/shutil.html?highlight=shutil#shutil.rmtree


-- 
Thanks  Regards,
Godson Gera
Python Consultant India http://blog.godson.in
-- 
http://mail.python.org/mailman/listinfo/python-list


Enabling the use of POSIX character classes in Python

2010-12-11 Thread Perry Johnson
Python's re module does not support POSIX character classes, for
example [:alpha:]. It is, of course, trivial to simulate them using
character ranges when the text to be matched uses the ASCII character
set. Sadly, my problem is that I need to process Unicode text. The re
module has its own character classes that do support Unicode, however
they are not sufficient.

I would find it extremely useful if there was information on the
Unicode code points that map to each of the POSIX character classes.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: how to read o/p of telenet (python) ?!

2010-12-11 Thread Ian Kelly

On 12/11/2010 4:20 AM, Darshak Bavishi wrote:

i have code to telnet remote machine (unix)
i am using port 5400 to telnet but o/p is not in visible format when i
run random commands or run


What is o/p?


when i give as read_some() it displays some lines but in case of
read_all() it gets hang !!


read_all() blocks until the server closes the connection.  If the server 
is waiting for a command, then it will be blocking for a long time.


Try sending the exit command before you call read_all().  The server 
should finish processing the previous command before exiting, so you 
will still receive all of the requested data.


Cheers,
Ian

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


Re: Enabling the use of POSIX character classes in Python

2010-12-11 Thread MRAB

On 11/12/2010 17:33, Perry Johnson wrote:

Python's re module does not support POSIX character classes, for
example [:alpha:]. It is, of course, trivial to simulate them using
character ranges when the text to be matched uses the ASCII character
set. Sadly, my problem is that I need to process Unicode text. The re
module has its own character classes that do support Unicode, however
they are not sufficient.

I would find it extremely useful if there was information on the
Unicode code points that map to each of the POSIX character classes.


Have a look at the new regex implementation on PyPI:

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


Re: Enabling the use of POSIX character classes in Python

2010-12-11 Thread Martin v. Loewis
Am 11.12.2010 18:33, schrieb Perry Johnson:
 Python's re module does not support POSIX character classes, for
 example [:alpha:]. It is, of course, trivial to simulate them using
 character ranges when the text to be matched uses the ASCII character
 set. Sadly, my problem is that I need to process Unicode text. The re
 module has its own character classes that do support Unicode, however
 they are not sufficient.
 
 I would find it extremely useful if there was information on the
 Unicode code points that map to each of the POSIX character classes.

By definition, this is not possible. The POSIX character classes are
locale-dependent, whereas the recommendation for Unicode regular
expressions is that they are not (i.e. a Unicode regex character class
should refer to the same characters independent from the locale).

If you want to construct locale-dependent Unicode character classes,
you should use this procedure:
- iterate over all byte values (0..255)
- perform the relevant locale-specific tests
- decode each byte into Unicode, using the locale's encoding
- construct a character class out of that

Unfortunately, that will work only for single-byte encodings.
I'm not aware of a procedure that does that for multi-byte strings.

But perhaps you didn't mean POSIX character class in this literal
way.

Regards,
Martin

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


Re: how to read o/p of telenet (python) ?!

2010-12-11 Thread MRAB

On 11/12/2010 17:44, Ian Kelly wrote:

On 12/11/2010 4:20 AM, Darshak Bavishi wrote:

i have code to telnet remote machine (unix)
i am using port 5400 to telnet but o/p is not in visible format when i
run random commands or run


What is o/p?


[snip]

o/p is an abbreviation for output (and i/p is abbreviation for
input).
--
http://mail.python.org/mailman/listinfo/python-list


Re: ctypes question

2010-12-11 Thread MrJean1
It is not entirely clear what the functions and especially what their
signatures are in that C library clibsmi.

In general, for shared libraries, you need to define those first as
prototype using ctypes.CFUNCTYPE() and then instantiate each prototype
once supplying the necessary parameter flags using
prototype(func_spec, tuple_of_param_flags).  See sections 15.16.2.3
and 4 of the ctypes docs*.

Take a look the Python bindings** for the VLC library, the file called
vlc.py***.  The function _Cfunction is used to create the Python
callable for each C function in that VLC library.  All the Python
callables are in the second half of the vlc.py file, starting at line
2600.

Hope this helps,

/Jean

*) http://docs.python.org/library/ctypes.html#foreign-functions

**) http://wiki.videolan.org/Python_bindings

***) http://git.videolan.org/?p=vlc/bindings/
python.git;a=tree;f=generated;b=HEAD


On Dec 10, 3:32 pm, News Wombat newswom...@gmail.com wrote:
 Hi everyone,

 I've been experimenting with the ctypes module and think it's great.
 I'm hitting a few snags though with seg faults.  I attached two links
 that holds the code.  The line i'm having problems with is this,

 sn=clibsmi.smiGetNextNode(pointer(sno),SMI_NODEKIND_ANY)

 It will work one time, and if I call it again with the result of the
 previous, even though the result (a c struct) looks ok, it will
 segfault.  I think it's a problem with pointers or maybe the function
 in the c library trying to change a string that python won't let it
 change.  I'm stuck, any tips would be appreciated.  Thanks, and Merry
 Christmas!

 constants.py:http://pastebin.com/HvngjzZN
 libsmi.py:http://pastebin.com/19C9kYEa

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


Re: Catching user switching and getting current active user from root on linux

2010-12-11 Thread mpnordland
sorry, I've been busy, it's on linux, and current active user is the
user currently using the computer. My program needs to switch log
files when a different user starts using the computer.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching user switching and getting current active user from root on linux

2010-12-11 Thread mpnordland
about the pyutmp, is the most recent entry at the top or bottom of the
file?

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


Re: Python critique

2010-12-11 Thread Steve Holden
On 12/11/2010 6:46 AM, Lie Ryan wrote:
 On 12/11/10 11:37, Dan Stromberg wrote:
 On Fri, Dec 10, 2010 at 3:51 PM, John Nagle na...@animats.com wrote:
 On 12/10/2010 3:25 PM, Stefan Behnel wrote:
 Benjamin Kaplan, 11.12.2010 00:13:
 On Fri, Dec 10, 2010 at 5:46 PM, Octavian Rasnita wrote:
 The only scopes Python has are module and function.

 There's more.  Both a lambda, and in Python 3.x,
 list comprehensions, introduce a new scope.

 And classes and methods.
 
 Also, class scope and instance scope, though similar, are distinct
 scopes. Python also have the hidden interpreter-level scope (the
 __builtins__).

But classes and instances don't have scopes. They have namespaces.

That is, if we are talking about lexical scoping.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Re: Python critique

2010-12-11 Thread Steve Holden
On 12/11/2010 6:46 AM, Lie Ryan wrote:
 Also, class scope and instance scope, though similar, are distinct
 scopes. Python also have the hidden interpreter-level scope (the
 __builtins__).

Kindly ignore my last post. Class scopes are lexical, instance scopes
are not.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Re: Python distribution recommendation?

2010-12-11 Thread Steve Holden
On 12/11/2010 9:31 AM, Octavian Rasnita wrote:
 Ok, thank you all for your recommendations.
 
 I think I will install ActivePython because it seems that it offers more 
 features for Windows programming than the other distro (by default, which is 
 important for a beginner).
 
 I will use WxPython and not other GUIS like QT, Tk or GTK because they are 
 not accessible for screen readers, so I will also need to install WxPython if 
 ActiveState's Python doesn't include it.
 
I must say that wxPython has been one of the most consistently easy
packages to install over the last ten years.

regards
 Steve
-- 
Steve Holden   +1 571 484 6266   +1 800 494 3119
PyCon 2011 Atlanta March 9-17   http://us.pycon.org/
See Python Video!   http://python.mirocommunity.org/
Holden Web LLC http://www.holdenweb.com/

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


Re: Making os.unlink() act like rm -f

2010-12-11 Thread Roy Smith
In article mailman.424.1292088328.2649.python-l...@python.org,
 Christian Heimes li...@cheimes.de wrote:

 Am 11.12.2010 18:04, schrieb Roy Smith:
  if os.access(file, os.F_OK):
 os.unlink(file)
  
  but that's annoying too.  What would people think about a patch to 
  os.unlink() to add an optional second parameter which says to ignore 
  attempts to remove non-existent files (just like rm -f)?  Then you 
  could do:
 
 -1
 
 os.unlink is a small wrapper around the unlink(2) function.

OK, fair enough.  Perhaps a better place would be in a higher level 
module like shutil.

It was suggested I look at shutil.rmtree(), but that only works of path 
is a directory.  Also, the meaning of the ignore_errors flag is not 
quite what I'm looking for.  I don't want to ignore errors, I just want 
if it doesn't exist, this is a no-op.  In short, exactly what rm -r 
does in the unix shell.

So, maybe a new function is shutils?

shutils.rm(path, force=False)
Delete the file at path.  If force is True, this is a no-op if path does 
not exist.  Raises OSError if the operation fails.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Catching user switching and getting current active user from root on linux

2010-12-11 Thread Tim Chase

On 12/11/2010 01:43 PM, mpnordland wrote:

it's on linux, and current active user is the user currently
using the computer. My program needs to switch log files when
a different user starts using the computer.


The problem is that multiple users can be logged on at the same 
time.  You might be able to come up with a solution that works 
for a small set of use-cases, but I admin several Linux boxes 
where multiple people can be logged-in at the same time.  There 
are also some multi-head arrangements (multiple 
keyboards/mice/monitors and sometimes even sound-cards attached 
to the same motherboard) and people can log into each terminal 
(if you will) concurrently, all on the same box.  So if I'm using 
the computer, and a co-worker logs in, I'm still using it at the 
same time you might catch the new user logged in event.


Watching wtmp (or possibly /var/log/auth) can capture the hey, 
somebody logged in event, but that doesn't mean that other 
previous users are done with their sessions.



-tkc



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


Re: python-parser running Beautiful Soup needs to be reviewed

2010-12-11 Thread Stef Mientki
On 11-12-2010 17:24, Martin Kaspar wrote:
 Hello commnity

 i am new to Python and to Beatiful Soup also!
 It is told to be a great tool to parse and extract content. So here i
 am...:

 I want to take the content of a td-tag of a table in a html
 document. For example, i have this table

 table class=bp_ergebnis_tab_info
 tr
 td
  This is a sample text
 /td

 td
  This is the second sample text
 /td
 /tr
 /table

 How can i use beautifulsoup to take the text This is a sample text?

 Should i make use
 soup.findAll('table' ,attrs={'class':'bp_ergebnis_tab_info'}) to get
 the whole table.

 See the target 
 http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=799.601437941842SchulAdresseMapDO=142323

 Well - what have we to do first:

 The first thing is t o find the table:

 i do this with Using find rather than findall returns the first item
 in the list
 (rather than returning a list of all finds - in which case we'd have
 to add an extra [0]
 to take the first element of the list):


 table = soup.find('table' ,attrs={'class':'bp_ergebnis_tab_info'})

 Then use find again to find the first td:

 first_td = soup.find('td')

 Then we have to use renderContents() to extract the textual contents:

 text = first_td.renderContents()

 ... and the job is done (though we may also want to use strip() to
 remove leading and trailing spaces:

 trimmed_text = text.strip()

 This should give us:


 print trimmed_text
 This is a sample text

 as desired.


 What do you think about the code? I love to hear from you!?
I've no opinion.
I'm just struggling with BeautifulSoup myself, finding it one of the toughest 
libs I've seen ;-)

So the simplest solution I came up with:

Text = 
table class=bp_ergebnis_tab_info
tr
td
 This is a sample text
/td

td
 This is the second sample text
/td
/tr
/table

Content = BeautifulSoup ( Text )
print Content.find('td').contents[0].strip()
 This is a sample text

And now I wonder how to get the next contents !!

cheers,
Stef
 greetings
 matze

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


Re: python-parser running Beautiful Soup needs to be reviewed

2010-12-11 Thread Peter Pearson
On Sat, 11 Dec 2010 22:38:43 +0100, Stef Mientki wrote:
[snip]
 So the simplest solution I came up with:

 Text = 
table class=bp_ergebnis_tab_info
 tr
 td
  This is a sample text
 /td

 td
  This is the second sample text
 /td
 /tr
/table
 
 Content = BeautifulSoup ( Text )
 print Content.find('td').contents[0].strip()
 This is a sample text

 And now I wonder how to get the next contents !!

Here's a suggestion:

pe...@eleodes:~$ python
Python 2.5.2 (r252:60911, Jul 22 2009, 15:35:03) 
[GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] on linux2
Type help, copyright, credits or license for more information.
 from BeautifulSoup import BeautifulSoup
 Text = 
... table class=bp_ergebnis_tab_info
... tr
... td
...  This is a sample text
... /td
... 
... td
...  This is the second sample text
... /td
... /tr
... /table
... 
 Content = BeautifulSoup ( Text )
 for xx in Content.findAll('td'):
...   print xx.contents[0].strip()
... 
This is a sample text
This is the second sample text
 

-- 
To email me, substitute nowhere-spamcop, invalid-net.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: python-parser running Beautiful Soup needs to be reviewed

2010-12-11 Thread Alexander Kapps

On 11.12.2010 22:38, Stef Mientki wrote:

On 11-12-2010 17:24, Martin Kaspar wrote:

Hello commnity

i am new to Python and to Beatiful Soup also!
It is told to be a great tool to parse and extract content. So here i
am...:

I want to take the content of atd-tag of a table in a html
document. For example, i have this table

table class=bp_ergebnis_tab_info
 tr
 td
  This is a sample text
 /td

 td
  This is the second sample text
 /td
 /tr
/table

How can i use beautifulsoup to take the text This is a sample text?

Should i make use
soup.findAll('table' ,attrs={'class':'bp_ergebnis_tab_info'}) to get
the whole table.

See the target 
http://www.schulministerium.nrw.de/BP/SchuleSuchen?action=799.601437941842SchulAdresseMapDO=142323

Well - what have we to do first:

The first thing is t o find the table:

i do this with Using find rather than findall returns the first item
in the list
(rather than returning a list of all finds - in which case we'd have
to add an extra [0]
to take the first element of the list):


table = soup.find('table' ,attrs={'class':'bp_ergebnis_tab_info'})

Then use find again to find the first td:

first_td = soup.find('td')

Then we have to use renderContents() to extract the textual contents:

text = first_td.renderContents()

... and the job is done (though we may also want to use strip() to
remove leading and trailing spaces:

trimmed_text = text.strip()

This should give us:


print trimmed_text
This is a sample text

as desired.


What do you think about the code? I love to hear from you!?

I've no opinion.
I'm just struggling with BeautifulSoup myself, finding it one of the toughest 
libs I've seen ;-)


Really? While I'm by no means an expert, I find it very easy to work 
with. It's very well structured IMHO.



So the simplest solution I came up with:

Text = 
table class=bp_ergebnis_tab_info
 tr
 td
  This is a sample text
 /td

 td
  This is the second sample text
 /td
 /tr
/table

Content = BeautifulSoup ( Text )
print Content.find('td').contents[0].strip()

This is a sample text


And now I wonder how to get the next contents !!


Content = BeautifulSoup ( Text )
for td in Content.findAll('td'):
print td.string.strip() # or td.renderContents().strip()
--
http://mail.python.org/mailman/listinfo/python-list


Re: Catching user switching and getting current active user from root on linux

2010-12-11 Thread Tim Harig
Mr. Chase, I really wouldn't even bother wasting my time on this one.
He asked an incomplete question to start with; so, the replies that
he received were insufficient to solve his problem.  He still has not
provided enough information to know how to answer his question propery.
He doesn't understand a sacastic reply when he hears one, he doesn't
understand the concept of a multi-user operating system, and he doesn't
understand the concept of how usenet threads work.  Until he demonstrates
some intelligence, I would say that he has flunked the Turing test.
-- 
http://mail.python.org/mailman/listinfo/python-list


Bind C++ program for use with both Python 2.x and 3.x

2010-12-11 Thread Peter C.
Hello, I am looking at the possibility of making a program in C++. The
catch is it will require the ability to work with binding for use with
scripting in both Python 2.x and 3.x for various tool plugins. Is
there any way to bind a C++ app to work with both Python 2.x and 3.x
using the Python C API? Note if I could I'd just do Python 3, however
I need Python 2 support to allow for the use of this application as a
plugin in apps that use Python 2 as well.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Bind C++ program for use with both Python 2.x and 3.x

2010-12-11 Thread Martin v. Loewis
Am 11.12.2010 23:41, schrieb Peter C.:
 Hello, I am looking at the possibility of making a program in C++. The
 catch is it will require the ability to work with binding for use with
 scripting in both Python 2.x and 3.x for various tool plugins. Is
 there any way to bind a C++ app to work with both Python 2.x and 3.x
 using the Python C API? Note if I could I'd just do Python 3, however
 I need Python 2 support to allow for the use of this application as a
 plugin in apps that use Python 2 as well.

Notice that binding to Python 2 may not be enough: you also need to
specify the Python 2 version (i.e. different bindings for 2.5, 2.6, and
2.7, say). You will have to ship different copies of the binding. Of
course, you can ship them in a single distribution (zip file, or
whatever your distribution format is).

If you are creating different copies of the binding, supporting both
2.x and 3.x simultaneously will be straight-forward.

Regards,
Martin

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


Re: Enabling the use of POSIX character classes in Python

2010-12-11 Thread Perry Johnson
On 2010-12-11, MRAB wrote:

 On 11/12/2010 17:33, Perry Johnson wrote:
 Python's re module does not support POSIX character classes, for
 example [:alpha:]. It is, of course, trivial to simulate them using
 character ranges when the text to be matched uses the ASCII character
 set. Sadly, my problem is that I need to process Unicode text. The re
 module has its own character classes that do support Unicode, however
 they are not sufficient.

 I would find it extremely useful if there was information on the
 Unicode code points that map to each of the POSIX character classes.

 Have a look at the new regex implementation on PyPI:

  http://pypi.python.org/pypi/regex

This is exactly what I needed! Thanks!
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ways of accessing this mailing list?

2010-12-11 Thread Martin Schoeoen
On 2010-11-04, Mark Wooding m...@distorted.org.uk wrote:
 John Bond li...@asd-group.com writes:

 Hope this isn't too O/T - I was just wondering how people read/send to
 this mailing list, eg. normal email client, gmane, some other software
 or online service?

 My normal inbox is getting unmanageable, and I think I need to find a
 new way of following this and other lists.

 I read and post to it as comp.lang.python.  I maintain a local NNTP
 server, which interacts with my ISP's news server.  I read and post news
 (and mail) using GNU Emacs and Gnus.

 (Interestingly, if enormous folders are your problem, Gnus can apply
 news-like expiry rules to email folders.)

Same here: comp.lang.python and gnus. Well, right now I am actually trying 
out slrn -- a bit of a dejavu experience since I used slrn a bit in the
early 1990s (and I have not used vi in many, many years).

I have tried out other programs such as traditional email clients and
mainstream gui programs such as Pan but find that user interface paradigm
does not work well for usenet news and me.

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


Re: Catching user switching and getting current active user from root on linux

2010-12-11 Thread Steven D'Aprano
On Sat, 11 Dec 2010 11:43:13 -0800, mpnordland wrote:

 sorry, I've been busy, it's on linux, and current active user is the
 user currently using the computer. My program needs to switch log files
 when a different user starts using the computer.

I think you have missed what people are trying to tell you: if you're 
running Linux, you may have more than one human being logged into and 
using the computer AT THE SAME TIME. You can also have a single human 
being logged into the computer as more than one user, and one user being 
used by multiple human beings.

As we speak, I am logged into my Linux computer eight times, five times 
as myself (two GUI sessions, just to prove I can do it, plus three 
terminals), two times as root, and one time as another user; my wife's 
computer has two people logged in simultaneously (me and her); I'm also 
logged into a server at work, which currently lists eight people logged 
in twenty-one times between them.

Perhaps you should explain what problem you are trying to solve, rather 
than how you think you should solve it (catch the user switching).



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


array and strings in Python 3

2010-12-11 Thread wander.lairson
Hello,

This is my first post on python mailing list. I've working in code
which must run on python 2 and python 3. I am using array.array as
data buffers. I am stuck with the following code line, which works on
Python 2, but not on Python 3.1.2:

 import array
 array.array('B', 'test')
Traceback (most recent call last):
  File stdin, line 1, in module
TypeError: an integer is required

According to Python 3 documentation (as far as I understood it), it
should work. Again, no problem on Python 2. I've googled for people
with similar problems, but got nothing. Does anyone have an idea what
could I be doing wrong?

Thanks in advance.

-- 
Best Regards,
Wander Lairson Costa
LCoN - Laboratório de Computação Natural - Natural Computing Laboratory
(http://www.mackenzie.com.br/lcon.html)
Programa de Pós-Graduação em Engenharia Elétrica (PPGEE)
Faculdade de Computação e Informática (FCI)
Universidade Presbiteriana Mackenzie - SP - Brazil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: array and strings in Python 3

2010-12-11 Thread Chris Rebert
On Sat, Dec 11, 2010 at 5:32 PM, wander.lairson
wander.lair...@gmail.com wrote:
 Hello,

 This is my first post on python mailing list. I've working in code
 which must run on python 2 and python 3. I am using array.array as
 data buffers. I am stuck with the following code line, which works on
 Python 2, but not on Python 3.1.2:

 import array
 array.array('B', 'test')
 Traceback (most recent call last):
  File stdin, line 1, in module
 TypeError: an integer is required

 According to Python 3 documentation (as far as I understood it), it
 should work.

I think you forgot to keep in mind the changes in bytes vs. unicode in
Python 3 when reading the docs.

 Again, no problem on Python 2. I've googled for people
 with similar problems, but got nothing. Does anyone have an idea what
 could I be doing wrong?

Recall that string handling changed incompatibly between Python 2 and
Python 3. Your 'test' was a bytestring in Python 2 but is now a
*Unicode string* in Python 3.

The `array` module's handling of strings changed as well. Reading the
Python 3 docs @ http://docs.python.org/dev/library/array.html , we
find (all emphases added):
class array.array(typecode[, initializer])
[...]
If given a list or string, the initializer is passed to the new
array’s fromlist(), frombytes(), or **fromunicode()** method (see
below) to add initial items to the array. Otherwise, the iterable
initializer is passed to the extend() method.
[...]
array.fromunicode(s)
Extends this array with data from the given unicode string. The
array **must be a type 'u' array**; **otherwise a ValueError is
raised**. Use array.frombytes(unicodestring.encode(enc)) to append
Unicode data to an array of some other type.

Since your array's typecode is not 'u', you're getting a ValueError
just like the docs say.

Try using a bytestring instead:
array.array('B', btest) # Note the b prefix

Incidentally, if you ran 2to3 over your code and weren't warned about
this change in the array module, then that's probably a bug in 2to3
which ought to be reported: http://bugs.python.org

Cheers,
Chris
--
http://blog.rebertia.com
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: array and strings in Python 3

2010-12-11 Thread wander.lairson
 The `array` module's handling of strings changed as well. Reading the
 Python 3 docs @ http://docs.python.org/dev/library/array.html , we
 find (all emphases added):
 class array.array(typecode[, initializer])
    [...]
    If given a list or string, the initializer is passed to the new
 array’s fromlist(), frombytes(), or **fromunicode()** method (see
 below) to add initial items to the array. Otherwise, the iterable
 initializer is passed to the extend() method.
 [...]
 array.fromunicode(s)
    Extends this array with data from the given unicode string. The
 array **must be a type 'u' array**; **otherwise a ValueError is
 raised**. Use array.frombytes(unicodestring.encode(enc)) to append
 Unicode data to an array of some other type.

Actually I was using the 3.1 docs as reference, as it is the stable
one. After your comments,
I dug a bit more in the documentation and in the code, and I figured
out that for unicode strings,
you must pass 'u' as the first constructor parameter.

 Incidentally, if you ran 2to3 over your code and weren't warned about
 this change in the array module, then that's probably a bug in 2to3
 which ought to be reported: http://bugs.python.org

I am not using 2to3 because I am not converting Python 2 code to
Python 3, I am writing
code that must run on Python 2 and Python 3.

Thank you for your help :)


-- 
Best Regards,
Wander Lairson Costa
LCoN - Laboratório de Computação Natural - Natural Computing Laboratory
(http://www.mackenzie.com.br/lcon.html)
Programa de Pós-Graduação em Engenharia Elétrica (PPGEE)
Faculdade de Computação e Informática (FCI)
Universidade Presbiteriana Mackenzie - SP - Brazil
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Ways of accessing this mailing list?

2010-12-11 Thread Monte Milanuk

On 12/11/10 3:32 PM, Martin Schoeoen wrote:

On 2010-11-04, Mark Woodingm...@distorted.org.uk  wrote:

John Bondli...@asd-group.com  writes:


Hope this isn't too O/T - I was just wondering how people read/send to
this mailing list, eg. normal email client, gmane, some other software
or online service?


Thunderbird + gmane works for me.


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


Re: Ways of accessing this mailing list?

2010-12-11 Thread Harishankar
On Sat, 11 Dec 2010 21:15:13 -0800, Monte Milanuk wrote:
 Thunderbird + gmane works for me.

I myself post using Pan Usenet client accessing this mailing list from 
gmane.

The advantage of a proper newsreader software is that it quotes correctly 
(i.e. quote at top, reply below). Many Usenet and mailing list users get 
angry if you top post (i.e. quote below the reply)


-- 
Harishankar (http://harishankar.org http://lawstudentscommunity.com)

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


[issue10676] Confusing note in Numeric Types

2010-12-11 Thread Georg Brandl

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

Thanks, fixed in r87169.

--
nosy: +georg.brandl
resolution:  - fixed
status: open - closed

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



[issue10677] make altinstall includes ABI codes in versioned executable name

2010-12-11 Thread Nick Coghlan

New submission from Nick Coghlan ncogh...@gmail.com:

make altinstall is currently installing python3.2m rather than python3.2.

Since PEP 3149 makes no mention of changing the executable name, this should be 
fixed to correctly install the executable as python3.2.

I suspect this will also affect a make install, but will be obscured in that 
case since the python3 symlink will still do the right thing. (I haven't tried 
it, since I don't want to clobber the Canonical provided 3.1 installation)

--
assignee: barry
messages: 123782
nosy: barry, georg.brandl, ncoghlan
priority: release blocker
severity: normal
status: open
title: make altinstall includes ABI codes in versioned executable name
versions: Python 3.2

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



[issue10677] make altinstall includes ABI codes in versioned executable name

2010-12-11 Thread Nick Coghlan

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


--
components: +Build
stage:  - needs patch
type:  - behavior

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



[issue10678] email.utils.mktime_tz Giving wrong result , by ignoring Timezone that comes from value of parsedate .

2010-12-11 Thread Phyo Arkar Lwin

New submission from Phyo Arkar Lwin phyo.arkarl...@gmail.com:

DESCRIPTION:

I am trying to parse Time Zone information out of email messages and i found 
out that mktime_tz is totally ignoring TimeZone information from parsedate_tz.


VERSION: 2.6.5
CODE and RESULTS:


from time import mktime
from email.utils import parsedate,parsedate_tz,formatdate,mktime_tz

parsedate_tz('Sat, 10 Apr 2004 03:50:19 +400')
 (2004, 4, 10, 3, 50, 19, 0, 1, -1, 14400)


mktime_tz(parsedate_tz('Sat, 10 Apr 2004 03:50:19 +400'))
1081554619.0
mktime(parsedate('Sat, 10 Apr 2004 03:50:19'))
1081545619.0

Same

formatdate(mktime_tz(parsedate_tz('Sat, 10 Apr 2004 03:50:19 +400')))
'Fri, 09 Apr 2004 23:50:19 -' # WRONG TOTALLY

Expected Result:
'Sat, 10 Apr 2004 03:50:19 +400'

--
components: None
messages: 123783
nosy: Phyo.Arkar.Lwin
priority: normal
severity: normal
status: open
title: email.utils.mktime_tz Giving wrong result , by ignoring Timezone  that 
comes from value of  parsedate .
versions: Python 2.6

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



[issue10678] email.utils.mktime_tz Giving wrong result , by ignoring Timezone that comes from value of parsedate_tz .

2010-12-11 Thread Phyo Arkar Lwin

Changes by Phyo Arkar Lwin phyo.arkarl...@gmail.com:


--
title: email.utils.mktime_tz Giving wrong result , by ignoring Timezone  that 
comes from value of  parsedate . - email.utils.mktime_tz Giving wrong result , 
by ignoring Timezone  that comes from value of  parsedate_tz .

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



[issue10679] make altinstall will clobber OS provided scripts

2010-12-11 Thread Nick Coghlan

New submission from Nick Coghlan ncogh...@gmail.com:

make altinstall installs 2to3, pydoc3 and idle3 without version 
specific names.

This was at least a deliberate decision in the case of 2to3, but there doesn't 
appear to be any reason not to use a properly qualified version suffix on the 
pydoc and idle executables.

--
messages: 123784
nosy: benjamin.peterson, georg.brandl, ncoghlan
priority: release blocker
severity: normal
stage: needs patch
status: open
title: make altinstall will clobber OS provided scripts
type: behavior

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



[issue10679] make altinstall may clobber OS provided scripts

2010-12-11 Thread Nick Coghlan

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

Softened the wording, since OS packages will often omit installing any 
executable files other than the main python binary.

--
title: make altinstall will clobber OS provided scripts - make altinstall 
may clobber OS provided scripts

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



[issue10678] email.utils.mktime_tz Giving wrong result , by ignoring Timezone that comes from value of parsedate_tz .

2010-12-11 Thread Phyo Arkar Lwin

Changes by Phyo Arkar Lwin phyo.arkarl...@gmail.com:


--
type:  - behavior

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



[issue10677] make altinstall includes ABI codes in versioned executable name

2010-12-11 Thread Nick Coghlan

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

The other thing that makes this clearly an error is, of course, the fact that 
all the shebang lines expect the executable to be called python3.2

--

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



[issue10515] csv sniffer does not recognize quotes at the end of line

2010-12-11 Thread Skip Montanaro

Skip Montanaro s...@pobox.com added the comment:

From the comment in the test_csv.py:

+# XXX: I don't know what the correct behavior should be for these.
+# Currently the first one raises an error that the delimiter can't
+# be determined while the second one returns '\r'.  The second
+# is obviously.
+('a,b,c,d\ne',  ''),
+('a,b,c,d\r\ne', ''),

Obviously what?  My guess would be wrong.  In the absence of any other
information \r\n has to be treated as a line separator.  It shouldn't be
considered as two separate characters, even in such a devoid-of-clues test
case.

Is the empty string a valid delimiter?  I've never tried it and it's been a
long time since I looked at any of the code.  I do use single-column CSV
files from time-to-time though.  I don't think a ',' would be a completely
unreasonable fallback scenario either.

Skip

--

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread Milko Krachounov

Milko Krachounov pyt...@milko.3mhz.net added the comment:

I attached unit tests that test that cloexec is properly set. I can't test my 
tests too well with the unpatched version because runtests.sh is too 
complicated to use, and doesn't print any useful output by default.

--
Added file: 
http://bugs.python.org/file20007/subprocess-cloexec-atomic-py3k-tests1.patch

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread Milko Krachounov

Changes by Milko Krachounov pyt...@milko.3mhz.net:


Removed file: 
http://bugs.python.org/file20007/subprocess-cloexec-atomic-py3k-tests1.patch

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread Milko Krachounov

Changes by Milko Krachounov pyt...@milko.3mhz.net:


Added file: 
http://bugs.python.org/file20008/subprocess-cloexec-atomic-py3k-tests1.patch

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread Milko Krachounov

Changes by Milko Krachounov pyt...@milko.3mhz.net:


Removed file: 
http://bugs.python.org/file20008/subprocess-cloexec-atomic-py3k-tests1.patch

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread Milko Krachounov

Changes by Milko Krachounov pyt...@milko.3mhz.net:


Added file: 
http://bugs.python.org/file20009/subprocess-cloexec-atomic-py3k-tests1.patch

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



[issue969718] BASECFLAGS are not passed to module build line

2010-12-11 Thread Jakub Wilk

Changes by Jakub Wilk jw...@jwilk.net:


--
nosy: +jwilk

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



[issue10642] site.py crashes on python startup due to defective .pth file

2010-12-11 Thread Arfrever Frehtes Taifersar Arahesis

Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com added the comment:

I suggest to:
- Print path to the .pth file, which causes exception. Current traceback 
doesn't help in finding the cause of problem:

# echo import nonexistent  /usr/lib64/python3.2/site-packages/some_file.pth
# python3.2 -c pass
Traceback (most recent call last):
  File /usr/lib64/python3.2/site.py, line 520, in module
main()
  File /usr/lib64/python3.2/site.py, line 509, in main
known_paths = addsitepackages(known_paths)
  File /usr/lib64/python3.2/site.py, line 301, in addsitepackages
addsitedir(sitedir, known_paths)
  File /usr/lib64/python3.2/site.py, line 177, in addsitedir
addpackage(sitedir, name, known_paths)
  File /usr/lib64/python3.2/site.py, line 148, in addpackage
exec(line)
  File string, line 1, in module
ImportError: No module named nonexistent

- Maybe change error into warning.

--

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



[issue6559] [PATCH]add pass_fds paramter to subprocess.Popen()

2010-12-11 Thread Milko Krachounov

Milko Krachounov pyt...@milko.3mhz.net added the comment:

The patch doesn't seem to work.

I added this before closerange in _close_all_but_a_sorted_few_fds:

print(Closing, start_fd, up to, fd, exclusive)

And used the attached script to run as a subprocess to check for open fds 
(taken from my tests patch for issue 7213).

Here's the result:
Python 3.2b1 (py3k:87158M, Dec 11 2010, 02:55:28) 
[GCC 4.4.5] on linux2
Type help, copyright, credits or license for more information.
 import sys
 import os
 import subprocess
 subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=False).wait()
0,1,2
0
 os.pipe()
(3, 4)
 os.pipe()
(5, 6)
 subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=False).wait()
0,1,2,3,4,5,6
0
 subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True).wait()
0,1,2
0
 subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True, 
 pass_fds=(6,)).wait()
0,1,2,6
0
 subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True, 
 pass_fds=(3,)).wait()
0,1,2
0
 subprocess._posixsubprocess = None
 subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True, 
 pass_fds=(6,)).wait()
Closing 3 up to 6 exclusive
Closing 7 up to 8 exclusive
0,1,2,6
0
 subprocess.Popen([sys.executable, 'fd_status.py'], close_fds=True, 
 pass_fds=(3,)).wait()
Closing 3 up to 8 exclusive
0,1,2
0

I also attach a possible test for pass_fds, and an example fix for Python-only 
implementation. The test requires either my tests patch for issue 7213, or the 
attached fd_status.py to be put in subprocessdata subdir of Lib/test. The fixed 
Python implementation passes my test and works fine in the console, I haven't 
tried the C one. (I don't have a patch for the fix, since it would conflict 
with the patches for issue 7213.)

--
nosy: +milko.krachounov
Added file: http://bugs.python.org/file20010/fd_status.py

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



[issue6559] [PATCH]add pass_fds paramter to subprocess.Popen()

2010-12-11 Thread Milko Krachounov

Changes by Milko Krachounov pyt...@milko.3mhz.net:


Added file: http://bugs.python.org/file20011/test_pass_fds.py

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



[issue6559] [PATCH]add pass_fds paramter to subprocess.Popen()

2010-12-11 Thread Milko Krachounov

Changes by Milko Krachounov pyt...@milko.3mhz.net:


Added file: 
http://bugs.python.org/file20012/subprocess-pass_fd_fix_example.patch

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



[issue10515] csv sniffer does not recognize quotes at the end of line

2010-12-11 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

Yeah, obviously wrong.  I forgot to finish editing the comment.

I think a fallback of ',' makes more sense than ''.  What would a delimiter of 
nothing mean?  I don't think the unquoted case can be changed for backward 
compatibility reasons, so those tests I added should presumably be changed to 
confirm the existing behavior (with an appropriate comment).

--

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread Milko Krachounov

Milko Krachounov pyt...@milko.3mhz.net added the comment:

I add a patch that tests close_fds (there's no test for close_fds), that 
requires the tests1 patch. By the way, should there be a test for the atomicity 
of the operations?

--
Added file: 
http://bugs.python.org/file20013/subprocess-cloexec-atomic-py3k-tests2-close_fds.patch

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



[issue10642] site.py crashes on python startup due to defective .pth file

2010-12-11 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

I like the suggestion of turning it into a warning, myself, but you are right 
that at the least the error message should be improved.

--
resolution: invalid - 
stage: committed/rejected - needs patch
status: closed - open

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



[issue10677] make altinstall includes ABI codes in versioned executable name

2010-12-11 Thread Georg Brandl

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

Nice, definitely a blocker.

(BTW, if you configured without any specific --prefix, you shouldn't clobber 
anything installed by the distribution...)

--

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



[issue10679] make altinstall may clobber OS provided scripts

2010-12-11 Thread Georg Brandl

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

Yes, this already irked me with previous versions.

--

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



[issue10678] email.utils.mktime_tz Giving wrong result , by ignoring Timezone that comes from value of parsedate_tz .

2010-12-11 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

mktime_tz is documented as turning the input into a *UTC* timestamp.  That's 
what your example shows it doing.

There is an open issue elsewhere in this tracker for providing a way to 
round-trip RFC2822 timestamps.

--
nosy: +r.david.murray
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

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



[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)

2010-12-11 Thread Mads Michelsen

New submission from Mads Michelsen madch...@gmail.com:

This is a follow-up to Issue 58 from the Google Project Hosting bug tracker 
(http://code.google.com/p/argparse/issues/detail?id=58). I couldn't find any 
equivalent/re-posting of it here, so I took the liberty of creating a new one - 
despite the bug being marked 'WontFix' on Google. The reason for this is that I 
cannot make the suggested workaround... well, work. 

The root problem: the argparse parser add_mutually_exclusive_group method does 
not accept title or description arguments. 

The workaround: steven.bethard suggests on google to create a 'straight' dummy 
group (i.e. one made using the title-accepting add_argument_group method) and 
then attach the mutually exclusive group to the dummy group - which is attached 
to the parser itself. 

The problem: while the group does appear as a group with title on the help 
output, the group does not appear to actually _be_ mutually exclusive (I get no 
objections to running several arguments from the same group together) nor does 
it display as mutually exclsuive on the help output. 

Please see attached file for code + resulting output.

(I hope I'm doing this right - this is my first bug report, so bear with and 
instruct me if I'm getting it wrong)

--
components: Library (Lib)
files: argsconfig.txt
messages: 123797
nosy: Mads.Michelsen
priority: normal
severity: normal
status: open
title: argparse: titles and add_mutually_exclusive_group don't mix (even with 
workaround)
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file20014/argsconfig.txt

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



[issue10642] site.py crashes on python startup due to defective .pth file

2010-12-11 Thread Éric Araujo

Éric Araujo mer...@netwok.org added the comment:

Aren’t there studies that show that people don’t read warnings?  I’m +0 on a 
warning and +1 on an error.

--

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



[issue10677] make altinstall includes ABI codes in versioned executable name

2010-12-11 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

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



[issue10679] make altinstall may clobber OS provided scripts

2010-12-11 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

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



[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)

2010-12-11 Thread Martin v . Löwis

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

Can you please formulate that is a test case? Use this structure:

1. do this
2. this happens
3. this should happen instead

--
nosy: +loewis

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



[issue10631] ZipFile and current directory change

2010-12-11 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +eric.araujo

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



[issue10680] argparse: titles and add_mutually_exclusive_group don't mix (even with workaround)

2010-12-11 Thread Mads Michelsen

Mads Michelsen madch...@gmail.com added the comment:

Okay, I'll try:

Save the following code as argparse_test.py:

[CODE]
#! /usr/bin/env python2

import argparse

def args_config(about):
parser = argparse.ArgumentParser(description=about)
dummy_group = parser.add_argument_group(title='mutually exclusive')
test_group = dummy_group.add_mutually_exclusive_group()
test_group.add_argument('-a', action='store_true', default=False, \
help='This is the r option')
test_group.add_argument('-b', action='store_true', default=False, \
help='This is the b option')
test_group.add_argument('-c', action='store_true', default=False, \
help='And this is the c option')
args_ns = parser.parse_args()
return args_ns

about = 'This is a test case'
args_ns = args_config(about)
print args_ns
[/CODE]

The use the -h argument to see help output:

[OUTPUT]
[~] python/argparse_test.py -h
usage: argparse_test.py [-h] [-a] [-b] [-c]

This is a test case

optional arguments:
  -h, --help  show this help message and exit

mutually exclusive:
  -a  This is the r option
  -b  This is the b option
  -c  And this is the c option
[/OUTPUT]

The run it with all the options together to test exclusivity:

[OUTPUT]
[~] python/argparse_test.py -abc
Namespace(a=True, b=True, c=True)
[/OUTPUT]

What happens: As you can see, there are no objections to using all three 
options at the same time. Neither does the help output indicate that there 
should be.

What should happen:
If I have understood the instructions in the Issue report on Google correctly, 
the assumption is that this workaround (i.e. using a dummy group) should 
produce the desired result (i.e. that running the command argparse_test.py 
-abc should appear as and be prbohibited)

--

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



[issue10642] Improve the error message of addpackage() (site.py) for defective .pth file

2010-12-11 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
title: site.py crashes on python startup due to defective .pth file - Improve 
the error message of addpackage() (site.py) for defective .pth file

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread STINNER Victor

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

subprocess-cloexec-atomic-py3k-tests2-close_fds.patch adds a test called to 
Win32ProcessTestCase which is specific to Windows. And this class has already a 
test with the same name. You should move your test to ProcessTestCase (and so 
it will test the C implementation, the Python implementation and also without 
poll).

--

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread STINNER Victor

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

 subprocess-cloexec-atomic-py3k-tests2-close_fds.patch adds a test
 called [test_close_fds] to Win32ProcessTestCase ...

Oops, forget my last comment, I didn't applied the patches in the right order. 
There are too much patches :-p Can you try to create one unique patch? It will 
be easier to test it and to review it.

--

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



[issue7695] missing termios constants

2010-12-11 Thread Rodolpho Eckhardt

Rodolpho Eckhardt r...@rhe.vg added the comment:

Because these constants might not exist on all platforms, the patch uses 
ifdef's around them.

--
keywords: +patch
nosy: +Rodolpho.Eckhardt
Added file: http://bugs.python.org/file20015/patch_termios_consts_issue7695.diff

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread STINNER Victor

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

subprocess-cloexec-atomic-py3k.patch:

+case $ac_sys_system in
+  GNU*|Linux*)
+  AC_CHECK_FUNC(pipe2, AC_DEFINE(HAVE_PIPE2, 1, [Define if the OS supports 
pipe2()]), )
+esac
 
I think that you can remove the test on the OS name. AC_CHECK_FUNC() doesn't 
hurt if the function doesn't exist. Other OS may have pipe2().

--

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



[issue10502] Add unittestguirunner to Tools/

2010-12-11 Thread Mark Roddy

Mark Roddy markro...@gmail.com added the comment:

Attaching patch that adds the unittestgui to Tools/scripts.  Also has updates 
to the unittest documentation which includes a note that this tool is for 
beginners and a CI system should be used in general.

--
keywords: +patch
nosy: +MarkRoddy
Added file: http://bugs.python.org/file20016/unittestgui.patch

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread STINNER Victor

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

test_pipe_cloexec_unix_tools() is specific to UNIX/BSD because it requires cat 
and grep programs. You should try to reuse the Python interpreter to have a 
portable test (eg. working on Windows), as you did with fd_status.py.


+data = b'\n'
+subdata = b'aaa'
+assert subdata in data, Test broken

Use maybe subdata = data[:3] to avoid an assertion.

I don't understand why do you talk about atomicity. Do you test add 
non-atomic operations? Was subprocess atomic?

If I understood correctly, you are fixing a specific issue which can be called 
something like subprocess: close pipes on exec(), set FD_CLOEXEC flag to all 
pipes, and no more changing the default value of close_fds. Can you update the 
title please?

--

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



[issue10188] tempfile.TemporaryDirectory may throw errors at shutdown

2010-12-11 Thread Jurko Gospodnetić

Jurko Gospodnetić jurko.gospodne...@gmail.com added the comment:

Also this class, because it defines __del__ too simply, will display a 
user-unfriendly error message when cleaning up a TemporaryDirectory object 
whose constructor raised an exception when attempting to create its temporary 
folder.

  For example try to create a TemporaryDirectory with prefix= on 
Windows. That should fail as folders there can not contain '' characters and 
later on in the program you should get an error message something like this one:

Exception AttributeError: 'TemporaryDirectory' object has no attribute 
'_closed' in bound method TemporaryDirectory.cleanup of 
tempfile.TemporaryDirectory object at 0x00CE1E10 ignored

  Hope this helps.

[Sorry, did not know whether to add this as a separate issue as it seemed kind 
of related to this one.]

--
nosy: +Jurko.Gospodnetić

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



[issue10188] tempfile.TemporaryDirectory may throw errors at shutdown

2010-12-11 Thread Jurko Gospodnetić

Jurko Gospodnetić jurko.gospodne...@gmail.com added the comment:

Clicked send too soon on the previous comment. :-(

  The simplest way I see you can fix the __del__ issue is to patch 
TemporaryDirectory.__init__() as follows:

def __init__(self, suffix=, prefix=template, dir=None):
self._closed = True
self.name = mkdtemp(suffix, prefix, dir)
self._closed = False

  This is based on the tempfile.py from the 3.2 beta 1 release on Windows.

--

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



[issue10681] PySlice_GetIndices() signature changed

2010-12-11 Thread Phil Thompson

New submission from Phil Thompson p...@riverbankcomputing.com:

In Python v3.2b1 the type of the first argument of PySlice_GetIndices() and 
PySlice_GetIndicesEx() has changed from PySliceObject* to PyObject*.

The documentation does not reflect this change.

Which is correct, the source code or the documentation?

--
assignee: d...@python
components: Documentation, Interpreter Core
messages: 123809
nosy: Phil.Thompson, d...@python
priority: normal
severity: normal
status: open
title: PySlice_GetIndices() signature changed
type: behavior
versions: Python 3.2

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



[issue10677] make altinstall includes ABI codes in versioned executable name

2010-12-11 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue10681] PySlice_GetIndices() signature changed

2010-12-11 Thread Martin v . Löwis

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

The source is correct. Fixed in r87171.

--
nosy: +loewis
resolution:  - fixed
status: open - closed

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



[issue10679] make altinstall may clobber OS provided scripts

2010-12-11 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue10663] configure shouldn't set a default OPT

2010-12-11 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue969718] BASECFLAGS are not passed to module build line

2010-12-11 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue7213] Popen.subprocess change close_fds default to True

2010-12-11 Thread Jakub Wilk

Changes by Jakub Wilk jw...@jwilk.net:


--
nosy: +jwilk

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



[issue10681] PySlice_GetIndices() signature changed

2010-12-11 Thread Phil Thompson

Phil Thompson p...@riverbankcomputing.com added the comment:

You might want to add a Changed in Python v3.2 because as it is an 
incompatible change.

--

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



[issue10188] tempfile.TemporaryDirectory may throw errors at shutdown

2010-12-11 Thread Georg Brandl

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

Applied the fix from msg123808 in r87172.

--
nosy: +georg.brandl

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



[issue10681] PySlice_GetIndices() signature changed

2010-12-11 Thread Martin v . Löwis

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

It's not an incompatible change, but I added the versionchanged anyway in 
r87173.

--

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



[issue10642] Improve the error message of addpackage() (site.py) for defective .pth file

2010-12-11 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

My guess is people don't read warnings when they are a common occurrence.  A 
working Python should not emit any warnings, and a properly working Python 
program (post 2.6/3.1 (or whenever it was we decided to suppress deprecation 
warnings by default)) should not either.  But certainly messages that don't 
cause program termination *can* be ignored, and thus are more often than 
program-terminating errors :)

On the other hand, this *is* an error.  If we agree that python startup and 
site.py should not fail in the face of misconfigured libraries (and we aren't 
necessarily agreed on that :) then another option would be to use the logging 
facility to generate an error that would, by default, be logged to stderr but 
still allow Python to start.  That's not that much different from emitting a 
warning, functionally, but by having the message make it clear that it is an 
error it might make it more likely the user would take action.

As for whether or not we should want Python to be able to start up in the face 
of 3rd party library misconfiguration, I think there are arguments on both 
sides.  The most compelling argument I can think of for having errors in third 
partly libraries not cause startup failure is that a user borking their system 
python by installing a malfunctioning library would then cause all 
python-dependent system functions to fail to run until they'd fixed the 
install.  With a system such as gentoo where the package manager that the user 
might want to use to do the uninstall uses Python, this could be a problem.

--

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



  1   2   >