[issue1596321] KeyError at exit after 'import threading' in other thread

2013-08-07 Thread Thomas Guettler

Thomas Guettler added the comment:

Only few people seem to use daemon threads. We do and see this problem often 
with Python 2.7.

How difficult is it to get this fixed for 2.7?

Is there a way to work around this problem?

--
nosy: +guettli

___
Python tracker 

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



[issue18674] Store weak references in modules_by_index

2013-08-07 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> It seems to me that the more appropriate change here would be to
> redefine PyState_FindModule as return a *new* ref rather than a
> borrowed ref and have it do the Py_INCREF before returning.
> 
> Code using it would then need to add an appropriate Py_DECREF. A
> reference leak is generally a less dangerous bug than an early free.

I hadn't thought about that. Code must add Py_DECREF only on 3.4+, then.

--

___
Python tracker 

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



[issue15787] PEP 3121 Refactoring

2013-08-07 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
dependencies: +PEP 3121 Refactoring applied to _csv module

___
Python tracker 

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



[issue15787] PEP 3121 Refactoring

2013-08-07 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
dependencies: +PEP 3121, 384 refactoring applied to curses_panel module

___
Python tracker 

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



[issue15787] PEP 3121, 384 Refactoring

2013-08-07 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
dependencies: +PEP 384 Refactoring applied to _csv module
title: PEP 3121 Refactoring -> PEP 3121, 384 Refactoring

___
Python tracker 

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



[issue15787] PEP 3121, 384 Refactoring

2013-08-07 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
dependencies: +PEP 384 inconsistent with implementation

___
Python tracker 

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



[issue1856] shutdown (exit) can hang or segfault with daemon threads running

2013-08-07 Thread Thomas Guettler

Thomas Guettler added the comment:

There are some examples to work around this for Python2: 
http://stackoverflow.com/questions/18098475/detect-interpreter-shut-down-in-daemon-thread

--
nosy: +guettli

___
Python tracker 

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



[issue15787] PEP 3121, 384 Refactoring

2013-08-07 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
nosy: +pitrou

___
Python tracker 

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



[issue15787] PEP 3121, 384 Refactoring

2013-08-07 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

"""
Regarding the suggestion of separating PEP3121 and PEP384. It might be true 
that datetime and other modules do not benefit directly from PEP 384, however 
it is still a fact that the stdlib modules should be seen as a set of reference 
modules, that are all implemented in a way that complies with the 
implementation fo the xxmodules.
I have talked with Martin von Löwis about this, and as far as I understood him 
correctly he also sees the PEP384 refactoring applied to the whole stdlib as a 
necessary "signal" to other developers to refactor their modules accordingly.
""" (Robin Schreiber, #15390, msg177274)

MvL have recently confirmed this on python-dev: "Choice of supporting PEP 384 
was deliberate. It will change all types into heap types, which is useful for 
multiple-interpreter support and GC."

Accordingly, I've changed the title of this issue and added a few PEP 384 only 
dependencies.

--

___
Python tracker 

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



[issue18675] Daemon Threads can seg fault

2013-08-07 Thread Thomas Guettler

New submission from Thomas Guettler:

This is a documentation bug: Since #1856  is not solved for Python2, it needs 
to be documented.

Daemon Threads on Python2 can seg fault.

Work arounds: 
http://stackoverflow.com/questions/18098475/detect-interpreter-shut-down-in-daemon-thread

--
assignee: docs@python
components: Documentation
messages: 194601
nosy: docs@python, guettli
priority: normal
severity: normal
status: open
title: Daemon Threads can seg fault
versions: Python 2.6, Python 2.7

___
Python tracker 

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



[issue15787] PEP 3121, 384 Refactoring

2013-08-07 Thread Alexander Belopolsky

Alexander Belopolsky added the comment:

With respect to PEP 384 refactoring, I would like to see 
Tools/scripts/abitype.py used for most of the conversions.  The PEP itself can 
probably be amended to advertise this tool more prominently.

--

___
Python tracker 

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



[issue13153] IDLE crashes when pasting non-BMP unicode char on Py3

2013-08-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

u'\U000104a2' == u'\ud801\udca2' on narrow build.

u'\ud801'.encode('utf-8', 'surrogatepass') == b'\xed\xa0\x81'
u'\udca2'.encode('utf-8', 'surrogatepass') == b'\xed\xb2\xa2'

Hope it will help.

--

___
Python tracker 

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



[issue18671] enhance formatting in logging package

2013-08-07 Thread M. Dietrich

M. Dietrich added the comment:

for a logging library the important thing would be to not loose the information 
that was meant to log. as i said i do alot of long-running huge-data-processing 
scripts in py using the library. if the logging breaks but doesnt log what was 
intended to log i judge this a major problem. and furthermore: it is so simple 
to add both information: the data that was to be logged plus the state that an 
error occured while formatting and where the log-call was made.

--
status: pending -> open

___
Python tracker 

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



[issue18668] Properly document setting m_size in PyModuleDef

2013-08-07 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 698fd628b001 by Eli Bendersky in branch '3.3':
Issue #18668: Properly document setting m_size in PyModuleDef
http://hg.python.org/cpython/rev/698fd628b001

New changeset 9877c25d9556 by Eli Bendersky in branch 'default':
Closing #18668: Properly document setting m_size in PyModuleDef
http://hg.python.org/cpython/rev/9877c25d9556

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

___
Python tracker 

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



[issue18668] Properly document setting m_size in PyModuleDef

2013-08-07 Thread Eli Bendersky

Eli Bendersky added the comment:

Thanks for the review!

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

___
Python tracker 

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



[issue18668] Properly document setting m_size in PyModuleDef

2013-08-07 Thread Eli Bendersky

Changes by Eli Bendersky :


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

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-07 Thread Eli Bendersky

Eli Bendersky added the comment:

Antoine, some questions about the patch:

First, I think it omits expat_capi from the state. Is that intentional?

Second, I'm not sure if this approach is fully aligned with PEP 3121. A global, 
shared state is still used. Instead of actually having a different module state 
per subinterpreter, this patch will have shared state. Another problem seems to 
be using PyModule_FindModule without using PyModule_AddModule first. 

These problems could be shared to all of Robin's original patches. Of course, 
there's also the possibility that I don't fully understand PEP 3121 yet :)

