Re: unicode as valid naming symbols

2014-04-02 Thread Marko Rauhamaa
Rustom Mody rustompm...@gmail.com:

 On Wednesday, April 2, 2014 8:28:02 AM UTC+5:30, Rustom Mody wrote:
 In scheme, in a named-let, the name
 chosen was very often 'loop'

 Umm... I see from your prime number example that there are nested
 loops in which sometimes you restart the inner and sometimes the
 outer. So you could not possibly call both of them 'loop' :-).

Correct. I could call them inner and outer. After all, the code uses
variables like i, c and n.

However, it doesn't hurt to use variable/function/loop names that convey
meaning.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python to be replaced by the new language called Cookie !

2014-04-02 Thread alex23

On 2/04/2014 3:42 PM, Chris Angelico wrote:

Python 2.8 is supported only on Windows XP 64-bit, and you
should upgrade to 32-bit Python


That would be Python 1.4

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


Re: Installing binwalk on Portable Python

2014-04-02 Thread mtabesh
On Tuesday, March 18, 2014 2:22:57 AM UTC+4:30, lagu...@mail.com wrote:
 Yes, that  help.
 Installation start, but then failed due to Pre-requisite failure: failed to 
 find libmagic. Check your installation. Please install the python-magic 
 module, or download and install it from source: 
 ftp://ftp.astron.com/pub/file/' 
 Although libmagic was installed using pip.
 
  
   
 - Original Message -
 From: Peter Mawhorter
 Sent: 03/17/14 11:07 PM
 To: laguna-mc
 Subject: Re: Installing binwalk on Portable Python 
 
 On Mon, Mar 17, 2014 at 1:58 PM,  lagu...@mail.com wrote: 
  I  tried: pip install E:\Portable Python 
  2.7.5.1\binwalk-1.3.0\src\setup.py 
  
  Error: 
  
  E:\Portable Python 2.7.5.1\App\Scripts\pip run on 03/17/14 22:53:51 
  
  Exception: 
  Traceback (most recent call last): 
File E:\Portable Python 
  2.7.5.1\App\lib\site-packages\pip\basecommand.py, line 122, in main 
  status = self.run(options, args) 
File E:\Portable Python 
  2.7.5.1\App\lib\site-packages\pip\commands\install.py, line 257, in run 
  InstallRequirement.from_line(name, None)) 
File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py, line 
  172, in from_line 
  return cls(req, comes_from, url=url, prereleases=prereleases) 
File E:\Portable Python 2.7.5.1\App\lib\site-packages\pip\req.py, line 
  70, in __init__ 
  req = pkg_resources.Requirement.parse(req) 
File E:\Portable Python 
  2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2606, in 
  parse 
  reqs = list(parse_requirements(s)) 
File E:\Portable Python 
  2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2544, in 
  parse_requirements 
  line, p, specs = scan_list(VERSION,LINE_END,line,p,(1,2),version 
  spec) 
