Re: No ValueError for large exponents?

2006-09-10 Thread enigmadude
Georg Brandl wrote:
 enigmadude wrote:
  As many have heard, IronPython 1.0 was released. When I was looking
  through the listed differences between CPython and IronPython, the
  document mentioned that using large exponents such as 10 **
  735293857239475 will cause CPython to hang, whereas IronPython will
  raise a ValueError.

 What message does that value error have?

 If it's a memory issue, the operation should raise MemoryError (at
 least in CPython).

 Georg

I haven't run IronPython yet, but the Differences document says that
IronPython would raise a ValueError. It wasn't any more specific than
that. As far as CPython, I didn't wait long enough for it to raise a
MemoryError if it was going to raise one at all. From a user point of
view, CPython appeared to hang for about one minute, slowly raising CPU
usage and RAM usage, before I finally decided to just kill the process.
I don't know whether or not it would have completed 5 minutes later or
whether it would hang indefinitely, I haven't tested it. Although I may
be overreacting, I would wonder about the ramifications of something
like this hanging the interpreter (possible vector for DOS attack on an
webapp server, or even the machine itself if it balloons RAM usage?).
I'm not trying to be a doomsayer or anything, but I just want to know
how CPython handles extreme cases like this.

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


Re: search and replace in a file :: newbie help

2006-09-10 Thread techie2go
thanks , i got it

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


Re: Can I make unicode in a repr() print readably?

2006-09-10 Thread Martin v. Löwis
Terry Hancock schrieb:
 Is it possible to define some combination of __repr__, __str__,
 and/or __unicode__ so that the unicode() wrapper isn't necessary
 in this statement:

I'm not aware of a way of doing so.

 Or, put another way, what exactly does 'print' do when it gets
 a class instance to print? It seems to do the right thing if
 given a unicode or string object, but I cant' figure out how to
 make it do the same thing for a class instance.

It won't. PyFile_WriteObject checks for Unicode objects, and whether
the file has an encoding attribute set, and if so, encodes the
Unicode object.

If it is not a Unicode object, it falls through to PyObject_Print,
which first checks for the tp_print slot (which can't be set in
Python), then uses PyObject_Str (which requires that the __str__
result is a true byte string), or PyObject_Repr (if the RAW
flag isn't set - it is when printing). PyObject_Str first checks
for tp_str; if that isn't set, it falls back to PyObject_Repr.

 And I understand that I might want that if I'm working in
 an ASCII-only terminal.  But it's a big help to be able to
 read/recognize the labels when I'm working with localized
 encodings, and I'd like to save the extra typing if I'm
 going to be looking at a lot of these

You can save some typing, of course, with a helper function:

def p(o):
  print unicode(o)

I agree that this is not optimal; contributions are welcome.
It would probably be easiest to drop the guarantee that
PyObject_Str returns a true string, or use _PyObject_Str
(which does not make this guarantee) in PyObject_Print.
One would have to think what the effect on backwards
compatibility is of such a change.

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


Re: OT: What encoding is this?

2006-09-10 Thread Martin v. Löwis
Neil Hodgson schrieb:
 http://www.loppen.dk/side.php?navn=getin

 More pages without declarations are produced on Windows so
 I'd guess that its Windows-1252. To tell, look for prices in Euros (€)
 on the site.

Ah, but they still use krones in Denmark :-)

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


Re: Function metadata (like Java annotations) in Python

2006-09-10 Thread Paddy
oripel wrote:
 Hi,

 I'm trying to attach some attributes to functions and methods, similar
 to Java annotations and .NET attributes.
 I also want to use a convenient decorator for it, something along the
 lines of

 @attr(name=xander, age=10)
 def foo():
   ...

 Assigning attributes to the function will work, as will assigning keys
 and values to a dictionary in an attribute. But if there are more
 decorators in the way, this could fail:

 @onedec
 @attr(...)
 @twodec
 def foo():
   ...

 Given 'foo' now, how do I find the attributes?

 Assigning to a global attribute registry (some interpreter-global
 dictionary), although less desirable, might have been acceptable, but
 then how do I identify the function after it's been wrapped in more
 decorators?

 Also, it may be nice to have the following work as well:

 @attr(name=Xander)
 @attr(age=10)
 @somedec
 @attr(hobby=knitting)
 def foo():
   ...


 Any thoughts? Am I rehashing something old that my search skills didn't
 uncover?

 Thanks!
 Ori.

I wrote up my investigation into function attributes and decorators on
my blog:

http://paddy3118.blogspot.com/2006/05/python-function-attributes.html
http://paddy3118.blogspot.com/2006/05/function-attributes-assigned-by.html

What do you think?

- Paddy.

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


Re: How to insert an email-link into wxPython's HtmlWindow

2006-09-10 Thread [EMAIL PROTECTED]

Thanks. It works now.

--Kneo

[EMAIL PROTECTED] wrote:
 Hello. I don't know if this topic is appropriate in this group (and my
 English is not good).

 My problem is here:

 I created a HtmlWindow in wxPython, then I wrote some code and set it
 to the page-text. In these code there was a line a
 href=mailto:[EMAIL PROTECTED][EMAIL PROTECTED]/a (where name was my
 real username). Then I showed this HtmlWindow and I thought there would
 be a mail-sending box when I clicked on the [EMAIL PROTECTED] link (like
 when I clicked it in a web browser). But there just came a Python
 Error-titled dialog: Unable to open requested HTML document
 mailto:[EMAIL PROTECTED] What should I do to solve this problem?
 
 (My OS is WinXP.)
 
 Thanks.

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


Re: Unicode / cx_Oracle problem