--

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-07 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> First, I think it omits expat_capi from the state. Is that
> intentional?

What would it do in the state? There's nothing to release.

> Second, I'm not sure if this approach is fully aligned with PEP 3121.
> A global, shared state is still used. Instead of actually having a
> different module state per subinterpreter, this patch will have
> shared state.

I don't understand what you are talking about. Perhaps you haven't looked
what PyState_FindModule() does?

--

___
Python tracker 

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



[issue18668] Properly document setting m_size in PyModuleDef

2013-08-07 Thread Nick Coghlan

Nick Coghlan added the comment:

I thought setting m_size to zero was for "No per module state, but
reinitialization is fine"? Does that not work? (I haven't actually tried it)

--

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-07 Thread Eli Bendersky

Eli Bendersky added the comment:

On Wed, Aug 7, 2013 at 6:28 AM, Antoine Pitrou wrote:

>
> Antoine Pitrou added the comment:
>
> > First, I think it omits expat_capi from the state. Is that
> > intentional?
>
> What would it do in the state? There's nothing to release.
>

That's true, but I thought one of the goals of PEP 3121 is to separate
states between sub-interpreters. So that one can't corrupt another. I'm not
sure how much it matters in practice in this case of the pyexpat capsule;
need to look into it more.

> > Second, I'm not sure if this approach is fully aligned with PEP 3121.
> > A global, shared state is still used. Instead of actually having a
> > different module state per subinterpreter, this patch will have
> > shared state.
>
> I don't understand what you are talking about. Perhaps you haven't looked
> what PyState_FindModule() does?
>

I did not look at the implementation yet. But the documentation says:

"""Returns the module object that was created from *def* for the current
interpreter. This method requires that the module object has been attached
to the interpreter state with
PyState_AddModule()beforehand.
In case the corresponding module object is not found or has not
been attached to the interpreter state yet, it returns NULL."""

I don't see a call to PyState_AddModule. What am I missing?

--

___
Python tracker 

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



[issue18676] Queue: zero should not be accepted as timeout value

2013-08-07 Thread Zhongyue Luo

New submission from Zhongyue Luo:

The docstring of methods put() and get() in Queue.py states

get(): If 'timeout' is a positive number, it blocks at most 'timeout' seconds 
and raises the Full exception if no free slot was available within that time.

put(): If 'timeout' is a positive number, it blocks at most 'timeout' seconds 
and raises the Empty exception if no item was available within that time.

Additionally the ValueError both methods raise is

 raise ValueError("'timeout' must be a positive number")

However the logic checks if 'timeout' is non-negative.

 elif timeout < 0:
 raise ValueError("'timeout' must be a positive number")

The logic should change as

 elif timeout <= 0:
 raise ValueError("'timeout' must be a positive number")

--
components: Library (Lib)
messages: 194611
nosy: zyluo
priority: normal
severity: normal
status: open
title: Queue: zero should not be accepted as timeout value
type: behavior
versions: Python 2.7

___
Python tracker 

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



[issue15651] PEP 3121, 384 refactoring applied to elementtree module

2013-08-07 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> That's true, but I thought one of the goals of PEP 3121 is to
> separate
> states between sub-interpreters. So that one can't corrupt another.
> I'm not
> sure how much it matters in practice in this case of the pyexpat
> capsule;
> need to look into it more.

pyexpat's "capi" object is a static struct inside pyexpat.c, so that
wouldn't change anything.
Separating states between sub-interpreters only matters when said state
is mutable, which it isn't here.

> I don't see a call to PyState_AddModule. What am I missing?

It is called implicitly when an extension module is imported.

--

___
Python tracker 

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



[issue18676] Queue: document that zero is accepted as timeout value

2013-08-07 Thread R. David Murray

R. David Murray added the comment:

This is more of a documentation issue than a code issue.  To be mathematically 
precise, the text and error message should read "a non-negative value".  
Alternatively the text and error could be changed to report that timeout may 
not be negative, which would probably be clearer.  (Note that timeout is a 
float value, and thus the proposed code change would only break code, it would 
not change the functionality in any significant way.)

--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python, r.david.murray
title: Queue: zero should not be accepted as timeout value -> Queue: document 
that zero is accepted as timeout value
versions: +Python 3.3, Python 3.4

___
Python tracker 

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



[issue18671] enhance formatting in logging package

2013-08-07 Thread Vinay Sajip

Vinay Sajip added the comment:

>From the line number you mentioned, it looks like you're talking about Python 
>2.7. However, Python 2.7 is closed to new features: generally speaking, only 
>bug fixes are supposed to be committed to this branch.

I can consider expanding the "Logged from ..." error message for 3.4.

--
resolution: invalid -> 
status: open -> pending
versions: +Python 3.4

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-07 Thread Kristján Valur Jónsson

New submission from Kristján Valur Jónsson:

A proposed patch adds two features to context managers:

1)It has always irked me that it was impossible to assemble nested context 
managers in the python language. See issue #5251.
The main problem, that exceptions in __enter__ cannot be properly handled, is 
fixed by introducing a new core exception, ContextManagerExit.  When raised by 
__enter__(), the body that the context manager protects is skipped.  This 
exception is in the spirit of other semi-internal exceptions such as 
GeneratorExit and StopIteration.  Using this exception, contextlib.nested can 
properly handle the case where the body isn't run because of an internal 
__enter__ exception which is handled by an outer __exit__.

2) The mechanism used in implementing ContextManagerExit above is easily 
extended to allowing a special context manager: None.  This is useful for 
having _optional_ context managers.  E.g. code like this:
with performance_timer():
do_work()

def performance_timer():
if profiling:
return accumulator
return None

None becomes the trivial context manager and its __enter__ and __exit__ calls 
are skipped, along with their overhead.

This patch implements both features.
In addition, it:
1) reintroduces contextlib.nested, which is based on nested_delayed
2) introduces contextlib.nested_delayed, which solves the other problem with 
previous versions of nested, that an inner context manager expression shouldn't 
be evaluated early.  contextlib.nested evaluates callables returning context 
managers, rather than managers directly.
3) Allows contextlib.contextmanager decorated functions to not yield, which 
amounts to skipping the protected body (implicitly raising ContextManagerExit)
4) unittests for the whole thing.

I'll introduce this stuff on python-ideas as well.

--
components: Interpreter Core
files: contextmanagerexit.patch
keywords: patch
messages: 194615
nosy: kristjan.jonsson
priority: normal
severity: normal
status: open
title: Enhanced context managers with ContextManagerExit and None
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file31182/contextmanagerexit.patch

___
Python tracker 

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



[issue11619] On Windows, don't encode filenames in the import machinery

2013-08-07 Thread Steven Velez

Steven Velez added the comment:

This may be a small use case, but a use case none-the less.  In my situation, I 
am distributing a frozen python package and it runs under the users home 
directory.   If the user's name has international characters, this will fail.

I expect we will have similar problems when dealing with our application which 
embeds python and is also running from within the user directory...

--
nosy: +Steven.Velez

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-07 Thread R. David Murray

R. David Murray added the comment:

Your use cases are either already addressed by contextlib.ExitStack, or should 
be addressed in the context of its existence.  It is the replacement for 
contextlib.nested.

--
nosy: +ncoghlan, r.david.murray

___
Python tracker 

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



[issue18678] Wrong struct members name for spwd module

2013-08-07 Thread Vajrasky Kok

New submission from Vajrasky Kok:

Both python2 and python3 have this behaviour.

>>> import os; os.getuid()
0
>>> 'I am root'
'I am root'
>>> import spwd
>>> spwd.getspnam('bin')
spwd.struct_spwd(sp_nam='bin', sp_pwd='*', sp_lstchg=15558, sp_min=0, 
sp_max=9, sp_warn=7, sp_inact=-1, sp_expire=-1, sp_flag=-1)
>>> spwd.getspnam.__doc__
'getspnam(name) -> (sp_namp, sp_pwdp, sp_lstchg, sp_min, sp_max,\n  
  sp_warn, sp_inact, sp_expire, sp_flag)\nReturn the shadow password 
database entry for the given user name.\nSee spwd.__doc__ for more on shadow 
password database entries.'

The documentation tells the function getspnam will give struct which has member 
sp_namp and sp_pwdp. But as you can see, the function getspnam gives me a tuple 
with has member sp_nam (without p) and sp_pwd (without p).

If you "man spwd", you can see the documentation is correct:
Structure
   The shadow password structure is defined in  as follows:

   struct spwd {
   char *sp_namp; /* Login name */
   char *sp_pwdp; /* Encrypted password */
   long  sp_lstchg;   /* Date of last change (measured
 in days since 1970-01-01 00:00:00 + 
(UTC)) */
   long  sp_min;  /* Min # of days between changes */
   long  sp_max;  /* Max # of days between changes */
   long  sp_warn; /* # of days before password expires
 to warn user to change it */
   long  sp_inact;/* # of days after password expires
 until account is disabled */
   long  sp_expire;   /* Date when account expires (measured
 in days since 1970-01-01 00:00:00 + 
(UTC)) */
   unsigned long sp_flag;  /* Reserved */
   };

For curious souls who do not have unix box:
http://linux.die.net/man/3/getspnam

I have contemplated about whether this behaviour is intended as it is, but I 
guess this is just a bug. Typo.

Attached the patch to fix this inconsistency. I also fixed some documentation 
about sp_inact and sp_expire.

I only marked this as Python 3.4 fix because I am not sure whether we should 
backport it to previous python versions. Some programs that expect sp_nam and 
sp_pwd names could break.

--
components: Extension Modules
files: spwd_struct_members_name_fix.patch
keywords: patch
messages: 194618
nosy: vajrasky
priority: normal
severity: normal
status: open
title: Wrong struct members name for spwd module
type: behavior
versions: Python 3.4
Added file: http://bugs.python.org/file31183/spwd_struct_members_name_fix.patch

___
Python tracker 

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



[issue18678] Wrong struct members name for spwd module

2013-08-07 Thread R. David Murray

R. David Murray added the comment:

Ideally, for backward compatibility reasons we really ought to support access 
by the old (incorrect) name even in 3.4 (with a deprecation warning, even more 
ideally).  I'm not sure if that's practical?

--
nosy: +r.david.murray

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-07 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

IMHO, exitstack is not a very nice construct.  It's implementation is far 
longer than contextlib.nested.

And the chief problem still remains, which has not been addressed until this 
patch (as far as I know):
In Python, it is impossible to combine existing context managers into a nested 
one.  ExitStack may address a use case of nested context managers, but it 
doesn't address the basic problem.

ContextManagerExit comes with its own nice little features, too.  Now you can 
write:

@contextlib.contextmanager:
def if_ctxt(condition):
if condition:
yield

#hey look! an if statement as a with statement!
with if_ctxt(condition):
do_work

This can easily be extended, where a context manager can both manage context, 
_and_ provide optional execution of its block.

--

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-07 Thread R. David Murray

R. David Murray added the comment:

Raising it on python-ideas sounds like a good idea, then.

I must admit that I don't understand what you mean by "combining existing 
context managers into a nested one" that isn't addressed by ExitStack.

--

___
Python tracker 

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



[issue11619] On Windows, don't encode filenames in the import machinery

2013-08-07 Thread Eric Snow

Changes by Eric Snow :


--
nosy: +eric.snow

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-07 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Simply put, there is no way in the language to nest two context managers, even 
though we have full access to their implementation model, i.e. can call 
__enter__ and __exit__ manually.  This reflects badly (pun intended) on 
Python's reflection and introspection capabilities.

If context managers are to be first class entities in the language, then you 
ought to be able to write absract code using them, and
assemble complex ones out of simple ones.  Hypothetical code here:

def nest(a, b):
# currently not possible
return c

def run_with_context(ctxt, callable):
# abstract executor
with ctxt:
return callable()

run_with_context(nested(a,b), callable)

ExitStack address one use case that contextlib.nested was supposed to solve, 
namely the cleanup of a dynamic sequence of context managers.  But it does this 
no by creating a new manager, but by providing a programming pattern to follow. 
 In that sensse, the multiple context manager syntax (with (a, b, c): ) is also 
a hack because it provides language magic to perform what you ought to be able 
to do dynamically...

Does this makes sense?

Anyway, by providing the ContextManagerExit exception, then sufficient 
flexibility is added to the context manager mechanism that at least the use 
case of nested() becomes possible.

Context managers are really interesting things.  I was inspired by Raymond 
Hettinger's talk last pycon to explore their capabilities and this is one of 
the things I came up with :)

--

___
Python tracker 

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



[issue13153] IDLE crashes when pasting non-BMP unicode char on Py3

2013-08-07 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Seems as Tk stores pasted "\U000104a2" as surrogate pair "\ud801\udca2". Then 
it encoded in UTF-8 as "\xed\xa0\x81\xed\xb2\xa2" end passed to Python. Python 
converts char* to Unicode object with PyUnicode_FromString() which forbids 
invalid UTF-8 including encoded surrogates.

Please test proposed patch on Windows.

--
Added file: http://bugs.python.org/file31184/tkinter_string_conv.patch

___
Python tracker 

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



[issue18674] Store weak references in modules_by_index

2013-08-07 Thread Antoine Pitrou

Antoine Pitrou added the comment:

(and of course, with module states not being PyObjects, we have the same 
lifetimes issues as with Py_buffers not being PyObjects)

--

___
Python tracker 

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



[issue13153] IDLE crashes when pasting non-BMP unicode char on Py3

2013-08-07 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


Removed file: http://bugs.python.org/file31184/tkinter_string_conv.patch

___
Python tracker 

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



[issue13153] IDLE crashes when pasting non-BMP unicode char on Py3

2013-08-07 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


Added file: http://bugs.python.org/file31185/tkinter_string_conv.patch

___
Python tracker 

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



[issue18679] include a codec to handle escaping only control characters but not any others

2013-08-07 Thread Derek Wilson

New submission from Derek Wilson:

Escaping strings for serialization or display is a common problem. Currently, 
in python3, in order to escape a sting, you need to do this:

'my\tstring'.encode('unicode_escape').decode('ascii')

This would give you a string that was represented like this:

'my\\tstring'

But this does not present a suitable representation when the string contains 
unicode characters. Consider this example:

s = 'Α\tΩ'

There is no method to write this string this with only the control character 
escaped.

Even python itself recognizes this as a problem and implemented a "solution" 
for it.

>>> s = 'Α\tΩ'
>>> print(s)
Α   Ω
>>> print(repr(s))
'Α\tΩ'
>>> print(s.encode('unicode_escape').decode('ascii'))
\u0391\t\u03a9

What I want is public exposure of the functionality to represent control 
characters with their common \ escape sequences (or \x## for control characters 
where necessary - for instance unit and record separators).

I have numerous use cases for this and python's own str.__repr__ implementation 
shows that the functionality is valuable. I would bet that the majority of 
cases where people use unicode_escape something like a control_escape is more 
along the lines of what is desired.

And while we're at it, it would be great if this were a unicode->unicode codec 
like the rot_13 codec. My desired soluiton would look like this:

>>> import codecs
>>> s = 'Α\tΩ'
>>> e = codecs.encode(s, 'control_escape'))
>>> print(e)
Α\tΩ
>>> print(codecs.decode(e, 'control_escape'))
Α   Ω

If this is something that could be included in python 3.4, that would be 
awesome. I am willing to work on this if so.

--
components: Library (Lib)
messages: 194625
nosy: underrun
priority: normal
severity: normal
status: open
title: include a codec to handle escaping only control characters but not any 
others
type: enhancement
versions: Python 3.4

___
Python tracker 

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



[issue18676] Queue: document that zero is accepted as timeout value

2013-08-07 Thread Zhongyue Luo

Zhongyue Luo added the comment:

David,

How about like below?

  elif timeout < sys.float_info.epsilon:
 raise ValueError("'timeout' must be a positive number")

The docstring has been there for quite a while and IMHO it just doesn't make 
sense passing 0.0 as a timeout value.

--

___
Python tracker 

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



[issue8713] multiprocessing needs option to eschew fork() under Linux

2013-08-07 Thread Richard Oudkerk

Changes by Richard Oudkerk :


Added file: http://bugs.python.org/file31186/b3620777f54c.diff

___
Python tracker 

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



[issue8713] multiprocessing needs option to eschew fork() under Linux

2013-08-07 Thread Richard Oudkerk

Richard Oudkerk added the comment:

I have done quite a bit of refactoring and added some extra tests.

When I try using the forkserver start method on the OSX Tiger buildbot (the 
only OSX one available) I get errors.  I have disabled the tests for OSX, but 
it seemed to be working before.  Maybe that was with a different buildbot.

--

___
Python tracker 

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



[issue18680] JSONDecoder should document that it raises a ValueError for malformed data

2013-08-07 Thread Corey Farwell

New submission from Corey Farwell:

Before someone comes in and tries to correct me, I know Python documentation is 
different than Javadocs. It is common to test if the JSON is malformed using a 
try...catch. What if I want to catch something more specific than Exception? 
The only way a user would know what to catch is to `python -c "import json; 
json.loads('FAIL')"`. Many other Python modules document which exception is 
raised on invalid input/parameters.

--
assignee: docs@python
components: Documentation
messages: 194628
nosy: corey, docs@python
priority: normal
severity: normal
status: open
title: JSONDecoder should document that it raises a ValueError for malformed 
data
type: enhancement
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python 
3.4, Python 3.5

___
Python tracker 

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



[issue18676] Queue: document that zero is accepted as timeout value

2013-08-07 Thread Richard Oudkerk

Richard Oudkerk added the comment:

> IMHO it just doesn't make sense passing 0.0 as a timeout value.

I have written lots of code that looks like

timeout = max(deadline - time.time(), 0)
some_function(..., timeout=timeout)

This makes perfect sense.  Working code should not be broken -- it is the 
docsting that should be changed.

I can't think of *any* function taking a timeout which rejects a zero timeout.  
See select(), poll(), Condition.wait(), Lock.acquire(), Thread.join().  In each 
case a zero timeout causes a non-blocking call.

Also, note that the implementation does not contradict the docstring or 
documentation: they say nothing about what happens it timeout is zero (or 
negative).

--
nosy: +sbt

___
Python tracker 

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



[issue18680] JSONDecoder should document that it raises a ValueError for malformed data

2013-08-07 Thread Corey Farwell

Corey Farwell added the comment:

Ideally, this would also be decoumented in json.loads/json.load

--

___
Python tracker 

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



[issue18679] include a codec to handle escaping only control characters but not any others

2013-08-07 Thread R. David Murray

R. David Murray added the comment:

In what way does repr(x)[1:-1] not serve your use case?

--
nosy: +r.david.murray

___
Python tracker 

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



[issue18676] Queue: document that zero is accepted as timeout value

2013-08-07 Thread R. David Murray

R. David Murray added the comment:

Exactly.  0 means "Don't wait, just raise an error immediately if the queue is 
empty/full".

--

___
Python tracker 

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



[issue18671] enhance formatting in logging package

2013-08-07 Thread M. Dietrich

M. Dietrich added the comment:

thanks, it will be really helpful for me to have this fixed.

as i consider this a "bug" it would be possible to "fix" this for 2.7 and yes 
you are right, i talked about 2.7 as we are still using this version in 
production.

--
status: pending -> open

___
Python tracker 

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



[issue18671] enhance formatting in logging package

2013-08-07 Thread Vinay Sajip

Vinay Sajip added the comment:

Sorry, not for 2.7 - it's not a bug.

--

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-07 Thread Nick Coghlan

Nick Coghlan added the comment:

I pitched the idea of making it possible to skip the with statement body
quite some time ago, and Guido convinced me it was a bad idea for much the
same reason he chose PEP 343 over his original PEP 340 design: allowing
suppression of exceptions from __enter__ hides local control flow by
blurring the boundaries between with and if statements.

Regarding nested, we killed that because it was a bug magnet for context
managers that acquire the resource in __init__ (like file objects), not
because it didn't work.
It's trivial to recreate that API on top of ExitStack if you like it,
though. The only thing that doesn't work (relative to actual nested with
statements) is suppressing exceptions raised inside __enter__ methods.

--

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-07 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Hi there.
"allowing
suppression of exceptions from __enter__ hides local control flow by
blurring the boundaries between with and if statements.
"
I'm not sure what this means.  To me, it is a serious language design flaw that 
you can write a context manager, and it has a well known interface that you can 
invoke manually, but that you cannot take two existing context managers and 
assemble them into a nested one, correctly, however much you wiggle.
In my mind, allowing context managers to skip the managed body breaks new 
ground.  Both, by allowing this "combination" to be possible.  And also by 
opening up new and exciting applications for context managers.  If you saw 
Raymond's talk last Pycon, you should feel inspired to do new and exciting 
things with them.

the bug-magnet you speak of I already addressed in my patch with 
nested-delayed, more as a measure of completeness (address both the problems 
that old "nested" had.  The more serious bug (IMHO) is the suppression of 
__enter__ exceptions.

--

___
Python tracker 

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



[issue18416] Move to absolute file paths for module.__file__

2013-08-07 Thread Madison May

Madison May added the comment:

Nick, it was definitely a good thing to mention.  I had to learn the "edit, 
build, test" cycle the hard way my first time.  It took me a good 15-20 minutes 
to figure out why none of my edits seemed to change anything :)


Anyhow, here's how I see the issue. It seems like we have three main options:

In option one, we only modify PathFinder._path_importer_cache().

 if path == '':
-path = '.'
+path = _os.getcwd()

This associates the cwd with FileFinder(cwd) in sys.path_importer_cache

In option two, we only modify FileFinder.__init__().

-self.path = path or '.'
+if not path or path == '.':
+path = _os.getcwd()
+self.path = path

This associates '.' with FileFinder(cwd) in sys.path_importer_cache.

In option three, we modify both PathFinder and FileFinder.  In 
PathFinder._path_importer_cache() we remove the line that reassigns path to '.' 
if path is the empty string.

-if path == '':
-path = '.'

In FileFinder.__init__(), we set path to _os.getcwd() if path is false.

-self.path = path or '.'
+self.path = path or _os.getcwd() 

This associates the empty string with FileFinder(cwd) in 
sys.path_importer_cache.

What are your thoughts? Which solution would you all support?

--

___
Python tracker 

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



[issue18676] Queue: document that zero is accepted as timeout value

2013-08-07 Thread Zhongyue Luo

Changes by Zhongyue Luo :


--
keywords: +patch
Added file: http://bugs.python.org/file31187/queue_timeout_docstring.patch

___
Python tracker 

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



[issue18676] Queue: document that zero is accepted as timeout value

2013-08-07 Thread Zhongyue Luo

Changes by Zhongyue Luo :


Added file: http://bugs.python.org/file31188/queue_timeout_docstring.patch

___
Python tracker 

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



[issue18676] Queue: document that zero is accepted as timeout value

2013-08-07 Thread Zhongyue Luo

Changes by Zhongyue Luo :


Added file: http://bugs.python.org/file31189/queue_timeout_docstring.patch

___
Python tracker 

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



[issue18526] Add resource management/guarding to unittest

2013-08-07 Thread Zachary Ware

Zachary Ware added the comment:

(Apologies for the delay in replies, my available time evaporated without 
notice...)

Antoine Pitrou wrote:
> Does registerResource() mutate some kind of global per-process state? This
> doesn't sound like a good idea.

It's not the greatest of ideas, no; but I hadn't come up with a better one
yet :).  Robert's review has given me a couple ideas to try to avoid this,
though.

> (and even less so the "default resources", IMO: these are stdlib test
> suite-specific)

That is true, though I attempted to pick out some of the ones used by our test
suite that are most likely to be applicable elsewhere.  I had a couple misses,
though, and I'm not against removing the defaults entirely.

---

Michael Foord wrote:
> My question is, is this generally useful enough for test suites beyond the
> Python standard library. Essentially it provides a command line interface to
> specialized test skipping.

To be honest, I'm not sure.  Theoretically, I can think of several situations
where it would be useful, but I have no concrete examples aside from the Pytohn
test suite.

> I *still* feel that a generalized mechanism for adding command line options to
> the standard test runner would allow for this and a myriad of other slightly
> specialized use cases. It's hard to see how to do that cleanly without full
> blown extension machinery (which I'm in favour of and have prototyped but it
> is a *much* bigger change set)

Is your prototype available anywhere for me to get a better idea what you mean?
That could indeed be a much better approach if it is what I think it is.

---

Robert Collins wrote:
> I'll do a full review shortly, but at the conceptual level, I don't see any
> benefit in making a new SkipTest base class, other than instantly breaking
> other runners when an unknown exception is raised. SkipTest is part of the
> API. Making a new exception part of the API requires a strong reason - not
> just 'we want to show it differently' but 'we want the runner to behave
> differently.

Actually, the real reason I created the new _BaseSkip exception was to avoid an
import loop between resources.py and case.py.  I think I was trying to keep
SkipTest defined in case.py, but in retrospect it is much saner to just move
it to util.py and import from there in both other modules, and directly subclass
SkipTest for the new Resource exceptions.  I'll respond to your review on 
Rietveld and with a new patch, as time allows (hopefully before the next alpha).

---

Thanks to all three of you for your comments :)

--

___
Python tracker 

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



[issue16248] Security bug in tkinter allows for untrusted, arbitrary code execution.

2013-08-07 Thread Zachary Ware

Zachary Ware added the comment:

Antoine Pitrou wrote:
> I've committed a fix to 2.7 (I hope it's really a fix, since I don't know how 
> to test it).
> I'll let Benjamin and Barry decide whether to backport to 2.6 and 3.2.
> As for 3.1, it's pretty much dead.

That fix does work, but it should probably get a NEWS entry since it fixes a 
regression from 2.7.3 to 2.7.5.

Also, I think the same fix should be backported to all three of 2.6, 3.1, and 
3.2.  The same regression as in 2.7.5 exists in 3.2.5, and would be introduced 
by the next (last?) releases of 2.6 and 3.1.

Sorry to have broken every possible version of Python :S

--

___
Python tracker 

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



[issue18273] Simplify calling and discovery of json test package

2013-08-07 Thread Zachary Ware

Zachary Ware added the comment:

Here's a new patch; test_json.__main__ now uses an absolute import rather than 
trying to use a relative one.  Also, Makefile.pre.in is fixed (thank you, Ned!).

--
Added file: http://bugs.python.org/file31190/test_json_discovery.v2-3.3.diff

___
Python tracker 

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



[issue18681] typo in imp.reload

2013-08-07 Thread Weizhao Li

New submission from Weizhao Li:

just a typo:

270c270
< raise ImportError(msg.format(parentname), name=parent_name)
---
> raise ImportError(msg.format(parent_name), name=parent_name)

--
components: Library (Lib)
messages: 194641
nosy: felloak
priority: normal
severity: normal
status: open
title: typo in imp.reload
type: behavior
versions: Python 3.3

___
Python tracker 

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



[issue18677] Enhanced context managers with ContextManagerExit and None

2013-08-07 Thread Eric Snow

Eric Snow added the comment:

Nick was probably talking about what is further elaborated in PEP 343.  I'd 
recommend taking a particular look at the "Motivation and Summary" section 
regarding flow control macros.

--
nosy: +eric.snow

___
Python tracker 

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



[issue16968] Fix test discovery for test_concurrent_futures.py

2013-08-07 Thread Zachary Ware

Zachary Ware added the comment:

That's a much better solution, thank you, Serhiy.  Here's a new patch.  
test.support is no longer changed at all, but regrtest.py still is; the extra 
reference to the tests still causes issues, so it is removed.

--
Added file: 
http://bugs.python.org/file31191/test_concurrent_futures_discovery.v5.diff

___
Python tracker 

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



[issue18583] Idle: enhance FormatParagraph

2013-08-07 Thread Terry J. Reedy

Changes by Terry J. Reedy :


--
dependencies: +IDLE Unit test for FormatParagrah.py

___
Python tracker 

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



[issue18226] IDLE Unit test for FormatParagrah.py

2013-08-07 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Added tests to get 100% coverage (not counting in __name__ block).
More test cleanups. Some of the extra newlines come from getting to 'end' 
instead of 'insert'. Others are avoided by adding newline to end of test 
strings, which is more realistic anyway. I commented out tests that I think 
test bad behavior that should be changed.

--
Added file: http://bugs.python.org/file31192/18226FormatPara8.diff

___
Python tracker 

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



[issue15301] os.chown: OverflowError: Python int too large to convert to C long

2013-08-07 Thread Larry Hastings

Larry Hastings added the comment:

Benjamin, do you want my elaborate fix in for 2.7?  It means adding two new 
converters, one for pid and one for gid, and switching everything that takes 
pid/gid arguments to use those.

--
nosy: +benjamin.peterson

___
Python tracker 

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