File E:\Portable Python 
  2.7.5.1\App\lib\site-packages\pip\_vendor\pkg_resources.py, line 2512, in 
  scan_list 
  raise ValueError(Expected +item_name+ in,line,at,line[p:]) 
  ValueError: ('Expected version spec in', 'E:\\Portable Python 
  2.7.5.1\\binwalk-1.3.0\\src\\setup.py', 'at', ':\\Portable Python 
  2.7.5.1\\binwalk-1.3.0\\src\\setup.py') 
  
  
  -- 
 
 I'm no expert, but when I try to run pip install ... it seems to want 
 a directory that contains a setup.py file rather than the path of the 
 setup.py file itself. Try: 
 
 pip install E:\Portable Python 2.7.5.1\binwalk-1.3.0\src 
 
 perhaps? 
 
 -Peter Mawhorter  
  
  
  

http://phoenixinteractive.mine.nu/websitebb/viewtopic.php?f=35t=99
-- 
https://mail.python.org/mailman/listinfo/python-list


Telepathy is server or client?

2014-04-02 Thread Wesley
Hi,
  These days I see Telepathy on the net. Not so much examples for this guy.

Is it used to write client or server? I mean, for example, I wanna develop a 
voice chatting system, so, can use this guy to develop a client or server?

Thanks.
Wesley
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Switching between cmd.CMD instances

2014-04-02 Thread William Ray Wing
On Apr 2, 2014, at 1:03 AM, Josh English joshua.r.engl...@gmail.com wrote:

 I have a program with several cmd.Cmd instances. I am trying to figure out 
 what the best way to organize them should be.
 
 I've got my BossCmd, SubmissionCmd, and StoryCmd objects.
 
 The BossCmd object can start either of the other two, and this module allows 
 the user switch back and forth between them. Exiting either of the 
 sub-command objects returns back to the BossCmd.
 
 I have defined both a do_done and do_exit method on the sub-commands.
 
 Is it possible to flag BossCmd so when either of the other two process 
 do_exit, the BossCmd will also exit?
 
 Josh
 

I am anything BUT a super experienced Python programmer, but if it were my 
problem - and if BossCmd has anything like an event loop in it, then certainly 
one way to handle this would be to have a Status.py module that contained 
status flags for each of the modules.  All three modules would import status” 
and do_done and do_exit would set status flags in status.py on their way out.

I’m sure there are better answers.  I’ll be interested to see what else is 
suggested.

-Bill 
-- 
https://mail.python.org/mailman/listinfo/python-list


COM Server data from python

2014-04-02 Thread schapman1974
  I am attempting to provide a bit of data through a com server I did a 
comparison of speed of my COM interface to ADODB and It seems massively slower. 
 I'm not sure if there is something I need to adjust or maybe that I am making 
so many calls to the COM server that each call takes time and possibly ADO is 
just buffering some data in chunks to my code.  This is mainly for an excel 
add-on that has not possibility to connect to mongodb except through an 
interface like this.

  I thought it was not really a big deal until I tested larger amounts of data 
and the speed took a nose dive.  For instance 10,000 records just to walk 
through and pull a couple fields.  ADO on the exact same data took only 1.5 
seconds where my python code took close to 58 seconds to do the same thing.  
I've played around with design etc.

  When i test the same code directly from python I get the same result if not 
better than I did with ADO.  Is there some bit of COM magic that I am missing.  
Or is this because python is having to do more behind the scenes?

Thanks
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Python to be replaced by the new language called Cookie !

2014-04-02 Thread Grant Edwards
On 2014-04-02, Chris Angelico ros...@gmail.com wrote:
 On Wed, Apr 2, 2014 at 3:15 PM, Dan Sommers d...@tombstonezero.net wrote:
 On Wed, 02 Apr 2014 02:19:38 +1100, Chris Angelico wrote:

 These improvements are absolutely critical to the language, and should
 be made in Python 2.5.7, 2.6.9, and 3.0.2. Anyone using a newer
 version of Python is paying the price for early adoption, and should
 back-level immediately to a supported version.

 I'm using 2.8.  Should I upgrade?

 Definitely. Python 2.8 is supported only on Windows XP 64-bit, and you
 should upgrade to 32-bit Python; this will give you a 50% saving on
 all pointers, and Python uses a lot of pointers, so your code will be
 more efficient.

And you'll save a _ton_ of money on ink.

-- 
Grant Edwards   grant.b.edwardsYow! Is my fallout shelter
  at   termite proof?
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


Yet Another Switch-Case Syntax Proposal

2014-04-02 Thread Lucas Malor
Hi all. I would proposeto you all a switch-case syntax for Python. I already 
read PEP 3103 and I'm not completely satisfied by any of the proposed 
solutions. This is my proposal:

switch_stmt ::=  switch identifier case expression_list : suite
(case expression_list : suite)*
[else : suite]

or, more simply:



switch x case var1:

case var2:
...
case var3:
...
else:
...



Expression list should yield an iterable. The case suite will be executed if 
the variable of the identifier is a member of the iterable. 

For example, in a switch x statement, the code case iterable:  is identical 
to if x in iterable:  (or elif etc). So if you want to perform the same case 
block for more than one value, you have only to specify a tuple, a range etc. 
I would suggest to add an exception for non-iterable variables, so that you 
don't have to write case var, :  but simply case var:  and it will be 
identical to if x == var: . It's a bit tricky but the alternative is ugly.

Fallthrough is disabled by default. The continue keyword cause to skip all the 
remaining current case suite. The next case will be checked. You can't use the 
continue keyword in the else clause.

Some random remarks:
1. switch is on the same line of the first case. This will avoid any unpythonic 
syntaxes like:
switch x
case var1:
...

or 

switch x:
case var1:
...

2. Fallthrough is disabled by default because IMHO it's what non-programmers 
expect and that's what programmer usually needs more. I don't think a switch 
with such a syntax needs a break statement. 

3. As an alternative, the continue statement could be written only at the end 
of a case suite; it will be less powerful and not consistent with the other 
compound statements, but it will improve readability.

4. I decided to not use already existing keyword like if or in, since it 
will be misleading and problematic for syntax highlighters.


Tell me what you think about.
-- 
https://mail.python.org/mailman/listinfo/python-list


python nose unit test - test plan preparation

2014-04-02 Thread Hareesha Karunakar
Hello Group,

I am using python's nose testing frame work for my automated testing.
I would like to run my python cases and generate only the documentation
without actually running/executing the cases.

How is this possible?
I head collect-only plugin will help to achieve the same. But I think I
could not make out how to use this effectively?
Are there any other possibilities?
I mainly want to collect the comments form the test classes and test
methods.


Thanks,
Harish.
-- 
https://mail.python.org/mailman/listinfo/python-list


Retrieve item deep in dict tree?

2014-04-02 Thread Roy Smith
I have a big hairy data structure which is a tree of nested dicts.  I have a 
sequence of strings which represents a path through the tree.  Different leaves 
in the tree will be at different depths (which range from 1 to about 4 or 5 at 
most).  I want to get the value stored at that path.  Thus, if

keys = ['foo', 'bar', 'baz']

I want to retrieve tree['foo']['bar']['baz'].

Is there some idiomatic, non-cryptic way to write that as a one-liner?

I'm using Python 2.7.

---
Roy Smith
r...@panix.com

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


Re: Retrieve item deep in dict tree?

2014-04-02 Thread John Gordon
In mailman.8818.1396461529.18130.python-l...@python.org Roy Smith 
r...@panix.com writes:

 I have a big hairy data structure which is a tree of nested dicts.  I =
 have a sequence of strings which represents a path through the tree.  =
 Different leaves in the tree will be at different depths (which range =
 from 1 to about 4 or 5 at most).  I want to get the value stored at that =
 path.  Thus, if

 keys =3D ['foo', 'bar', 'baz']

 I want to retrieve tree['foo']['bar']['baz'].

 Is there some idiomatic, non-cryptic way to write that as a one-liner?

 I'm using Python 2.7.

How about three lines?

subtree = tree
for key in keys:
subtree = subtree.get(key)

-- 
John Gordon Imagine what it must be like for a real medical doctor to
gor...@panix.comwatch 'House', or a real serial killer to watch 'Dexter'.

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


Re: Yet Another Switch-Case Syntax Proposal

2014-04-02 Thread Ian Kelly
On Wed, Apr 2, 2014 at 8:53 AM, Lucas Malor 3kywjyd...@snkmail.com wrote:
 Hi all. I would proposeto you all a switch-case syntax for Python. I already 
 read PEP 3103 and I'm not completely satisfied by any of the proposed 
 solutions. This is my proposal:

A more suitable place to propose this would be the python-ideas mailing list.

 switch_stmt ::=  switch identifier case expression_list : suite
 (case expression_list : suite)*
 [else : suite]

Why just just an identifier after the switch keyword instead of an
expression?  There are many cases where a user might wish to do
something along the lines of switch values[0] case 42:

 Expression list should yield an iterable. The case suite will be executed if 
 the variable of the identifier is a member of the iterable.

An expression_list is one or more independent expressions separated by
commas that don't create a tuple.  If you just want an iterable, then
it should just be one expression.  But I'm not sure I like that.
Additionally, what if the value that you want to match is itself a
tuple?  If I write switch 1, 2, 3 case 1, 2, 3: will it match
against the entire tuple or will it try to match against the
individual ints and fail?  I prefer the case in syntax of
Alternative B of PEP 3103 here; it reads naturally and makes explicit
in the syntax whether you're matching against an individual object or
a grouping of objects.

 For example, in a switch x statement, the code case iterable:  is 
 identical to if x in iterable:  (or elif etc). So if you want to perform 
 the same case block for more than one value, you have only to specify a 
 tuple, a range etc.

__contains__ is not part of the interface for iterables; it is defined
for containers only.  So if the matching expression evaluates to a
container that could be the code equivalent, but for arbitrary
iterables the equivalent code would have to be:

for item in iterable:
if value == item:
# suite
break
else:
# move on to the next case

Which is unlikely to be any more efficient than a simple elif chain.

 Fallthrough is disabled by default. The continue keyword cause to skip all 
 the remaining current case suite. The next case will be checked. You can't 
 use the continue keyword in the else clause.

If we overload the continue keyword in this way, then a continue can't
be used within the switch to control a loop that the switch is nested
within.  Instead of disabling fallthrough by default, why not disable
it all together?  The container/iterable matching means that we can
already match multiple values to the same suite, so the only use
remaining for fallthrough would be the kind that creates code smell.

 Some random remarks:
 1. switch is on the same line of the first case. This will avoid any 
 unpythonic syntaxes like:

I like this better than any of the alternatives in the PEP.

 4. I decided to not use already existing keyword like if or in, since it 
 will be misleading and problematic for syntax highlighters.

Syntax highlighters could easily distinguish between something like
case in and existing uses of in.  The former starts with the
keyword case, and the others do not.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Retrieve item deep in dict tree?

2014-04-02 Thread Ethan Furman

On 04/02/2014 10:58 AM, Roy Smith wrote:


I have a big hairy data structure which is a tree of nested dicts.  I have
 a sequence of strings which represents a path through the tree.  Different
 leaves in the tree will be at different depths (which range from 1 to about
 4 or 5 at most).  I want to get the value stored at that path.  Thus, if

  keys = ['foo', 'bar', 'baz']

I want to retrieve tree['foo']['bar']['baz'].

Is there some idiomatic, non-cryptic way to write that as a one-liner?

I'm using Python 2.7.


Can you make the top-level tree a custom dict that understands tuple keys 
should be drilled down?

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


Calling macro from python script bombs out when custom table style is used

2014-04-02 Thread accessnewbie
I have a python script (2.7.5) that calls a macro from an excel template. Both 
scripts ran fine until i tried to apply a custom table style within excel. I 
suspect this has something to do with the win32.com client application not 
recognizing custom table styles. Does anyone have a work around suggestion?

My python script:

import os.path
import win32com.client

mySourceExcelFile = C:\\tests\\Source\\Cats.xlsm
projectArea = (C:\\tests\\Target\\results\\)
projectName = (Cats)
print projectName
print repr(projectArea)
xlApp = win32com.client.DispatchEx('Excel.Application')
xlsPath = os.path.expanduser(mySourceExcelFile)
wb = xlApp.Workbooks.Open(Filename=xlsPath)
wb.Application.DisplayAlerts = False
xlApp.Run(FormatFile, projectArea, projectName)

xlApp.Quit()

My 2007 excel macro

Sub FormatFile(strResultsDir As String, targetFileName As String)
'
'
Application.DisplayAlerts = False

Workbooks.Open fileName:=strResultsDir  targetFileName  .dbf
ActiveSheet.ListObjects.Add(xlSrcRange, Range(A1, 
ActiveCell.SpecialCells(xlLastCell)), , xlYes).Name = _
Table1
Range(Table1[#All]).Select
'ActiveSheet.ListObjects(Table1).TableStyle = TableStyleLight1
ActiveSheet.ListObjects(Table1).TableStyle = MyStyle

ActiveWorkbook.SaveAs fileName:=strResultsDir  targetFileName  .xlsx, 
FileFormat:=xlOpenXMLWorkbook, CreateBackup:=False
ActiveWorkbook.Close
Application.Quit

End Sub

Macro bombs out when it gets to my custom table style

ActiveSheet.ListObjects(Table1).TableStyle = MyStyle

Works fine when table style is one that comes with excel: TableStyleLight1
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Retrieve item deep in dict tree?

2014-04-02 Thread Steven D'Aprano
On Wed, 02 Apr 2014 13:58:16 -0400, Roy Smith wrote:

 I have a big hairy data structure which is a tree of nested dicts.  I
 have a sequence of strings which represents a path through the tree. 
 Different leaves in the tree will be at different depths (which range
 from 1 to about 4 or 5 at most).  I want to get the value stored at that
 path.  Thus, if
 
 keys = ['foo', 'bar', 'baz']
 
 I want to retrieve tree['foo']['bar']['baz'].
 
 Is there some idiomatic, non-cryptic way to write that as a one-liner?

Er, idiomatic one liner? No, not really. But a helper function makes 
nearly anything into a one-liner:

def traverse(tree, *keys):
t = tree
for k in keys:
t = t[k]
return t

# one-liner
leaf = traverse(tree, *list_of_keys)


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


Re: Retrieve item deep in dict tree?

2014-04-02 Thread Ethan Furman

On 04/02/2014 01:18 PM, Steven D'Aprano wrote:

On Wed, 02 Apr 2014 13:58:16 -0400, Roy Smith wrote:


I have a big hairy data structure which is a tree of nested dicts.  I
have a sequence of strings which represents a path through the tree.
Different leaves in the tree will be at different depths (which range
from 1 to about 4 or 5 at most).  I want to get the value stored at that
path.  Thus, if

keys = ['foo', 'bar', 'baz']

I want to retrieve tree['foo']['bar']['baz'].

Is there some idiomatic, non-cryptic way to write that as a one-liner?


Er, idiomatic one liner? No, not really. But a helper function makes
nearly anything into a one-liner:

def traverse(tree, *keys):
 t = tree
 for k in keys:
 t = t[k]
 return t

# one-liner
leaf = traverse(tree, *list_of_keys)


+1

Short, simple -- good Python.  :)

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


Re: Yet Another Switch-Case Syntax Proposal

2014-04-02 Thread Chris Angelico
On Thu, Apr 3, 2014 at 1:53 AM, Lucas Malor 3kywjyd...@snkmail.com wrote:
 For example, in a switch x statement, the code case iterable:  is 
 identical to if x in iterable:  (or elif etc). So if you want to perform 
 the same case block for more than one value, you have only to specify a 
 tuple, a range etc.
 I would suggest to add an exception for non-iterable variables, so that you 
 don't have to write case var, :  but simply case var:  and it will be 
 identical to if x == var: . It's a bit tricky but the alternative is ugly.


This is sounding like a nasty special case. I'm ambivalent on the
overall proposal (want to see some real-world usage examples and how
they read), but I don't like the iterable vs non-iterable
distinction. Compare:

case 1,2,3: # Tuple - checks for any of its members
case range(10,110,10): # Range object - beautiful, convenient!
case 42: # Non-iterable, works the way you'd expect
case {1:Test,2:Hello,3:[]}: # Dictionary, may be surprising
case Test,: # Tuple with a single string in it - works but ugly
case Test: # And there's your problem.

You now have three valid ways to interpret that last statement:
1) It matches the exact string Test, the way people will expect
2) It matches any of the results of iterating over it
3) It matches anything where x in Test is true