2006-09-10 Thread Diez B. Roggisch
Richard Schulman schrieb:
  cursor.execute(INSERT INTO mean (mean_id,mean_eng_txt)
  VALUES (:id,:mean),id=id,mean=mean)
 ...
  cx_Oracle.NotSupportedError: Variable_TypeByValue(): unhandled data
 type unicode

 But when I try putting a codecs.BOM_UTF16_LE in various plausible
 places, I just end up generating different errors.
 
 Diez:
 Show us the alleged plausible places, and the different errors. 
 Otherwise it's crystal ball time again.
 
 More usefully, let's just try to fix the code above. Here's the error
 message I get:
 
 NotSupportedError: Variable_TypeByValue(): unhandled data type unicode
 
 Traceback (innermost last):
 
 File c:\pythonapps\LoadMeanToOra.py, line 1, in ?
   # LoadMeanToOra reads a UTF-16LE input file one record at a time
 File c:\pythonapps\LoadMeanToOra.py, line 23, in ?
   cursor.execute(INSERT INTO mean (mean_id,mean_eng_txt)
 
 What I can't figure out is whether cx_Oracle is saying it can't handle
 Unicode for an Oracle nvarchar2 data type or whether it can handle the
 input but that it needs to be in a specific format that I'm not
 supplying.

What does

print repr(mean)

give you?

It _looks_ to me (don't have an orcacle available right now) as if it is 
  a unicode object. That you have to consider as some abstract string 
representation. Which means it has to be encoded in some way before sent 
over the wire. There might exist db-api bindings that can deal with 
them, by applying a default encoding or somehow figuring out what 
encoding the DB expects. But I don't see any references to unicode in 
pep 249, so I presume you can't rely on that - which seems to be the 
case here.

The oracle NLS is a sometimes tricky beast, as it sets the encoding it 
tries to be clever and assigns an existing connection some encoding, 
based on the users/machines locale. Which can yield unexpected results, 
such as Dusseldorf instead of Düsseldorf when querying a german city 
list with an english locale.

So - you have to figure out, what encoding your db-connection expects. 
You can do so by issuing some queries against the session tables I 
believe - I don't have my oracle resources at home, but googling will 
bring you there, the important oracle term is NLS.

Then you need to encode the unicode string before passing it - something 
like this:

mean = mean.encode(latin1)

That should help.

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


Re: pyExcelerator question - dates map to floats?

2006-09-10 Thread skip

John Check out my xlrd package.
John http://cheeseshop.python.org/pypi/xlrd/0.5.2

...

John,

Thank you.  I wasn't aware of it.  I'd seen mention of pyExcelerator a few
times recently.  All I need is to read Excel spreadsheets anyway.  I will
check it out.

I'm up for reading a good rant. ;-)

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


Re: Function metadata (like Java annotations) in Python

2006-09-10 Thread oripel
Thanks bearophile,

I prefer not to use docstrings for metadata.

1. Not interfering with the other accepted docstring uses may be
difficult (doctests, epydoc)

2. It's impractical for attributes generated by code:

@attr(reference_profile_stats=pstats.Stats(foo.profile))
def foo():
  ...

Regards,
Ori.

[EMAIL PROTECTED] wrote:
 oripel:

 Maybe this is a silly suggestion, the docstring is already overloaded,
 but it may be used for this too:

 def foo():
 
 ...
 ...
 @ATTR name=Xander
 @ATTR age=10
 @ATTR hobby=knitting
 
 ...

 (Or somethins similar without the @). Later you can retrive the
 attributes from the docstring, for example using a verbose RE like:
 r\s* @ATTR \s+ (\w*) \s* = \s* (.*)
 And you use it to create a dict of attributes.
 The decorators you apply to foo() must keep its docstring too.
 
 Bye,
 bearophile

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


Re: No ValueError for large exponents?

2006-09-10 Thread Felipe Almeida Lessa
2006/9/6, Robin Becker [EMAIL PROTECTED]:
 enigmadude wrote:
  As many have heard, IronPython 1.0 was released. When I was looking
  through the listed differences between CPython and IronPython, the
  document mentioned that using large exponents such as 10 **
  735293857239475 will cause CPython to hang, whereas IronPython will
  raise a ValueError. Trying this on my own machine, it did indeed seem
  to cause CPython to hang. In cases such as this, should this be
  considered a bug in the CPython implementation that needs to be fixed?
  Or is there a reason for this, such as consideration of future changes
  and language definition vs language implementation, etc.?
 
 I suspect the hang may be python actually trying to work out the
 1 followed by 735293857239475 zeroes. Perhaps IronPython has a forward
 looking algorithm that knows when to give up early.

I think that IronPython does the same as the .Net runtime does. Look
at boo's output:

$ booish
Welcome to booish, an interpreter for the boo programming language.

Running boo 0.7.5.2013.

The following builtin functions are available:
dir(Type): lists the members of a type
help(Type): prints detailed information about a type
load(string): evals an external boo file
globals(): returns the names of all variables known to the interpreter

Enter boo code in the prompt below.
 10**100
1E+100
 10**100
∞
 10**735293857239475
ERROR: Error reading from 'input3': 'Value too large or too small.'.
 (10**100).GetType()
System.Double

Well, it's a double on boo instead of a very long int as in Python. I
don't know if in IronPython it's the same.

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

Re: Function metadata (like Java annotations) in Python

2006-09-10 Thread oripel
Thanks!

Now I see it's accepted to assume nice decorators that update __dict__.
At least until __decorates__ or something similar is added...

fumanchu wrote:
 oripel wrote:
  I'm trying to attach some attributes to functions and methods, similar
  to Java annotations and .NET attributes.
  ...
  Assigning attributes to the function will work, as will assigning keys
  and values to a dictionary in an attribute. But if there are more
  decorators in the way, this could fail:
 
  @onedec
  @attr(...)
  @twodec
  def foo():
...
 
  Given 'foo' now, how do I find the attributes?
  ...
  Any thoughts? Am I rehashing something old that my search skills didn't
  uncover?

 There are past discussions about this; google for python-dev decorator
 metadata. For example:
 http://thread.gmane.org/gmane.comp.python.devel/77506/focus=77507


 Robert Brewer
 System Architect
 Amor Ministries
 [EMAIL PROTECTED]

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


Re: Looking for the Perfect Editor

2006-09-10 Thread urielka
use Eclipse!!!
it is not a editor but it is the best free IDE out there.
for python use Pydev(pydev.sf.net) plugin:it got
EVERYTHING:completteion,debuging(with thread support)you can`t work
without a debugger for serious projects.
for Web Develop use Aptana(aptana.com) another plugin for eclipse,in
eairly stages but it is very amazing support most of open source
javascript library with auto-complete and outline of code.
Scribes look very nice for a editor i will try it for lightweight
editing.

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


Re: Secure Postgres access

2006-09-10 Thread [EMAIL PROTECTED]
Paul Rubin wrote:
 Reid Priedhorsky [EMAIL PROTECTED] writes:
  B) Work machine. Run by others, many users. I'd like to also run my
  database client (Python) here.

 Well, just how much do you distrust that machine?  If you think it's
 totally pwned by attackers who will stop at nothing to subvert your
 client, you shouldn't run the client there.

I got the impression that he didn't trust other normal users on the box
but that root wasn't hostile.

  What I'd like is functionality similar to what Subversion does with
  svn+ssh:// URLs: an SSH tunnel that accepts only one connection and
  doesn't have race conditions.
[SNIP]
 And even if you have an SSH mode that accepts just one connection,
 since your db app is separate and has to connect to the
 forwarding port after you use a separate program open the port,
 how do you stop someone else from grabbing it first?

(I think that's what he meant by doesn't have race conditions.)

 That seems to mean one of:

   2) authentication through SCM_CREDENTIALS on a PF_UNIX socket

That looks like the best option of those you list.

 Actually, looking at the doc for ssh-agent(1), it looks like it might
 do something like #2 above.  If I understand it, you would run your db
 client as something like

ssh-agent your-client 

That's cool, I'm looking for something similar, thanks!

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


Re: Function metadata (like Java annotations) in Python

2006-09-10 Thread oripel
Thanks Paddy - you're showing normal use of function attributes.
They're still hidden when wrapped by an uncooperative decorator.

Paddy wrote:
 oripel wrote:
  Hi,
 
  I'm trying to attach some attributes to functions and methods, similar
  to Java annotations and .NET attributes.
  I also want to use a convenient decorator for it, something along the
  lines of
 
  @attr(name=xander, age=10)
  def foo():
...
 
  Assigning attributes to the function will work, as will assigning keys
  and values to a dictionary in an attribute. But if there are more
  decorators in the way, this could fail:
 
  @onedec
  @attr(...)
  @twodec
  def foo():
...
 
  Given 'foo' now, how do I find the attributes?
 
  Assigning to a global attribute registry (some interpreter-global
  dictionary), although less desirable, might have been acceptable, but
  then how do I identify the function after it's been wrapped in more
  decorators?
 
  Also, it may be nice to have the following work as well:
 
  @attr(name=Xander)
  @attr(age=10)
  @somedec
  @attr(hobby=knitting)
  def foo():
...
 
 
  Any thoughts? Am I rehashing something old that my search skills didn't
  uncover?
 
  Thanks!
  Ori.

 I wrote up my investigation into function attributes and decorators on
 my blog:

 http://paddy3118.blogspot.com/2006/05/python-function-attributes.html
 http://paddy3118.blogspot.com/2006/05/function-attributes-assigned-by.html
 
 What do you think?
 
 - Paddy.

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


Re: pyExcelerator question - dates map to floats?

2006-09-10 Thread skip

John Check out my xlrd package.
John http://cheeseshop.python.org/pypi/xlrd/0.5.2

Very nice.  Thanks for the pointer.  I threw away about 75% of the
xls-to-csv converter I wrote using pyExcelerator.  And it worked with Python
2.3 without having to comment out all the decorators.

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


Re: Function metadata (like Java annotations) in Python

2006-09-10 Thread George Sakkis
oripel wrote:
 Thanks Paddy - you're showing normal use of function attributes.
 They're still hidden when wrapped by an uncooperative decorator.

The decorator module may be helpful in defining cooperative decorators:
http://www.phyast.pitt.edu/~micheles/python/documentation.html

George

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


Re: OT: What encoding is this?

2006-09-10 Thread Morten Juhl Johansen
Martin v. Löwis wrote:
 Neil Hodgson schrieb:
 http://www.loppen.dk/side.php?navn=getin
 More pages without declarations are produced on Windows so
 I'd guess that its Windows-1252. To tell, look for prices in Euros (€)
 on the site.
 
 Ah, but they still use krones in Denmark :-)
 
 Regards,
 Martin

True. Yes, it is Danish.
The specific Danish characters æøå are visible with several encodings.
(I write this characters in unicode here).
And there are no prices on that page, since it describes the hardware
available at the small concert place Loppen.

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

Re: Looking for the Perfect Editor

2006-09-10 Thread Morten Juhl Johansen
mystilleef wrote:
 I recommend Scribes.
 
 http://scribes.sf.net

Scribes looks good. Does it need any Gnome components except what is
mentioned @ http://scribes.sourceforge.net/documentation.html#requirements ?

Yours,
Morten
-- 
http://mail.python.org/mailman/listinfo/python-list


Ghostscript interface

2006-09-10 Thread defcon8
Does a ghostscript interface for python exist? I have searched google
quite a bit and all I have been able to find are command line hacks
from within python. Thanks in advance for any useful help.

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


Re: Ghostscript interface

2006-09-10 Thread John Purser
On Sun, 2006-09-10 at 08:14 -0700, defcon8 wrote:
 Does a ghostscript interface for python exist? I have searched google
 quite a bit and all I have been able to find are command line hacks
 from within python. Thanks in advance for any useful help.
 

I'm not sure what you mean by a Ghostscript interface.  Ghostscript is
a program.  Yes, you can run it from Python using the same methods you
run any other program from Python but I'd hardly call that an
interface.

If you're looking for a python postscript generator I believe a google
search will turn up a number of products.

If you're looking for a python .pdf generator you might want to check
out:
http://www.reportlab.org/

John Purser

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


Re: egg and modpython

2006-09-10 Thread Bruno Desthuilliers
Wensheng a écrit :
 I installed pysqlite2 using easy_install.
 and got this when using it from modpython:
 --
 Mod_python error: PythonHandler etc.modpython
 
 Traceback (most recent call last):
 
(snip)
 
 ExtractionError: Can't extract file(s) to egg cache
 
 The following error occurred while trying to extract file(s) to the
 Python egg
 cache:
 
   [Errno 13] Permission denied: '/var/www/.python-eggs'
 
 The Python egg cache directory is currently set to:
 
   /var/www/.python-eggs
 
 Perhaps your account does not have write access to this directory?  You
 can
 change the cache directory by setting the PYTHON_EGG_CACHE environment
 variable to point to an accessible directory.
 
 
 Can peak developers fix this please?

Why should they fix something that's
1/ documented
- http://peak.telecommunity.com/DevCenter/EggFormats#zip-file-issues
2/ not a an egg specific issue
3/ really just a configuration/permission problem

(snip)

 in the mean time, I just have to use old download, unzip/untar 
 python setup.py install way.

No - you have to read the manual and fix you configuration. FWIW, the 
above traceback gives far enough clues (it's even written in all letters).

Or you may read easy_install's doc to avoid installing zipped eggs:
http://peak.telecommunity.com/DevCenter/EasyInstall#compressed-installation

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


Re: OT: What encoding is this?

2006-09-10 Thread skip

I appreciate all the useful feedback on my request.  For some reason Safari
initially refused to display the page properly with iso-8859-1, and after a
bit more poking around with it eventually dropped a note to the list.  I
eventually discovered that Firefox has a much larger set of encodings to
choose from.  I don't know why Safari didn't display it properly the first
time.  It eventually did.

Skip

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


Re: Function metadata (like Java annotations) in Python

2006-09-10 Thread oripel
Thanks,
In Python 2.5 there are also functools.wraps and
functools.update_wrapper:
http://docs.python.org/dev/whatsnew/pep-309.html

George Sakkis wrote:
 oripel wrote:
  Thanks Paddy - you're showing normal use of function attributes.
  They're still hidden when wrapped by an uncooperative decorator.

 The decorator module may be helpful in defining cooperative decorators:
 http://www.phyast.pitt.edu/~micheles/python/documentation.html
 
 George

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


Re: Looking for the Perfect Editor

2006-09-10 Thread John Bokma
urielka [EMAIL PROTECTED] wrote:

 use Eclipse!!!

Q: how can I do x with A
A: use B!!! OMG LOLLZZ111!!!11eleven


-- 
John   MexIT: http://johnbokma.com/mexit/
   personal page:   http://johnbokma.com/
Experienced programmer available: http://castleamber.com/
Happy Customers: http://castleamber.com/testimonials.html
-- 
http://mail.python.org/mailman/listinfo/python-list


Algorithm Question

2006-09-10 Thread Andrew McLean
This really an algorithm question more that a Python question, but it 
would be implemented in Python

I have a list of strings, A. I want to find a set of strings B such that 
for any a in A there exists b in B such that b is a sub-string of a. 
But I also want to minimise T = sum_j t_j where

t_j = count of the number of elements in A which have b[j] as a sub-string

My guess is that finding the smallest possible T satisfying the 
constraint would be hard. However, for my application just keeping it 
reasonably small would help.

In my case the list A contains over two million addresses.

The (top down) heuristic approach I am tempted to employ is to start by 
dividing the entries in A into sets of tokens, then take the union of 
all these sets as a starting point for B. Then I would try to trim B by

1. looking for elements that I could remove while still satisfying the 
constraint

2. replacing two elements by a common sub-string if that reduced T

Anyway. It occurred to me that this might be a known problem. Any 
pointers gratefully received.

- Andrew

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


wxPython, how to autoresize a frame?

2006-09-10 Thread David
Dear all,

In a wxPyhton frame I make a group of controls hiding by pressing a button
and i want the whole frame to resize accordingly.

The test GUI I wrote is structured like this:

frame
  |
  +-sizer0 (BoxSizer, 1 slot)
  |
  +-panel (style=wx.EXPAND)
  |
  +-sizer1 (BoxSizer vertical, 2 slots)
  |
  +-sizer2 (FlexGridSizer, 2x2)
  |   |
  |   +-controls to hide
  |
  +-button


The problem is that, when sizer2 containig hidden controls collapses to
zero dimensions, the panel resizes, but sizer1 and sizer0 don't!
Consequently the frame does not want to autoresize.

You con dowload the code here:
http://www.box.net/public/evfxs7cp5j

Someone con help me?

Thanks

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


Refactoring Dilemma

2006-09-10 Thread Kamilche
'''
I'm in the middle of a refactoring dilemma.
I have several singletons that I'm turning into modules, for ease of
access.
The usual method is noted as 'Module 1' below.
The new method is noted as 'Module 2'.
Is there any reason NOT to do this that I may be unaware of?
It's easier than remembering to declare global variables at the top of
the function.
'''

# --- Module 1.py 
# Normal module processing
var = 0

def MyRoutine():
global var
var = 1

MyRoutine()
print var


# --- Module 2.py 
# 'Self' module processing
import sys
var = 0
self = sys.modules[__name__]

def MyRoutine():
self.var = 1

MyRoutine()
print var

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


Tkinter listbox:get

2006-09-10 Thread Sorin Schwimmer
lb.curselection() won't return an integer, but a tuple of strings. Also, a StringVar receives a new value with the set() method. So, you'll have to write something like:idx=lb.curselection()StringValue.set(lb.get(int(idx[0])))This will grab the first value from the tuple, convert it in integer, and pass it to lb.get() to extract the line in your Listbox, and set it in your Entry via the StringVar. If
 you allow multiple selections from your Listbox, you may have more than one value in idx, and you'll have to decide how you intend to process them.Check any of these (or both):http://www.pythonware.com/library/tkinter/introduction/index.htmhttp://infohost.nmt.edu/tcc/help/pubs/tkinter/They're both easy to follow, and you'll save more time, than asking one little think at a time, and then waiting for someone to answer.Good luck!Sorin-- 
http://mail.python.org/mailman/listinfo/python-list

downloading eggs

2006-09-10 Thread Bryan
i'm trying to just download the turbogears eggs without installing it.  i've 
read the turbogear install instructions and the easy_install help.


from the easy_install web site:

If you have another machine of the same operating system and library versions 
(or if the packages aren't platform-specific), you can create the directory of 
eggs using a command like this:

easy_install -zmaxd somedir SomePackage



i tried this:


C:\python\turbogearseasy_install -zmaxd TurboGears TurboGears
Processing TurboGears
error: Couldn't find a setup script in TurboGears


C:\python\turbogearseasy_install -zmaxd . TurboGears
Processing TurboGears
error: Couldn't find a setup script in TurboGears



on the turbogears mailing list, someone posted this:

You could even do easy_install -zmaxd TurboGears at home to just
download the files and then bring in the files on a usb key and then
easy_install -f . TurboGears from the usb drive.


i tried this:

C:\python\turbogearseasy_install -zmaxd TurboGears
error: No urls, filenames, or requirements specified (see --help)


i copied the ez_setup.py file from turbogears and tried the commands against 
that script but it didn't work.  i'm using setuptools-0.6c2 if that is helpful 
to anyone.


thanks,

bryan



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


get the en of a program running in background

2006-09-10 Thread awalter1
Hi,
I develop a graphical user interface (with pyGTK) where a click on a
button shall launch a program P in background. I want to get the end of
this program P but I don't want that my HMI be freezed while P is
running.
I try to use fork examplesI found on the web, but it seems to not run
as expected.
I am not familiar with these techniques in unix as well as python.
But I suppose that my needs are usual, despite that I don't find
anything on the web ...
Is someone can give me a standard way to call a background program,
wait its end, with an IHM still active ?

Thank a lot for any idea.

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


Re: makepy, ADO and dynamic.py

2006-09-10 Thread Roger Upole

Chris Curvey [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
 I'm trying to track down a performance issue in my Windows code, and
 hotshot is telling me that the most time and calls are spent in these
 methods

   ncalls  tottime  percall  cumtime  percall filename:lineno(function)
75975 63982.7790.842 124464.4191.638
 c:\python24\lib\site-packages\win32com\client\dynamic.py:285(_make_method_)
71294 47871.4240.671 50629.2240.710
 c:\python24\lib\site-packages\win32com\client\__init__.py:444(_ApplyTypes_)

 If I understand correctly, running makepy on the appropriate COM class
 should get rid of the dynamic stuff and let it be called directly.  I
 use ADODB to talk to my database server, and I've run makepy for
 Microsoft Active X Data Objects 2.8 Library [1] and on Microsoft
 ActiveX Data Objects Recordset 2.8 Library, but I'm still seeing the
 call to the dynamic.py class.

 Am I right that seeing the calls in dynamic.py implies that I'm
 running makepy on the wrong thing?  Any idea what I should be running
 makepy on?

 [1] I seem to have a bunch of versions of Microsoft ActiveX Data
 Objects Library, is there a chance that another ADO library is being
 used?


The most reliable way to make sure the generated support is used is
to call win32com.client.gencache.EnsureDispatch.  If a typelib can
be found, the corresponding python module will be created if it doesn't
already exist.

   Roger


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


Re: Refactoring Dilemma

2006-09-10 Thread George Sakkis
Kamilche wrote:
 '''
 I'm in the middle of a refactoring dilemma.
 I have several singletons that I'm turning into modules, for ease of
 access.
 The usual method is noted as 'Module 1' below.
 The new method is noted as 'Module 2'.
 Is there any reason NOT to do this that I may be unaware of?
 It's easier than remembering to declare global variables at the top of
 the function.
 '''

 # --- Module 1.py 
 # Normal module processing
 var = 0

 def MyRoutine():
 global var
 var = 1

 MyRoutine()
 print var


 # --- Module 2.py 
 # 'Self' module processing
 import sys
 var = 0
 self = sys.modules[__name__]

 def MyRoutine():
 self.var = 1

 MyRoutine()
 print var


What's wrong with
code
def MyRoutine():
 return 1

var = MyRoutine()
/code
?

George

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


Re: New SourceForge project: Diet Python!!!

2006-09-10 Thread Peter Beattie
TOFU sucks!

The Eternal Squire wrote:
 Best interface for roguelike gaming.
 
 Jarek Zgoda wrote:
 The Eternal Squire napisa³(a):

 Diet Python is a flavor of Python with allegro, multiarray, umath,
 calldll, npstruct and curses builtin, all else nonessential to language
 ripped out. Total size  3MB, 1% of PSF Python. Diet Python helps keep
 clients thin :)
 Why do you think curses are essential? I'd rip out them too, they have
 no use on Windows.

 -- 
 Jarek Zgoda
 http://jpa.berlios.de/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Two ethernet cards/networks (still)

2006-09-10 Thread Bob Greschke

Steve Holden [EMAIL PROTECTED] wrote in message 
news:[EMAIL PROTECTED]
 Bob Greschke wrote:
 The reason that binding to a specific address is almost never used for a 
 client is because it's the server destination address that the network 
 layer will use to determine which interface is used to communicate with a 
 specific server host.

 Suppose your network setup looks like this:


 +---++ Network A
 |
 |
 |
 | 192.168.12.34/24
 |
+++
| |
| |
| YOUR HOST   |
| |
| |
+++
 |
 | 201.46.34.22/24
 |
 |
 |
 +---+--+-+ Network B
|
+
   +++
   |  router |
   |   to internet   |
   +-+

 If your client program tries to communicate with, say, 192.168.12.18 then 
 by the IP network layer will automatically select network A as the medium, 
 since the destination is local to that network. If you then want to 
 communicate the results to 201.46.34.118 then network B will be used, 
 again because the destination is local to that network (its first 24 bits 
 are the same as the first 24 bits of the destination).

 In this case the router on network B will almost certainly be the default 
 route for the host, as it's the way to everywhere else.

 This isn't really Python-related, so I hope it answers your question!

 regards
  Steve
 -- 
 Steve Holden   +44 150 684 7255  +1 800 494 3119
 Holden Web LLC/Ltd  http://www.holdenweb.com
 Skype: holdenweb   http://holdenweb.blogspot.com
 Recent Ramblings http://del.icio.us/steve.holden


Nice explanation!  Thanks!  You mean I don't have to do anything special?? 
That sounds suspiciously easy. :)

To muddy the water a little the equipment I want to get info from (some 
seismic digitizing/recording equipment) comes back to us from the field with 
the IP addresses set to whatever that last user needed.  What we do now is 
put the unit(s) on the bench, connect them to the private network and use a 
broadcast address (like 255.255.255.255) and a specific port number to query 
and see who is connected.  Then we (a program) can get in (login, basically) 
and reset the all of the IPs to the same subnet to proceed with checkout, 
calibration, etc.  We have to disconnect from (or disable the card for) the 
outside network when we do this discovery or else the program discovers all 
of these instruments that we have running in the building (monitoring a 
seismic pier, in people's offices, etc.).  I'm guessing here we will still 
need to do this?  It's not a biggie, but finding a way to not have to do 
this was what started this whole thing.  Once the program knows which 
instruments it found on the private network it doesn't matter.  It will only 
work on those ones.

Thanks!

Bob


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


Re: Unicode / cx_Oracle problem

2006-09-10 Thread Richard Schulman
On Sun, 10 Sep 2006 11:42:26 +0200, Diez B. Roggisch
[EMAIL PROTECTED] wrote:

What does print repr(mean) give you?

That is a useful suggestion.

For context, I reproduce the source code:

in_file = codecs.open(c:\\pythonapps\\mean.my,encoding=utf_16_LE)
connection = cx_Oracle.connect(username, password)
cursor = connection.cursor()
for row in in_file:
id = row[0]
mean = row[1]
print Value of row is , repr(row)#debug line
print Value of the variable 'id' is , repr(id)   #debug line
print Value of the variable 'mean' is , repr(mean)   #debug line
cursor.execute(INSERT INTO mean (mean_id,mean_eng_txt)
VALUES (:id,:mean),id=id,mean=mean)

Here is the result from the print repr() statements:

Value of row is  u\ufeff(3,'sadness, lament; sympathize with,
pity')\r\n
Value of the variable 'id' is  u'\ufeff'
Value of the variable 'mean' is  u'('

Clearly, the values loaded into the 'id' and 'mean' variables are not
satisfactory but are picking up the BOM.

... 
The oracle NLS is a sometimes tricky beast, as it sets the encoding it 
tries to be clever and assigns an existing connection some encoding, 
based on the users/machines locale. Which can yield unexpected results, 
such as Dusseldorf instead of Düsseldorf when querying a german city 
list with an english locale.

Agreed.

So - you have to figure out, what encoding your db-connection expects. 
You can do so by issuing some queries against the session tables I 
believe - I don't have my oracle resources at home, but googling will 
bring you there, the important oracle term is NLS.

It's very hard to figure out what to do on the basis of complexities
on the order of

http://download-east.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25108/xedev_global.htm#sthref1042

(tiny equivalent http://tinyurl.com/fnc54

But I'm not even sure I got that far. My problems so far seem prior:
in Python or Python's cx_Oracle driver. To be candid, I'm very tempted
at this point to abandon the Python effort and revert to an all-ucs2
environment, much as I dislike Java and C#'s complexities and the poor
support available for all-Java databases.

Then you need to encode the unicode string before passing it - something 
like this:

mean = mean.encode(latin1)

I don't see how the Chinese characters embedded in the English text
will carry over if I do that.

In any case, thanks for your patient and generous help.

Richard Schulman
Delete the antispamming 'xx' characters for email reply
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Is it just me, or is Sqlite3 goofy?

2006-09-10 Thread Paul Boddie
Dennis Lee Bieber wrote:

  Talking to myself again, I see...

Not quite. ;-)

[...]

  How interesting... With MySQL/MySQLdb I did NOT get exceptions or
 error results on inserting bad numeric data supplied as character string
 format (ie, as read from the CSV). Instead, MySQL SILENTLY converted
 them to ZEROS

  A price of Priceless becomes Decimal(0.00).

  The Customer number of 68 became 0L

This kind of thing is classic MySQL behaviour.

  Which would one rather have to work with -- a database that copied
 invalid numerics as string literals (which, in my mind, makes it much
 easier to correct the data later, using update  set field = correct
 where field = invalid) or a database that silently converts them all to
 0 values. (Of course, I now expect to have a rejoinder about Using a
 REAL database instead of MySQL -- but unless said person wishes to
 start making the same comments about SQLite on at least as regular a
 basis, I believe the objection itself is invalid for this example).

Given subsequent research into SQLite's affinity modes and their
presumed status as future features, the solution in that database
system's case is to apply validation in the driver/module or through
driver extensions, and there is apparently some flexibility in the
pysqlite2 modules for changing the way data types are handled, although
a cursory inspection of the documentation doesn't appear to suggest a
convenient, ready-made solution.

As for MySQL, the situation is possibly more awkward: one expects the
database system to complain about certain things, which it probably
does from time to time, but it would seem wasteful to duplicate
whatever validation the database system does do just to cover those
situations where the system misbehaves.

Paul

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


Re: [Fwd: Problems with PyGridTableBase]

2006-09-10 Thread [EMAIL PROTECTED]
Hopefully this helps keep your post alive..  I looked all over the
internet for examples written with wxgrid and wxgrid with python and
haven't realy found out how to add the other functions to a
boa-constructor program there just isn't anything except the simple
example incuded with boa.  This is as far as I got and I am not sure I
am very close (with my example trying to add the extra functions to the
class instead of inheriting it from grid)

#Boa:Frame:Frame3

import wx
import wx.grid

def create(parent):
return Frame3(parent)

[wxID_FRAME3, wxID_FRAME3BUTTON1, wxID_FRAME3GRID1,
wxID_FRAME3TEXTCTRL1,
] = [wx.NewId() for _init_ctrls in range(4)]

class Frame3(wx.Frame):
def _init_ctrls(self, prnt):
# generated method, don't edit
wx.Frame.__init__(self, id=wxID_FRAME3, name='', parent=prnt,
  pos=wx.Point(401, 118), size=wx.Size(367, 585),
  style=wx.DOUBLE_BORDER, title=u'')
self.SetClientSize(wx.Size(361, 579))

self.grid1 = wx.grid.Grid(id=wxID_FRAME3GRID1, name='grid1',
  parent=self, pos=wx.Point(8, 16), size=wx.Size(80, 392),
  style=wx.WANTS_CHARS | wx.TRANSPARENT_WINDOW |
wx.MINIMIZE_BOX | wx.DOUBLE_BORDER | wx.VSCROLL)

self.textCtrl1 = wx.TextCtrl(id=wxID_FRAME3TEXTCTRL1,
name='textCtrl1',
  parent=self, pos=wx.Point(112, 16), size=wx.Size(232,
392),
  style=wx.TE_LINEWRAP, value=u'')
self.textCtrl1.SetThemeEnabled(False)
self.textCtrl1.SetCursor(wx.CROSS_CURSOR)

self.button1 = wx.Button(id=wxID_FRAME3BUTTON1, label=u'exit',
  name='button1', parent=self, pos=wx.Point(72, 440),
  size=wx.Size(136, 23), style=0)
self.button1.Bind(wx.EVT_BUTTON, self.OnButton1Button,
  id=wxID_FRAME3BUTTON1)

def __init__(self, parent):
self._init_ctrls(parent)
self.grid1.CreateGrid(0, 1)

def OnButton1Button(self, event):
self.Close()
def update_instument_list(csndname):
csdInstrumentList(csndname) #needs to have a file variable..
noinlist=0
for number in range(0,noinlist):
 self.grid1.AppendRows(1)
 self.grid1.SetCellValue(number,0,instrlist[number])

http://www.dexrow.com



Mario Lacunza wrote:
 - Mensaje reenviado 
 De: Mario Lacunza [EMAIL PROTECTED]
 Para: Lista Python Ing python-list@python.org
 Asunto: Problems with PyGridTableBase
 Fecha: Sat, 09 Sep 2006 00:03:20 -0500

 Hello,

 I attach two files:frmClientes and frmClientesNE.

 frmClientes charge a Grid with resume Costumers data: Name, Commercial
 ID, address, etc. and edition options.

 frmClientes in

 Line 178
 def OnBtnNuevoButton(self, event):

 call to frmClientesNE. Its append a new record to the database and clear
 all controls and when I close it, the grid in frmClientes: grClte must
 be recharge with the new data, but that dont work. Only work when a
 Delete some record.

 I couldnt send yours a runable .py version, because both of them files
 pickup data from a Firebird's database.

 I try to implement the wxPython Demo model: Grid_MegaExample, follow
 that my class Grilla must be:

 Line 224:
 class Grilla(Grid.Grid):

 but for the Boa Constructors controls creation I couldnt inherit from
 Grid.Grid, thats my problem, I need your help I try for two days and
 nothing :-( ... some ideas??

 Thanks in advance!!

 ==
 FILE: FRMCLIENTES.PY
 ==

 # -*- coding: utf8 -*-#
 #Boa:Frame:frmClientes

 __version__='0.5'
 __autor__='Mario Lacunza Vasquez [EMAIL PROTECTED]'

 import wx
 import wx.grid
 import modGlobals
 from Conectar import Conectar
 import errores

 def create(parent):
 return frmClientes(parent)

 [wxID_FRMCLIENTES, wxID_FRMCLIENTESBRNSALIR, wxID_FRMCLIENTESBTNBORRAR,
  wxID_FRMCLIENTESBTNEDIT, wxID_FRMCLIENTESBTNNUEVO,
 wxID_FRMCLIENTESGRCLTE,
  wxID_FRMCLIENTESLBLTITULO, wxID_FRMCLIENTESPANEL1,
 ] = [wx.NewId() for _init_ctrls in range(8)]

 class frmClientes(wx.Frame):
 def _init_coll_fsGrid_Growables(self, parent):
 # generated method, don't edit

 parent.AddGrowableRow(0)

 def _init_coll_fsGrid_Items(self, parent):
 # generated method, don't edit

 parent.AddWindow(self.grClte, 0, border=2, flag=wx.EXPAND |
 wx.ALL)

 def _init_coll_fsBtn_Items(self, parent):
 # generated method, don't edit

 parent.AddWindow(self.btnNuevo, 0, border=2, flag=wx.EXPAND |
 wx.ALL)
 parent.AddWindow(self.btnEdit, 0, border=2, flag=wx.EXPAND |
 wx.ALL)
 parent.AddWindow(self.btnBorrar, 0, border=2, flag=wx.EXPAND |
 wx.ALL)
 parent.AddWindow(self.brnSalir, 0, border=2, flag=wx.EXPAND |
 wx.ALL)

 def _init_coll_fsTit_Items(self, parent):
 # generated method, don't edit

 parent.AddWindow(self.lblTitulo, 0, border=6, 

Re: Looking for the Perfect Editor

2006-09-10 Thread Kent Johnson
Dick Moores wrote:
 At 01:10 PM 9/8/2006, Doug Stell wrote:
 Try www.TextPad.com. I've used it for years and love it. It
 understands many programming language constructs and can be taught to
 understand python so that things show up in color.
 
 Any tips on how to teach TextPad to understand python?

Download and install the Python syntax highlighting definition from the 
TextPad website.

I make a tool to run the front window in Python. Here are the values 
from the preferences window for the tool:

Command: C:\Python24\python.exe
Parameters: -u $File
Init fldr: $FileDir

regex to match output:
^.*([^]+), *line ([0-9]+)

with File: 1, Line: 2

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


Re: Unicode / cx_Oracle problem

2006-09-10 Thread Diez B. Roggisch
 Value of the variable 'id' is  u'\ufeff'
 Value of the variable 'mean' is  u'('

So they both are unicode objects - as I presumed.


 It's very hard to figure out what to do on the basis of complexities
 on the order of
 
 http://download-east.oracle.com/docs/cd/B25329_01/doc/appdev.102/b25108/xedev_global.htm#sthref1042
 
 (tiny equivalent http://tinyurl.com/fnc54

Yes, that is somewhat intimidating.

 But I'm not even sure I got that far. My problems so far seem prior:
 in Python or Python's cx_Oracle driver. To be candid, I'm very tempted
 at this point to abandon the Python effort and revert to an all-ucs2
 environment, much as I dislike Java and C#'s complexities and the poor
 support available for all-Java databases.

That actually doesn't help you much I guess - just because JDBC will 
convert java's unicode strings to byte strings behind the curtains, you 
will lose all encoding information nonetheless - especially if the DB 
itself isn't running an encoding that will allow for all possible 
unicode characters to be represented.

 Then you need to encode the unicode string before passing it - something 
 like this:

 mean = mean.encode(latin1)
 
 I don't see how the Chinese characters embedded in the English text
 will carry over if I do that.

Me neither, but how could I have foreseen that? So use something else 
instead - utf-8 for example, or whatever the oracle connection will grok.

I think you should read up on what unicode and encodings are, and how 
they work in python, and unfortunately how they do work in oracle. 
Because even if you use java - not understanding how things are 
connected will hit you in the neck at some point.

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


Re: Method resolution for super(Class, obj).

2006-09-10 Thread Bruno Desthuilliers
ddtl a écrit :
 On 7 Sep 2006 10:42:54 -0700, in comp.lang.python you wrote:
 
 
Let's examine what the mro order is for class D:

D.mro()

[class '__main__.D', class '__main__.B', class '__main__.C',
class '__mai
n__.A', type 'object']

When you call d.met(), the call dispatches to the D.met() method.
After printing out 'D.met', you use super() to get the next class in
the mro order, and call that class's met method.

As shown with the mro(), the class after D is B.  So B.met() is called.
Normally, we would be done.  But take a look at B's method!


class B(A):
def met(self):
print 'B.met'
super(B,self).met()

B.met calls super, and invokes the next met method!  So, the code does
exactly what you've asked it to do, and searches for the next class
after B in the mro list: class C.
 
 
 But when super(B,self).met() is invoked, isn't it supposed to look
 at MRO order of *B*, 

No. It's supposed to look at the MRO of self for what comes after B.

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


Re: get the en of a program running in background

2006-09-10 Thread oripel
Module 'subprocess' may be a better fit for you than fork+exec.
Here's an example with a signal handler
(1) use subprocess, don't fork and exec
(2) maybe this will help:

---
import signal, subprocess

# define the signal handler
def logsignal(signum, frame):
   print Caught signal

# register the signal handler for SIGCHLD
signal.signal(signal.SIGCHLD, logsignal)

# run the subprocess in the background
subprocess.Popen([sleep, 3])

# Do more stuff
---

The signal handler will be called when the child process ends. Just
register your own handler.

You only need to register the handler once.
If you need this for a single run only, or need different behavior for
different subprocesses, have your signal handler re-register the old
handler (see the docs for module 'signal').

A note about the example: if you run it as is, the parent process will
end before the child process does. Add a call to 'os.wait()' to have it
wait for the child. In your GUI you probably won't want it.

Hope this helps.

awalter1 wrote:
 Hi,
 I develop a graphical user interface (with pyGTK) where a click on a
 button shall launch a program P in background. I want to get the end of
 this program P but I don't want that my HMI be freezed while P is
 running.
 I try to use fork examplesI found on the web, but it seems to not run
 as expected.
 I am not familiar with these techniques in unix as well as python.
 But I suppose that my needs are usual, despite that I don't find
 anything on the web ...
 Is someone can give me a standard way to call a background program,
 wait its end, with an IHM still active ?
 
 Thank a lot for any idea.

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


Re: Unicode / cx_Oracle problem

2006-09-10 Thread John Machin
Richard Schulman wrote:
 On Sun, 10 Sep 2006 11:42:26 +0200, Diez B. Roggisch
 [EMAIL PROTECTED] wrote:

 What does print repr(mean) give you?

 That is a useful suggestion.

 For context, I reproduce the source code:

 in_file = codecs.open(c:\\pythonapps\\mean.my,encoding=utf_16_LE)
 connection = cx_Oracle.connect(username, password)
 cursor = connection.cursor()
 for row in in_file:
 id = row[0]
 mean = row[1]
 print Value of row is , repr(row)#debug line
 print Value of the variable 'id' is , repr(id)   #debug line
 print Value of the variable 'mean' is , repr(mean)   #debug line
 cursor.execute(INSERT INTO mean (mean_id,mean_eng_txt)
 VALUES (:id,:mean),id=id,mean=mean)

 Here is the result from the print repr() statements:

 Value of row is  u\ufeff(3,'sadness, lament; sympathize with,
 pity')\r\n
 Value of the variable 'id' is  u'\ufeff'
 Value of the variable 'mean' is  u'('

 Clearly, the values loaded into the 'id' and 'mean' variables are not
 satisfactory but are picking up the BOM.

Well of course they're unsatisfactory and this is absolutely nothing
to do with Oracle and cx_Oracle.

row is a string of characters. row[0] is the BOM. Read my lips (from a
previous thread):


Use utf_16 -- it will strip off the BOM for you.

and again:

|  codecs.open('guff.utf16le', 'r', encoding='utf_16').read()
| u'abc\n\rdef\n\rghi' # Look, Mom, no BOM!


row[1] is the first ***character*** of what looks suspiciously like the
Python representation of a tuple:

(3,'sadness, lament; sympathize with, pity')

Who wrote that like that??? If it is at all under your control, do it
like this:
Encode each Unicode text field in UTF-8. Write the file as a CSV file
using Python's csv module. Read the CSV file using the same module.
Decode the text fields from UTF-8.

You need to parse the incoming line into column values (the csv module
does this for you) and then convert each column value from
string/Unicode to a Python type that is compatible with the Oracle type
for that column.

My guess (not having used cx_Oracle) is that the error is happening
because the column id has a numeric type and you are trying to jam a
Unicode string into it. IOW, nothing to do with the mean column
(yet!).

BTW, I've managed to decode that eng means English not engineering
and mean means meaning i.e. not average and not stingy. Holy
obfuscation, Batman!

HTH,
John

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


ANN: Pocoo (bulletin board software) 0.1 beta released

2006-09-10 Thread Georg Brandl
We're pleased to announce that

  Pocoo 0.1 (beta) was released today (Sept. 10, 2006).

Pocoo http://www.pocoo.org/ is a bulletin board software (aka. message board)
written in Python, adhering to the WSGI standard. In the long term, it is meant
to compete with systems like phpBB.

It provides an advanced plugin system with a component architecture which
allows other developers to modify Pocoo to their liking without the need to
touch existing source code. Building upon SQLAlchemy, Pocoo is able to
use either MySQL, SQLite, Oracle or Postgres as the storage backend.

The 0.1 release is not meant to be feature complete. It's more like a preview
to show off what's already there. If you like the idea, *feel free to join us!*


Features


Currently implemented:

  * Support for either flat or threaded post view
  * URLs are very readable, furthermore one URL works for both flat and
threaded view
  * Support for JSONRPC and XmlHTTPRequest to dynamically fetch data where
useful while having a fallback for non-JS users
  * Very powerful plugin system
  * Extensible authentication system
  * WSGI compliancy
  * Database support for MySQL, Sqlite, Postgres, Oracle
  * BBCode/rst/safehtml parsers for markup
  * Javascript editors for the markup
  * Avatar support
  * User profiles and settings

Planned features

... can be found in the Idea Pool at http://trac.pocoo.org/wiki/IdeaPool.


Download


Download the release at http://www.pocoo.org/download.


Cheers,
Georg Brandl, on behalf of the Pocoo Team
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Refactoring Dilemma

2006-09-10 Thread Carl Banks
Kamilche wrote:
 '''
 I'm in the middle of a refactoring dilemma.
 I have several singletons that I'm turning into modules, for ease of
 access.
 The usual method is noted as 'Module 1' below.
 The new method is noted as 'Module 2'.
 Is there any reason NOT to do this that I may be unaware of?
 It's easier than remembering to declare global variables at the top of
 the function.
 '''

 # --- Module 1.py 
 # Normal module processing
 var = 0

 def MyRoutine():
 global var
 var = 1

 MyRoutine()
 print var


 # --- Module 2.py 
 # 'Self' module processing
 import sys
 var = 0
 self = sys.modules[__name__]

 def MyRoutine():
 self.var = 1

 MyRoutine()
 print var

I don't see any major problem with it.  In fact, I think it's a very
good idea to do this, rather than use global statements, when using
module as a singleton class.

I recently made the same transition myself, though I solved it a bit
differently.  I used a decorator to pass the module as the first
argument (actually it passes a proxy to module's global dict, since the
module itself isn't accesible from the function object).

def modmethod(func):
class modproxy(object):
__getattribute__ = func.func_globals.__getitem__
__setattr__ = func.func_globals.__setitem__
self = modproxy()
def call_with_module(*args,**kwargs):
return func(self,*args,**kwargs)
call_with_module.func_name = func.func_name
return call_with_module

@modmethod
def MyRoutine(self):
self.var = 1

MyRoutine()
print var

One problem with my decorator is it makes stack traces a little
bloated. (Also attribute errors are raised as KeyError, but that's
easily fixable.)  Other than that, I've been running it for awhile
without any problems.  I doubt your approach would have many problems,
either. 


Carl Banks

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


Re: Ghostscript interface

2006-09-10 Thread Andrew MacIntyre
defcon8 wrote:
 Does a ghostscript interface for python exist? I have searched google
 quite a bit and all I have been able to find are command line hacks
 from within python. Thanks in advance for any useful help.

I'm not aware of a specific interface to the Ghostscript API, but it is
trivial to implement one with ctypes (included with 2.5).

-- 
-
Andrew I MacIntyre These thoughts are mine alone...
E-mail: [EMAIL PROTECTED]  (pref) | Snail: PO Box 370
[EMAIL PROTECTED] (alt) |Belconnen ACT 2616
Web:http://www.andymac.org/   |Australia
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: ANN: Pocoo (bulletin board software) 0.1 beta released

2006-09-10 Thread Paul Rubin
Georg Brandl [EMAIL PROTECTED] writes:
 Pocoo http://www.pocoo.org/ is a bulletin board software
 (aka. message board) written in Python, adhering to the WSGI
 standard. In the long term, it is meant to compete with systems like
 phpBB.

You too, huh?  I've also always wanted to write one of those.  Mine
would be performance-intensive.  I've never understood why the phpBB,
vBulletin, etc. systems that I use bog down so much.  It's a very
serious problem--the bigger boards I hang out on all have to use
multiple servers, resulting in big hosting bills ($1000's per month),
so they have to take advertising, hold fundraisers all the time, etc.
But the raw hardware really needed if the software were any good,
including adequate bandwidth, should fit within the cheap
managed-hosting servers (typically a 1U rack-mounted single processor
Celeron box for $100 a month or so) or on a VPS for smaller loads
($50/month or less).  That means the hosting fees can be paid out of
pocket by a few donors, getting rid of all kinds of fundraising
headaches and increasing organizational and content flexibility a lot.

So, I think it's not worth thinking about writing yet another BBS
unless it can handle a Slashdot-sized load on a commodity PC.  For
very large loads it should be able to use multiprocessor hardware
effectively (an 8-core Athlon server costs as much today as an entry
level engineering workstation of the 1990's).  I've even played with
the idea of using MPI for this (imagine a Beowulf cluster of...)
which would let you couple multiple boxes together with ordinary LAN
hardware, letting you scale straightforwardly to hundreds of cpu's.  I
think it should be possible to do all this, using a system still
written mostly in Python.

My suggestions:

1) ditch the SQL back end, or at least don't depend on it.  Someone
had the clever idea of using an NNTP back end, using a news server (or
a network of them) as a message store.  That gets you all kinds of
features for free.  Otherwise, keep all messages in an mmap'd disk
file that can be shared in memory between multiple processes.  Adding
messages would append to the file, and to some kind of log that would
reconstruct in-memory structures in the event of server restart.
You'd also need some IPC synchronization scheme.  

2) Look at the architecture of WebCrossing and also of OKWS (www.okws.org). 

3) Hmm I had some more, I'll keep thinking.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Refactoring Dilemma

2006-09-10 Thread Carl Banks
George Sakkis wrote:
 Kamilche wrote:
  '''
  I'm in the middle of a refactoring dilemma.
  I have several singletons that I'm turning into modules, for ease of
  access.
  The usual method is noted as 'Module 1' below.
  The new method is noted as 'Module 2'.
  Is there any reason NOT to do this that I may be unaware of?
  It's easier than remembering to declare global variables at the top of
  the function.
  '''
 
  # --- Module 1.py 
  # Normal module processing
  var = 0
 
  def MyRoutine():
  global var
  var = 1
 
  MyRoutine()
  print var
 
 
  # --- Module 2.py 
  # 'Self' module processing
  import sys
  var = 0
  self = sys.modules[__name__]
 
  def MyRoutine():
  self.var = 1
 
  MyRoutine()
  print var


 What's wrong with
 code
 def MyRoutine():
  return 1

 var = MyRoutine()
 /code
 ?


Kamilche simplified things in his example that obscured the main use
case.  Short story is, var is considered a state of the module, and
MyRoutine() is designed to be called from outside the module to modify
the state.  Your suggestion can only modify the state of the module
from within, so it won't do.

More detailed discussion:

A common piece of advice when people ask how can I implement a
singleton in Python is to use a module.  A module, after all, is a
singleton object.

But there's a big problem using a module as a singleton: you need to
use then global statement to rebind module-level variables.  Which
means that if you want your module to have lots of modifyable state,
most likely you'll have to use a bunch global statements.  And that's a
major pain in the neck when you have to do it a lot and in many
functions.

In these cases, it would be nice if a module could access its own state
in the same way that an instance does, that is, as an attribute.  My
approach of using a decorator to pass in a module proxy, and Kamilche's
approach  of binding the module object to self, both accomplish this.
Internally, the module behaves very much like a class instance.
Functions in the module act almost exactly like bound methods, and
module-level variables act like instance attributes.  The difference
between writing a module and a singleton class thus becomes mostly a
matter of indentation.

In fact, when I made a major switch from using singleton classes to
modules, I was able to change it by dedenting once, and pasting a
@modmethod decoration above each method, with very few other changes.

Carl Banks

Carl Banks

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


Re: ANN: Pocoo (bulletin board software) 0.1 beta released

2006-09-10 Thread Felipe Almeida Lessa
10 Sep 2006 16:17:08 -0700, Paul Rubin http://phr.cx@nospam.invalid:
 So, I think it's not worth thinking about writing yet another BBS
 unless it can handle a Slashdot-sized load on a commodity PC.

Python is slow. Psyco helps, but you should use C instead.

And yes, I am kidding =)

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


Re: Looking for the Perfect Editor

2006-09-10 Thread Dick Moores
At 02:15 PM 9/10/2006, Kent Johnson wrote:
Dick Moores wrote:
  At 01:10 PM 9/8/2006, Doug Stell wrote:
  Try www.TextPad.com. I've used it for years and love it. It
  understands many programming language constructs and can be taught to
  understand python so that things show up in color.
 
  Any tips on how to teach TextPad to understand python?
Download and install the Python syntax highlighting definition from the
TextPad website.

Thanks very much, Kent. I've been using TextPad for 10 years and 
never considered using it for Python.

I downloaded Python (7) from 
http://www.textpad.com/add-ons/synn2t.html and put the file 
PythonV2.4.syn in C:\Program Files\TextPad 4\system .

I make a tool to run the front window in Python. Here are the values
from the preferences window for the tool:

Command: C:\Python24\python.exe
Parameters: -u $File
Init fldr: $FileDir

regex to match output:
^.*([^]+), *line ([0-9]+)

with File: 1, Line: 2

After fumbling around, I believe I've made the tool, using your 
values, except I used E:\Python24\python.exe instead of 
C:\Python24\python.exe .

I also associated .py with TextPad. I'm now able to open a Python 
script with TextPad, and execute it with  Ctrl+4.

However, no syntax highlighting is showing up. so I must have done 
something wrong. Do I have to do something other than put 
PythonV2.4.syn in C:\Program Files\TextPad 4\system ?

Also, why do you use TextPad instead of IDLE?

Thanks,

Dick Moores


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


Re: Is it just me, or is Sqlite3 goofy?

2006-09-10 Thread [EMAIL PROTECTED]

Dennis Lee Bieber wrote:
 Guess I lied...

 On Sat, 09 Sep 2006 05:22:20 GMT, Dennis Lee Bieber
 [EMAIL PROTECTED] declaimed the following in comp.lang.python:

   Talking to myself again, I see...

 snip
 rs = cr.execute(insert into invoice_1
 (CustNo, Title, Author, Year, Price)
 values (?,?,?,?,?),
 r)

 Whoops, r = rv, though the exceptions raised made it moot

 rs = cr.execute(insert into invoice_2
 (CustNo, Title, Author, Year, Price)
 values (?,?,?,?,?),
 r)

 Same comment

   Out of curiousity, I converted to using MySQL(db) as a test. As
 expected, the pre-insert validation code worked with same results (well,
 the price was declared decimal, and Python 2.4 appears to handle that as
 a Decimal(value) on return G)

   Now, taking out the pre-validation and type conversion, supplying
 all data as it came from the CSV file:

 -=-=-=-=-=-=-
 Inserting:
 ['066', '101 Ways to Start A Fight', 'some Irish gentleman', '1919',
 '19.95']
 ['032', 'A Sale of Two Titties', 'Charles Dikkens', '1855', '20.00']
 ['001', 'Olsens Standard Book of British Birds (Expurgated)', 'Olsen',
 'None', '99.95']
 ['066', 'Ethel the Aardvark Goes Quantity Surveying', 'None', '1975',
 '9.99']
 ['032', 'David Coperfield', 'Edmund Wells', '1955', '3.95']
 ['68', 'Strawmen and Dorothy', '', '2006', '49.89']
 ['033', The Emperor's Old Clothes, 'Grimm Hound', '1887', 'Priceless']

 Select all from Invoice_1 (CustNo is CHARACTER)
 (1L, '066', '101 Ways to Start A Fight', 'some Irish gentleman', 1919L,
 Decimal(19.95))
 (2L, '032', 'A Sale of Two Titties', 'Charles Dikkens', 1855L,
 Decimal(20.00))
 (3L, '001', 'Olsens Standard Book of British Birds (Expurgated)',
 'Olsen', 0L, Decimal(99.95))
 (4L, '066', 'Ethel the Aardvark Goes Quantity Surveying', 'None', 1975L,
 Decimal(9.99))
 (5L, '032', 'David Coperfield', 'Edmund Wells', 1955L, Decimal(3.95))
 (6L, '68', 'Strawmen and Dorothy', '', 2006L, Decimal(49.89))
 (7L, '033', The Emperor's Old Clothes, 'Grimm Hound', 1887L,
 Decimal(0.00))

 Select all from Invoice_2 (CustNo is INTEGER)
 (1L, 66L, '101 Ways to Start A Fight', 'some Irish gentleman', 1919L,
 Decimal(19.95))
 (2L, 32L, 'A Sale of Two Titties', 'Charles Dikkens', 1855L,
 Decimal(20.00))
 (3L, 1L, 'Olsens Standard Book of British Birds (Expurgated)', 'Olsen',
 0L, Decimal(99.95))
 (4L, 66L, 'Ethel the Aardvark Goes Quantity Surveying', 'None', 1975L,
 Decimal(9.99))
 (5L, 32L, 'David Coperfield', 'Edmund Wells', 1955L, Decimal(3.95))
 (6L, 0L, 'Strawmen and Dorothy', '', 2006L, Decimal(49.89))
 (7L, 33L, The Emperor's Old Clothes, 'Grimm Hound', 1887L,
 Decimal(0.00))
 -=-=-=-=-=-=-

   How interesting... With MySQL/MySQLdb I did NOT get exceptions or
 error results on inserting bad numeric data supplied as character string
 format (ie, as read from the CSV). Instead, MySQL SILENTLY converted
 them to ZEROS

   A price of Priceless becomes Decimal(0.00).

   The Customer number of 68 became 0L


   Which would one rather have to work with -- a database that copied
 invalid numerics as string literals (which, in my mind, makes it much
 easier to correct the data later, using update  set field = correct
 where field = invalid) or a database that silently converts them all to
 0 values. (Of course, I now expect to have a rejoinder about Using a
 REAL database instead of MySQL -- but unless said person wishes to
 start making the same comments about SQLite on at least as regular a
 basis, I believe the objection itself is invalid for this example).

 (Apparently we have fallen afoul of this clause from the old
 O'Reilly/MySQL black/brown book: When asked to store a value in a
 numeric column that is outside the column type's allowable range, MySQL
 clips the value to the appropriate endpoint of the range and stores the
 resulting value instead. -- seems character data clips to zero.


Are you saying that MySQL is goofy? ;-)

Based on these replies, I'm pulling back and retrenching.

As I said before, I'm not entering 500,000 records by writing
INSERT statements for each record, so reading csv files is
a more realistic test. Nevertheless, I am still convinced that
the documentation (or lack thereof) is mainly responsible for
my confusion. I was, after all, mimicing the examples given
(which still have errors).

I think an explanation of how Sqlite3 differs from SQL and
a better set of examples is still warranted.

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


Re: ANN: Pocoo (bulletin board software) 0.1 beta released

2006-09-10 Thread [EMAIL PROTECTED]

Georg Brandl wrote:
 We're pleased to announce that

   Pocoo 0.1 (beta) was released today (Sept. 10, 2006).

 Pocoo http://www.pocoo.org/ is a bulletin board software (aka. message 
 board)
 written in Python, adhering to the WSGI standard. In the long term, it is 
 meant
 to compete with systems like phpBB.


Python needs good forums :) I'm writing my own forum app also, called
MyghtyBoard - http://code.google.com/p/diamanda/ using Django :)
[check the screenshots].

python isn't PHP - most python powered sites use a framework (from
zope to web.py) so it would nice if the script could be easily plugged
in to popular python frameworks (users, permissions, forum data) :)

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


Re: Javadoc style python manual?

2006-09-10 Thread xiong . xu . cn
Thanks for all replies regard with this question!
I think I will get used to python help system:)
Maybe I will look into epydoc, too...

-Xiong

Michele Simionato 写道:

 Ben Sizer wrote:
  Michele Simionato wrote:
   Ben Sizer wrote:
I agree that the Python docs aren't quite as effective as reference
material due to the lack of simple function and method lists though.
  
   http://docs.python.org/lib/modindex.html, pydoc and ipython are more
   than enough for me.
 
  modindex is comprehensive but too 'flat'. Sometimes you want to see all
  of one object's methods and properties listed together.
 
  I was unaware of pydoc until this thread; its existence seems to be
  buried, somewhat. Looking at pydoc.org (assuming that is a good example
  of it in use), it looks more like what the original poster and I might
  want, but sadly it's still very inconsistent, with many things
  undescribed.
 
  --
  Ben Sizer

 Don't miss IPython, too.

 $ ipython
 Python 2.4.1 (#2, Aug 25 2005, 18:20:57)
 Type copyright, credits or license for more information.

 IPython 0.6.15 -- An enhanced Interactive Python.
 ?   - Introduction to IPython's features.
 %magic  - Information about IPython's 'magic' % functions.
 help- Python's own help system.
 object? - Details about 'object'. ?object also works, ?? prints more.

 In [1]: import email.FeedParser

 In [2]: email.FeedParser.FeedParser?
 Type:   classobj
 String Form:email.FeedParser.FeedParser
 Namespace:  Interactive
 File:   /usr/lib/python2.4/email/FeedParser.py
 Docstring:
 A feed-style parser of email.

 Constructor information:
 Definition: email.FeedParser.FeedParser(self, _factory=class
 email.Message.Message at 0xb77f5ddc)
 Docstring:
 _factory is called with no arguments to create a new message obj


 In [3]: help(email.FeedParser.FeedParser)
 Help on class FeedParser in module email.FeedParser:

 class FeedParser
  |  A feed-style parser of email.
  |
  |  Methods defined here:
  |
  |  __init__(self, _factory=class email.Message.Message)
  |  _factory is called with no arguments to create a new message
 obj
  |
  |  close(self)
  |  Parse all remaining data and return the root message object.
  |
  |  feed(self, data)
  |  Push more data into the parser.


 In [4]: email.FeedParser.FeedParser??
 Type:   classobj
 String Form:email.FeedParser.FeedParser
 Namespace:  Interactive
 File:   /usr/lib/python2.4/email/FeedParser.py
 Source:
 class FeedParser:
 A feed-style parser of email.

 def __init__(self, _factory=Message.Message):
 _factory is called with no arguments to create a new message
 obj
 self._factory = _factory
 self._input = BufferedSubFile()
 self._msgstack = []
 self._parse = self._parsegen().next
 self._cur = None
  ...

 Unfortunately, the nice colors of IPython are lost in the post :-(
 
   Michele Simionato

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

Bloomberg

2006-09-10 Thread domer
Hi everyone,

I was wondering if somebody knows how to extract intraday
fields(price,volume,trades) from Bloomberg in order to calculate the
VWAP. 

Appreciate any help

Kind regards,

Domer

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


Re: Refactoring Dilemma

2006-09-10 Thread George Sakkis
Carl Banks wrote:
 Kamilche wrote:
  '''
  I'm in the middle of a refactoring dilemma.
  I have several singletons that I'm turning into modules, for ease of
  access.
  The usual method is noted as 'Module 1' below.
  The new method is noted as 'Module 2'.
  Is there any reason NOT to do this that I may be unaware of?
  It's easier than remembering to declare global variables at the top of
  the function.
  '''
 
  # --- Module 1.py 
  # Normal module processing
  var = 0
 
  def MyRoutine():
  global var
  var = 1
 
  MyRoutine()
  print var
 
 
  # --- Module 2.py 
  # 'Self' module processing
  import sys
  var = 0
  self = sys.modules[__name__]
 
  def MyRoutine():
  self.var = 1
 
  MyRoutine()
  print var

 I don't see any major problem with it.  In fact, I think it's a very
 good idea to do this, rather than use global statements, when using
 module as a singleton class.

 I recently made the same transition myself, though I solved it a bit
 differently.  I used a decorator to pass the module as the first
 argument (actually it passes a proxy to module's global dict, since the
 module itself isn't accesible from the function object).

 def modmethod(func):
 class modproxy(object):
 __getattribute__ = func.func_globals.__getitem__
 __setattr__ = func.func_globals.__setitem__
 self = modproxy()
 def call_with_module(*args,**kwargs):
 return func(self,*args,**kwargs)
 call_with_module.func_name = func.func_name
 return call_with_module

 @modmethod
 def MyRoutine(self):
 self.var = 1

 MyRoutine()
 print var

This looks quite hackish, both the implementation and the usage; most
people would get confused when they didn't find var's assignment at
global scope. I prefer the the simple global statements if they aren't
that many, otherwise the assignment of the module to self is also fine.

George

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


Re: Looking for the Perfect Editor

2006-09-10 Thread Kent Johnson
Dick Moores wrote:

 I downloaded Python (7) from 
 http://www.textpad.com/add-ons/synn2t.html and put the file 
 PythonV2.4.syn in C:\Program Files\TextPad 4\system .
 
 However, no syntax highlighting is showing up. so I must have done 
 something wrong. Do I have to do something other than put 
 PythonV2.4.syn in C:\Program Files\TextPad 4\system ?

One more step - make a new Document Class for Python (in the prefs). 
Associate it with *.py, turn on syntax highlighting and select the 
syntax file you downloaded.

 
 Also, why do you use TextPad instead of IDLE?

You're kidding, right?

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


Re: Two ethernet cards/networks (still)

2006-09-10 Thread Steve Holden
Bob Greschke wrote:
 Steve Holden [EMAIL PROTECTED] wrote in message 
 news:[EMAIL PROTECTED]
 
Bob Greschke wrote:
The reason that binding to a specific address is almost never used for a 
client is because it's the server destination address that the network 
layer will use to determine which interface is used to communicate with a 
specific server host.

Suppose your network setup looks like this:


+---++ Network A
|
|
|
| 192.168.12.34/24
|
   +++
   | |
   | |
   | YOUR HOST   |
   | |
   | |
   +++
|
| 201.46.34.22/24
|
|
|
+---+--+-+ Network B
   |
   +
  +++
  |  router |
  |   to internet   |
  +-+

If your client program tries to communicate with, say, 192.168.12.18 then 
by the IP network layer will automatically select network A as the medium, 
since the destination is local to that network. If you then want to 
communicate the results to 201.46.34.118 then network B will be used, 
again because the destination is local to that network (its first 24 bits 
are the same as the first 24 bits of the destination).

In this case the router on network B will almost certainly be the default 
route for the host, as it's the way to everywhere else.

This isn't really Python-related, so I hope it answers your question!

regards
 Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

 
 
 Nice explanation!  Thanks!  You mean I don't have to do anything special?? 
 That sounds suspiciously easy. :)
 
 To muddy the water a little the equipment I want to get info from (some 
 seismic digitizing/recording equipment) comes back to us from the field with 
 the IP addresses set to whatever that last user needed.  What we do now is 
 put the unit(s) on the bench, connect them to the private network and use a 
 broadcast address (like 255.255.255.255) and a specific port number to query 
 and see who is connected.  Then we (a program) can get in (login, basically) 
 and reset the all of the IPs to the same subnet to proceed with checkout, 
 calibration, etc.  We have to disconnect from (or disable the card for) the 
 outside network when we do this discovery or else the program discovers all 
 of these instruments that we have running in the building (monitoring a 
 seismic pier, in people's offices, etc.).  I'm guessing here we will still 
 need to do this?  It's not a biggie, but finding a way to not have to do 
 this was what started this whole thing.  Once the program knows which 
 instruments it found on the private network it doesn't matter.  It will only 
 work on those ones.
 

Ah, so you want to do a limited broadcast over a single interface (the 
one for the private network) to avoid having to disable the other 
interface? That's a different kettle of fish.

I suspect you could do it by binding the local socket to a single 
address, but I'd need to play around to get it right. Maybe someone else 
has already done this?

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Looking for the Perfect Editor

2006-09-10 Thread Steve Holden
Dick Moores wrote:
 At 01:10 PM 9/8/2006, Doug Stell wrote:
 
Try www.TextPad.com. I've used it for years and love it. It
understands many programming language constructs and can be taught to
understand python so that things show up in color.
 
 
 Any tips on how to teach TextPad to understand python?
 
The procedure is explained in How do I create a new document class to 
do syntax highlighting? on page

   http://www.textpad.com/support/faq/config.html

You can download an appropriate .syn file from

   http://www.textpad.com/add-ons/synn2t.html

regards
  Steve
-- 
Steve Holden   +44 150 684 7255  +1 800 494 3119
Holden Web LLC/Ltd  http://www.holdenweb.com
Skype: holdenweb   http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden

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


Re: Refactoring Dilemma

2006-09-10 Thread Carl Banks

George Sakkis wrote:
 Carl Banks wrote:
  I don't see any major problem with it.  In fact, I think it's a very
  good idea to do this, rather than use global statements, when using
  module as a singleton class.
 
  I recently made the same transition myself, though I solved it a bit
  differently.  I used a decorator to pass the module as the first
  argument (actually it passes a proxy to module's global dict, since the
  module itself isn't accesible from the function object).
 
  def modmethod(func):
  class modproxy(object):
  __getattribute__ = func.func_globals.__getitem__
  __setattr__ = func.func_globals.__setitem__
  self = modproxy()
  def call_with_module(*args,**kwargs):
  return func(self,*args,**kwargs)
  call_with_module.func_name = func.func_name
  return call_with_module
 
  @modmethod
  def MyRoutine(self):
  self.var = 1
 
  MyRoutine()
  print var

 This looks quite hackish, both the implementation and the usage;

Once again, the function MyRoutine is intended to be called from
another module.  The usage I have here is just an example demonstrating
that var is in the module's dict.  Please keep this in mind when
criticizing usage.  The intended usage would be something like this
(from another module):

from xxx import yyy
yyy.MyRoutine()

As far as the caller is concerned, yyy could be a module using globals,
a module with this hack, or a class instance, or something else.  It
doesn't matter; usage is the same in all three cases.

As for the implementation...

 most
 people would get confused when they didn't find var's assignment at
 global scope. I prefer the the simple global statements if they aren't
 that many, otherwise the assignment of the module to self is also fine.

For ordinary modules that might have one or two serial number counters
or debug flags or whatnot, I agree.  For modules that have lots of
state and act more like class instances than modules, the massive
amounts of globals are ugly and error prone.  In that case you should
either use a regular class, or tolerate the hack; don't use a bunch
of globals.

I think a simple comment at the top could take care of any confusion
about what's happening.  Since it mimics how a class works, it won't be
anything completely new.

YMMV.

Carl Banks

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


Re: Refactoring Dilemma

2006-09-10 Thread Carl Banks
George Sakkis wrote:
 I prefer the the simple global statements if they aren't
 that many, otherwise the assignment of the module to self is also fine.

I replied to this article, and then canceled the reply (but that never
works), thinking you were criticizing the general concept of module as
a singleton and not just my approach.  I should learn to read.  I
apologize for the misunderstanding.

I do agree my implementation is a little hacky, although IMHO it feels
to fit in with the way classes work better, which appeals to me but
probably not most people :).  For one thing, the methods have the
explicit self argument, like regular classes.  For another, it uses a
decorator to affect the binding of the modules.  In regular classes,
functions are instance methods by default, and become class methods or
static methods with a decorator.  I like to think of modules as having
a special metaclass that treats functions as static methods by default,
and uses a decorator to get an instance method.  (Even though that
isn't remotely how it works, it fits how it would work if you were
implementing modules based on classes.)

Having said that, I've no problem with Kamilche's approach.  The real
evil in my mind is using lots of global statements, and anything you
can do to stay away from that is a good thing.


Carl Banks

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


CPython keeps on getting faster

2006-09-10 Thread John Machin
Here are some data points that illustrate the improvement in speed
since 2.1 for one (probably atypical) application: rummaging through a
120MB Microsoft Excel spreadsheet file using the xlrd package.

The time shown is the number of seconds required to open the file and
parse out all data content -- heavy usage of struct.unpack(). The only
code that is conditional on the Python version is where it defines
things to stop 2.1 barfing, like a dummy class called object .

2.1.3: 117
2.2.3:  95
2.3.5:  75
2.4.3:  62
2.5c1:  49

Other info:
xlrd version: 0.6.0a2 -- coming soon to a cheese shop near you :-)
OS: Windows XP SP2
CPU:
PROCESSOR_IDENTIFIER=x86 Family 15 Model 4 Stepping 1, GenuineIntel
HumanSpeak: Intel dual-core Pentium (R) 4, nominal speed is
3.20Ghz
Memory: 1 Gb (enough to avoid swapping)

Well done, core devs!

FWIW, IronPython 1.0.60816 does it in 132 seconds. For avoidance of
doubt (and flak!) I'd like to clarify that IMHO the mere existence of
IronPython merits plaudits. I do however trust that it will similarly
become faster over time. And nobody mentioned the possibility of an
188% increase in memory usage, which may well be partially explained by
this:

DOS prompt\ironpython\ipy
IronPython 1.0.60816 on .NET 2.0.50727.42
Copyright (c) Microsoft Corporation. All rights reserved.
 str is unicode
True

Cheers,
John

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


Simple regex with whitespaces

2006-09-10 Thread mathieu . malaterre
Hello,

  I cannot figure out a way to find a regular expression that would
match one and only one of these two strings:

s1 = '  how are you'
s2 = 'hello world   how are you'

  All I could come up with was:
patt = re.compile('^[ ]*([A-Za-z]+)[  ]+([A-Za-z]+)$')

  Which of course does not work. I cannot express the fact: sentence
have 0 or 1 whitespace, separation of group have two or more
whitespaces.

Any suggestion ? Thanks a bunch !
Mathieu

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


Python on handhelds

2006-09-10 Thread Nick

Hi all,

I have never programmed in Python a day in my life. My group is working
on developing an application on the Dell Axim hand held that has a
tight deadline. I have heard that Python is particularly advantageous
in rapid prototyping and deployment. I would like to lean this way if I
can. Does anyone know if I can run Python on the Dell Axim handheld. It
runs Windows CE. If so, what all is needed to make this possible.
Thanks


Nick../

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


Re: Python on handhelds

2006-09-10 Thread Paul Rubin
Nick [EMAIL PROTECTED] writes:
 I have never programmed in Python a day in my life. My group is working
 on developing an application on the Dell Axim hand held that has a
 tight deadline. I have heard that Python is particularly advantageous
 in rapid prototyping and deployment. I would like to lean this way if I
 can. Does anyone know if I can run Python on the Dell Axim handheld. It
 runs Windows CE. If so, what all is needed to make this possible.

Someone did a WinCE port a while back, but I don't think it's actively
used much.  The approach might be reasonable if you're an expert with
some time on your hands, but for a newcomer with an onrushing
deadline, you may be better off using whatever you're already using
(VB or whatever), and keeping Python in mind for some future project.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Looking for the Perfect Editor

2006-09-10 Thread Dick Moores
At 06:30 PM 9/10/2006, Kent Johnson wrote:
Dick Moores wrote:

  I downloaded Python (7) from
  http://www.textpad.com/add-ons/synn2t.html and put the file
  PythonV2.4.syn in C:\Program Files\TextPad 4\system .
 
  However, no syntax highlighting is showing up. so I must have done
  something wrong. Do I have to do something other than put
  PythonV2.4.syn in C:\Program Files\TextPad 4\system ?

One more step - make a new Document Class for Python (in the prefs).
Associate it with *.py, turn on syntax highlighting and select the
syntax file you downloaded.

OK. Done.

  Also, why do you use TextPad instead of IDLE?

You're kidding, right?

No. Tell me, please. Macros? Comparing files? What else?

Dick



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


Re: Simple regex with whitespaces

2006-09-10 Thread Mark Peters
   Which of course does not work. I cannot express the fact: sentence
 have 0 or 1 whitespace, separation of group have two or more
 whitespaces.

 Any suggestion ? Thanks a bunch !
How about this:

 import re
 s = 'hello world   how are you'
 re.split(r\s{2,},s)
['', 'hello world', 'how are you']

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


win32service (wxpython) -- i cannot install service

2006-09-10 Thread kkt49
# vim: et sw=4 ts=8 sts

from wxPython.wx import *
import sys, os, time
import pywintypes
import win32serviceutil
import win32service
import win32event
import win32process

ID_ABOUT = 101
ID_EXIT = 102

# the max seconds we're allowed to spend backing off
BACKOFF_MAX = 300
# if the process runs successfully for more than BACKOFF_CLEAR_TIME
# seconds, we reset the backoff stats to their initial values
BACKOFF_CLEAR_TIME = 30
# the initial backoff interval (the amount of time we wait to restart
# a dead process)
BACKOFF_INITIAL_INTERVAL = 5

class Service(win32serviceutil.ServiceFramework):
 A class representing a Windows NT service that can manage an
instance-home-based Zope/ZEO/ZRS processes 

# The comment below is mostly irrelevant if you're running a
standalone
# SchoolBell server, I think. -TEH

# The PythonService model requires that an actual on-disk class
declaration
# represent a single service.  Thus, the below definition of
start_cmd,
# must be overridden in a subclass in a file within the instance
home for
# each instance.  The below-defined start_cmd (and
_svc_display_name_
# and _svc_name_) are just examples.

# To use this script with SchoolTool, just replace SchoolBell
# with SchoolTool in the variables below.
# You'll also need to change 'Python24' to 'Python23' if that's
# what you've got.  -TEH

#cmd_str = os.environ[moin_service]

#_svc_name_ = r'moin_service'
#_svc_display_name_ = r'moin_service'
#start_cmd = rc:\mmde\moin.exe
info = ['', '', '']

def __init__(self):
self._svc_name = info[0]
self._svc_display_name_ = info[1]
self.start_cmd = info[2]

win32serviceutil.ServiceFramework.__init__(self)

# Create an event which we will use to wait on.
# The service stop request will set this event.
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
self.redirectOutput()

def __init__(self, args):
self._svc_name = info[0]
self._svc_display_name_ = info[1]
self.start_cmd = info[2]

win32serviceutil.ServiceFramework.__init__(self, args)
# Create an event which we will use to wait on.
# The service stop request will set this event.
self.hWaitStop = win32event.CreateEvent(None, 0, 0, None)
self.redirectOutput()

def redirectOutput(self):
#pass
sys.stdout.close()
sys.stderr.close()
sys.stdout = NullOutput()
sys.stderr = NullOutput()

def SvcStop(self):
# Before we do anything, tell the SCM we are starting the stop
process.
self.ReportServiceStatus(win32service.SERVICE_STOP_PENDING)

# TODO:  This TerminateProcess call doesn't make much sense:
it's
# doing a hard kill _first_, never giving the process a chance
to
# shut down cleanly.  Compare to current Zope2 service code,
which
# uses Windows events to give the process a chance to shut down
# cleanly, doing a hard kill only if that doesn't succeed.

# stop the process if necessary
try:
win32process.TerminateProcess(self.hZope, 0)
except pywintypes.error:
# the process may already have been terminated
pass
# And set my event.
win32event.SetEvent(self.hWaitStop)

# SvcStop only gets triggered when the user explictly stops (or
restarts)
# the service.  To shut the service down cleanly when Windows is
shutting
# down, we also need to hook SvcShutdown.
SvcShutdown = SvcStop

def createProcess(self, cmd):
return win32process.CreateProcess(
None, cmd, None, None, 0, 0, None, None,
win32process.STARTUPINFO())

def SvcDoRun(self):
# indicate to Zope that the process is daemon managed
(restartable)
# os.environ['ZMANAGED'] = '1'

# daemon behavior:  we want to to restart the process if it
# dies, but if it dies too many times, we need to give up.

# we use a simple backoff algorithm to determine whether
# we should try to restart a dead process:  for each
# time the process dies unexpectedly, we wait some number of
# seconds to restart it, as determined by the backoff interval,
# which doubles each time the process dies.  if we exceed
# BACKOFF_MAX seconds in cumulative backoff time, we give up.
# at any time if we successfully run the process for more thab
# BACKOFF_CLEAR_TIME seconds, the backoff stats are reset.

# the initial number of seconds between process start attempts
backoff_interval = BACKOFF_INITIAL_INTERVAL
# the cumulative backoff seconds counter
backoff_cumulative = 0

import servicemanager

# log a service started message
servicemanager.LogMsg(
servicemanager.EVENTLOG_INFORMATION_TYPE,
servicemanager.PYS_SERVICE_STARTED,

PyPy with a smaller PVM for the full Python?

2006-09-10 Thread Casey Hawthorne
Currently PyPy is working toward compiling to C a restricted subset of
Python, called RPython.

Would it be possible for PyPy to compile the full subset of Python
by also using a lot smaller version of the PVM (Python Virtual
Machine) to go with the compiled code?
So, the user would be running the C object code and also a smaller
PVM!

Or would this completely remove or severely reduce any speed advantage
of the compiled code?


Similarly, for JPython (which is at Python 2.2?), could one also use a
lot smaller accompanying PVM with the JPython source code and JVM to
use Python 2.5 in its entirety?

--
Regards,
Casey
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Simple regex with whitespaces

2006-09-10 Thread James Stroud
[EMAIL PROTECTED] wrote:
 Hello,
 
   I cannot figure out a way to find a regular expression that would
 match one and only one of these two strings:
 
 s1 = '  how are you'
 s2 = 'hello world   how are you'
 
   All I could come up with was:
 patt = re.compile('^[ ]*([A-Za-z]+)[  ]+([A-Za-z]+)$')
 
   Which of course does not work. I cannot express the fact: sentence
 have 0 or 1 whitespace, separation of group have two or more
 whitespaces.
 
 Any suggestion ? Thanks a bunch !
 Mathieu
 


py import re
py s1 = '  how are you'
py s2 = 'hello world   how are you'
py s3 = 'group herenow here but not here   but now here'
py patt_2plus = re.compile(r'(?:(?:\S+(?:\s|$))+(?:\s+|$)){2,}')
py patt_3plus = re.compile(r'(?:(?:\S+(?:\s|$))+(?:\s+|$)){3,}')

positive tests:

py patt_2plus.search(s2).group(0)
'hello world   how are you'
py patt_2plus.search(s3).group(0)
'group herenow here but not here   but now here'
py patt_3plus.search(s3).group(0)
'group herenow here but not here   but now here'



negative tests:

py patt_3plus.search(s2).group(0)
Traceback (most recent call last):
   File stdin, line 1, in ?
AttributeError: 'NoneType' object has no attribute 'group'
py patt_3plus.search(s1).group(0)
Traceback (most recent call last):
   File stdin, line 1, in ?
AttributeError: 'NoneType' object has no attribute 'group'
py patt_2plus.search(s1).group(0)
Traceback (most recent call last):
   File stdin, line 1, in ?
AttributeError: 'NoneType' object has no attribute 'group' 



James

-- 
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: CPython keeps on getting faster

2006-09-10 Thread George Sakkis
John Machin wrote:

 Here are some data points that illustrate the improvement in speed
 since 2.1 for one (probably atypical) application: rummaging through a
 120MB Microsoft Excel spreadsheet file using the xlrd package.

 The time shown is the number of seconds required to open the file and
 parse out all data content -- heavy usage of struct.unpack(). The only
 code that is conditional on the Python version is where it defines
 things to stop 2.1 barfing, like a dummy class called object .

 2.1.3: 117
 2.2.3:  95
 2.3.5:  75
 2.4.3:  62
 2.5c1:  49

 Other info:
 xlrd version: 0.6.0a2 -- coming soon to a cheese shop near you :-)
 OS: Windows XP SP2
 CPU:
 PROCESSOR_IDENTIFIER=x86 Family 15 Model 4 Stepping 1, GenuineIntel
 HumanSpeak: Intel dual-core Pentium (R) 4, nominal speed is
 3.20Ghz
 Memory: 1 Gb (enough to avoid swapping)

 Well done, core devs!

 FWIW, IronPython 1.0.60816 does it in 132 seconds. For avoidance of
 doubt (and flak!) I'd like to clarify that IMHO the mere existence of
 IronPython merits plaudits. I do however trust that it will similarly
 become faster over time. And nobody mentioned the possibility of an
 188% increase in memory usage, which may well be partially explained by
 this:

 DOS prompt\ironpython\ipy
 IronPython 1.0.60816 on .NET 2.0.50727.42
 Copyright (c) Microsoft Corporation. All rights reserved.
  str is unicode
 True

This might also explain in part the relative slowness you noticed.
OTOH, IronPython on Mono is around 20% faster than cPython 2.4 and
2.5c1 running pystone on my laptop (~50K pystones/sec for IronPython,
~41K  pystones/sec for cPython; not significant difference between 2.4
and 2.5c1). Just adding a datapoint from a completely different
environment:

CPU: Pentium-M 730 (1.6GHz)
Memory: 512 MB
OS: Ubuntu Dapper (6.06 LTS Dapper Drake)
Python2.4: 2.4.3 (#2, Apr 27 2006, 14:43:58) [GCC 4.0.3 (Ubuntu
4.0.3-1ubuntu5)]
Python2.5: 2.5c1 (r25c1:51305, Aug 18 2006, 19:18:03) [GCC 4.0.3
(Ubuntu 4.0.3-1ubuntu5)]
IronPython: 1.0.2444 on .NET 2.0.50727.42
Mono JIT compiler version 1.1.17
TLS:   normal
GC:Included Boehm (with typed GC)
SIGSEGV:   normal
Disabled:  none

George

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


Re: Simple regex with whitespaces

2006-09-10 Thread John Machin
[EMAIL PROTECTED] wrote:
 Hello,

   I cannot figure out a way to find a regular expression that would
 match one and only one of these two strings:

 s1 = '  how are you'
 s2 = 'hello world   how are you'

   All I could come up with was:
 patt = re.compile('^[ ]*([A-Za-z]+)[  ]+([A-Za-z]+)$')

   Which of course does not work. I cannot express the fact: sentence
 have 0 or 1 whitespace, separation of group have two or more
 whitespaces.

 Any suggestion ? Thanks a bunch !
 Mathieu

1. A word is one or more non-whitespace charaters -- subpattern is
\S+
2. A sentence is one or more words separated by a single white space
IOW a word followed by zero or more occurrences of  whitespace+word --
so a sentence will be matched by \S+(\s\S+)*
3. Leading and trailing runs of whitespace should be ignored -- use \s*
4. You will need to detect the case of 0 sentences (all whitespace)
separately -- I trust you don't need to be told how to do that :-)
5. Don't try to match two or more sentences; match one sentence, and
anything that fails must 0 or 2+ sentences.

So :

| s1 = '  how are you'
| s2 = 'hello world   how are you'
| pat = r^\s*\S+(\s\S+)*\s*$
| import re
| re.match(pat, s1)
|_sre.SRE_Match object at 0x00AED9E0
| re.match(pat, s2)
| re.match(pat, '  ')
| re.match(pat, ' a b')
| re.match(pat, ' a b')
|_sre.SRE_Match object at 0x00AED8E0
| re.match(pat, ' ab')
|_sre.SRE_Match object at 0x00AED920
| re.match(pat, ' a')
|_sre.SRE_Match object at 0x00AED9E0
| re.match(pat, 'a')
|_sre.SRE_Match object at 0x00AED8E0
|

HTH,
John

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


Flash Python

2006-09-10 Thread SamFeltus
Comical new updated link

http://sonomasunshine.com/sonomasunshine/index_sunshine.php?pagename=ufo_and_more

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


[ python-Bugs-780714 ] infinite __str__ recursion in thread causes seg fault

2006-09-10 Thread SourceForge.net
Bugs item #780714, was opened at 2003-07-31 18:37
Message generated for change (Comment added) made by aimacintyre
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=780714group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.3
Status: Open
Resolution: Fixed
Priority: 5
Submitted By: Stefan Gregory (stefan_gregory)
Assigned to: Nobody/Anonymous (nobody)
Summary: infinite __str__ recursion in thread causes seg fault

Initial Comment:
The following code reliably produces a segmentation
fault under Solaris8 in Python2.3, Python2.2,
Python2.1.3 and Python1.5. It produces a Bus Error when
run on Python2.2 under OSX. Clearly it should produce a
Python RuntimeError.

import thread, time

class Frog:

def __str__(self):
return str(self)

f = Frog()
thread.start_new_thread(str,(f,))
time.sleep(1000)

This problem manifests in scenarios such as when you
have 2 publishing objects (such as HTMLgen objects) A
and B and you put A inside B and B inside A and each
objects __str__ method calls its childrens __str__
methods and voila! (I hope this might be the reason my
Zope server has been intermitently crashing for the
past year or so though I have not found any recursive
structures yet.)

With Python2.3 gdb reports:

vgetargskeywords (args=0x1bdaf0, keywords=0x0,
format=0xd2579 quot;0:strquot;, kwlist=0xf7b4c,
p_va=0xfed0C02c) at Python/getargs.c:1167

Though with Python2.1 it dies at line 330 in getargs.c.



--

Comment By: Andrew I MacIntyre (aimacintyre)
Date: 2006-09-10 17:14

Message:
Logged In: YES 
user_id=250749

As of 2.5, the stack size for a thread can be set before the
thread is created.

Windows and Linux seem to default to generous thread stack
sizes (1MB or more), other platforms are parsimonious by
comparison (eg FreeBSD at 64kB).


--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 10:03

Message:
Logged In: YES 
user_id=21627

I fail to see the problem. You have to change the recursion
limit; if you do, you risk a crash, as the documentation says:

http://docs.python.org/lib/module-sys.html
This should be done with care, because a too-high limit can
lead to a crash.

With an unmodified recursionlimit in 2.4.3 on Windows, I get
the expected RuntimeError. If it causes a crash on some
system, it just means that the default recursion limit is
too high for that platform (however, we don't seem to have a
confirmation that the default recursion limit is too large
for this application on any platform for Python 2.4 or 2.5).

It is quite common that the system provides the main thread
with a larger stack space than any additional thread, so it
is not surprising that the stack overflow is detected on
some system when the code is run in the main thread, yet
crashes in an additional thread. The default recursion limit
should be the conservative minimum of what the system
minimally guarantees for any thread.

It seems that the original problem has been fixed (although
nobody apparently has tested Python 2.4 or 2.5 on Solaris8);
I suggest to close this as fixed again.

--

Comment By: Josiah Carlson (josiahcarlson)
Date: 2006-08-16 17:42

Message:
Logged In: YES 
user_id=341410

 import sys
 sys.setrecursionlimit(1)
 class foo:
... def __str__(self):
... return str(self)
...
 import threading
 threading.Thread(target=foo().__str__).start()

Kills 2.3, 2.4, and 2.5 on Windows, and 2.3 and 2.4 on linux
(I can't test 2.5 on linux).  Running in the main thread on
Windows doesn't seem to be a big deal:

 import sys
 sys.setrecursionlimit(1)
 class foo:
... def __str__(self):
... return str(self)
...
 try:
... str(foo())
... except Exception, why:
... print why
...
Stack overflow


Note that the above crashes 2.3 and 2.4 on Linux.

This is still a bug, at least in maintenance on 2.4. 
Suggested reopen.


--

Comment By: SourceForge Robot (sf-robot)
Date: 2006-08-14 12:20

Message:
Logged In: YES 
user_id=1312539

This Tracker item was closed automatically by the system. It was
previously set to a Pending status, and the original submitter
did not respond within 14 days (the time period specified by
the administrator of this Tracker).

--

Comment By: Georg Brandl (gbrandl)
Date: 2006-07-30 21:16

Message:
Logged In: YES 
user_id=849994

Under 2.5, I get a runtime error now, so this might be fixed.

--

Comment By: Brett Cannon (bcannon)
Date: 

[ python-Bugs-1550791 ] UCS-4 tcl not found on SUSE 10.1 with tcl and tk 8.4.12-14

2006-09-10 Thread SourceForge.net
Bugs item #1550791, was opened at 2006-09-02 08:23
Message generated for change (Comment added) made by aimacintyre
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1550791group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Tkinter
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Submitted By: Davin (dmpotts)
Assigned to: Martin v. Löwis (loewis)
Summary: UCS-4 tcl not found on SUSE 10.1 with tcl and tk 8.4.12-14

Initial Comment:
PROBLEM DESCRIPTION:  UCS-4 tcl is not found during
configuration on a SUSE 10.1 (x86-32) system where
tk-8.4.12-14 and tcl-8.4.12-14 have been installed as
part of the SUSE installation (and visible/managed by
YaST).  This results in _tkinter and dependent codes
not being built.

EXPECTED BEHAVIOUR:  The installed tcl/tk packages
(provided as part of the SUSE 10.1 install) should have
been detected successfully and _tkinter and related
packages should have been configured for build.

TO REPRODUCE:  Install SUSE 10.1 on x86 hardware,
taking care to ensure that tcl and tk packages are
included in that install.  Download, expand, and
attempt to configure Python 2.5 release candidate 1
(Python-2.5c1.tar.bz2).  Note that the following occurs
during configuration and that _tkinter is subsequently
not built:
checking for UCS-4 tcl... no


--

Comment By: Andrew I MacIntyre (aimacintyre)
Date: 2006-09-10 17:27

Message:
Logged In: YES 
user_id=250749

Where are tcl.h and tk.h on this system?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1550791group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1531862 ] subprocess.Popen(cmd, stdout=sys.stdout) fails

2006-09-10 Thread SourceForge.net
Bugs item #1531862, was opened at 2006-07-31 18:53
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1531862group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Closed
Resolution: None
Priority: 5
Submitted By: John A Meinel (jfmeinel)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: subprocess.Popen(cmd, stdout=sys.stdout) fails

Initial Comment:
I'm currently using subprocess.Popen() to run a
command, and I allow the caller to specify where the
output should go.

One valid output is to send it to sys.stdout (fileno == 1)

The subprocess module seems to unconditionally close
stdout if a file handle is passed (even if it stdout).

Compare:
python -c import subprocess,sys; \
  subprocess.Popen(['echo', 'hello'])

versus
python -c import subprocess,sys; \
  subprocess.Popen(['echo', 'hello'], stdout=sys.stdout)

or even
python -c import subprocess,sys; \
  subprocess.Popen(['echo', 'hello'], stdout=1)

The first one prints 'hello' as expected.

The latter two give an error:
echo: write error: Bad file descriptor

Attached is a possible patch to subprocess.py

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 11:53

Message:
Logged In: YES 
user_id=21627

How did you run the test cases yourself? They should have
failed for you as well; buildbot has nothing to do with that.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-07 02:50

Message:
Logged In: YES 
user_id=7887

Problem fixed again in 51797 (trunk) and 51794 (2.5), after
removing tests which were offending buildbot due to
sys.stdout being set to a StringIO.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 14:52

Message:
Logged In: YES 
user_id=7887

Notice that in all buildbots that reported the failure,
subprocess tests still pass correctly.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 14:48

Message:
Logged In: YES 
user_id=7887

Wow.. this is strange. I don't see any reason why the build
bots would break with this change, except for the reason
that the test needs to output data to stdout/stderr to check
if it's working or not.  Is the buildbot checking these
somehow?  Is there any additional information about these
failures?

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-09-06 05:59

Message:
Logged In: YES 
user_id=33168

I have reverted both of these changes since all the
buildbots were broken.

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-09-06 04:34

Message:
Logged In: YES 
user_id=33168

This change has broken many (all?) of the buildbots.
http://www.python.org/dev/buildbot/all/

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 04:06

Message:
Logged In: YES 
user_id=7887

Fixed in 51758, backported to 2.5 in 51759.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 03:44

Message:
Logged In: YES 
user_id=7887

Neal, I'm preparing a patch which fixes this problem as well.

Anthony, we should really be checking fd numbers, since
they're the ones dup'ed in the child. If sys.stdout has a
fileno() not in (0, 1, 2), that's not an issue.

--

Comment By: Anthony Baxter (anthonybaxter)
Date: 2006-08-16 06:16

Message:
Logged In: YES 
user_id=29957

Making it check for particular FD numbers is a bad idea.
Instead, it should check that any FD that's being closed
isn't in the set
(sys.stdin.fileno(), sys.stdout.fileno(), sys.stderr.fileno()) 




--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-08-16 06:11

Message:
Logged In: YES 
user_id=33168

If stderr == stdout, this patch won't fix that, will it? 
Shouldn't you add 1, 2 to the blacklist for stderr?  (The
patch adds 2, I think 1 may also be required.)

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1531862group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Feature Requests-1547300 ] Wireless on Python

2006-09-10 Thread SourceForge.net
Feature Requests item #1547300, was opened at 2006-08-26 23:36
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1547300group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Submitted By: Ahmet Bişkinler (ahmetbiskinler)
Assigned to: Nobody/Anonymous (nobody)
Summary: Wireless on Python

Initial Comment:
It would be very nice if Python had a Wireless Module
that works on all platforms.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 12:26

Message:
Logged In: YES 
user_id=21627

Would you like to contribute one?

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1547300group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Feature Requests-1528154 ] New sequences for Unicode groups and block ranges needed

2006-09-10 Thread SourceForge.net
Feature Requests item #1528154, was opened at 2006-07-25 06:44
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1528154group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Regular Expressions
Group: None
Status: Open
Resolution: None
Priority: 6
Submitted By: gmarketer (gmarketer)
Assigned to: Nobody/Anonymous (nobody)
Summary: New sequences for Unicode groups and block ranges needed

Initial Comment:
The special sequences consist of \ and another
character need to be added to RE sintax to simplify the
finding of several Unicode classes like:
 * All uppercase letters
 * All lowercase letters


--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 12:36

Message:
Logged In: YES 
user_id=21627

If anything, I think Python should implement Unicode TR#18:

http://www.unicode.org/unicode/reports/tr18/

This does include the \p notation for property expressions,
e.g. \p{Ll} or \p{East Asian Width:Narrow}.

We currently don't include the Script property, so \p{Greek}
could not be implemented (we can, of course, add support for
the script property). I can't find anything in the report
that makes \p{IsGreek} valid, so we shouldn't support it.

--

Comment By: gmarketer (gmarketer)
Date: 2006-07-26 04:06

Message:
Logged In: YES 
user_id=1334865

We need to process several strings in utf-8 and need to use
regular expressions to match pattern, for ex.:
r[ANY_LANGUAGE_UPPERCASE_LETTER,0-9ANY_LANGUAGE_LOWERCASE_LETTER]+|NOT_ANY_LANGUAGE_CURRENCY

We don't know how to implement this logic by our hands.

Also, I found this logic implemented in Microsoft dot NET
regular expressions:

\p{name}Matches any character in the named character
class 'name'. Supported names are Unicode groups and block
ranges. For example Ll, Nd, Z, IsGreek, IsBoxDrawing, and Sc
(currency). 

\P{name}Matches text not included in the named
character class 'name'. 

We need same logic in regular expressions.


--

Comment By: M.-A. Lemburg (lemburg)
Date: 2006-07-25 09:45

Message:
Logged In: YES 
user_id=38388

Could you make your request a little more specific ?

We already have catregories in the re module, so adding a
few more would be possible (patches are welcome !). However,
we do need to know why you need them and whether there are
other RE implementations that already have such special
matching characters, e.g. the Perl RE implementation.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=355470aid=1528154group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1409455 ] email.Message.set_payload followed by bad result get_payload

2006-09-10 Thread SourceForge.net
Bugs item #1409455, was opened at 2006-01-18 22:09
Message generated for change (Comment added) made by fresh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1409455group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.3
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Mark Sapiro (msapiro)
Assigned to: Barry A. Warsaw (bwarsaw)
Summary: email.Message.set_payload followed by bad result get_payload

Initial Comment:
Under certain circumstances, in particular when charset
is 'iso-8859-1', where msg is an email.Message() instance,

msg.set_payload(text, charset)

'apparently' encodes the text as quoted-printable and
adds a

Content-Transfer-Encoding: quoted-printable

header to msg. I say 'apparently' because if one prints
msg or creates a Generator instance and writes msg to a
file, the message is printed/written as a correct,
quoted-printable encoded message, but

text = msg._payload
or

text = msg.get_payload()

gives the original text, not quoted-printable encoded, and

text = msg.get_payload(decode=True)

gives a quoted-printable decoding of the original text
which is munged if the original text included '=' in
some ways.

This is causing problems in Mailman which are currently
worked around by flagging if the payload was set by
set_payload() and not subsequently 'decoding' in that
case, but it would be better if
set_payload()/get_payload() worked properly.

A script is attached which illustrates the problem.

--

Comment By: Chris Withers (fresh)
Date: 2006-09-10 12:26

Message:
Logged In: YES 
user_id=24723

This fix seems to have caused issues for code that does the
following:

from email.Charset import Charset,QP
from email.MIMEText import MIMEText

charset = Charset('utf-8')
charset.body_encoding = QP

msg = MIMEText(
u'Some text with chars that need encoding: \xa3',
'plain',
)
# set the charset 
msg.set_charset(charset)

print msg.as_string()

Before this fix, the above would result in:

MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=utf-8

Some text with chars that need encoding: =A3

Now I get:

Traceback (most recent call last):
  File test_encoding.py, line 14, in ?
msg.as_string()
  File c:\python24\lib\email\Message.py, line 129, in
as_string
g.flatten(self, unixfrom=unixfrom)
  File c:\python24\lib\email\Generator.py, line 82, in flatten
self._write(msg)
  File c:\python24\lib\email\Generator.py, line 113, in _write
self._dispatch(msg)
  File c:\python24\lib\email\Generator.py, line 139, in
_dispatch
meth(msg)
  File c:\python24\lib\email\Generator.py, line 182, in
_handle_text
self._fp.write(payload)
UnicodeEncodeError: 'ascii' codec can't encode character
u'\xa3' in position 41:
 ordinal not in range(128)

Am I doing something wrong here or is this patch in error?

--

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2006-02-08 13:34

Message:
Logged In: YES 
user_id=12800

r42270 for Python 2.3/email 2.5.  I will forward port these
to Python 2.4 and 2.5 (email 3.0).

--

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2006-02-08 03:07

Message:
Logged In: YES 
user_id=12800

See the latest patch in issue 1409458:

https://sourceforge.net/support/tracker.php?aid=1409538


--

Comment By: Barry A. Warsaw (bwarsaw)
Date: 2006-02-06 03:42

Message:
Logged In: YES 
user_id=12800

See the attached patch for what I think is ultimately the
right fix.  The idea is that when set_payload() is called,
the payload is immediately encoded so that get_payload()
will do the right thing.  Also, Generator.py has to be fixed
to not doubly encode the payload.

Run against your example, it seems to DTRT.  It also passes
all but one of the email pkg unit tests.  The one failure
is, I believe due to an incorrect test.  The patch includes
a fix for that as well as adding a test for
get_payload(decode=True).

I'd like to get some feedback from the email-sig before
applying this, but it seems right to me.

--

Comment By: Mark Sapiro (msapiro)
Date: 2006-01-20 23:19

Message:
Logged In: YES 
user_id=1123998

I've looked at the email library and I see the problem.
msg.set_payload() never QP encodes msg._payload. When the
message is stringified or flattened by a generator, the
generator's _handle_text() method does the encoding and it
is msg._charset that signals the need to do this. Thus when
the message object is ultimately converted to a suitable
external form, the body is QP encoded, but 

[ python-Bugs-1545659 ] distutils needs vendor-packages support

2006-09-10 Thread SourceForge.net
Bugs item #1545659, was opened at 2006-08-24 02:28
Message generated for change (Comment added) made by movement
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545659group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Submitted By: John Levon (movement)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils needs vendor-packages support

Initial Comment:
Currently, distutils supports site-packages. It
should also provide an option for vendor-packages.

--

Comment By: John Levon (movement)
Date: 2006-09-10 14:52

Message:
Logged In: YES 
user_id=53034

It appears that I was mistaken that this went upstream,
as it was refused for some bizarre reason:

http://sourceforge.net/tracker/index.php?func=detailaid=1298835group_id=5470atid=305470

So this should be closed too, and we'll have to fix it locally.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 00:09

Message:
Logged In: YES 
user_id=21627

What is vendor-packages?

It is not something that is part of Python, AFAICT, so I
don't think Python should support it.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545659group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1545658 ] distutils home scheme lacks python versioning

2006-09-10 Thread SourceForge.net
Bugs item #1545658, was opened at 2006-08-24 02:27
Message generated for change (Comment added) made by movement
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: John Levon (movement)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils home scheme lacks python versioning

Initial Comment:
The home scheme, as described here:

http://docs.python.org/inst/alt-install-windows.html

seems to be broken: no version suffix is appended,
yet .pyc files are not guaranteed across Python
revisions. Thus, breakage can occur.

This is quite annoying, as an OS vendor often would like
to install stuff into /usr/lib/python2.x/ (not using
vendor-packages).

--

Comment By: John Levon (movement)
Date: 2006-09-10 14:55

Message:
Logged In: YES 
user_id=53034

http://www.python.org/doc/1.5.2p2/lib/module-marshal.html

specifically:

Details of the format are undocumented on purpose; it may
change between Python versions (although it rarely does).

Thus, anyone using the home scheme can hit these changes as
the format is not architecturally guaranteed.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 00:13

Message:
Logged In: YES 
user_id=21627

I fail to see the problem. Can you please provide a scenario
where breakage does occur (instead of merely suggesting that
it can occur)? What is the specific error message that you
get?

Also, what does that have to do with OS vendors? They
shouldn't use the home scheme.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1545659 ] distutils needs vendor-packages support

2006-09-10 Thread SourceForge.net
Bugs item #1545659, was opened at 2006-08-24 02:28
Message generated for change (Settings changed) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545659group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: Feature Request
Status: Closed
Resolution: None
Priority: 5
Submitted By: John Levon (movement)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils needs vendor-packages support

Initial Comment:
Currently, distutils supports site-packages. It
should also provide an option for vendor-packages.

--

Comment By: John Levon (movement)
Date: 2006-09-10 14:52

Message:
Logged In: YES 
user_id=53034

It appears that I was mistaken that this went upstream,
as it was refused for some bizarre reason:

http://sourceforge.net/tracker/index.php?func=detailaid=1298835group_id=5470atid=305470

So this should be closed too, and we'll have to fix it locally.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 00:09

Message:
Logged In: YES 
user_id=21627

What is vendor-packages?

It is not something that is part of Python, AFAICT, so I
don't think Python should support it.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545659group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1545659 ] distutils needs vendor-packages support

2006-09-10 Thread SourceForge.net
Bugs item #1545659, was opened at 2006-08-24 04:28
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545659group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: Feature Request
Status: Closed
Resolution: None
Priority: 5
Submitted By: John Levon (movement)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils needs vendor-packages support

Initial Comment:
Currently, distutils supports site-packages. It
should also provide an option for vendor-packages.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 17:24

Message:
Logged In: YES 
user_id=21627

For the record: patch #1298835 wasn't refused; it was
withdrawn by the submitter. 

--

Comment By: John Levon (movement)
Date: 2006-09-10 16:52

Message:
Logged In: YES 
user_id=53034

It appears that I was mistaken that this went upstream,
as it was refused for some bizarre reason:

http://sourceforge.net/tracker/index.php?func=detailaid=1298835group_id=5470atid=305470

So this should be closed too, and we'll have to fix it locally.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 02:09

Message:
Logged In: YES 
user_id=21627

What is vendor-packages?

It is not something that is part of Python, AFAICT, so I
don't think Python should support it.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545659group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1545658 ] distutils home scheme lacks python versioning

2006-09-10 Thread SourceForge.net
Bugs item #1545658, was opened at 2006-08-24 04:27
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: John Levon (movement)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils home scheme lacks python versioning

Initial Comment:
The home scheme, as described here:

http://docs.python.org/inst/alt-install-windows.html

seems to be broken: no version suffix is appended,
yet .pyc files are not guaranteed across Python
revisions. Thus, breakage can occur.

This is quite annoying, as an OS vendor often would like
to install stuff into /usr/lib/python2.x/ (not using
vendor-packages).

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 17:26

Message:
Logged In: YES 
user_id=21627

It's true that the format of marshal may change. More
regularly, the format of .pyc files may change due to
changes in the byte codes. Yet, I fail to see why this can
cause breakage. The pyc format is deliberately so designed
that nothing will break even if the format changes.

I'm still waiting for a demonstrable problem.

--

Comment By: John Levon (movement)
Date: 2006-09-10 16:55

Message:
Logged In: YES 
user_id=53034

http://www.python.org/doc/1.5.2p2/lib/module-marshal.html

specifically:

Details of the format are undocumented on purpose; it may
change between Python versions (although it rarely does).

Thus, anyone using the home scheme can hit these changes as
the format is not architecturally guaranteed.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 02:13

Message:
Logged In: YES 
user_id=21627

I fail to see the problem. Can you please provide a scenario
where breakage does occur (instead of merely suggesting that
it can occur)? What is the specific error message that you
get?

Also, what does that have to do with OS vendors? They
shouldn't use the home scheme.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1555842 ] email package and Unicode strings handling

2006-09-10 Thread SourceForge.net
Bugs item #1555842, was opened at 2006-09-10 16:04
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1555842group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Manlio Perillo (manlioperillo)
Assigned to: Nobody/Anonymous (nobody)
Summary: email package and Unicode strings handling

Initial Comment:
The support for Unicode strings in the email package
(notably MIMEText and Header class) is not uniform.

The behaviour with Unicode strings in Header is
documented but the interface is not good.

This code works, but it should not:

 h = Header.Header(uàèìòù, charset=us-ascii)
 m = Message.Message()
 m[Subject] = h
 print m.as_string()


Allowing this to work can cause confusion, I'm saying
that the charset is us-ascii, not utf-8.

With MIMEText I obtain:

m = MIMEText.MIMEText(uàèìòù, _charset=us-ascii)
 print m.as_string()

[ exception ]


I think that the correct behaviour (for all functions
accepting strings) is:

- Do not accept plain str strings (8-bit).
  Accept only if they are plain ascii (7-bit).
- The charset specified should not be considered an 
  hint, but the charset I want to be used.



Regards  Manlio Perillo

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1555842group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1555842 ] email package and Unicode strings handling

2006-09-10 Thread SourceForge.net
Bugs item #1555842, was opened at 2006-09-10 16:04
Message generated for change (Comment added) made by manlioperillo
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1555842group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Manlio Perillo (manlioperillo)
Assigned to: Nobody/Anonymous (nobody)
Summary: email package and Unicode strings handling

Initial Comment:
The support for Unicode strings in the email package
(notably MIMEText and Header class) is not uniform.

The behaviour with Unicode strings in Header is
documented but the interface is not good.

This code works, but it should not:

 h = Header.Header(uàèìòù, charset=us-ascii)
 m = Message.Message()
 m[Subject] = h
 print m.as_string()


Allowing this to work can cause confusion, I'm saying
that the charset is us-ascii, not utf-8.

With MIMEText I obtain:

m = MIMEText.MIMEText(uàèìòù, _charset=us-ascii)
 print m.as_string()

[ exception ]


I think that the correct behaviour (for all functions
accepting strings) is:

- Do not accept plain str strings (8-bit).
  Accept only if they are plain ascii (7-bit).
- The charset specified should not be considered an 
  hint, but the charset I want to be used.



Regards  Manlio Perillo

--

Comment By: Manlio Perillo (manlioperillo)
Date: 2006-09-10 17:35

Message:
Logged In: YES 
user_id=1054957

The last example is not right.
Here is the correct one:

  m = MIMEText.MIMEText(uàèìòù, _charset=utf-8)
 
Traceback (most recent call last):
  File stdin, line 1, in ?
  File C:\Python2.4\lib\email\MIMEText.py, line 28, in
__init__
self.set_payload(_text, _charset)
  File C:\Python2.4\lib\email\Message.py, line 218, in
set_payload
self.set_charset(charset)
  File C:\Python2.4\lib\email\Message.py, line 260, in
set_charset
self._payload = charset.body_encode(self._payload)
  File C:\Python2.4\lib\email\Charset.py, line 366, in
body_encode
return email.base64MIME.body_encode(s)
  File C:\Python2.4\lib\email\base64MIME.py, line 136, in
encode
enc = b2a_base64(s[i:i + max_unencoded])
UnicodeEncodeError: 'ascii' codec can't encode characters in
position 0-2: ordinal not in range(128)


So it seems that email.Message does not handle Unicode strings.

The code works if I set the charset to latin-1.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1555842group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1545658 ] distutils home scheme lacks python versioning

2006-09-10 Thread SourceForge.net
Bugs item #1545658, was opened at 2006-08-24 02:27
Message generated for change (Comment added) made by movement
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: John Levon (movement)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils home scheme lacks python versioning

Initial Comment:
The home scheme, as described here:

http://docs.python.org/inst/alt-install-windows.html

seems to be broken: no version suffix is appended,
yet .pyc files are not guaranteed across Python
revisions. Thus, breakage can occur.

This is quite annoying, as an OS vendor often would like
to install stuff into /usr/lib/python2.x/ (not using
vendor-packages).

--

Comment By: John Levon (movement)
Date: 2006-09-10 18:51

Message:
Logged In: YES 
user_id=53034

Consider a shared tree where users do not have access to
write new .pyc's. Just like the standard python libraries,
there could be a significant speed slowdown due to not being
able to use the old .pyc's.

It's the exact same case that prompts distro's to install
into /usr/lib/pythonX.X/

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 15:26

Message:
Logged In: YES 
user_id=21627

It's true that the format of marshal may change. More
regularly, the format of .pyc files may change due to
changes in the byte codes. Yet, I fail to see why this can
cause breakage. The pyc format is deliberately so designed
that nothing will break even if the format changes.

I'm still waiting for a demonstrable problem.

--

Comment By: John Levon (movement)
Date: 2006-09-10 14:55

Message:
Logged In: YES 
user_id=53034

http://www.python.org/doc/1.5.2p2/lib/module-marshal.html

specifically:

Details of the format are undocumented on purpose; it may
change between Python versions (although it rarely does).

Thus, anyone using the home scheme can hit these changes as
the format is not architecturally guaranteed.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 00:13

Message:
Logged In: YES 
user_id=21627

I fail to see the problem. Can you please provide a scenario
where breakage does occur (instead of merely suggesting that
it can occur)? What is the specific error message that you
get?

Also, what does that have to do with OS vendors? They
shouldn't use the home scheme.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1545658 ] distutils home scheme lacks python versioning

2006-09-10 Thread SourceForge.net
Bugs item #1545658, was opened at 2006-08-24 04:27
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: None
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: John Levon (movement)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils home scheme lacks python versioning

Initial Comment:
The home scheme, as described here:

http://docs.python.org/inst/alt-install-windows.html

seems to be broken: no version suffix is appended,
yet .pyc files are not guaranteed across Python
revisions. Thus, breakage can occur.

This is quite annoying, as an OS vendor often would like
to install stuff into /usr/lib/python2.x/ (not using
vendor-packages).

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 21:00

Message:
Logged In: YES 
user_id=21627

Why would a user not have the right to install to its own
home directory? That's what the home scheme is there for.

In any case, it seems that there won't be actual breakage,
only a possible slowdown. I very much doubt that the
slowdown would ever be significant, though.

It seems you want to use the home scheme for something that
it was not designed for. Notice that it is merely an
abbreviation - you can specify the directories directly if
you want to.

I'm closing this as invalid: the original report (Thus,
breakage can occur.) is apparently wrong.

--

Comment By: John Levon (movement)
Date: 2006-09-10 20:51

Message:
Logged In: YES 
user_id=53034

Consider a shared tree where users do not have access to
write new .pyc's. Just like the standard python libraries,
there could be a significant speed slowdown due to not being
able to use the old .pyc's.

It's the exact same case that prompts distro's to install
into /usr/lib/pythonX.X/

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 17:26

Message:
Logged In: YES 
user_id=21627

It's true that the format of marshal may change. More
regularly, the format of .pyc files may change due to
changes in the byte codes. Yet, I fail to see why this can
cause breakage. The pyc format is deliberately so designed
that nothing will break even if the format changes.

I'm still waiting for a demonstrable problem.

--

Comment By: John Levon (movement)
Date: 2006-09-10 16:55

Message:
Logged In: YES 
user_id=53034

http://www.python.org/doc/1.5.2p2/lib/module-marshal.html

specifically:

Details of the format are undocumented on purpose; it may
change between Python versions (although it rarely does).

Thus, anyone using the home scheme can hit these changes as
the format is not architecturally guaranteed.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 02:13

Message:
Logged In: YES 
user_id=21627

I fail to see the problem. Can you please provide a scenario
where breakage does occur (instead of merely suggesting that
it can occur)? What is the specific error message that you
get?

Also, what does that have to do with OS vendors? They
shouldn't use the home scheme.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1545658 ] distutils home scheme lacks python versioning

2006-09-10 Thread SourceForge.net
Bugs item #1545658, was opened at 2006-08-24 02:27
Message generated for change (Comment added) made by movement
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: None
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: John Levon (movement)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils home scheme lacks python versioning

Initial Comment:
The home scheme, as described here:

http://docs.python.org/inst/alt-install-windows.html

seems to be broken: no version suffix is appended,
yet .pyc files are not guaranteed across Python
revisions. Thus, breakage can occur.

This is quite annoying, as an OS vendor often would like
to install stuff into /usr/lib/python2.x/ (not using
vendor-packages).

--

Comment By: John Levon (movement)
Date: 2006-09-10 20:12

Message:
Logged In: YES 
user_id=53034

 not have the right to install

Did you actually read the example I gave?

Just because it's a possible slowdown doesn't mean
that this behaviour is both inconsistent and potentially
troublesome. But I suppose you don't care.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 19:00

Message:
Logged In: YES 
user_id=21627

Why would a user not have the right to install to its own
home directory? That's what the home scheme is there for.

In any case, it seems that there won't be actual breakage,
only a possible slowdown. I very much doubt that the
slowdown would ever be significant, though.

It seems you want to use the home scheme for something that
it was not designed for. Notice that it is merely an
abbreviation - you can specify the directories directly if
you want to.

I'm closing this as invalid: the original report (Thus,
breakage can occur.) is apparently wrong.

--

Comment By: John Levon (movement)
Date: 2006-09-10 18:51

Message:
Logged In: YES 
user_id=53034

Consider a shared tree where users do not have access to
write new .pyc's. Just like the standard python libraries,
there could be a significant speed slowdown due to not being
able to use the old .pyc's.

It's the exact same case that prompts distro's to install
into /usr/lib/pythonX.X/

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 15:26

Message:
Logged In: YES 
user_id=21627

It's true that the format of marshal may change. More
regularly, the format of .pyc files may change due to
changes in the byte codes. Yet, I fail to see why this can
cause breakage. The pyc format is deliberately so designed
that nothing will break even if the format changes.

I'm still waiting for a demonstrable problem.

--

Comment By: John Levon (movement)
Date: 2006-09-10 14:55

Message:
Logged In: YES 
user_id=53034

http://www.python.org/doc/1.5.2p2/lib/module-marshal.html

specifically:

Details of the format are undocumented on purpose; it may
change between Python versions (although it rarely does).

Thus, anyone using the home scheme can hit these changes as
the format is not architecturally guaranteed.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 00:13

Message:
Logged In: YES 
user_id=21627

I fail to see the problem. Can you please provide a scenario
where breakage does occur (instead of merely suggesting that
it can occur)? What is the specific error message that you
get?

Also, what does that have to do with OS vendors? They
shouldn't use the home scheme.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1545658 ] distutils home scheme lacks python versioning

2006-09-10 Thread SourceForge.net
Bugs item #1545658, was opened at 2006-08-24 04:27
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Distutils
Group: None
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: John Levon (movement)
Assigned to: Nobody/Anonymous (nobody)
Summary: distutils home scheme lacks python versioning

Initial Comment:
The home scheme, as described here:

http://docs.python.org/inst/alt-install-windows.html

seems to be broken: no version suffix is appended,
yet .pyc files are not guaranteed across Python
revisions. Thus, breakage can occur.

This is quite annoying, as an OS vendor often would like
to install stuff into /usr/lib/python2.x/ (not using
vendor-packages).

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 23:08

Message:
Logged In: YES 
user_id=21627

I read the example you gave. In case of a shared directory,
you shouldn't use the home scheme. If you do anyway, you
have to live with the consequences. The home scheme is
called home scheme for a reason: the target directory is
expected to be inside the user's home directory.

--

Comment By: John Levon (movement)
Date: 2006-09-10 22:12

Message:
Logged In: YES 
user_id=53034

 not have the right to install

Did you actually read the example I gave?

Just because it's a possible slowdown doesn't mean
that this behaviour is both inconsistent and potentially
troublesome. But I suppose you don't care.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 21:00

Message:
Logged In: YES 
user_id=21627

Why would a user not have the right to install to its own
home directory? That's what the home scheme is there for.

In any case, it seems that there won't be actual breakage,
only a possible slowdown. I very much doubt that the
slowdown would ever be significant, though.

It seems you want to use the home scheme for something that
it was not designed for. Notice that it is merely an
abbreviation - you can specify the directories directly if
you want to.

I'm closing this as invalid: the original report (Thus,
breakage can occur.) is apparently wrong.

--

Comment By: John Levon (movement)
Date: 2006-09-10 20:51

Message:
Logged In: YES 
user_id=53034

Consider a shared tree where users do not have access to
write new .pyc's. Just like the standard python libraries,
there could be a significant speed slowdown due to not being
able to use the old .pyc's.

It's the exact same case that prompts distro's to install
into /usr/lib/pythonX.X/

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 17:26

Message:
Logged In: YES 
user_id=21627

It's true that the format of marshal may change. More
regularly, the format of .pyc files may change due to
changes in the byte codes. Yet, I fail to see why this can
cause breakage. The pyc format is deliberately so designed
that nothing will break even if the format changes.

I'm still waiting for a demonstrable problem.

--

Comment By: John Levon (movement)
Date: 2006-09-10 16:55

Message:
Logged In: YES 
user_id=53034

http://www.python.org/doc/1.5.2p2/lib/module-marshal.html

specifically:

Details of the format are undocumented on purpose; it may
change between Python versions (although it rarely does).

Thus, anyone using the home scheme can hit these changes as
the format is not architecturally guaranteed.

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 02:13

Message:
Logged In: YES 
user_id=21627

I fail to see the problem. Can you please provide a scenario
where breakage does occur (instead of merely suggesting that
it can occur)? What is the specific error message that you
get?

Also, what does that have to do with OS vendors? They
shouldn't use the home scheme.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1545658group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1531862 ] subprocess.Popen(cmd, stdout=sys.stdout) fails

2006-09-10 Thread SourceForge.net
Bugs item #1531862, was opened at 2006-07-31 16:53
Message generated for change (Comment added) made by niemeyer
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1531862group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Closed
Resolution: None
Priority: 5
Submitted By: John A Meinel (jfmeinel)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: subprocess.Popen(cmd, stdout=sys.stdout) fails

Initial Comment:
I'm currently using subprocess.Popen() to run a
command, and I allow the caller to specify where the
output should go.

One valid output is to send it to sys.stdout (fileno == 1)

The subprocess module seems to unconditionally close
stdout if a file handle is passed (even if it stdout).

Compare:
python -c import subprocess,sys; \
  subprocess.Popen(['echo', 'hello'])

versus
python -c import subprocess,sys; \
  subprocess.Popen(['echo', 'hello'], stdout=sys.stdout)

or even
python -c import subprocess,sys; \
  subprocess.Popen(['echo', 'hello'], stdout=1)

The first one prints 'hello' as expected.

The latter two give an error:
echo: write error: Bad file descriptor

Attached is a possible patch to subprocess.py

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-10 22:01

Message:
Logged In: YES 
user_id=7887

Interesting. I was running tests directly most of the times
and also in verbose mode, which indeed was hiding the
problem that would happen when stdout is replaced.

Now, one thing I wonder is about this:

http://www.python.org/dev/buildbot/all/g4%20osx.4%20trunk/builds/1424/step-test/0

Why is it failing?  In the first run, when all buildbots
were broken, this is what was happening.  It does look like
tests are succeeding, and the implementation is the same as
the currently committed one, but buildbot still says it's
broken for some reason, and no error messages. Strange.


--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 09:53

Message:
Logged In: YES 
user_id=21627

How did you run the test cases yourself? They should have
failed for you as well; buildbot has nothing to do with that.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-07 00:50

Message:
Logged In: YES 
user_id=7887

Problem fixed again in 51797 (trunk) and 51794 (2.5), after
removing tests which were offending buildbot due to
sys.stdout being set to a StringIO.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 12:52

Message:
Logged In: YES 
user_id=7887

Notice that in all buildbots that reported the failure,
subprocess tests still pass correctly.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 12:48

Message:
Logged In: YES 
user_id=7887

Wow.. this is strange. I don't see any reason why the build
bots would break with this change, except for the reason
that the test needs to output data to stdout/stderr to check
if it's working or not.  Is the buildbot checking these
somehow?  Is there any additional information about these
failures?

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-09-06 03:59

Message:
Logged In: YES 
user_id=33168

I have reverted both of these changes since all the
buildbots were broken.

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-09-06 02:34

Message:
Logged In: YES 
user_id=33168

This change has broken many (all?) of the buildbots.
http://www.python.org/dev/buildbot/all/

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 02:06

Message:
Logged In: YES 
user_id=7887

Fixed in 51758, backported to 2.5 in 51759.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 01:44

Message:
Logged In: YES 
user_id=7887

Neal, I'm preparing a patch which fixes this problem as well.

Anthony, we should really be checking fd numbers, since
they're the ones dup'ed in the child. If sys.stdout has a
fileno() not in (0, 1, 2), that's not an issue.

--

Comment By: Anthony Baxter (anthonybaxter)
Date: 2006-08-16 04:16

Message:
Logged In: YES 
user_id=29957

Making it check for particular FD numbers is a bad idea.
Instead, it should check that any FD that's being closed
isn't in the set
(sys.stdin.fileno(), sys.stdout.fileno(), sys.stderr.fileno()) 





[ python-Bugs-1541697 ] Recently introduced sgmllib regexp bug hangs Python

2006-09-10 Thread SourceForge.net
Bugs item #1541697, was opened at 2006-08-16 18:51
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1541697group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: John J Lee (jjlee)
Assigned to: Neal Norwitz (nnorwitz)
Summary: Recently introduced sgmllib regexp bug hangs Python

Initial Comment:
Looks like revision 47154 introduced a regexp that
hangs Python (Ctrl-C won't kill the process, CPU usage
sits near 100%) under some circumstances.  A test case
is attached (sgmllib.html and hang_sgmllib.py).

The problem isn't seen if you read the whole file (or
nearly the whole file) at once.  But that doesn't make
it a non-bug, AFAICS.

I'm not sure what the problem is, but presumably the
relevant part of the patch is this:

+starttag = re.compile(r'[a-zA-Z][-_.:a-zA-Z0-9]*\s*('
+r'\s*([a-zA-Z_][-:.a-zA-Z_0-9]*)(\s*=\s*'
+   
r'(\'[^\']*\'|[^]*|[-a-zA-Z0-9./,:;+*%?!$\(\)[EMAIL PROTECTED]'
+   
r'[][\-a-zA-Z0-9./,:;+*%?!$\(\)_#=~\'@]*(?=[\s/])))?'
+r')*\s*/?\s*(?=[])')


The patch attached to bug 1515142 (also from Sam Ruby
-- claims to fix a regression introduced by his recent
sgmllib patches, and has not yet been applied) does NOT
fix the problem.


--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-09-10 21:25

Message:
Logged In: YES 
user_id=33168

I reverted the patch and added the test case for sgml so the
infinite loop doesn't recur.

Committed revision 51854. (head)
Committed revision 51850. (2.5)
Committed revision 51853. (2.4)

I will add the hang_re test cause to test_crashers or somewhere.

--

Comment By: kovan (kovan)
Date: 2006-09-05 14:40

Message:
Logged In: YES 
user_id=1426755

Sorry, correct URL is
http://svn.python.org/view/python/trunk/Lib/sgmllib.py?rev=47154r1=47080r2=47154



--

Comment By: kovan (kovan)
Date: 2006-09-05 14:24

Message:
Logged In: YES 
user_id=1426755

Again FYI, here's the diff where presumably the bug was
introduced:
http://svn.python.org/view/python/trunk/Lib/sgmllib.py?rev=47080r1=46996r2=47080

--

Comment By: kovan (kovan)
Date: 2006-09-05 14:04

Message:
Logged In: YES 
user_id=1426755

I've been testing quiver's test case:

- With Eclipse's QuickREx plugin: it hangs. It was
configured in PCRE mode (which uses Jakarta-ORO Perl 5
regular expressions implementation), and no additional options.

- With grep: grep exits with a fatal error and dumps a stack
trace. grep was run also in Perl mode, with the command:
grep -P -f regexp.txt test.txt

I can't find an explanation for this, but I don't know much
about regexps. I hope it has some utility for the resolution
of this bug nevertheless.

--

Comment By: George Yoshida (quiver)
Date: 2006-08-17 21:55

Message:
Logged In: YES 
user_id=671362

Slimmed down test case is attached.(The regex pattern in
question is used)

FYI, r47154 is backported to 2.4 branch(r47155).


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1541697group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1504333 ] sgmllib should allow angle brackets in quoted values

2006-09-10 Thread SourceForge.net
Bugs item #1504333, was opened at 2006-06-11 05:58
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1504333group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
Status: Open
Resolution: None
Priority: 5
Submitted By: Sam Ruby (rubys)
Assigned to: Nobody/Anonymous (nobody)
Summary: sgmllib should allow angle brackets in quoted values

Initial Comment:
Real live example (search for otherbr /corrections)

http://latticeqcd.blogspot.com/2006/05/non-relativistic-qcd.html

This addresses the following (included in the file):

# XXX The following should skip matching quotes (' or )


--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-09-10 21:26

Message:
Logged In: YES 
user_id=33168

I reverted the patch and added the test case for sgml so the
infinite loop doesn't recur.  This was mentioned several
times on python-dev.

Committed revision 51854. (head)
Committed revision 51850. (2.5)
Committed revision 51853. (2.4)


--

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2006-06-29 10:17

Message:
Logged In: YES 
user_id=3066

I checked in a modified version of this patch: changed to
use separate REs for start and end tags to reduce matching
cost for end tags; extended tests; updated to avoid breaking
previous changes to support IPv6 addresses in unquoted
attribute values.

Committed as revisions 47154 (trunk) and 47155
(release24-maint).

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1504333group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1531862 ] subprocess.Popen(cmd, stdout=sys.stdout) fails

2006-09-10 Thread SourceForge.net
Bugs item #1531862, was opened at 2006-07-31 18:53
Message generated for change (Comment added) made by loewis
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detailatid=105470aid=1531862group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Closed
Resolution: None
Priority: 5
Submitted By: John A Meinel (jfmeinel)
Assigned to: Gustavo Niemeyer (niemeyer)
Summary: subprocess.Popen(cmd, stdout=sys.stdout) fails

Initial Comment:
I'm currently using subprocess.Popen() to run a
command, and I allow the caller to specify where the
output should go.

One valid output is to send it to sys.stdout (fileno == 1)

The subprocess module seems to unconditionally close
stdout if a file handle is passed (even if it stdout).

Compare:
python -c import subprocess,sys; \
  subprocess.Popen(['echo', 'hello'])

versus
python -c import subprocess,sys; \
  subprocess.Popen(['echo', 'hello'], stdout=sys.stdout)

or even
python -c import subprocess,sys; \
  subprocess.Popen(['echo', 'hello'], stdout=1)

The first one prints 'hello' as expected.

The latter two give an error:
echo: write error: Bad file descriptor

Attached is a possible patch to subprocess.py

--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-11 07:16

Message:
Logged In: YES 
user_id=21627

It often happens that the tests fail first and then pass
when rerun; it is not that clear why that happens. In many
cases, this has turned out to be a consequence of the
sequence in which the tests are run, where earlier tests
break some state information to let later tests fail.

It should be possible to enhance regrtest/unittest to keep
more information about a failure, e.g. which specific test
method failed. This might give a clue in cases like this.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-11 00:01

Message:
Logged In: YES 
user_id=7887

Interesting. I was running tests directly most of the times
and also in verbose mode, which indeed was hiding the
problem that would happen when stdout is replaced.

Now, one thing I wonder is about this:

http://www.python.org/dev/buildbot/all/g4%20osx.4%20trunk/builds/1424/step-test/0

Why is it failing?  In the first run, when all buildbots
were broken, this is what was happening.  It does look like
tests are succeeding, and the implementation is the same as
the currently committed one, but buildbot still says it's
broken for some reason, and no error messages. Strange.


--

Comment By: Martin v. Löwis (loewis)
Date: 2006-09-10 11:53

Message:
Logged In: YES 
user_id=21627

How did you run the test cases yourself? They should have
failed for you as well; buildbot has nothing to do with that.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-07 02:50

Message:
Logged In: YES 
user_id=7887

Problem fixed again in 51797 (trunk) and 51794 (2.5), after
removing tests which were offending buildbot due to
sys.stdout being set to a StringIO.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 14:52

Message:
Logged In: YES 
user_id=7887

Notice that in all buildbots that reported the failure,
subprocess tests still pass correctly.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 14:48

Message:
Logged In: YES 
user_id=7887

Wow.. this is strange. I don't see any reason why the build
bots would break with this change, except for the reason
that the test needs to output data to stdout/stderr to check
if it's working or not.  Is the buildbot checking these
somehow?  Is there any additional information about these
failures?

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-09-06 05:59

Message:
Logged In: YES 
user_id=33168

I have reverted both of these changes since all the
buildbots were broken.

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2006-09-06 04:34

Message:
Logged In: YES 
user_id=33168

This change has broken many (all?) of the buildbots.
http://www.python.org/dev/buildbot/all/

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 04:06

Message:
Logged In: YES 
user_id=7887

Fixed in 51758, backported to 2.5 in 51759.

--

Comment By: Gustavo Niemeyer (niemeyer)
Date: 2006-09-06 03:44

Message:
Logged In: