Re: python logging filter limitation, looks intentional?

2012-01-17 Thread Chris Withers

On 16/01/2012 23:21, Vinay Sajip wrote:



Why is this? There must be some rationale for this rather than what, for me and



others I've talked to, would seem more natural, ie: a filter on the root
logger would get messages both logged to it and any messages propagated to it
from child loggers to process.


Perhaps you're right, but this can't be changed without breaking existing code, 
AFAICT.


How breaking code? Configuration, maybe, but I can't see anyone being 
upset that filtering would begin working the same as everything else.

This just feels like a bug...


  However, if you find your usage pattern occurring very commonly in your

applications, it's easy enough to create a DelegatingHandler handler class
which passes its events on to any number of handlers you like.



But this is just extra work when the normal built-in
delegation-upwards-ending-in-root works exactly as I want.


It's not in general useful to filter on message content, when one factors in 
use of third-party libraries.


Actually, the filter I want to work on (log_nerf) is precisely for 3rd 
party libraries; if a library author thinks a message should be error 
but you think it should be debug, and vice versa, having a filter that 
alters the level is the only way to sort things out without hacking the 
3rd party library. I've also seen this technique used successfully where 
the filter looks to a database for config and nerfs messages during a 
certain time period.



Of course, if you are in control in the whole software stack you're using, or 
in certain very specific scenarios, it may be more useful - but in general it's 
most useful to filter on level and using logger names. The __name__ for loggers 
is useful to locate the source of events to a module, but you can have child 
loggers under that to log specific types of events in that module, and use the 
verbosity of those sub-module loggers to control output.


Again, this doesn't help if the __name__-ish loggers are in third party 
packages that you don't want to have to fork ;-)



It's also the opposite of what I'd need, I'd need to plug one
handler into all the specific loggers that get used (and bear in mind that many
libraries log to __name__ from modules and sub-modules) this is a pretty onerous
task :-(


I thought from an earlier comment - rather than just the root logger where my 
handlers live - that you had your handlers attached to the root logger, in which 
case it wouldn't be onerous at all. In place of those individual handlers attached to the 
root, you simply attach your DelegatingHandler to the root logger, and attach the filter 
and the other handlers to that DelegatingHandler instance.


Both use cases are valid, and a DelegatingHandler just feels like a hack 
to work around a deficiency in the framework...


cheers,

Chris

--
Simplistix - Content Management, Batch Processing  Python Consulting
- http://www.simplistix.co.uk
--
http://mail.python.org/mailman/listinfo/python-list


Re: python logging filter limitation, looks intentional?

2012-01-17 Thread Vinay Sajip
 From: Chris Withers ch...@simplistix.co.uk

 How breaking code? Configuration, maybe, but I can't see anyone being upset 
 that filtering would begin working the same as everything else.
 This just feels like a bug...

Well, it means that filters that don't get called now would get called - and 
that's a change in behaviour.

It's not a bug, because it's like that by design. I understand that you don't 
agree with that particular design decision, but it's out there now. What you're 
asking for isn't unreasonable, but not achievable without a change in 
behaviour. I don't want people to have to code differently for Python 3.3 and 
for older versions.
 
 Actually, the filter I want to work on (log_nerf) is precisely for 3rd party 
 libraries; if a library author thinks a message should be error but you think 
 it 
 should be debug, and vice versa, having a filter that alters the level is the 
 only way to sort things out without hacking the 3rd party library. I've also 
 seen this technique used successfully where the filter looks to a database 
 for 
 config and nerfs messages during a certain time period.

Okay,  then applying a filter on handlers is a way of achieving this.

 Again, this doesn't help if the __name__-ish loggers are in third party 
 packages that you don't want to have to fork ;-)

True, but as I said earlier, you can attach a filter to your handlers. It's 
rather unlikely that you would have more than half-a-dozen handlers (since 
handlers ~= potential audiences for log events), but even so, I can't believe 
it's especially onerous to set up filter configuration for those handlers - and 
even easier if you add a DelegatingHandler to the mix. In 
https://gist.github.com/1623702 I've shown a DelegatingHandler; it's quite 
short.
 
 Both use cases are valid, and a DelegatingHandler just feels like a hack to 
 work 
 around a deficiency in the framework...

Rather, the approach I've taken is not to assume I'll meet everyone's needs out 
of the box, but that the right pieces are in place for people to use logging in 
useful ways in scenarios that I haven't thought of - which shortcomings might 
well be termed deficiencies according to your point of view - by deriving and 
overriding classes, or by composing using filters, or setting module-level 
flags. There are numerous examples on e.g. Stack Overflow where a small amount 
of customisation (e.g. a custom handler like DelegatingHandler) has been 
suggested to meet a specific user requirement. I don't think of these as hacks 
- I occasionally have to subclass stdlib classes in other areas to get the 
behaviour I want, and that's part and parcel of having OO at your disposal.

Regards,

Vinay Sajip

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


Re: THAT WHAT NEED EXPECT FROM OPERATORS OF PYTHON. (e-mail get by the list moderator)

2012-01-17 Thread Sean Wolfe
On Mon, Jan 16, 2012 at 4:01 AM, Steven D'Aprano
steve+comp.lang.pyt...@pearwood.info wrote:
 On Mon, 16 Jan 2012 09:03:54 +0300, _ wrote:

 # THAT WHAT NEED EXPECT FROM OPERATORS OF PYTHON: Worddr = 56 # CREATE
 A STRING: 56 Word = [12] # CREATE A LIST WITH ONE SIGNED: 12 Word
 = Word.append(34)
 ...


 Do you have a question, or are you just dumping a lot of noise in one
 post?



I think it's a secret code. I just watched Sherlock Holmes last night
so I know all about that s**t.
-- 
http://mail.python.org/mailman/listinfo/python-list


First python project : Tuner

2012-01-17 Thread Jérôme
Hi all.

Like others before me, I'd like to show you my first python attempt, in the
hope in can get advices on how to improve my coding.

I started learning python and pyGTK last november. I had had a short
experience of GTK with C, but had given up as I lacked time and I found it
more difficult than I expected. python makes things more easy. Yet, after
starting with pyGTK, I switched to PyGObject, and lack of documentation made
small things a bit hard sometimes...

The project I chose as an exercise is some sort of guitar tuner. It can be
found here :
http://devs.jolimont.fr/tuner/

The choice of the sound backends was already discussed on this list. Next
step would be to switch to a python audio library and use threads instead of
processes.

I added flags to avoid race conditions, perhaps with a little bit of
clumsyness. This makes the code more complicated than it deserved to be.

Any comment is welcome, be it about code optimization, coding style,
pythonification, good practices, or simply program features and usability.

Thanks.

-- 
Jérôme
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First python project : Tuner

2012-01-17 Thread Rick Johnson
On Jan 17, 8:16 am, Jérôme jer...@jolimont.fr wrote:

 Any comment is welcome, be it about code optimization, coding style,
 pythonification, good practices, or simply program features and usability.

Step one would be to show a screen shot in both English AND French
language. Besides, not everyone in this community is a card carrying
pacifist.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First python project : Tuner

2012-01-17 Thread Jérôme
Tue, 17 Jan 2012 08:48:13 -0800 (PST)
Rick Johnson a écrit:

 On Jan 17, 8:16 am, Jérôme jer...@jolimont.fr wrote:
 
  Any comment is welcome, be it about code optimization, coding style,
  pythonification, good practices, or simply program features and usability.
 
 Step one would be to show a screen shot in both English AND French
 language. 

The screenshot was a dissatisfying mix of english and french because until
I18n is done (next in TODO list) all the strings are in english, but the stock
buttons are localized as my system is in french. Yet the inconsistency.

I didn't know it was as easy as 

LANGUAGE=EN ./tuner_v2_0.py

to re-localize a program. Now the screenshot is english only.

Anyway, I was trying to bring people's attention to the python program
itself :
http://devs.jolimont.fr/tuner/downloads/tuner_v2_0.py

 Besides, not everyone in this community is a card carrying
 pacifist.

?

-- 
Jérôme
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First python project : Tuner

2012-01-17 Thread Rodrick Brown
You would get more responses if you used one of those sites that displayed
the code right in the browser.

On Tue, Jan 17, 2012 at 12:26 PM, Jérôme jer...@jolimont.fr wrote:

 Tue, 17 Jan 2012 08:48:13 -0800 (PST)
 Rick Johnson a écrit:

  On Jan 17, 8:16 am, Jérôme jer...@jolimont.fr wrote:
 
   Any comment is welcome, be it about code optimization, coding style,
   pythonification, good practices, or simply program features and
 usability.
 
  Step one would be to show a screen shot in both English AND French
  language.

 The screenshot was a dissatisfying mix of english and french because until
 I18n is done (next in TODO list) all the strings are in english, but the
 stock
 buttons are localized as my system is in french. Yet the inconsistency.

 I didn't know it was as easy as

LANGUAGE=EN ./tuner_v2_0.py

 to re-localize a program. Now the screenshot is english only.

 Anyway, I was trying to bring people's attention to the python program
 itself :
 http://devs.jolimont.fr/tuner/downloads/tuner_v2_0.py

  Besides, not everyone in this community is a card carrying
  pacifist.

 ?

 --
 Jérôme
 --
 http://mail.python.org/mailman/listinfo/python-list

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


Re: First python project : Tuner

2012-01-17 Thread Jérôme
Tue, 17 Jan 2012 12:28:11 -0500
Rodrick Brown a écrit:

 You would get more responses if you used one of those sites that displayed
 the code right in the browser.

Thanks for the tip.

I thought people would rather open it in their own editor. (And I tend to
avoid third-party hosting.)

Here's an html rendering :

http://devs.jolimont.fr/tuner/downloads/tuner_v2_0.py.html

This is done with gvim. Too bad it lacks line numbering.

-- 
Jérôme
-- 
http://mail.python.org/mailman/listinfo/python-list


Finding x is 1, and x is 'foo' comparisons in a code base

2012-01-17 Thread Alex Willmer
Hello,

I'm looking for a way to find the occurrences of x is y comparisons in
an existing code base. Except for a few special cases (e.g. x is [not]
None) they're a usually mistakes, the correct test being x == y.
However they happen to work most of the time on CPython (e.g. when y
is a small integer or string) so they slip into production code
unnoticed.

PyLint and PyFlakes don't check this AFAICT. Any suggestions for such
a tool, or a pointer how to add the check to an existing tool would be
most welcome.

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


Re: First python project : Tuner

2012-01-17 Thread gst
On 17 jan, 15:16, Jérôme jer...@jolimont.fr wrote:
 Hi all.


hi,

just my 2 cents:

you have quite lot of such test:

 if self._index is 0:

I think it's better to compare with equality against 0 (or other
needed value) ; that is:

if self._index == 0:

otherwise your code looks very nice to me, though I just had a very
quick look ;)

regards,

GS.

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


Re: Finding x is 1, and x is 'foo' comparisons in a code base

2012-01-17 Thread MRAB

On 17/01/2012 17:10, Alex Willmer wrote:

Hello,

I'm looking for a way to find the occurrences of x is y comparisons in
an existing code base. Except for a few special cases (e.g. x is [not]
None) they're a usually mistakes, the correct test being x == y.
However they happen to work most of the time on CPython (e.g. when y
is a small integer or string) so they slip into production code
unnoticed.

PyLint and PyFlakes don't check this AFAICT. Any suggestions for such
a tool, or a pointer how to add the check to an existing tool would be
most welcome.


I would search using a regex such as:

\bis\b(?! +None| +not +None)

in either a text editor or using a Python script.
--
http://mail.python.org/mailman/listinfo/python-list


Re: Finding x is 1, and x is 'foo' comparisons in a code base

2012-01-17 Thread Thomas Heller

Am 17.01.2012 18:10, schrieb Alex Willmer:

Hello,

I'm looking for a way to find the occurrences of x is y comparisons in
an existing code base. Except for a few special cases (e.g. x is [not]
None) they're a usually mistakes, the correct test being x == y.
However they happen to work most of the time on CPython (e.g. when y
is a small integer or string) so they slip into production code
unnoticed.

PyLint and PyFlakes don't check this AFAICT. Any suggestions for such
a tool, or a pointer how to add the check to an existing tool would be
most welcome.


Pychecker contains a check for this mistake.
--
http://mail.python.org/mailman/listinfo/python-list


Re: First python project : Tuner

2012-01-17 Thread Jérôme
Tue, 17 Jan 2012 10:16:02 -0800 (PST)
gst a écrit:

 you have quite lot of such test:
 
  if self._index is 0:
 
 I think it's better to compare with equality against 0 (or other
 needed value) ; that is:
 
 if self._index == 0:

Yes, I just saw that thanks to Alex Willmer's e-mail.

I used to have ==, until for some strange reason I figured is was more
pythonic, so I replaced all == I could with is. I shouldn't have.

I appended this issue on top of my TODO list.

Although I try to read as much documentation as I can to do things clean,
there is still a lot of trial and error and sometimes my criterion ends up
being does it works or does it not, whithout comprehensive understanding.
 
 otherwise your code looks very nice to me, though I just had a very
 quick look ;)

Thank you for the feedback.

-- 
Jérôme
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First python project : Tuner

2012-01-17 Thread Ben Finney
Jérôme jer...@jolimont.fr writes:

 Anyway, I was trying to bring people's attention to the python program
 itself

Welcome!

You have some replies now, that's good.

 Rick Johnson a écrit:
  Besides, not everyone in this community is a card carrying
  pacifist.

 ?

You have attracted the attention of a troll.

Please search for that person's past messages in the recent archives of
this forum, and then decide whether it's worth continuing a dialogue
with him.

-- 
 \“Choose mnemonic identifiers. If you can't remember what |
  `\mnemonic means, you've got a problem.” —Larry Wall |
_o__)  |
Ben Finney
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: First python project : Tuner

2012-01-17 Thread Jean-Michel Pichavant

Jérôme wrote:

Hi all.

Like others before me, I'd like to show you my first python attempt, in the
hope in can get advices on how to improve my coding.

I started learning python and pyGTK last november. I had had a short
experience of GTK with C, but had given up as I lacked time and I found it
more difficult than I expected. python makes things more easy. Yet, after
starting with pyGTK, I switched to PyGObject, and lack of documentation made
small things a bit hard sometimes...

The project I chose as an exercise is some sort of guitar tuner. It can be
found here :
http://devs.jolimont.fr/tuner/

The choice of the sound backends was already discussed on this list. Next
step would be to switch to a python audio library and use threads instead of
processes.

I added flags to avoid race conditions, perhaps with a little bit of
clumsyness. This makes the code more complicated than it deserved to be.

Any comment is welcome, be it about code optimization, coding style,
pythonification, good practices, or simply program features and usability.

Thanks.

  

My system failed to import gi.repository
But don't bother I won't install anything anyway.
If it is not listed in your dependencies, maybe you should add it.

You could also display the frequency of A2 (possibly 440Hz), would give 
a pro touch to the thing :D


As for python, why don't use use 'pylint' on it. It is one good way to 
know about your code. It's not about correcting any error reported, but 
by simply looking at the messages/warnings, and asking yourself why 
that rule ? you can improve your coding style and design, maybe for the 
next application.


JM


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


Re: First python project : Tuner

2012-01-17 Thread Rick Johnson
On Jan 17, 1:38 pm, Ben Finney ben+pyt...@benfinney.id.au wrote:
 Jérôme jer...@jolimont.fr writes:
  Rick Johnson a écrit:
   Besides, not everyone in this community is a card carrying
   pacifist.
  ?
 You have attracted the attention of a troll.

What is worse: A wolf, or a wolf in sheep's clothing?

There is no trolling in my reply. A nice quip, yes. Trolling, no.
The fact remains that English is very important to Python. In fact,
English is SO important that the great Guido van Rossum himself
mentioned English explicitly in PEP8. And as we know, English is NOT
his first language!

GvR said: Python coders from non-English speaking countries: please
write your comments in English, unless you are 120% sure that the code
will never be read by people who don't speak your language.

GvR said: All identifiers in the Python standard library MUST use
ASCII-only identifiers, and SHOULD use English words wherever feasible
(in many cases, abbreviations and technical terms are used which
aren't English).

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


Re: First python project : Tuner

2012-01-17 Thread Chris Angelico
On Wed, Jan 18, 2012 at 7:38 AM, Rick Johnson
rantingrickjohn...@gmail.com wrote:
 On Jan 17, 1:38 pm, Ben Finney ben+pyt...@benfinney.id.au wrote:
 You have attracted the attention of a troll.

 What is worse: A wolf, or a wolf in sheep's clothing?

 There is no trolling in my reply. A nice quip, yes. Trolling, no.

Well, as we learn from Innistrad, worse is a wolf in shepherd's
clothing. (Look up 'Gatstaf Shepherd'.)

Ben didn't say there was trolling in your reply. He said that the OP
had attracted the attention of a troll. That said, though, I would
have to say that your post was trollish.

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


Using python to dynamically divine the contents of a CORBA (omniORB) interface

2012-01-17 Thread Jeff Frontz
I'm trying to write a self-maintaining test tool that can be used from
the command line against a server via CORBA (omniORB). To start, I'd
be happy with a tool that could describe the interface(s) that the
server implements (e.g., essentially regenerating the IDL that defined
the interfaces to begin with). From there, I'd grow it into something
that could accept parameters, make the CORBA call, and print the
results.

I know that python has introspection that should make it possible to
not have to write (much) code every time an argument changes or a new
method is added [in the IDL]. But I don't understand enough of the
python binding for omniORB (or enough python) to know how to do this
easily (or whether an infrastructure already exists to do this).

I've inherited some code that I'm trying to morph into my test tool.
The problem is that I don't know how much is something that is stock
omniORB python support and how much is homebrew.

From what I'm seeing, it looks like an omniORB CORBA interface appears
in python as a class (that part seems likely standard). The methods of
said interface appear as members of this class--they are each tuples
with naming that appears to be the method name from the IDL prefixed
with _d_. The input parameters for a given interface method are
described by said method's first tuple element; the second element
describes the return values. Each element is another tuple of tuples,
with each describing a successive parameter.

I'm hoping this reflects the implementation of omniORBpy. Assuming
that it does, are there well-defined routines for interrogating/
manipulating these interface class objects?

Thanks,
Jeff

[note: this was originally posted at stackoverflow
http://stackoverflow.com/questions/8840900/using-python-to-dynamically-divine-the-contents-of-a-corba-omniorb-interface
]
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: THAT WHAT NEED EXPECT FROM OPERATORS OF PYTHON. (e-mail get by the list moderator)

2012-01-17 Thread Rick Johnson
On Jan 16, 12:03 am, _ pan...@yandex.ru wrote:
 # THAT WHAT NEED EXPECT FROM OPERATORS OF PYTHON:
 Worddr = 56 # CREATE A STRING: 56
 Word = [12] # CREATE A LIST WITH ONE SIGNED: 12
 Word = Word.append(34) # APPEND TO LIST ONE MORE SIGNED: 34
 Word = Word + 34 # MUST APPEND TO LIST ONE MORE SIGNED: 34
 Wordpr = Word[1] # MUST SIGNED TO THE Wordpr THE SECOND SIGNED OF THE Word
 LIST: 34, AND IT'S ALL PARAMETRS
 Wordpr = Wordpr + Worddr[1] # MUST ADD TO THE STRING Wordpr: 34, A SECOND
 SIGNED OF STRING Worddr: 6
 Word[1] = Word[1] + Worddr[1] # MUST ADD TO THE SECOND STRING LIST Word:
 346, A SECOND SIGNED OF STRING Worddr: 6

Someone needs to _underscore_ the importance of articulate-Usenet-
post-composition to the OP.

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


thread example question

2012-01-17 Thread Rodrick Brown
Can any idea help me figure out why the following output is sequential? I'm
running this example on a 4 core system.
I would expect the output to look random.

import _thread as thread
import time

class thread_counter(object):
def __init__(self, thr_cnt, sleep_int):
self.thr_cnt = thr_cnt
self.sleep_int = sleep_int

def counter(myId, count):
for i in range(count):
time.sleep(1)
print('[{}] = {}'.format(myId, i))

def main():
for i in range(5):
thread.start_new_thread(counter, (i, 5))
time.sleep(6)
print('Main thread exiting..')

if __name__ == '__main__':
main()


[0] = 0
[0] = 1
[0] = 2
[0] = 3
[0] = 4
Main thread exiting..
[1] = 0
[1] = 1
[1] = 2
[1] = 3
[1] = 4
Main thread exiting..
[2] = 0
[2] = 1
[2] = 2
[2] = 3
[2] = 4
Main thread exiting..
[3] = 0
[3] = 1
[3] = 2
[3] = 3
[3] = 4
Main thread exiting..
[4] = 0
[4] = 1
[4] = 2
[4] = 3
[4] = 4
Main thread exiting..
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: thread example question

2012-01-17 Thread Mark Hammond

On 18/01/2012 4:22 PM, Rodrick Brown wrote:

import _thread as thread
import time

class thread_counter(object):
 def __init__(self, thr_cnt, sleep_int):
 self.thr_cnt = thr_cnt
 self.sleep_int = sleep_int

def counter(myId, count):
 for i in range(count):
 time.sleep(1)
 print('[{}] = {}'.format(myId, i))

def main():
 for i in range(5):
 thread.start_new_thread(counter, (i, 5))


I think you meant for the following 2 lines to be outside the loop (ie, 
to be dedented one level).  Once you do that the output is as *I* expect :)


Mark


 time.sleep(6)
 print('Main thread exiting..')

if __name__ == '__main__':
 main()



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


sys.argv as a list of bytes

2012-01-17 Thread Olive
In Unix the operating system pass argument as a list of C strings. But
C strings does corresponds to the bytes notions of Python3. Is it
possible to have sys.argv as a list of bytes ? What happens if I pass
to a program an argumpent containing funny character, for example
(with a bash shell)?

python -i ./test.py $'\x01'$'\x05'$'\xFF'


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


[issue13500] Hitting EOF gets cmd.py into a infinite EOF on return loop

2012-01-17 Thread Garrett Cooper

Garrett Cooper yaneg...@gmail.com added the comment:

Here's a unittest patch for the py3k branch.

{{{
1 items passed all tests:
  32 tests in test.test_cmd.samplecmdclass
32 tests in 19 items.
32 passed and 0 failed.
Test passed.
doctest (test.test_cmd) ... 32 tests with zero failures
test_file_with_missing_final_nl (__main__.TestAlternateInput) ... ok
test_input_reset_at_EOF (__main__.TestAlternateInput) ... ok

--
Ran 2 tests in 0.000s

OK
}}}

--
Added file: http://bugs.python.org/file24257/python-issue13500-test.patch

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



[issue12600] Support parameterized TestCases in unittest

2012-01-17 Thread Mark Diekhans

Mark Diekhans ma...@kermodei.com added the comment:

Allowing loadTestsFromTestCase() to take either a testCaseClass
or a (testCaseClass, param) tuple, where the param is then past
to the __init__ function might do the trick.  One param is sufficient, since it 
can
be a container for any number of params. This allows more fields
to be added to the tuple for some future, unforeseen need.

An container object for class and parameters would be a bit more
structured than a tuple.

A factory function would be the most flexible, however it seems
to go against the class introspection for discovering tests.
Then again, I don't know the code very well.

R. David Murray rep...@bugs.python.org writes:
 
 R. David Murray rdmur...@bitdance.com added the comment:
 
 Maybe we could add a recipe for doing this to the load_tests docs?
 
 I don't think that load_tests is going to be more readable, though, since it 
 doesn't allow you to put the parameterization next to the class you are 
 parameterizing (unless you do some additional hackery).
 
 But yes, if anything else is done a concrete API proposal is the first 
 requirement.
 
 --
 
 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue12600
 ___

--

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



[issue8285] IDLE not smart indenting correctly in nested statements

2012-01-17 Thread Cherniavsky Beni

Cherniavsky Beni b...@google.com added the comment:

Mark: customizing tabs to be anything but 8 spaces is inadvisable with Python, 
because Python always parses them as 8.
Sooner or later one would mix tabs and spaces and the result would be really 
painful to debug.

--
nosy: +cben

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



[issue13792] The os.execl call doesn't give programs exit code

2012-01-17 Thread Kay Hayen

Kay Hayen kayha...@gmx.de added the comment:

Does the Python standard library not offer anything that does replace with 
current process code with another? I checked with subprocess, and admittedly 
it's not that. Does Win32 API offer nothing for that?

--

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



[issue8285] IDLE not smart indenting correctly in nested statements

2012-01-17 Thread Tal Einat

Changes by Tal Einat talei...@gmail.com:


--
nosy:  -taleinat

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



[issue13804] Python library structure creates hard to read code when using higher order functions

2012-01-17 Thread Martin Häcker

New submission from Martin Häcker spamfaen...@gmx.de:

Code that uses higher order methods is often the clearest description of what 
you want to do. However since the higher order methods in python (filter, map, 
reduce) are free functions and aren't available on collection classes as 
methods, using them creates really hard to read code.

For example, if I want to get an attribute out of an array of objects and 
concatenate the results it's two steps, get the attributes out of the object, 
then concatenate the results.

Without higher order methods its like this. Uses three lines, intermediate 
variable is quite clear, but hard to compose and hard to abstract out parts of 
it.

 self.questions = []
 for topic in self.topics:
   self.questions.append(topic.questions)

if I want to do it with higher order functions there's really two ways, do it 
in one step with reduce:
 self.questions = reduce(lambda memo, topic: memo + topic.questions, 
self.topics, [])

Or use two steps with the operator module
 self.questions = reduce(operator.add, map(operator.attrgetter('questions'), 
self.topics), [])

Of these thee first still couples two steps into one lambda, while the second 
one decoples everything nicely but is a total train wreck to read, as you need 
to constantly jump back and forth in the line to understand what it does.

Having map and reduce defined on collections would not only make it drastically 
shorter but also allows you to read it from front to back in one go. (Ok, there 
is still the caveat that the assignment is in the front instead of at the end, 
but hey)

 self.questions = self.topics.map(attrgetter('questions')).reduce(add, [])

That would be nicely separated into individual steps that exactly describe what 
each step is actually doing, is easy to abstract over and actually very 
succinct.

--
messages: 151435
nosy: dwt
priority: normal
severity: normal
status: open
title: Python library structure creates hard to read code when using higher 
order functions
type: enhancement

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



[issue12415] Missing: How to checkout the Doc sources

2012-01-17 Thread Ezio Melotti

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

+The documentation sources are part of the main :ref:`CPython Mercurial
+repository setup`.

I think documentation sources is a bit vague.  If the goal is enable people 
to find those files, IMHO it would be better to state explicitly that there are 
bunch of rst files in the Doc/ directory that comes with cpython and that they 
are used to build the online documentation.

--

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



[issue13799] Base 16 should be hexadecimal in Unicode HOWTO

2012-01-17 Thread Ezio Melotti

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

Do you mean the base 16 in this sentence: A code point is an integer value, 
usually denoted in base 16.?
Why would hexadecimal be better than base 16?

--
assignee: docs@python - ezio.melotti
nosy: +ezio.melotti
versions:  -Python 2.6, Python 3.1

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



[issue13792] The os.execl call doesn't give programs exit code

2012-01-17 Thread Amaury Forgeot d'Arc

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

No. On Windows the only way to start a new executable is to create a new 
process (with the CreateProcess function, which all spawn* and exec* functions 
ultimately call), and this yields a new PID.
This is a fundamental difference with unix, where the only way to create a 
process is to clone the current one with fork().

And yes, this makes launchers more difficult to write on Windows.  For a 
discussion see the paragraph Process Launching in 
http://www.python.org/dev/peps/pep-0397/

--
nosy: +amaury.forgeotdarc
resolution:  - invalid
status: open - pending

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



[issue13805] [].sort() should return self

2012-01-17 Thread Martin Häcker

New submission from Martin Häcker spamfaen...@gmx.de:

[].sort() returns None which means you can't chain it.

So for example someDict.keys().sort()[0] doesn't work but you have to use 
sorted(someDict.keys())[0] instead which is harder to read as you have to read 
the line not from the beginning to the end but jump back and forth in it to 
understand it (which gets progressively harder as the individual parts of it 
get longer / more complex).

--
messages: 151439
nosy: dwt
priority: normal
severity: normal
status: open
title: [].sort() should return self
type: enhancement
versions: Python 2.7

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



[issue13805] [].sort() should return self

2012-01-17 Thread Martin Häcker

Martin Häcker spamfaen...@gmx.de added the comment:

It really should return self.

--

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



[issue13805] [].sort() should return self

2012-01-17 Thread Ezio Melotti

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

This is by design.
Methods that mutate the object return None.
Methods that create a new object return the new object.
list.sort sorts the list in place, so it returns None.

--
nosy: +ezio.melotti
resolution:  - rejected
stage:  - committed/rejected
status: open - closed

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



[issue13805] [].sort() should return self

2012-01-17 Thread Ezio Melotti

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

See also 
http://docs.python.org/faq/design.html#why-doesn-t-list-sort-return-the-sorted-list

--

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



[issue12600] Support parameterized TestCases in unittest

2012-01-17 Thread Nick Coghlan

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

Back on topic...

While I can see the advantage of parameterisation at the level of individual 
tests, I'm not at all clear on the benefits at the TestCase level.

For CPython's own test suite, if we want to share tests amongst multiple test 
cases, we just use ordinary inheritance. You get parameterisation pretty much 
for free with that approach:

class _BaseTest(object):
# Tests go here
# setUp and tearDown often go here, too

class FooTestCase(_BaseTest, TestCase):
# Parameter settings go here

class BarTestCase(_BaseTest, TestCase):
# Parameter settings go here

If you want to get data-driven about it, you can also do dynamic TestCase 
creation based on a sequence of parameter sets.

So, absent a compelling explanation for why the ordinary inheritance mechanisms 
aren't adequate, I'd be in favour of closing this one.

--

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



[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

2012-01-17 Thread Kristján Valur Jónsson

Kristján Valur Jónsson krist...@ccpgames.com added the comment:

Thanks Nick.  Looking through this discussion it looks as though you 
encountered all the confusing bits that I ran into (dup_buffer, ownership 
issues, reference counting and so forth.) Good work.

--

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



[issue13781] gzip module does the wrong thing with an os.fdopen()'ed fileobj

2012-01-17 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

Attached is a fix for 3.x.

--
keywords: +patch
Added file: http://bugs.python.org/file24258/gzip-fdopen.diff

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



[issue10181] Problems with Py_buffer management in memoryobject.c (and elsewhere?)

2012-01-17 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Thanks for the comments. Most of them should be easy to fix.

Nick Coghlan rep...@bugs.python.org wrote:
 [...] expose the Py_buffer len field as memoryview.size instead of
 memoryview.len (to reduce confusion with len(memoryview) and
 to encourage a conceptual link with sys.getsizeof()).

I agree with this. The best thing is probably to have both versions
work in 3.3 and remove memoryview.len in 3.4 (or later).

 As noted in the review, I also think fixing #12384 should be fairly
 straightforward and it would be nice to have that working when the
 change is applied.

tobytes() currently calls PyBuffer_ToContiguous(..., 'C') from
Objects/abstract.c. Since the function repeatedly calls
PyBuffer_GetPointer(), it has this comment:

/* XXX : This is not going to be the fastest code in the world
 several optimizations are possible.
 */

So if the fix for tobytes() should go in, I'd like to use the
copy_buffer() function from _testbuffer.c. PyBuffer_ToContiguous()
would need to be fixed separately.

test_buffer.py already asserts that for each result, result.tolist()
and result.tobytes() match the results obtained from 
PyBuffer_GetPointer(indices)
(See: test_buffer.py:779), so I'm not worried about using the same
implementation in the tests as in the production code.

--

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



[issue13703] Hash collision security issue

2012-01-17 Thread STINNER Victor

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

Patch version 8: the whole test suite now pass successfully.

The remaining question is if CryptoGen should be used instead of the
weak LCG initialized by gettimeofday() and getpid(). According to
Martin von Loewis, we must link statically Python to advapi32.dll. It
should speed up the startup.

--
Added file: http://bugs.python.org/file24259/random-8.patch

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue13703
___diff --git a/Doc/using/cmdline.rst b/Doc/using/cmdline.rst
--- a/Doc/using/cmdline.rst
+++ b/Doc/using/cmdline.rst
@@ -460,6 +460,13 @@ These environment variables influence Py
option.
 
 
+.. envvar:: PYTHONHASHSEED
+
+   If this is set, it is used as a fixed seed for the Unicode randomized hash:
+   number in range [0; 4294967295]. The value 0 disables the Unicode randomized
+   hash.
+
+
 .. envvar:: PYTHONIOENCODING
 
If this is set before running the interpreter, it overrides the encoding 
used
diff --git a/Include/pythonrun.h b/Include/pythonrun.h
--- a/Include/pythonrun.h
+++ b/Include/pythonrun.h
@@ -246,6 +246,8 @@ typedef void (*PyOS_sighandler_t)(int);
 PyAPI_FUNC(PyOS_sighandler_t) PyOS_getsig(int);
 PyAPI_FUNC(PyOS_sighandler_t) PyOS_setsig(int, PyOS_sighandler_t);
 
+/* Random */
+PyAPI_FUNC(int) _PyOS_URandom (void *buffer, Py_ssize_t size);
 
 #ifdef __cplusplus
 }
diff --git a/Include/unicodeobject.h b/Include/unicodeobject.h
--- a/Include/unicodeobject.h
+++ b/Include/unicodeobject.h
@@ -376,6 +376,12 @@ typedef struct {
 PyAPI_DATA(PyTypeObject) PyUnicode_Type;
 PyAPI_DATA(PyTypeObject) PyUnicodeIter_Type;
 
+typedef struct {
+Py_hash_t prefix;
+Py_hash_t suffix;
+} _Py_unicode_hash_secret_t;
+PyAPI_DATA(_Py_unicode_hash_secret_t) _Py_unicode_hash_secret;
+
 #define PyUnicode_Check(op) \
  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_UNICODE_SUBCLASS)
 #define PyUnicode_CheckExact(op) (Py_TYPE(op) == PyUnicode_Type)
diff --git a/Lib/json/__init__.py b/Lib/json/__init__.py
--- a/Lib/json/__init__.py
+++ b/Lib/json/__init__.py
@@ -31,7 +31,9 @@ Encoding basic Python object hierarchies
 Compact encoding::
 
  import json
- json.dumps([1,2,3,{'4': 5, '6': 7}], separators=(',', ':'))
+ from collections import OrderedDict
+ mydict = OrderedDict([('4', 5), ('6', 7)])
+ json.dumps([1,2,3,mydict], separators=(',', ':'))
 '[1,2,3,{4:5,6:7}]'
 
 Pretty printing::
diff --git a/Lib/os.py b/Lib/os.py
--- a/Lib/os.py
+++ b/Lib/os.py
@@ -761,23 +761,6 @@ try:
 except NameError: # statvfs_result may not exist
 pass
 
-if not _exists(urandom):
-def urandom(n):
-urandom(n) - str
-
-Return a string of n random bytes suitable for cryptographic use.
-
-
-try:
-_urandomfd = open(/dev/urandom, O_RDONLY)
-except (OSError, IOError):
-raise NotImplementedError(/dev/urandom (or equivalent) not found)
-bs = b
-while len(bs)  n:
-bs += read(_urandomfd, n - len(bs))
-close(_urandomfd)
-return bs
-
 # Supply os.popen()
 def popen(cmd, mode=r, buffering=-1):
 if not isinstance(cmd, str):
diff --git a/Lib/packaging/create.py b/Lib/packaging/create.py
--- a/Lib/packaging/create.py
+++ b/Lib/packaging/create.py
@@ -311,8 +311,11 @@ class MainProgram:
  'package_data', 'extra_files'):
 if not(name in self.data and self.data[name]):
 continue
-fp.write('%s = %s\n'
- % (name, '\n'.join(self.data[name]).strip()))
+data = self.data[name]
+if name == extra_files:
+data.sort()
+data = '\n'.join(data).strip()
+fp.write('%s = %s\n' % (name, data))
 fp.write('\nresources =\n')
 for src, dest in self.data['resources']:
 fp.write('%s = %s\n' % (src, dest))
diff --git a/Lib/packaging/tests/test_create.py 
b/Lib/packaging/tests/test_create.py
--- a/Lib/packaging/tests/test_create.py
+++ b/Lib/packaging/tests/test_create.py
@@ -150,16 +150,16 @@ class CreateTestCase(support.TempdirMana
 mymodule
 scripts = my_script
 bin/run
-extra_files = Martinique/Lamentin/dady
+extra_files = Alexander
+Flora
+Martinique/Lamentin/bro
+Martinique/Lamentin/dady
 Martinique/Lamentin/mumy
 Martinique/Lamentin/sys
-Martinique/Lamentin/bro
+Pom
+README
+pyxfoil/fengine.so
 setup.py
-README
-Pom
-Flora
-Alexander
-pyxfoil/fengine.so
 
 resources =
 

[issue13703] Hash collision security issue

2012-01-17 Thread STINNER Victor

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

Hum, test_runpy fails something with a segfault and/or a recursion
limit because of my hack to rerun regrtest.py to set PYTHONHASHSEED
environment variable. The fork should be defined if main() of
regrtest.py is called directly. Example:

diff --git a/Lib/test/regrtest.py b/Lib/test/regrtest.py
--- a/Lib/test/regrtest.py
+++ b/Lib/test/regrtest.py
@@ -258,7 +258,7 @@ def main(tests=None, testdir=None, verbo
  findleaks=False, use_resources=None, trace=False, coverdir='coverage',
  runleaks=False, huntrleaks=False, verbose2=False, print_slow=False,
  random_seed=None, use_mp=None, verbose3=False, forever=False,
- header=False, failfast=False, match_tests=None):
+ header=False, failfast=False, match_tests=None, allow_fork=False):
 Execute a test suite.

 This also parses command-line options and modifies its behavior
@@ -559,6 +559,11 @@ def main(tests=None, testdir=None, verbo
 except ValueError:
 print(Couldn't find starting test (%s), using all tests % start)
 if randomize:
+hashseed = os.getenv('PYTHONHASHSEED')
+if (not hashseed and allow_fork):
+os.environ['PYTHONHASHSEED'] = str(random_seed)
+os.execv(sys.executable, [sys.executable] + sys.argv)
+return
 random.seed(random_seed)
 print(Using random seed, random_seed)
 random.shuffle(selected)
@@ -1809,4 +1814,4 @@ if __name__ == '__main__':
 # change the CWD, the original CWD will be used. The original CWD is
 # available from support.SAVEDCWD.
 with support.temp_cwd(TESTCWD, quiet=True):
-main()
+main(allow_fork=True)

As Antoine wrote on IRC, regrtest.py should be changed later.

--

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



[issue12600] Support parameterized TestCases in unittest

2012-01-17 Thread R. David Murray

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

I'd still like to see a recipe for creating parameterized test cases via 
load_tests added to the docs.  It may be relatively obvious how to do it once 
you think of it, but it isn't obvious to a relative newcomer that you *can* do 
it, and it would make a great example of how load_tests can be used.  (The 
current example is very trivial since it just re-implements the default 
behavior, and while that's useful, it doesn't really demonstrate the power of 
load_tests).

--

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



[issue13411] Hashable memoryviews

2012-01-17 Thread Stefan Krah

Changes by Stefan Krah stefan-use...@bytereef.org:


--
dependencies: +Problems with Py_buffer management in memoryobject.c (and 
elsewhere?)
resolution: fixed - remind
status: closed - open

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



[issue13411] Hashable memoryviews

2012-01-17 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

Reopening as a reminder that it isn't fixed yet in 
http://hg.python.org/features/pep-3118 .

--

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



[issue12600] Add example of using load_tests to parameterise Test Cases

2012-01-17 Thread Nick Coghlan

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

I agree with David, so switching this over to a docs enhancement request.

--
assignee:  - docs@python
components: +Documentation
nosy: +docs@python
title: Support parameterized TestCases in unittest - Add example of using 
load_tests to parameterise Test Cases
versions: +Python 2.7, Python 3.2

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



[issue13589] Aifc low level serialization primitives fix

2012-01-17 Thread Oleg Plakhotnyuk

Oleg Plakhotnyuk oleg...@gmail.com added the comment:

I have absolutely no idea :-)
I just covered every line of code with tests. Some bugs prevented me from do 
it, so I fixed them.

--

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



[issue13804] Python library structure creates hard to read code when using higher order functions

2012-01-17 Thread Amaury Forgeot d'Arc

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

Did you consider list comprehension?

self.questions = sum((topic.questions for topic in self.topics), [])

--
nosy: +amaury.forgeotdarc

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



[issue13803] Under Solaris, distutils doesn't include bitness in the directory name

2012-01-17 Thread Jesús Cea Avión

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

Proposed patch for Python 2.7:


--- util.py.old 2011-12-12 01:34:04.412234183 +0100
+++ util.py 2012-01-17 15:15:23.262257886 +0100
@@ -12,6 +12,7 @@
 from distutils.spawn import spawn
 from distutils import log
 from distutils.errors import DistutilsByteCompileError
+import platform
 
 def get_platform ():
 Return a string that identifies the current platform.  This is used
@@ -76,6 +77,7 @@
 if release[0] = 5:   # SunOS 5 == Solaris 2
 osname = solaris
 release = %d.%s % (int(release[0]) - 3, release[2:])
+machine += .%s %platform.architecture()[0]
 # fall through to standard osname-release-machine representation
 elif osname[:4] == irix:  # could be irix64!
 return %s-%s % (osname, release)


So now the directory is named like lib.solaris-2.10-i86pc.32bit-2.7.

Please, review.

I will commit it to 2.7, 3.1, 3.2 and 3.3 in a few days.

--
assignee: tarek - jcea
stage:  - patch review

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



[issue13695] type specific to type-specific

2012-01-17 Thread Boštjan Mejak

Boštjan Mejak bostjan.me...@gmail.com added the comment:

Well, actually, it's the only correct way to write it (i-th). This is a simple 
orthographical error that was made. Ezio, please fix those two additional 
typos. And Georg, stop being such a wise-ass.

--

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



[issue13804] Python library structure creates hard to read code when using higher order functions

2012-01-17 Thread Martin Häcker

Martin Häcker spamfaen...@gmx.de added the comment:

Yes - however it has the same problem as the higher order version in the python 
libraries that to read it you need to constantly jump back and forth in the 
line.

--

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



[issue13796] use 'text=...' to define the text attribute of and xml.etree.ElementTree.Element

2012-01-17 Thread patrick vrijlandt

patrick vrijlandt patrick.vrijla...@gmail.com added the comment:

Hi,

Did you look at lxml (http://lxml.de)?

from lxml.builder import E
from lxml import etree

tree = etree.ElementTree(
E.Hello(
Good morning!,
E.World(How do you do, humour = excellent),
Fine,
E.Goodbye(),
),
)

print(etree.tostring(tree, pretty_print=True).decode())

# output, even more prettified

Hello
Good morning!
World humour=excellent
  How do you do
/World
  Fine
Goodbye/
/Hello

By the way, your Element enhancement is buggy, because all newly create
elements will share the same attrib dictionary (if attrib is not given).
Notice that Donald Duck will be sad; by the time we print even Hello is sad.

import xml.etree.ElementTree as etree

class Element(etree.Element):
def __init__(self, tag, attrib={}, **extra):
super().__init__(tag)
self.tag = tag
self.attrib = attrib
self.attrib.update(extra)
self.text = self.attrib.pop('text', None)
self.tail = self.attrib.pop('tail', None)
self._children = []

if __name__ == '__main__':

test = Element('Hello',)
test2 = Element('World',{'humour':'excelent'},text = 'How do you do',
tail=Fine)
test3 = Element('Goodbye', humour='sad')
test4 = Element('Donaldduck')
test.append(test2)
test.append(test3)
test.append(test4)
tree = etree.ElementTree(test)
print(etree.tostring(test, encoding=utf-8, method=xml))

Hello humour=sad
World humour=excelentHow do you do/WorldFine
Goodbye humour=sad /
Donaldduck humour=sad /
/Hello'

The correct idiom would be:

def __init__(self, tag, attrib=None, **extra):
if attrib is None:
attrib = {}
super().__init__(tag)

Cheers,

Patrick

2012/1/16 Pedro Andres Aranda Gutierrez rep...@bugs.python.org


 Pedro Andres Aranda Gutierrez paag...@gmail.com added the comment:

 Touché :-)
 I was just frustrated because my XMLs never have tail or text as
 attributes and I wanted to have more compact code...

 On Mon, Jan 16, 2012 at 12:14 PM, patrick vrijlandt
 rep...@bugs.python.org wrote:
 
  patrick vrijlandt patrick.vrijla...@gmail.com added the comment:
 
  I agree the Element syntax is sometimes awkward.
 
  But how would you represent text or tail attributes within this enhanced
 element?
  animal name=cat tail=yes comes to mind ...
 
  --
  nosy: +patrick.vrijlandt
 
  ___
  Python tracker rep...@bugs.python.org
  http://bugs.python.org/issue13796
  ___

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue13796
 ___


--

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



[issue13806] Audioop decompression frames size check fix

2012-01-17 Thread Oleg Plakhotnyuk

New submission from Oleg Plakhotnyuk oleg...@gmail.com:

According to documentation (http://docs.python.org/library/audioop.html), 
adpcm2lin, alaw2lin and ulaw2lin are using 'width' argument to represent output 
frames width. However, in audioop.c module there are checks that are raising 
exceptions if input frames length is not multiple of 'width'. I have replaced 
checking of 'len' to match 'size' with checking of 'len*size' to match 'size' 
in order to retain only basic length validity checks.

--
components: Library (Lib)
files: audioop_size_check.patch
keywords: patch
messages: 151459
nosy: Oleg.Plakhotnyuk, ezio.melotti, sandro.tosi
priority: normal
severity: normal
status: open
title: Audioop decompression frames size check fix
type: behavior
versions: Python 3.2, Python 3.3
Added file: http://bugs.python.org/file24260/audioop_size_check.patch

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



[issue13681] Aifc read compressed frames fix

2012-01-17 Thread Oleg Plakhotnyuk

Changes by Oleg Plakhotnyuk oleg...@gmail.com:


Removed file: http://bugs.python.org/file24112/aifc_compression.patch

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



[issue13681] Aifc read compressed frames fix

2012-01-17 Thread Oleg Plakhotnyuk

Oleg Plakhotnyuk oleg...@gmail.com added the comment:

Ok, I have opened issue 13806 with audioop fix alone. However, I cannot change 
current issue's dependencies to reflect that current issue depends on issue 
13806. Could anyone do this for me please?

--
Added file: http://bugs.python.org/file24261/aifc_compression.patch

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



[issue12705] Make compile('1\n2\n', '', 'single') raise an exception instead of silently truncating?

2012-01-17 Thread Meador Inge

Meador Inge mead...@gmail.com added the comment:

The attached patch fixes this be checking what is left in the input
buffer after parsing.  Anything but trailing whitespace and comments
triggers the exception.

Ignoring trailing whitespace and comments makes sense, but it is also 
somewhat required.  Trailing comments are common in doctests:

 doctest.testfile('test_doctest.txt', raise_on_error=True)
... # doctest: +ELLIPSIS

and trailing whitespace is used by the codeop heuristics.

Here is an example of the new exception:

 compile('1 + 2\n3 + 4\n', '','single')
Traceback (most recent call last):
  File stdin, line 1, in module
  File , line 1
1 + 2
^
SyntaxError: multiple statements found while compiling a single statement

Tested on Fedora 15; no regressions.

--
keywords: +patch
stage: needs patch - patch review
Added file: http://bugs.python.org/file24262/issue12705-0.patch

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



[issue13807] logging.Handler.handlerError() may raise AttributeError in traceback.print_exception()

2012-01-17 Thread Thomas Ryschawy

New submission from Thomas Ryschawy thomasotto.rysch...@emerson.com:

It seems to be known that in case of a Windows GUI app that isn’t connected to 
a console sys.stderr can be None. See the Note on 
http://docs.python.org/py3k/library/sys.html: Under some conditions stdin, 
stdout and stderr as well as the original values __stdin__, __stdout__ and 
__stderr__ can be None. It is usually the case for Windows GUI apps that aren’t 
connected to a console and Python apps started with pythonw.
In combination with logging this leads to an issue similar to issue #5971. In 
my case sys.stderr is None and File: lib\logging\__init__.py, Class: Handler, 
Method: handleError raises AttributeError: 'NoneType' object has no attribute 
'write'.
A 'simple' solution would be to check if sys.stderr is not None. In case it is 
None handleError must not call traceback.print_exception() and not directly 
write to sys.stderr.

--
components: Library (Lib)
files: traceback.txt
messages: 151462
nosy: ThomasRyschawy
priority: normal
severity: normal
status: open
title: logging.Handler.handlerError() may raise AttributeError in 
traceback.print_exception()
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 3.4
Added file: http://bugs.python.org/file24263/traceback.txt

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



[issue13807] logging.Handler.handlerError() may raise AttributeError in traceback.print_exception()

2012-01-17 Thread Thomas Ryschawy

Changes by Thomas Ryschawy thomasotto.rysch...@emerson.com:


Removed file: http://bugs.python.org/file24263/traceback.txt

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



[issue13807] logging.Handler.handlerError() may raise AttributeError in traceback.print_exception()

2012-01-17 Thread Thomas Ryschawy

Changes by Thomas Ryschawy thomasotto.rysch...@emerson.com:


Added file: http://bugs.python.org/file24264/traceback.txt

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



[issue13691] pydoc help (or help('help')) claims to run a help utility; does nothing

2012-01-17 Thread Éric Araujo

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

Just a heads-up: I’ll be offline between January 19 and the end of the month, 
so don’t worry if you make a patch and it’s not reviewed immediately (at least 
not by me, other developers may do it :)

--

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



[issue13691] pydoc help (or help('help')) should show the doc for help

2012-01-17 Thread Éric Araujo

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


--
title: pydoc help (or help('help')) claims to run a help utility; does nothing 
- pydoc help (or help('help')) should show the doc for help

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



[issue13589] Aifc low level serialization primitives fix

2012-01-17 Thread Roundup Robot

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

New changeset f715c4a5a107 by Antoine Pitrou in branch '3.2':
Issue #13589: Fix some serialization primitives in the aifc module.
http://hg.python.org/cpython/rev/f715c4a5a107

New changeset b039965b0066 by Antoine Pitrou in branch 'default':
Issue #13589: Fix some serialization primitives in the aifc module.
http://hg.python.org/cpython/rev/b039965b0066

New changeset 8fac90d0f4cd by Antoine Pitrou in branch '2.7':
Issue #13589: Fix some serialization primitives in the aifc module.
http://hg.python.org/cpython/rev/8fac90d0f4cd

--
nosy: +python-dev

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



[issue13804] Python library structure creates hard to read code when using higher order functions

2012-01-17 Thread Éric Araujo

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

I think this discussion would be more useful on the python-ideas mailing list.  
The request (adding map to sequences) will probably be rejected*, but you have 
a good chance to get an explanation for this design choice by Guido van Rossum 
or one of the old-timer core devs.

*I think so because of str.join: people have said that they would prefer a list 
operation, but it’s always been denied because it would put the burden on any 
sequency type to implement the method, whereas with a str method then all 
iterables and iterators are supported for free.

--
nosy: +eric.araujo

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



[issue13589] Aifc low level serialization primitives fix

2012-01-17 Thread Antoine Pitrou

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

I've finally committed the patch, thank you!

--
resolution:  - fixed
stage:  - committed/rejected
status: open - closed
versions: +Python 2.7

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



[issue13794] Copyright Year - Change it to 2012 please

2012-01-17 Thread Éric Araujo

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

Websites that Python devs can work on are updated, now the request should go to 
the pydotorg mailing list or webmaster email address.

--
nosy: +eric.araujo
resolution:  - fixed
stage: needs patch - committed/rejected
status: open - closed

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



[issue13681] Aifc read compressed frames fix

2012-01-17 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
dependencies: +Audioop decompression frames size check fix

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



[issue13703] Hash collision security issue

2012-01-17 Thread Éric Araujo

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

#13712 contains a patch for test_packaging.

--

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



[issue13803] Under Solaris, distutils doesn't include bitness in the directory name

2012-01-17 Thread Éric Araujo

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

OK.

 from distutils.spawn import spawn
 from distutils import log
 from distutils.errors import DistutilsByteCompileError
+import platform

Please put that import higher up (with the other “import X”, before the “from X 
import Y”).
 
+machine += .%s %platform.architecture()[0]

One space after the % operator please.

 I will commit it to 2.7, 3.1, 3.2 and 3.3 in a few days.

Not to 3.1, this is not a security issue.

--
versions:  -Python 2.6, Python 3.1

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



[issue6727] ImportError when package is symlinked on Windows

2012-01-17 Thread Éric Araujo

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

(3.1 doesn’t get non-security bug fixes either)

--
versions:  -Python 3.1

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



[issue12415] Missing: How to checkout the Doc sources

2012-01-17 Thread Éric Araujo

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

 I think documentation sources is a bit vague.
I don’t know.  I probably wrote it under the assumption that the audience of 
this doc was developers, who already know that programmers don’t write HTML 
manually but generate it, and just need to know where to find the sources.  To 
a C programmer wanting to fix a bug, we just say “the sources for X are in 
Include and Modules”, and it’s enough.

Thinking about it, the assumption is probably bad.  Sometimes we have to 
explain to new contributors where to find a Python module in the repo and how 
to write a test, so it would probably be better to explain more.  Here’s my 
draft, feel free to improve my patch with it (there may be duplication) and 
commit the result when you two are in agreement while I’ll be offline.

  The documentation in HTML, PDF or epub format is generated from text files
  written using the :ref:`reStructuredText format markup and contained in
  the :ref:`CPython Mercurial repository setup`.

--

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



[issue13703] Hash collision security issue

2012-01-17 Thread STINNER Victor

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

 #13712 contains a patch for test_packaging.

It doesn't look related to randomized hash function. random-8.patch
contains a fix to test_packaging.

--

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



[issue13806] Audioop decompression frames size check fix

2012-01-17 Thread Antoine Pitrou

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

Well, you should just replace these calls with audioop_check_size() instead. 
Apparently the checks were blindly added in issue7673.

By the way, I'm surprised audioop accepts unicode strings... :/

--
nosy: +haypo, pitrou
versions: +Python 2.7

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



[issue13703] Hash collision security issue

2012-01-17 Thread Éric Araujo

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

 #13712 contains a patch for test_packaging.
 It doesn't look related to randomized hash function.
Trust me.  (If you read the whole report you’ll see why it looks unrelated: 
instead of sorting things like your patch does mine addresses a more serious 
behavior bug).

 random-8.patch contains a fix to test_packaging.
I know, but mine is a bit better.

--

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



[issue12705] Make compile('1\n2\n', '', 'single') raise an exception instead of silently truncating?

2012-01-17 Thread Éric Araujo

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

I don’t understand why some two-liners are allowed (like class X:\n pass).  
The doc says “a single interactive statement”.

--

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



[issue13787] PyCode_New not round-trippable (TypeError)

2012-01-17 Thread Amaury Forgeot d'Arc

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

co_freevars and co_cellvars are the last arguments of the function.  Your 
co_what2.py version of the script is correct, but co_what.py has a 
different order.

--
nosy: +amaury.forgeotdarc
resolution:  - invalid
status: open - closed

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



[issue11805] package_data only allows one glob per-package

2012-01-17 Thread Éric Araujo

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

Here are patches for CPython and the d2 repo.  There is no doc update as the 
setupscript page still talks about setup.py and the setupcfg spec does not 
mention package_data at all (the negationists resources-promoters at work :), 
so this can wait for my big doc updates.  The changes to 
test_command_{build_py,sdist} are unrelated, I just found some fixes to do 
after grepping for package_data and I’ll commit them separately.

Please review.  (I’ll be offline until the end of the month FYI, but I’ll 
commit after that.)

--

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



[issue11805] package_data only allows one glob per-package

2012-01-17 Thread Éric Araujo

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


--
keywords: +patch
Added file: 
http://bugs.python.org/file24265/fix-package_data-multivalue-cpy33.diff

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



[issue11805] package_data only allows one glob per-package

2012-01-17 Thread Éric Araujo

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


Added file: http://bugs.python.org/file24266/fix-package_data-multivalue-d2.diff

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



[issue11805] package_data only allows one glob per-package

2012-01-17 Thread Éric Araujo

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

Note that my proposed syntax does not allow something equivalent to {'': 
[etc.]} in distutils, i.e. package data for top-level modules.  I think this is 
okay: modules should not install data in their installation dir.  I don’t think 
it was widely used, but maybe I should ask on distutils-sig or survey setup.py 
scripts on PyPI to be sure.

--

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



[issue11240] Running unit tests in a command line tool leads to infinite loop with multiprocessing on Windows

2012-01-17 Thread Chris Jones

Chris Jones ch...@chrisejones.com added the comment:

You can work around this issue by using:
python.exe -c import nose; nose.main()
instead of nosetests

Note that nose.main() with no args parses sys.argv

--
nosy: +Chris.Jones

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



[issue13695] type specific to type-specific

2012-01-17 Thread Georg Brandl

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

Once you start contributing anything useful, I will start treating it as such.

--

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



[issue12705] Make compile('1\n2\n', '', 'single') raise an exception instead of silently truncating?

2012-01-17 Thread Meador Inge

Meador Inge mead...@gmail.com added the comment:

On Tue, Jan 17, 2012 at 10:56 AM, Éric Araujo rep...@bugs.python.org wrote:

 I don’t understand why some two-liners are allowed (like class X:\n pass).  
 The doc says “a single interactive statement”.

Because a single statement can be multiple lines (as is the case for
compound statements).  Look at the grammar for a single input
statement
(interactive_input):
http://docs.python.org/dev/reference/toplevel_components.html#interactive-input.
 This issue is really about multiple statements
and not multiple lines.

--

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



[issue12705] Make compile('1\n2\n', '', 'single') raise an exception instead of silently truncating?

2012-01-17 Thread Georg Brandl

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

Because a class statement is one statement (it is a compound statement, but 
still just one).  The docs don't talk about lines :)

A single interactive statement is what you can enter at the interactive 
prompt in one line, or more than one line with only secondary prompts from the 
second line on.

--
nosy: +georg.brandl

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



[issue13804] Python library structure creates hard to read code when using higher order functions

2012-01-17 Thread Daniel Stutzbach

Daniel Stutzbach stutzb...@google.com added the comment:

If I'm understanding Martin Häcker's code correctly, the list comprehension 
equivalent is:

self.questions = [topic.questions for topic in self.topics]

The reduce() variants are not only much harder to read, but they will take 
O(n**2) operations because they create an O(n) list O(n) times.

--
nosy: +stutzbach

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



[issue13703] Hash collision security issue

2012-01-17 Thread Jim Jewett

Jim Jewett jimjjew...@gmail.com added the comment:

To be more explicit about Martin A. Lemburg's msg151121 (which I agree with):

Count the collisions on a single lookup. 
If they exceed a threshhold, do something different.

Martin's strawman proposal was threshhold=1000, and raise.  It would be just as 
easy to say whoa!  5 collisions -- time to use the alternative hash instead 
(and, possibly, to issue a warning).  

Even that slight tuning removes the biggest objection, because it won't ever 
actually fail.

Note that the use of a (presumably stronger 2nd) hash wouldn't come into play 
until (and unless) there was a problem for that specific key in that specific 
dictionary.  For the normal case, nothing changes -- unless we take advantage 
of the existence of a 2nd hash to simplify the first few rounds of collision 
resolution.  (Linear probing is more cache-friendly, but also more vulnerable 
to worst-case behavior -- but if probing stops at 4 or 8, that may not matter 
much.)  For quick scripts, the 2nd hash will almost certainly never be needed, 
so startup won't pay the penalty.

The only down side I see is that the 2nd (presumably randomized) hash won't be 
cached without another slot, which takes more memory and shouldn't be done in a 
bugfix release.

--
nosy: +Jim.Jewett

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



[issue5689] Support xz compression in tarfile module

2012-01-17 Thread Amaury Forgeot d'Arc

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

Ping.  Windows buildbots are still failing with MemoryError because of this 
preset=9.
The patch looks good to me as well.

--
nosy: +amaury.forgeotdarc

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



[issue13727] Accessor macros for PyDateTime_Delta members

2012-01-17 Thread Roundup Robot

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

New changeset 463acb73fd79 by Amaury Forgeot d'Arc in branch 'default':
Issue #13727: Add 3 macros to access PyDateTime_Delta members:
http://hg.python.org/cpython/rev/463acb73fd79

--
nosy: +python-dev

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



[issue13727] Accessor macros for PyDateTime_Delta members

2012-01-17 Thread Amaury Forgeot d'Arc

Changes by Amaury Forgeot d'Arc amaur...@gmail.com:


--
resolution:  - fixed
status: open - closed

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



[issue13787] PyCode_New not round-trippable (TypeError)

2012-01-17 Thread Mahmoud Hashemi

Mahmoud Hashemi mak...@gmail.com added the comment:

Yes, I knew it was an issue with crossed wires somewhere. The Python 2 code 
doesn't translate well to Python 3 because the function signature changed to 
add kwargonlycount. And I guess the argument order is substantially different, 
too, as described in Objects/codeobject.c#l291.

Thanks for clearing that up, though,

Mahmoud

--

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



[issue13808] url for Tutor mailing list is broken

2012-01-17 Thread Tshepang Lekhonkhobe

New submission from Tshepang Lekhonkhobe tshep...@gmail.com:

faq.rst: correct url is http://mail.python.org/mailman/listinfo/tutor

--
components: Devguide
messages: 151488
nosy: ezio.melotti, tshepang
priority: normal
severity: normal
status: open
title: url for Tutor mailing list is broken

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



[issue13808] url for Tutor mailing list is broken

2012-01-17 Thread Roundup Robot

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

New changeset 471f70b0b6b0 by Ezio Melotti in branch 'default':
#13808: fix a link and specify the IRC server.
http://hg.python.org/devguide/rev/471f70b0b6b0

--
nosy: +python-dev

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



[issue13808] url for Tutor mailing list is broken

2012-01-17 Thread Ezio Melotti

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

Fixed, thanks for the report!

--
assignee:  - ezio.melotti
resolution:  - fixed
stage:  - committed/rejected
status: open - closed
type:  - enhancement

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



[issue13809] bz2 does not work when threads are disabled

2012-01-17 Thread Amaury Forgeot d'Arc

New submission from Amaury Forgeot d'Arc amaur...@gmail.com:

In bz2.py, import threading prevents the bz2 module from working when threads 
are not enabled.  The attached patch removes the limitation and provides a fake 
lock object.

I don't know if this should be backported to 3.2.

--
components: Library (Lib)
files: bz2_nothread.patch
keywords: patch
messages: 151491
nosy: amaury.forgeotdarc
priority: normal
severity: normal
stage: patch review
status: open
title: bz2 does not work when threads are disabled
type: behavior
versions: Python 3.3
Added file: http://bugs.python.org/file24267/bz2_nothread.patch

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



[issue13809] bz2 does not work when threads are disabled

2012-01-17 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +nadeem.vawda

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



[issue13809] bz2 does not work when threads are disabled

2012-01-17 Thread Georg Brandl

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

Isn't there already a dummy lock in dummy_threading?

--
nosy: +georg.brandl

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



[issue13809] bz2 does not work when threads are disabled

2012-01-17 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

As Georg suggested, it would be better to use dummy_threading.RLock,
rather than providing our own implementation.

The test in the patch fails when I try to run it on a no-thread build.
support.import_fresh_module seems to treat the absence of the threading
module as an error, and returns None instead of allowing the bz2 module
to recover from the ImportError.

We needn't worry about 3.2. It still uses the old all-C implementation,
which has its threading dependencies protected by #ifdefs.

--

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



[issue6531] atexit_callfuncs() crashing within Py_Finalize() when using multiple interpreters.

2012-01-17 Thread Antoine Pitrou

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

Hmm something else: currently the atexit funcs are only called when the main 
interpreter exits, but that doesn't really make sense: if I register a function 
from a sub-interpreter, why would it execute correctly from another 
interpreter? All kind of fun things can happen...

--

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



[issue6531] atexit_callfuncs() crashing within Py_Finalize() when using multiple interpreters.

2012-01-17 Thread Roundup Robot

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

New changeset eb47af6e9e22 by Antoine Pitrou in branch '3.2':
Test running of code in a sub-interpreter
http://hg.python.org/cpython/rev/eb47af6e9e22

New changeset a108818aaa0d by Antoine Pitrou in branch 'default':
Test running of code in a sub-interpreter
http://hg.python.org/cpython/rev/a108818aaa0d

--
nosy: +python-dev

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



[issue6531] atexit_callfuncs() crashing within Py_Finalize() when using multiple interpreters.

2012-01-17 Thread Antoine Pitrou

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

Here is a patch for subinterp-wise atexit functions.
(I haven't got any specific test for the crash but the patch adds a test and it 
works)

--
keywords: +patch
stage:  - patch review
Added file: http://bugs.python.org/file24268/atexitsubinterps.patch

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



[issue13809] bz2 does not work when threads are disabled

2012-01-17 Thread Roundup Robot

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

New changeset 2fb93282887a by Nadeem Vawda in branch 'default':
Issue #13809: Make bz2 module work with threads disabled.
http://hg.python.org/cpython/rev/2fb93282887a

--
nosy: +python-dev

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



[issue13809] bz2 does not work when threads are disabled

2012-01-17 Thread Nadeem Vawda

Nadeem Vawda nadeem.va...@gmail.com added the comment:

Fix committed. For the test, it turns out we can get the desired behavior
by telling import_fresh_module to block the threading module directly,
instead of blocking _thread.

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

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



  1   2   >