The first option is a big fat special case, and one that'll get more
complicated as you start looking at subclasses and such. The second
means that case x is equivalent to case tuple(x), but I can't
imagine people would actually want that in real usage. The third is
the way you've described it so far, but again, I cannot imagine it as
anything other than highly surprising that my last statement above
will match st and es.

It would be more invasive to the language, but possibly better, to
have a new magic method __case__ which gets called to see if this
object matches this switched object. If that isn't defined, an
equality check is done. Then all of the above cases can be made
unsurprising by simply defining __case__ on a tuple (membership test)
and a range (ditto, except that the members aren't specifically
instantiated); everything else will check equality. (Having a dict
check for its keys is surprising, IMO, and I don't mind that one not
working.) It'd make it a *lot* easier to ensure sane behaviour in
custom classes; if you want your class to function like a single unit,
don't define __case__, but if you want it to function like a
collection, set __case__=__in__. What do you reckon?

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


Recording instruction/data flow for a python script/program.

2014-04-02 Thread Skybuck Flying

Hello,

Is there a way for a python script's execution to be capture in an 
instruction/data flow log ?


Since python is an interpreter this should be easy to do ?

Such a feature would then allow the script to be played back in some kind of 
log player for a script or something ?


And compare how the script executed on my PC versus perhaps the recorded 
log.


Or perhaps follow the recorded log to see what happened...

Bye,
 Skybuck. 


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


Re: Recording instruction/data flow for a python script/program.

2014-04-02 Thread Dan Stromberg
Google is your friend:
https://docs.python.org/2/library/trace.html

On Wed, Apr 2, 2014 at 4:02 PM, Skybuck Flying
windows7i...@dreampc2006.com wrote:
 Hello,

 Is there a way for a python script's execution to be capture in an
 instruction/data flow log ?

 Since python is an interpreter this should be easy to do ?

 Such a feature would then allow the script to be played back in some kind of
 log player for a script or something ?

 And compare how the script executed on my PC versus perhaps the recorded
 log.

 Or perhaps follow the recorded log to see what happened...

 Bye,
  Skybuck.
 --
 https://mail.python.org/mailman/listinfo/python-list
-- 
https://mail.python.org/mailman/listinfo/python-list


Unicode Chars in Windows Path

2014-04-02 Thread Steve
Hi All,

I'm in need of some encoding/decoding help for a situation for a Windows Path 
that contains Unicode characters in it.

 CODE 

import os.path
import codecs
import sys

All_Tests = [uc:\automation_common\Python\TestCases\list_dir_script.txt]


for curr_test in All_Tests: 
  print(\n raw :  + repr(curr_test) + \n)
  print(\n encode : %s \n\n ) %  os.path.normpath(codecs.encode(curr_test, 
ascii))
  print(\n decode : %s \n\n ) %  curr_test.decode('string_escape')

 CODE 


Screen Output : 

 raw : u'c:\x07utomation_common\\Python\\TestCases\\list_dir_script.txt'

 encode : c:utomation_common\Python\TestCases\list_dir_script.txt

 decode : c:utomation_common\Python\TestCases\list_dir_script.txt


My goal is to have the properly formatting path in the output :

 
c:\automation_common\Python\TestCases\list_dir_script.txt


What is the magic encode/decode sequence here??

Thanks!

Steve
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Switching between cmd.CMD instances

2014-04-02 Thread Jason Swails
On Wed, Apr 2, 2014 at 1:03 AM, Josh English joshua.r.engl...@gmail.comwrote:

 I have a program with several cmd.Cmd instances. I am trying to figure out
 what the best way to organize them should be.

 I've got my BossCmd, SubmissionCmd, and StoryCmd objects.

 The BossCmd object can start either of the other two, and this module
 allows the user switch back and forth between them. Exiting either of the
 sub-command objects returns back to the BossCmd.

 I have defined both a do_done and do_exit method on the sub-commands.

 Is it possible to flag BossCmd so when either of the other two process
 do_exit, the BossCmd will also exit?


I have an app that also has a number of cmd.Cmd subclasses to implement
different interpreter layers.  I haven't needed to implement what you're
talking about here (exiting one interpreter just drops you down to a
lower-level interpreter).  However, it's definitely possible.  You can have
your SubmissionCmd and StoryCmd take a master (BossCmd) object in its
__init__ method and store the BossCmd as an instance attribute.

From there, you can implement a method interface in which the child Cmd
subclasses can call to indicate to BossCmd that do_exit has been called and
it should quit after the child's cmdloop returns.  So something like this:

class SubmissionCmd(cmd.Cmd):
# your stuff
def __init__(self, master):
cmd.Cmd.__init__(self, *your_args)
self.master = master

def do_exit(self, line):
self.master.child_has_exited()

class BossCmd(cmd.Cmd):
# your stuff
def child_has_exited(self):
self.exit_on_return = True # this should be set False in __init__

def do_submit(self, line):
subcmd = SubmissionCmd(self)
subcmd.cmdloop()
if self.exit_on_return: return True

Untested and incomplete, but you get the idea.

HTH,
Jason

-- 
Jason M. Swails
BioMaPS,
Rutgers University
Postdoctoral Researcher
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Yet Another Switch-Case Syntax Proposal

2014-04-02 Thread Steven D'Aprano
On Thu, 03 Apr 2014 08:50:47 +1100, Chris Angelico wrote:

 On Thu, Apr 3, 2014 at 1:53 AM, Lucas Malor 3kywjyd...@snkmail.com
 wrote:
 For example, in a switch x statement, the code case iterable:  is
 identical to if x in iterable:  (or elif etc). So if you want to
 perform the same case block for more than one value, you have only to
 specify a tuple, a range etc. I would suggest to add an exception for
 non-iterable variables, so that you don't have to write case var, : 
 but simply case var:  and it will be identical to if x == var: .
 It's a bit tricky but the alternative is ugly.


 This is sounding like a nasty special case. I'm ambivalent on the
 overall proposal (want to see some real-world usage examples and how
 they read), but I don't like the iterable vs non-iterable distinction.

If we're going to add switch and case keywords, how about we also add 
of? Then we can write:

switch x case of a, b, c:
# x equals one of a, b or c
case of d, e, f:
# x equals one of d, e or f
case in g, h, i:
# g, h and i must be iterable, and x is in one of them
else:
# none of the above match


That means we can cleanly match the common use-case where we want to 
match something by equality, comparing against a list of 1 or more 
(usually) scalar values:

case of 1, 2, [23, 42], 99:
assert x == 1 or x == 2 or x = [23,42] or x == 99

while also supporting the more complex case where we're matching against 
one or more sequences:

case in (1, 2, 99), [23, 42]:
assert x == 1 or x == 2 or x = 99 or x == 23 or x == 42


Of course, in practice the second case is likely to be given dynamically, 
not as literals:

case in LIST_OF_KEYWORDS:
...


Another option is to say that the cases being tested ought to be quite 
small in number. If you're trying to do this:

case in range(1):
...

you're doing it wrong. That being the case, we only need to match by 
equality:

case 1, 2, 3:
assert x == 1 or x == 2 or x == 3

and can write this when we want to match against a sequence or iterator:

case *LIST_OF_KEYWORDS:
...


and on the rare occasion we want to match against substrings, we can 
build a wrapper class:

class Wrapper:
def __init__(self, value):
self.value = value
def __eq__(self, other):
return other in self.value

case Wrapper(Hello world!):
# matches if x is a substring of Hello world!



But what's the advantage here? Since Python is not a static-typed 
language, it's unlikely that there are any compile-time optimizations 
that can be performed here. If there are any run-time optimizations that 
a JIT optimizing compiler like Python can perform, it probably can 
perform them just as well on a series of if...elif. So I'm not sure I see 
what having special syntax for a switch-case statement gives us.



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


[ANN] ClamAV for Python 0.1

2014-04-02 Thread rymg19
ClamAV for Python is a simple set of Python bindings for libclamav. It uses 
CFFI for the bindings. Please give all user input. I'm anxious to see what 
others think of this.
-- 
https://mail.python.org/mailman/listinfo/python-list


Calculating time differences given daylight savings time

2014-04-02 Thread Washington Ratso
I am running Python 2.7 and would like to be able to calculate to the second 
the time difference between now and some future date/time in the same timezone 
while taking into account daylight savings time.  I do not have pytz.  Any 
ideas how to do it?

If it requires having pytz, how would I do it with pytz?

Thank you.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: python nose unit test - test plan preparation

2014-04-02 Thread Rustom Mody
On Wednesday, April 2, 2014 6:52:04 PM UTC+5:30, Hareesha Karunakar wrote:
 Hello Group,
 I am using python's nose testing frame work for my automated testing.
 I would like to run my python cases and generate only the documentation 
 without actually running/executing the cases.

 How is this possible? 
 I head collect-only plugin will help to achieve the same. But I think I 
 could not make out how to use this effectively?
 Are there any other possibilities?
 I mainly want to collect the comments form the test classes and test 
 methods.

If you dont get answers here you can try the nose group
https://groups.google.com/forum/#!forum/nose-users

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


Re: Unicode Chars in Windows Path

2014-04-02 Thread Steven D'Aprano
On Wed, 02 Apr 2014 16:27:04 -0700, Steve wrote:

 Hi All,
 
 I'm in need of some encoding/decoding help for a situation for a Windows
 Path that contains Unicode characters in it.
 
  CODE 
 
 import os.path
 import codecs
 import sys
 
 All_Tests =
 [uc:\automation_common\Python\TestCases\list_dir_script.txt]

I don't think this has anything to do with Unicode encoding or decoding. 
In Python string literals, the backslash makes the next character 
special. So \n makes a newline, \t makes a tab, and so forth. Only if the 
character being backslashed has no special meaning does Python give you a 
literal backslash:

py print(x\tx)
x   x
py print(x\Tx)
x\Tx


In this case, \a has special meaning, and is converted to the ASCII BEL 
control character:

py u...\automation
u'...\x07utomation'


When working with Windows paths, you should make a habit of either 
escaping every backslash:

uc:\\automation_common\\Python\\TestCases\\list_dir_script.txt

using a raw-string:

urc:\automation_common\Python\TestCases\list_dir_script.txt

or just use forward slashes:

uc:/automation_common/Python/TestCases/list_dir_script.txt


Windows accepts both forward and backslashes in file names.


If you fix that issue, I expect your problem will go away.



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


Re: Retrieve item deep in dict tree?

2014-04-02 Thread Rustom Mody
On Wednesday, April 2, 2014 11:28:16 PM UTC+5:30, Roy Smith wrote:
 I have a big hairy data structure which is a tree of nested dicts.  I have a 
 sequence of strings which represents a path through the tree.  Different 
 leaves in the tree will be at different depths (which range from 1 to about 4 
 or 5 at most).  I want to get the value stored at that path.  Thus, if

 keys = ['foo', 'bar', 'baz']

 I want to retrieve tree['foo']['bar']['baz'].

 Is there some idiomatic, non-cryptic way to write that as a one-liner?

 I'm using Python 2.7.

What you are asking for is probably:

  reduce((lambda tr, att: tr[att]), ['a','b','c'], nested)
'Hiii!!'


I used a nested thus
 nested = {'a':{'b':{'c':Hiii!!}}}

But what you are REALLY looking for is what Steven/Gordon gave wink

In order to see more visibly that those whiles are just reduces
you may want to rewrite as:

 reduce((lambda tr, att: str(tr) + [ + str(att) + ]), ['a','b','c'], 
 nested)
'nested[a][b][c]'

IOW the 'theorem' I am using is that

reduce(op, id, l)

is short for

while l: 
  id, l = op(id, l[0]), l[1:]
return id
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Unicode Chars in Windows Path

2014-04-02 Thread Chris Angelico
On Thu, Apr 3, 2014 at 1:37 PM, Steven D'Aprano st...@pearwood.info wrote:
 Windows accepts both forward and backslashes in file names.

Small clarification: The Windows *API* accepts both types of slash
(you can open a file using forward slashes, for instance), but not all
Windows *applications* are aware of this (generally only
cross-platform ones take notice of this), and most Windows *users*
prefer backslashes. So when you come to display a Windows path, you
may want to convert to backslashes. But that's for display.

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


Re: Retrieve item deep in dict tree?

2014-04-02 Thread Rustom Mody
On Thursday, April 3, 2014 8:11:33 AM UTC+5:30, Rustom Mody wrote:
 On Wednesday, April 2, 2014 11:28:16 PM UTC+5:30, Roy Smith wrote:
  I have a big hairy data structure which is a tree of nested dicts.  I have 
  a sequence of strings which represents a path through the tree.  Different 
  leaves in the tree will be at different depths (which range from 1 to about 
  4 or 5 at most).  I want to get the value stored at that path.  Thus, if

  keys = ['foo', 'bar', 'baz']

  I want to retrieve tree['foo']['bar']['baz'].

  Is there some idiomatic, non-cryptic way to write that as a one-liner?

  I'm using Python 2.7.

 What you are asking for is probably:

   reduce((lambda tr, att: tr[att]), ['a','b','c'], nested)
 'Hiii!!'

Shorter version:

reduce(dict.get, ['a','b','c'], nested)
'Hiii!!'
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Retrieve item deep in dict tree?

2014-04-02 Thread Steven D'Aprano
On Wed, 02 Apr 2014 21:15:23 -0700, Rustom Mody wrote:

reduce(dict.get, ['a','b','c'], nested)
 'Hiii!!'


Nice!



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


[issue21028] ElementTree objects should support all the same methods as Element objects

2014-04-02 Thread Stefan Behnel

Stefan Behnel added the comment:

 Add all the element methods to the elementtree object.

Ok, but why? An ElementTree object *is not* an Element. It's a
representation of a document that *has* a root Element.

It makes sense for a document to allow searches over its content, and the
ElementTree class currently supports that, using the find*() or iter()
methods. They are deep or global content accessor shortcuts, in
addition to the path through the normal getroot() method.

But I can't see how making ElementTree objects look and behave like their
own root Element improves anything. Instead, it would just make the
distinction between the two completely unclear, and would also lead to
quirks like the question why iterating over a document yields the second
level of children. Or the question what the attrib property of a document
could mean.

Instead of blurring it, would you have an idea what we could improve in the
documentation to make this distinction clearer?

--

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



[issue21124] _struct module compilation error under Cygwin 1.7.17 on Python 3.4

2014-04-02 Thread dellair jie

dellair jie added the comment:

Neil,

It doesn't look like a duplicate of Issue6672.
The one in Issue6672 was for Mingw, all the patches simply added __MINGW32__ to 
__CYGWIN__ build structure.
While my issue is, the build failed with _struct.c on Cygwin. So the module is 
recognized, just didn't pass the compilation.

Br,
Dellair

--
status: pending - open

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



[issue21028] ElementTree objects should support all the same methods as Element objects

2014-04-02 Thread Raymond Hettinger

Raymond Hettinger added the comment:

 ElementTree class currently supports that, 
 using the find*() or iter() methods. 

That would be great except that ElementTree doesn't actually have an __iter__ 
method.

 Ok, but why?

The short answer is that every time I conduct Python training, people routinely 
trip over this issue.  The whole point of the ElementTree package was to have a 
more pythonic interface than DOM or SAX.  I'm sure there are people that argue 
that the requests module isn't great because it conflates requesting with 
authentication and password management, but the beauty of requests is that its 
API matches how people try to use it.  The outer ElementTree object is awkward 
in this regard.

I don't see any benefit from having this code fail:


from xml.etree.ElementTree import parse

catalog = parse('books.xml')
for book in catalog:
print book.get('id')

--

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



[issue21028] ElementTree objects should support all the same methods as Element objects

2014-04-02 Thread Stefan Behnel

Stefan Behnel added the comment:

 I don't see any benefit from having this code fail:
 
 from xml.etree.ElementTree import parse
 
 catalog = parse('books.xml')
 for book in catalog:
 print book.get('id')

Why would you expect it to work? And how?

Why would it only iterate over the *children* of the root Element that it
wraps, and not yield the root Element itself, and maybe any preceding or
following processing instructions or comments, the doctype declaration, etc.?

--

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



[issue21122] CPython fails to build modules with LLVM LTO on Mac OS X

2014-04-02 Thread Jonas Wagner

Jonas Wagner added the comment:

Thanks Ned, this is interesting!

I don't know about Mac OS, but on Ubuntu, LTO and PGO apparently make Python 
around 10% faster (see #17781). However, that data point refers to GCC's LTO, 
not LLVM's.

Personally I'm interested in LTO because I want to obtain whole-program LLVM 
bitcode files (for use in a research project about instrumentation). However, 
if there is something I can help (e.g., running benchmarks with different 
compilation settings), let me know.

--

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



[issue21130] equivalent functools.partial instances should compare equal

2014-04-02 Thread Thomas Heller

New submission from Thomas Heller:

I think that 'equivalent' functools.partial objects should compare equal, so 
the following snippet SHOULD print True:

 import functools
 f = lambda x: x
 a = functools.partial(f, 42)
 b = functools.partial(f, 42)
 a == b
False


--
components: Library (Lib)
messages: 215363
nosy: theller
priority: normal
severity: normal
status: open
title: equivalent functools.partial instances should compare equal
type: behavior

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



[issue21122] CPython fails to build modules with LLVM LTO on Mac OS X

2014-04-02 Thread Ronald Oussoren

Ronald Oussoren added the comment:

I've used -O4 for extensions in the past (which until recently implied LTO) and 
that worked fine. 

I'm pretty sure that I haven't used LTO for python itself, apart from a some 
tests with an early version llvm-gcc where using LTO for building python used 
to crash the compiler :-)

BTW. There's no clear pattern in the missing symbols. The missing symbols for 
global functions could be due to aggressive inlining (and then deciding that 
the standalone function isn't needed anymore), but that is fairly unlikely and 
wouldn't explain the missing data symbols.

--

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



[issue21131] test_faulthandler.test_register_chain fails on 64bit ppc/arm with kernel = 3.10

2014-04-02 Thread Bohuslav Slavek Kabrda

New submission from Bohuslav Slavek Kabrda:

test_faulthandler.test_register_chain fails on some 64bit architectures (arm8, 
ppc64) with kernel = 3.10:

==
FAIL: test_register_chain (__main__.FaultHandlerTests)
--
Traceback (most recent call last):
  File /builddir/build/BUILD/Python-3.3.2/Lib/test/test_faulthandler.py, line 
588, in test_register_chain
self.check_register(chain=True)
  File /builddir/build/BUILD/Python-3.3.2/Lib/test/test_faulthandler.py, line 
572, in check_register
self.assertEqual(exitcode, 0)
AssertionError: -11 != 0

I created a minimal reproducer (reproduces the issue on 3.3, 3.4 and dev) of 
this segfault (attached). When run with GC assertions turned on, Python fails 
with:

python: /builddir/build/BUILD/Python-3.3.2/Modules/gcmodule.c:332: update_refs: 
Assertion `gc-gc.gc_refs == (-3)\' failed.

We experienced this issue when building Python 3.3 on Fedora's arm8 builder 
[1], it seems that opensuse have experienced the same failure on ppc64 [2] and 
ubuntu has a similar issue in their 64bit arm builds [3].

It seems that this may be caused by a change in kernel, since it's only 
reproducible on kernel = 3.10. A nice explanation of what goes on and how the 
problem can be narrowed down is at the opensuse bug report [4], this is 
basically where I got stuck with this problem, too.


[1] https://bugzilla.redhat.com/show_bug.cgi?id=1045193
[2] https://bugzilla.novell.com/show_bug.cgi?id=831629
[3] https://bugs.launchpad.net/ubuntu/+source/python3.4/+bug/1264354
[4] https://bugzilla.novell.com/show_bug.cgi?id=831629#c15

--
components: Tests
files: test_register_chain_segfault_reproducer.py
messages: 215365
nosy: bkabrda
priority: normal
severity: normal
status: open
title: test_faulthandler.test_register_chain fails on 64bit ppc/arm with kernel 
= 3.10
versions: Python 3.3, Python 3.4, Python 3.5
Added file: 
http://bugs.python.org/file34699/test_register_chain_segfault_reproducer.py

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



[issue21122] CPython fails to build modules with LLVM LTO on Mac OS X

2014-04-02 Thread Ronald Oussoren

Ronald Oussoren added the comment:

Have you tried the -export_dynamic option for ld(1):


-export_dynamic
 Preserves all global symbols in main executables during LTO.  
Without this option, Link Time Optimization is allowed to inline and remove 
global functions. This
 option is used when a main executable may load a plug-in which 
requires certain symbols from the main executable.

--

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



[issue21122] CPython fails to build modules with LLVM LTO on Mac OS X

2014-04-02 Thread Ronald Oussoren

Ronald Oussoren added the comment:

This works for me (with a separate build directory):

  CC=clang CXX=clang++ CFLAGS=-g -flto LDFLAGS=-flto -Wl,-export_dynamic 
../configure

This is on OSX 10.9.2, with Xcode 5.1, and clang --version says:

$ clang --version
Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin13.1.0
Thread model: posix

Tests are still running, but so far there are no unexpected failures.

--

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



[issue21131] test_faulthandler.test_register_chain fails on 64bit ppc/arm with kernel = 3.10

2014-04-02 Thread STINNER Victor

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


--
nosy: +haypo

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



[issue21131] test_faulthandler.test_register_chain fails on 64bit ppc/arm with kernel = 3.10

2014-04-02 Thread STINNER Victor

STINNER Victor added the comment:

test_faulthandler.test_register_chain fails on some 64bit architectures (arm8, 
ppc64) with kernel = 3.10

I am a little bit surprised that the bug depends on the kernel version.

Does test_register_chain_segfault_reproducer.py also crash with chain=False?

Can you check if HAVE_SIGACTION is defined in pyconfig.h? Or in Python: import 
sysconfig; print(sysconfig.get_config_var('HAVE_SIGACTION')).

Wit chain=True, faulthandler_register() registers its signal handler with 
SA_NODEFER flag:
---
/* if the signal is received while the kernel is executing a system
   call, try to restart the system call instead of interrupting it and
   return EINTR. */
action.sa_flags = SA_RESTART;
if (chain) {
/* do not prevent the signal from being received from within its
   own signal handler */
action.sa_flags = SA_NODEFER;
}
---

With chain=True, the faulthandler_user() function calls the previous signal 
handler with:
---
#ifdef HAVE_SIGACTION
if (user-chain) {
(void)sigaction(signum, user-previous, NULL);
errno = save_errno;

/* call the previous signal handler */
raise(signum);

save_errno = errno;
(void)faulthandler_register(signum, user-chain, NULL);
errno = save_errno;
}
#else
if (user-chain) {
errno = save_errno;
/* call the previous signal handler */
user-previous(signum);
}
#endif
---

You can try to add #undef HAVE_SIGACTION in faulthandler.c (after #include 
Python.h) to see if the bug can be reproduced without sigaction. The code 
using signal() is very different, especially when chaining signal handlers.

--

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



[issue21130] equivalent functools.partial instances should compare equal

2014-04-02 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Even equivalent functions don't compare as equal:

(lambda x: x*x) == (lambda x: x*x)
   False

--
nosy: +rhettinger

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



[issue21131] test_faulthandler.test_register_chain fails on 64bit ppc/arm with kernel = 3.10

2014-04-02 Thread STINNER Victor

STINNER Victor added the comment:

Would it be possible to list the kernel version (full version including the 
minor version) on which the test works or crash? You are talking about 3.10 
without the minor version. It may be a regression in the kernel.

Example of change in Linux kernel 3.10.17:
---
commit 19a420033da02200c424adfa3a7b9eed6e3a6dc2
Author: Christian Ruppert christian.rupp...@abilis.com
Date:   Wed Oct 2 11:13:38 2013 +0200

ARC: Fix signal frame management for SA_SIGINFO

commit 10469350e345599dfef3fa78a7c19fb230e674c1 upstream.

Previously, when a signal was registered with SA_SIGINFO, parameters 2
and 3 of the signal handler were written to registers r1 and r2 before
the register set was saved. This led to corruption of these two
registers after returning from the signal handler (the wrong values were
restored).
With this patch, registers are now saved before any parameters are
passed, thus maintaining the processor state from before signal entry.

Signed-off-by: Christian Ruppert christian.rupp...@abilis.com
Signed-off-by: Vineet Gupta vgu...@synopsys.com
Signed-off-by: Greg Kroah-Hartman gre...@linuxfoundation.org
---

Extract of changes of Linux 3.10.6:
---
  ARM: move signal handlers into a vdso-like page
  ARM: make vectors page inaccessible from userspace
  ARM: fix a cockup in 48be69a02 (ARM: move signal handlers into a 
vdso-like page)
  ARM: fix nommu builds with 48be69a02 (ARM: move signal handlers into a 
vdso-like page)
---
Commit:
http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=48be69a02

I would like to make sure that the bug is not a kernel bug.

--

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



[issue21131] test_faulthandler.test_register_chain fails on 64bit ppc/arm with kernel = 3.10

2014-04-02 Thread Bohuslav Slavek Kabrda

Bohuslav Slavek Kabrda added the comment:

I'm also surprised that this depends on kernel version, however that's what I 
found out (and the opensuse guys seem to only have reproduced this on kernel = 
3.10, too).

- Full kernel version (uname -r output): 3.13.0-0.rc7.28.sa2.aarch64
- The reproducer *doesn't* crash with chain=False.
- HAVE_SIGACTION:
 import sysconfig; print(sysconfig.get_config_var('HAVE_SIGACTION'))
1
- I'll do rebuild with #undef HAVE_SIGACTION and post my results here as soon 
as it's finished.

--

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



[issue18652] Add itertools.first_true (return first true item in iterable)

2014-04-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3e2354dde892 by Raymond Hettinger in branch '3.4':
Issue #18652:  Add an itertools recipe for first_true()
http://hg.python.org/cpython/rev/3e2354dde892

--
nosy: +python-dev

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



[issue18652] Add itertools.first_true (return first true item in iterable)

2014-04-02 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
resolution:  - fixed
status: open - closed

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



[issue21131] test_faulthandler.test_register_chain fails on 64bit ppc/arm with kernel = 3.10

2014-04-02 Thread Bohuslav Slavek Kabrda

Bohuslav Slavek Kabrda added the comment:

Ok, so with #undef HAVE_SIGACTION both the reproducer and the original test 
(as well as all tests in test_faulthandler) pass fine.

--

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



[issue21130] equivalent functools.partial instances should compare equal

2014-04-02 Thread Thomas Heller

Thomas Heller added the comment:

Sure.  I'm not sure 'equivalent' is the word I should have used.

I suggest (and I would have expected) that partial instances (a, b) should 
compare equal when

  a.func == b.func \
  and a.args == b.args \
  and a.keywords == b.keywords

--

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



[issue19662] smtpd.py should not decode utf-8

2014-04-02 Thread Sreepriya Chalakkal

Sreepriya Chalakkal added the comment:

Hi David,
The variable decode_data is included to control decoding. But I am not sure 
what needs to be done while calling the process_message inside found_terminator 
when it is binary data. How to work around with binary data? Can you tell me 
what are the data types concerning binary data?

--
Added file: http://bugs.python.org/file34700/switch_while_decode1.patch

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



[issue17846] Building Python on Windows - Supplementary info

2014-04-02 Thread Martin v . Löwis

Martin v. Löwis added the comment:

The limitation of build.bat (as you also reported) is that it builds a debug 
build.

--

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



[issue21130] equivalent functools.partial instances should compare equal

2014-04-02 Thread eryksun

eryksun added the comment:

Function equality is based on identity, as inherited from object. But there's a 
precedent for this idea in method_richcompare, which compares the method's 
__func__ and __self__: 

http://hg.python.org/cpython/file/04f714765c13/Objects/classobject.c#l208

--
nosy: +eryksun

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



[issue21132] Failure to import win32api

2014-04-02 Thread David Woakes

New submission from David Woakes:

I've seen issue 21050 and tried a complete uninstall, delete c:\python34 and 
install of python 3.4.

I can't get win32api to load unless I copy pythoncom34.dll and 
psywintypes34.dll to C:\Python34\Lib\site-packages\win32 from 
C:\Python34\Lib\site-packages\pywin32_system32.

Here's output from a python -v session:

 import win32api
Traceback (most recent call last):
  File stdin, line 1, in module
  File frozen importlib._bootstrap, line 2214, in _find_and_load
  File frozen importlib._bootstrap, line 2203, in _find_and_load_unlocked
  File frozen importlib._bootstrap, line 1191, in _load_unlocked
  File frozen importlib._bootstrap, line 1161, in _load_backward_compatible
  File frozen importlib._bootstrap, line 539, in _check_name_wrapper
  File frozen importlib._bootstrap, line 1692, in load_module
  File frozen importlib._bootstrap, line 321, in _call_with_frames_removed
ImportError: DLL load failed: The specified module could not be found.
 import pdb; pdb.pm()
# C:\Python34\lib\__pycache__\pdb.cpython-34.pyc matches C:\Python34\lib\pdb.py
# code object from 'C:\\Python34\\lib\\__pycache__\\pdb.cpython-34.pyc'
# C:\Python34\lib\__pycache__\re.cpython-34.pyc matches C:\Python34\lib\re.py
# code object from 'C:\\Python34\\lib\\__pycache__\\re.cpython-34.pyc'
# C:\Python34\lib\__pycache__\sre_compile.cpython-34.pyc matches 
C:\Python34\lib\sre_compile.py
# code object from 'C:\\Python34\\lib\\__pycache__\\sre_compile.cpython-34.pyc'
# C:\Python34\lib\__pycache__\sre_parse.cpython-34.pyc matches 
C:\Python34\lib\sre_parse.py
# code object from 'C:\\Python34\\lib\\__pycache__\\sre_parse.cpython-34.pyc'
# C:\Python34\lib\__pycache__\sre_constants.cpython-34.pyc matches 
C:\Python34\lib\sre_constants.py
# code object from 
'C:\\Python34\\lib\\__pycache__\\sre_constants.cpython-34.pyc'
import 'sre_constants' # _frozen_importlib.SourceFileLoader object at 
0x02EB21B0
import 'sre_parse' # _frozen_importlib.SourceFileLoader object at 0x02EAE4B0
import 'sre_compile' # _frozen_importlib.SourceFileLoader object at 0x027D4BF0
# C:\Python34\lib\__pycache__\copyreg.cpython-34.pyc matches 
C:\Python34\lib\copyreg.py
# code object from 'C:\\Python34\\lib\\__pycache__\\copyreg.cpython-34.pyc'
import 'copyreg' # _frozen_importlib.SourceFileLoader object at 0x02EB23B0
import 're' # _frozen_importlib.SourceFileLoader object at 0x027D44D0
# C:\Python34\lib\__pycache__\cmd.cpython-34.pyc matches C:\Python34\lib\cmd.py
# code object from 'C:\\Python34\\lib\\__pycache__\\cmd.cpython-34.pyc'
# C:\Python34\lib\__pycache__\string.cpython-34.pyc matches 
C:\Python34\lib\string.py
# code object from 'C:\\Python34\\lib\\__pycache__\\string.cpython-34.pyc'
import 'string' # _frozen_importlib.SourceFileLoader object at 0x02EB2CB0
import 'cmd' # _frozen_importlib.SourceFileLoader object at 0x02EAEDF0
# C:\Python34\lib\__pycache__\bdb.cpython-34.pyc matches C:\Python34\lib\bdb.py
# code object from 'C:\\Python34\\lib\\__pycache__\\bdb.cpython-34.pyc'
# C:\Python34\lib\__pycache__\fnmatch.cpython-34.pyc matches 
C:\Python34\lib\fnmatch.py
# code object from 'C:\\Python34\\lib\\__pycache__\\fnmatch.cpython-34.pyc'
# C:\Python34\lib\__pycache__\posixpath.cpython-34.pyc matches 
C:\Python34\lib\posixpath.py
# code object from 'C:\\Python34\\lib\\__pycache__\\posixpath.cpython-34.pyc'
import 'posixpath' # _frozen_importlib.SourceFileLoader object at 0x02EBBFD0
import 'fnmatch' # _frozen_importlib.SourceFileLoader object at 0x02EBBD30
# C:\Python34\lib\__pycache__\inspect.cpython-34.pyc matches 
C:\Python34\lib\inspect.py
# code object from 'C:\\Python34\\lib\\__pycache__\\inspect.cpython-34.pyc'
# C:\Python34\lib\__pycache__\ast.cpython-34.pyc matches C:\Python34\lib\ast.py
# code object from 'C:\\Python34\\lib\\__pycache__\\ast.cpython-34.pyc'
import 'ast' # _frozen_importlib.SourceFileLoader object at 0x02ED7D30
# C:\Python34\lib\importlib\__pycache__\__init__.cpython-34.pyc matches 
C:\Python34\lib\importlib\__init__.py
# code object from 
'C:\\Python34\\lib\\importlib\\__pycache__\\__init__.cpython-34.pyc'
# C:\Python34\lib\__pycache__\warnings.cpython-34.pyc matches 
C:\Python34\lib\warnings.py
# code object from 'C:\\Python34\\lib\\__pycache__\\warnings.cpython-34.pyc'
import 'warnings' # _frozen_importlib.SourceFileLoader object at 0x02EF94B0
import 'importlib' # _frozen_importlib.SourceFileLoader object at 0x02EF92D0
# C:\Python34\lib\importlib\__pycache__\machinery.cpython-34.pyc matches 
C:\Python34\lib\importlib\machinery.py
# code object from 
'C:\\Python34\\lib\\importlib\\__pycache__\\machinery.cpython-34.pyc'
import 'importlib.machinery' # _frozen_importlib.SourceFileLoader object at 
0x02EF9410
# C:\Python34\lib\__pycache__\linecache.cpython-34.pyc matches 
C:\Python34\lib\linecache.py
# code object from 'C:\\Python34\\lib\\__pycache__\\linecache.cpython-34.pyc'
# C:\Python34\lib\__pycache__\tokenize.cpython-34.pyc matches 
C:\Python34\lib\tokenize.py
# code object from 

[issue21124] _struct module compilation error under Cygwin 1.7.17 on Python 3.4

2014-04-02 Thread Masayuki Yamamoto

Masayuki Yamamoto added the comment:

I wrote a patch file.
In other extention module source codes, global variable PyTypeObject has 
initialized to using PyVarObject_HEAD_INIT(NULL, 0).
And so, as with other modules, I tried to edit and compiling _struct.c in 
Cygwin 1.7.28.
The module compiling was passing, And struct module passed a test python3.4 -m 
test test_struct.

--
keywords: +patch
nosy: +masamoto
Added file: http://bugs.python.org/file34701/3.4-struct.patch

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



[issue21133] unittest discover should allow option to run each package separately

2014-04-02 Thread the mulhern

New submission from the mulhern:

You can run python -m unittest discover some args and the unittests 
discovered by discover will be run. This is nice.

However, it is actually desirable to run each unittest package individually, 
rather than in the same interpreter instance. When run via discover, imports 
from previous unittests corrupt the namespace of subsequent unittests and lead 
to failures (usually if there are mock objects in previously imported unit 
tests) and successes (usually if some other test module has imported something 
that the current test module ought to import but does not) which are both 
erroneous.

discover should have some option to start the interpreter afresh for each 
unittest package or perhaps just clear all its imports.

--
components: Library (Lib)
messages: 215380
nosy: the.mulhern
priority: normal
severity: normal
status: open
title: unittest discover should allow option to run each package separately
type: enhancement
versions: Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4, Python 3.5

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



[issue20375] ElementTree: Document handling processing instructions

2014-04-02 Thread Eli Bendersky

Eli Bendersky added the comment:

I left some comments in Rietveld.

There shouldn't be a problem getting these into 3.4 too - doc changes are 
usually excempt from most restrictions.

--

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



[issue21028] ElementTree objects should support all the same methods as Element objects

2014-04-02 Thread Eli Bendersky

Eli Bendersky added the comment:

 Do you have concrete suggestions? Make the tree iterable?

   Add all element methods to the tree, implicitly forwarding to the root?

 Yes, that is the feature request.  Add all the element methods to the
 elementtree object.

 Implicitly forwarding to the root would be a reasonable way to do it, but
 that is just an implementation detail.

Porting over all methods of Element to ElementTree sounds like an overkill
to me. How about just making a sensibly-behaving __iter__ for ElementTree?
This should be easy because ElementTree already has a iter() method that
behaves as needed (goes over all elements including root). Would iteration
+ perhaps clearer documentation solve most of the problem?

--

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



[issue21128] testing stdlib and compatibility with pypy

2014-04-02 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
nosy: +brett.cannon

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



[issue21028] ElementTree objects should support all the same methods as Element objects

2014-04-02 Thread Stefan Behnel

Stefan Behnel added the comment:

 How about just making a sensibly-behaving __iter__ for ElementTree?

Well, the problem is to determine what sensibly-behaving is. I can see
three options.

1) tree.iter()  ==  tree.getroot().iter()

2) iter(tree.getroot())

3) iter([tree.getroot()])

The second option feels plain wrong to me.

The last one would allow the extension towards PI/comment siblings, as I
described before. There isn't currently a way to get at them (which doesn't
hurt, because ET doesn't currently even pass them through from its parser,
as discussed in issue 9521). Once there is a way in ET to parse them in (as
in lxml), making ElementTree objects iterable would nicely solve the issue
of how to process them afterwards.

It's not the only solution for that problem, though, adding a
.gettoplevel() method would similarly work. Thus, either 1) or 3) would
fit the API, with the downside of 1) being that it's just completely
redundant functionality and I don't consider saving 7 simple characters
worth the increase in API overhead.

That leaves 3) as an option. It's nice because the iteration then works on
the same axis as for Elements, so x.iter() and iter(x) would behave in the
same way for both classes.

--

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



[issue21134] Segfault when stringifying UnicodeEncodeError (or UnicodeDecodeError) created with __new__()

2014-04-02 Thread Marek Kowalski

New submission from Marek Kowalski:

I'm attaching a minimal script to reproduce. I tested only with 3.2 and 2.7 
versions. Its possible that it has been fixed since 3.2.

--
components: Unicode
files: segv.py
messages: 215384
nosy: Marek.Kowalski, ezio.melotti, haypo
priority: normal
severity: normal
status: open
title: Segfault when stringifying UnicodeEncodeError (or UnicodeDecodeError) 
created with __new__()
type: crash
versions: Python 2.7, Python 3.2
Added file: http://bugs.python.org/file34702/segv.py

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



[issue21124] _struct module compilation error under Cygwin 1.7.17 on Python 3.4

2014-04-02 Thread dellair jie

dellair jie added the comment:

Yamamoto,

Thanks, the patch you offered did make the _struct error disappeared. I will do 
a bit more testing.

Dellair

--

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



[issue21134] Segfault when stringifying UnicodeEncodeError (or UnicodeDecodeError) created with __new__()

2014-04-02 Thread STINNER Victor

STINNER Victor added the comment:

Python 3.2 is not getting bugfixes anymore, only 3.4 and 3.5 (and 2.7).

--
versions: +Python 3.4, Python 3.5 -Python 3.2

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



[issue21120] PyArena type is used in headers from the limited API

2014-04-02 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue21118] str.translate is absurdly slow in majority of use cases (takes up to 60x longer than similar functions)

2014-04-02 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 bytes.translate() is much faster because it builds a C array of 256
 items to fast table lookup, whereas str.translate() requires a Python
 dict lookup for each character, which is much slower.

It should be easy to devise a simple hash table for the common case of 
one-to-one translation (and also deletion).

--
nosy: +pitrou

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



[issue17390] display python version on idle title bar

2014-04-02 Thread bagrat lazaryan

bagrat lazaryan added the comment:

guys,
the filename should be the first thing on the titlebar of idle editor window. 
that way, on taskbar, one can see the file that's open in editor. i suggest the 
format of editor's title be changed to:
xxx.py - python x.y.z - path
or whatever you will as separator between elements.

--

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



[issue21134] Segfault when stringifying UnicodeEncodeError (or UnicodeDecodeError) created with __new__()

2014-04-02 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 140c5da3dc82 by Benjamin Peterson in branch '3.4':
bail in unicode error's __str__ methods if the objects are not properly 
initialized (closes #21134)
http://hg.python.org/cpython/rev/140c5da3dc82

New changeset afa7fb2cbe3b by Benjamin Peterson in branch '2.7':
bail in unicode error's __str__ methods if the objects are not properly 
initialized (closes #21134)
http://hg.python.org/cpython/rev/afa7fb2cbe3b

New changeset 0aeaea247d7d by Benjamin Peterson in branch 'default':
merge 3.4 (#21134)
http://hg.python.org/cpython/rev/0aeaea247d7d

--
nosy: +python-dev
resolution:  - fixed
stage:  - committed/rejected
status: open - closed

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



[issue21134] Segfault when stringifying UnicodeEncodeError (or UnicodeDecodeError) created with __new__()

2014-04-02 Thread STINNER Victor

STINNER Victor added the comment:

Benjamin: I don't like your change. You silently ignore the error. I would 
prefer to raise an exception on str(exc) if the Unicode exception object was 
not properly initialized.

--
resolution: fixed - 
status: closed - open

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



[issue21134] Segfault when stringifying UnicodeEncodeError (or UnicodeDecodeError) created with __new__()

2014-04-02 Thread Benjamin Peterson

Benjamin Peterson added the comment:

I don't care as long as it doesn't segfault.

--
nosy: +benjamin.peterson

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



[issue21019] PyMethodDef ml_name is char* instead of const char*

2014-04-02 Thread Tshepang Lekhonkhobe

Changes by Tshepang Lekhonkhobe tshep...@gmail.com:


--
nosy: +tshepang

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



[issue21027] difflib new cli interface

2014-04-02 Thread Tshepang Lekhonkhobe

Changes by Tshepang Lekhonkhobe tshep...@gmail.com:


--
nosy: +tshepang

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



[issue21034] Python docs reference the Distribute package which has been deprecated in favor of Setuptools

2014-04-02 Thread Tshepang Lekhonkhobe

Changes by Tshepang Lekhonkhobe tshep...@gmail.com:


--
nosy: +tshepang

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



[issue17846] Building Python on Windows - Supplementary info

2014-04-02 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Since a debug build (F7 in VS) is the only thing I have ever built, or that a 
developer like me needs to build, that is not a limitation.

--

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



[issue17390] display python version on idle title bar

2014-04-02 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Bagrat, are you on XP by any chance? In Win7, all windows for a program are 
attached to one program icon on the taskbar, which has the program name. When I 
hover over the program icon, mini views of each window are displayed, with each 
window view showing about 30 chars of the window title. For instance Python 
3.4.0: CallTipsWindow, which is fine for me. Moving the mouse over the mini 
window displays the complete title.

--

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



[issue20942] _frozen_importlib should not have a __file__ attribute

2014-04-02 Thread Boštjan Mejak

Boštjan Mejak added the comment:

No one interested in fixing this anymore, despite the patch and all?

--

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



[issue20942] _frozen_importlib should not have a __file__ attribute

2014-04-02 Thread Brett Cannon

Brett Cannon added the comment:

My Python free time is on Fridays, which is when I plan to make a final call 
and either apply to Python 3.4 and 3.5 or just Python 3.5.

--
assignee:  - brett.cannon

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



[issue21135] Remove useless _vb_pattern parameter in cgi.valid_boundary

2014-04-02 Thread Eijebong

New submission from Eijebong:

The parameter _vb_pattern parameter in cgi.valid_boundary has no reason to 
exist since it's forced to a value later.

--
components: Library (Lib)
files: valid_boundary.patch
keywords: patch
messages: 215396
nosy: Eijebong
priority: normal
severity: normal
status: open
title: Remove useless _vb_pattern parameter in cgi.valid_boundary
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file34703/valid_boundary.patch

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



[issue21130] equivalent functools.partial instances should compare equal

2014-04-02 Thread Raymond Hettinger

Raymond Hettinger added the comment:

What is the use case?

What would be the criteria for comparing functions?  Would the func_name have 
to match?  Would the func_defaults have to match?  Would the 
f.__code__.co_names have to match (the internal variable names?  Do the 
function attributes in f.__dict__ have to match?  Does the func.__doc__ have to 
match?

The problem is that functions are complex objects and the equivalence criteria 
means different things to different people.  In the absence of a clear spec 
that makes sense to most people, object identity is the only sure definition of 
equivalence.

--

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



[issue19662] smtpd.py should not decode utf-8

2014-04-02 Thread Sreepriya Chalakkal

Changes by Sreepriya Chalakkal sreepriya1...@gmail.com:


Added file: http://bugs.python.org/file34704/switch_while_decode2.patch

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



[issue19640] Dynamically generate the _source attribute of namedtuple to save memory)

2014-04-02 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Victor, I don't think the added complexity is worth 2k per named tuple class.  
Every time I've gone down the path of lazy evaluation, I've paid an unexpected 
price for it down the road.  If the savings were huge, it might be worth it, 
but that isn't the case here.  This isn't really different than proposing that 
all docstring be in a separate module to be lazily loaded only when people look 
at help.

--
resolution:  - rejected
status: open - closed

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



[issue17390] display python version on idle title bar

2014-04-02 Thread bagrat lazaryan

bagrat lazaryan added the comment:

terry, i'm on 7 but i have my taskbar configured not to combine buttons. see 
the screenshot attached.

(does anyone know why on earth i am not receiving email notifications when 
someone posts to an issue i have started or i have commented to?)

--
Added file: http://bugs.python.org/file34705/taskbar.png

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



[issue17862] itertools.chunks(iterable, size, fill=None)

2014-04-02 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Nothing new is happening in this thread, so I'm closing it for the reasons  
listed in the other posts.  

The main issue is that the generic concept of break data into chunks tends to 
occur is situations where the iterator protocol would be at odds with a clean 
solution.  A reshape() method on lists would be much better suited to the task.

--
resolution:  - rejected
status: open - closed

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



[issue20198] xml.etree.ElementTree.ElementTree.write attribute sorting

2014-04-02 Thread bagrat lazaryan

bagrat lazaryan added the comment:

well... ElementTree.py imports some c accelerators as can be seen at the end of 
the file. i have no idea how to get to those accelerators, and even if i had, i 
don't think i would make anything of them.
as far as the pure python code concerns in the rest of ElementTree.py, it 
suffices not to sort the items in _serialize_xml:

line 929 of ElementTree.py:
-for k, v in sorted(items):  # lexical order
+for k, v in items:

i gather something similar must be done in c accelerators.

(by the way, does anyone know why i am not receiving email notifications when 
someone posts to an issue i have started or i have commented to?)

--

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



[issue20198] xml.etree.ElementTree.ElementTree.write attribute sorting

2014-04-02 Thread bagrat lazaryan

Changes by bagrat lazaryan bagra...@live.com:


--
versions: +Python 3.4

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



[issue21130] equivalent functools.partial instances should compare equal

2014-04-02 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
Removed message: http://bugs.python.org/msg215397

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



[issue21117] inspect.signature: inaccuracies for partial functions

2014-04-02 Thread Yury Selivanov

Yury Selivanov added the comment:

Please review the attached patch.

Here's the new partial signature semantics:

   foo(a, b, /, c, d, *args, e)

   partial(foo, 10) - (b, /, c, d, *args, e)
   partial(foo, 10, c=11) - (b, /, *, c=11, d, e)
   partial(foo, 10, 20, 30) - (d, *args, e)
   partial(foo, 10, 20, 30, 40, 50) - (*args, e)
   partial(foo, 10, 20, c=20) - (*, c=20, d, e)

Good news: 

1. no more special attributes and other hidden hacks.

2. only with this patch we properly support functools.partial. So this is 
definitely something we can classify as a bug fix and push in 3.4.1.

--
keywords: +patch
Added file: http://bugs.python.org/file34706/signature_partial_fix_01.patch

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



[issue21130] equivalent functools.partial instances should compare equal

2014-04-02 Thread R. David Murray

R. David Murray added the comment:

But since the two partial instances are (conceptually, I don't care how they 
are implemented) two separate functions, then reasoning by analogy from two 
identical functions not comparing equal, I would expect two partial instances 
to not compare equal.

--
nosy: +r.david.murray

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



[issue21116] Failure to create multiprocessing shared arrays larger than 50% of memory size under linux

2014-04-02 Thread Charles-François Natali

Charles-François Natali added the comment:

Zero-filling mmap's backing file isn't really optimal: why not use truncate() 
instead? This way, it'll avoid completely I/O on filesystems that support 
sparse files, and should still work on FS that don't.

--
nosy: +neologix

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



[issue21130] equivalent functools.partial instances should compare equal

2014-04-02 Thread R. David Murray

R. David Murray added the comment:

Of course, as soon as I hit send, I had second thoughts :).  I guess a partial 
is a binding, not a function.

--

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



[issue17390] display python version on idle title bar

2014-04-02 Thread Ezio Melotti

Ezio Melotti added the comment:

Other editors (e.g. Kate) use the format filename - editor name.  This is 
common for other applications as well (e.g. Firefox uses page title - Mozilla 
Firefox), so the request seems reasonable to me.

If you want to go the extra mile you could have an option to decide if the 
filename should be first or not or even a format string that would allow users 
to fully configure the titlebar (e.g. {file} - IDLE {version}), but that 
might be out of the scope of this issue.  FWIW I don't think Kate has an option 
for that, but it has one to show the full path in titlebar.

(@bagrat: assuming your email address is correct, if you are not getting 
notifications they might have ended up in the spam folder.)

--

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



[issue21116] Failure to create multiprocessing shared arrays larger than 50% of memory size under linux

2014-04-02 Thread Médéric Boquien

Médéric Boquien added the comment:

If I remember correctly the problem is that some OS like linux (and probably 
others) do not really allocate space until something is written. If that's the 
case then the process may get killed later on when it writes something in the 
array.

Here is a quick example:

$ truncate -s 1T test.file
$ ls -lh test.file 
-rw-r--r-- 1 mederic users 1.0T Apr  2 23:10 test.file
$ df -h
Filesystem  Size  Used Avail Use% Mounted on
/dev/sdb1   110G   46G   59G  44% /home

--

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



[issue21116] Failure to create multiprocessing shared arrays larger than 50% of memory size under linux

2014-04-02 Thread Richard Oudkerk

Richard Oudkerk added the comment:

Using truncate() to zero extend is not really portable: it is only guaranteed 
on XSI-compliant POSIX systems.

Also, the FreeBSD man page for mmap() has the following warning:

WARNING! Extending a file with ftruncate(2), thus creating a big
hole, and then filling the hole by modifying a shared mmap() can
lead to severe file fragmentation.  In order to avoid such
fragmentation you should always pre-allocate the file's backing
store by write()ing zero's into the newly extended area prior to
modifying the area via your mmap().  The fragmentation problem is
especially sensitive to MAP_NOSYNC pages, because pages may be
flushed to disk in a totally random order.

--

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



[issue21136] fractions.Fraction.__pow__ does unneeded renormalization

2014-04-02 Thread William Ehlhardt

New submission from William Ehlhardt:

The following Python runs unnecessarily slowly:

import fractions
fractions.Fraction(6249919, 625) ** 89993


The problem here is that Fraction.__pow__ constructs a new Fraction() to 
return, and Fraction.__new__ tries to gcd to normalize the 
numerator/denominator. The gcd is very, very slow, and more to the point, 
unnecessary; raising a normalized fraction to an integer power will always 
yield another normalized fraction.


fractions.Fraction.__pow__ should use this trick to make the code snippet above 
fast.

--
components: Library (Lib)
messages: 215409
nosy: Orborde
priority: normal
severity: normal
status: open
title: fractions.Fraction.__pow__ does unneeded renormalization
type: performance
versions: Python 2.7, Python 3.2

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



[issue21136] fractions.Fraction.__pow__ does unneeded renormalization

2014-04-02 Thread Ezio Melotti

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


--
nosy: +ezio.melotti, mark.dickinson, rhettinger
stage:  - needs patch
versions: +Python 3.5 -Python 2.7, Python 3.2

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



[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'

2014-04-02 Thread paul j3

paul j3 added the comment:

There are a couple of complications to using 'fileno'.

We probably don't want to close 'sys.stdin' or 'sys.stdout' (not even if they 
are redirected to other files?).  That means using:

open(sys.stdin.fileno(), ..., closefd=False)

'closefd', on the other hand, has to be True for string file specifications.

But in 'test_argparse.py', 'sys.stdout' is redirected to an 'io.StringIO'.  
This has many of the same features as an open file, but 'fileno' is not 
implemented.  So the TypeFile probably needs to make an exception for this 
case.  I don't how this will play with a 'BytesIO' for 'wb' cases.

--

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



[issue1191964] asynchronous Subprocess

2014-04-02 Thread Josiah Carlson

Josiah Carlson added the comment:

Had some time to work on this today.

I was missing something in my earlier versions of the code, and have managed to 
get overlapped IOs to work, so at least I'm not quite so far behind the dozen 
or so core developers who know more about the Windows pieces than I do. 
Richard, thank you for the post, I wasn't looking hard enough for how to get 
overlapped IOs to work, and your message made me look harder.

On Linux, it is trivial to support the blocking communicate() and non-blocking 
additions. There's only one weirdness, and that's the fcntl bit flipping during 
write.

On Windows, it's not all that difficult to switch to using overlapped IOs for 
*all* writes, and maybe even for communicate()-based reads, which would remove 
the need for threads. Ironically enough, non-blocking reads actually *don't* 
require overlapped IO thanks to PeekNamedPipe, which could even be used to cut 
the number of extra threads from 2 to 1 in communicate().

Now that I've got it working, I can do one of the following (from least changes 
to the most):
1. Add a nonblocking flag, which pre-flips the fcntl bit in Linux and uses 
overlapped IO on writes in Windows - this would be documented to remove the 
ability to call communicate()
2. As an alternative to #1, I can create a new class that lacks the 
communicate() method and adds the non-blocking methods
3. Gut/rewrite the Windows-based communicate() function to use overlapped IO on 
everything, removing the threads, and making it at least superficially like 
Linux (prepare your overlapped IO, then use WaitForMultipleObjects() to 
multiplex), while also adding the non-blocking methods

Unless someone brings up an important counterpoint, I'll work on #3 tonight or 
tomorrow evening to get an initial code/test patch, with docs coming shortly 
after (if not immediately).

--

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



[issue21136] fractions.Fraction.__pow__ does unneeded renormalization

2014-04-02 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This looks easily doable.

--
assignee:  - rhettinger
keywords: +easy

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



[issue21137] Better repr for threading.Lock()

2014-04-02 Thread Raymond Hettinger

New submission from Raymond Hettinger:

It is really nice to have the open/closed status in the __repr__ of file 
objects: 

  open file 'data.txt', mode 'r' at 0x102c8ec90
  closed file 'data.txt', mode 'r' at 0x102c8ec90

I would like to have the same for locks:

  unlocked thread.lock object at 0x1002b1330
  locked thread.lock object at 0x1002b1330

This would be nice in logs and tracebacks for example.

--
components: Library (Lib)
keywords: easy
messages: 215413
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Better repr for threading.Lock()
type: enhancement
versions: Python 3.5

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



[issue21136] fractions.Fraction.__pow__ does unneeded renormalization

2014-04-02 Thread Raymond Hettinger

Changes by Raymond Hettinger raymond.hettin...@gmail.com:


--
keywords: +patch
Added file: http://bugs.python.org/file34707/fraction_pow.diff

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



[issue21138] mimetypes.MimeType UnicodeDecodeError

2014-04-02 Thread tanbro

New submission from tanbro:

when new a mimetypes.MimeType instance in a my Windows, whose default coding is 
mbcs, UnicdeDecodeError occurred.

Python 2.7.6 (default, Nov 10 2013, 19:24:18) [MSC v.1500 32 bit (Intel)] on win
32
Type help, copyright, credits or license for more information.
 from mimetypes import MimeTypes
 mt = MimeTypes()
Traceback (most recent call last):
  File stdin, line 1, in module
  File D:\Python27\lib\mimetypes.py, line 66, in __init__
init()
  File D:\Python27\lib\mimetypes.py, line 358, in init
db.read_windows_registry()
  File D:\Python27\lib\mimetypes.py, line 258, in read_windows_registry
for subkeyname in enum_types(hkcr):
  File D:\Python27\lib\mimetypes.py, line 249, in enum_types
ctype = ctype.encode(default_encoding) # omit in 3.x!
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc7 in position 8: ordinal
not in range(128)

i think this error was caused by the code in mimetypes.py's line 256

default_encoding = sys.getdefaultencoding() 

if change this line to:

default_encoding = sys.getfilesystemencoding()

such error will be resolved

--
components: Library (Lib)
messages: 215414
nosy: tanbro
priority: normal
severity: normal
status: open
title: mimetypes.MimeType UnicodeDecodeError
type: behavior
versions: Python 2.7

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



[issue20375] ElementTree: Document handling processing instructions

2014-04-02 Thread Nikolaus Rath

Nikolaus Rath added the comment:

Thanks for your feedback! I've attached an updated patch.

--
Added file: http://bugs.python.org/file34708/issue20375.diff

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



  1   2   >