[issue16507] Patch selectmodule.c to support WSAPoll on Windows

2012-11-19 Thread Trent Nelson

Trent Nelson added the comment:

On Sun, Nov 18, 2012 at 03:19:19PM -0800, Antoine Pitrou wrote:
> 
> Antoine Pitrou added the comment:
> 
> Related post:
> http://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/

Yeah, came across that yesterday.  Few other relevant links, for the
records:


http://social.msdn.microsoft.com/Forums/en/wsk/thread/18769abd-fca0-4d3c-9884-1a38ce27ae90
 (has a code example of what doesn't work)


http://www.codeproject.com/Articles/140533/The-Differences-Between-Network-Calls-in-Windows-a

http://blogs.msdn.com/b/wndp/archive/2006/10/26/wsapoll.aspx

http://curl.haxx.se/mail/lib-2012-10/0038.html

--

___
Python tracker 

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



[issue16499] CLI option for isolated mode

2012-11-19 Thread Marc-Andre Lemburg

Marc-Andre Lemburg added the comment:

On 18.11.2012 15:30, Christian Heimes wrote:
> 
> Christian Heimes added the comment:
> 
> The first patch implements the arg parsing, sys.flags, PySys_SetArgv() 
> modification that doesn't include the current directory as sys.path[0] and 
> some doc updates.
> 
> Open issue:
> 
>  - MAL has addressed concerns that '-I' is too similar to GCC's -I (include 
> path) option
>  - Is 'isolated mode' a good term to describe the feature? IMO 'restricted 
> mode' is also a good name but it sounds too similar to PyPy's restricted 
> python.

Some other possible names:

 - unmodified mode (-U)
 - encapsulated mode (-e)
 - installation only mode (-I)
 - non-local mode (-l)

Since this mode will often be used for testing Python installation
and setup issues, perhaps emphasizing on the testing nature would
be good...

 - test installation mode (-T)

FWIW: Isolated and -I works for me as well.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Nov 19 2012)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...   http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...http://python.egenix.com/


::: Try our new mxODBC.Connect Python Database Interface for free ! 

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
   Registered at Amtsgericht Duesseldorf: HRB 46611
   http://www.egenix.com/company/contact/

--

___
Python tracker 

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



[issue13538] Improve doc for str(bytesobject)

2012-11-19 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Updating patch after Ezio's review on Rietveld.

--
Added file: http://bugs.python.org/file28040/issue-13538-6-default.patch

___
Python tracker 

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



[issue16493] Document the 'optimize' argument to compile()

2012-11-19 Thread Kushal Das

Kushal Das added the comment:

I guess somebody already did the work 
http://docs.python.org/3.4/library/functions.html?highlight=compile#compile ?

--

___
Python tracker 

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



[issue16493] Document the 'optimize' argument to compile()

2012-11-19 Thread Ezio Melotti

Ezio Melotti added the comment:

Looks like Georg did: 713c6b6ca5ce.
The documentation is missing on 2.7, but AFAICT that's because the arg is only 
in 3.2+.
Brett, if you meant that this should be documented somewhere else, feel free to 
reopen the issue.

--
resolution:  -> out of date
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



[issue16510] Using appropriate checks in tests

2012-11-19 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

The proposed patch upgrades tests to use specialized checks added in 3.1 and 
3.2 (assertIsNone(x) instead assertTrue(x is None), assertLess(a, b) instead 
assertTrue(a < b), etc).  This modern checks provide a more useful error 
message in case of a fail.

Replaced only those checks that are not related to the tested operators.  For 
example, assertTrue(a < b) preserved if the operator "<" is tested.

--
components: Tests
files: tests_asserts.patch
keywords: patch
messages: 175953
nosy: ezio.melotti, michael.foord, pitrou, serhiy.storchaka
priority: normal
severity: normal
stage: patch review
status: open
title: Using appropriate checks in tests
type: enhancement
versions: Python 3.4
Added file: http://bugs.python.org/file28041/tests_asserts.patch

___
Python tracker 

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



[issue11679] readline interferes with characters beginning with byte \xe9

2012-11-19 Thread Thomas Kluyver

Thomas Kluyver added the comment:

OK, thanks, and sorry for the noise. I've closed this issue.

Looking at the readline manual, it looks like this is tied up with the options 
input-meta, output-meta and convert-meta. Fiddling around with .inputrc hasn't 
clarified exactly what they do, but it seems that the terminal can either 
handle unicode, or shortcuts involving meta (alt), but not both.

--
resolution:  -> invalid
status: open -> closed

___
Python tracker 

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



[issue16475] Support object instancing and recursion in marshal

2012-11-19 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

If you have string sharing, adding support for general sharing falls 
automatically out without any effort.  There is no reason _not_ to support it, 
in other words.
Marshal may be primarily used for .pyc files but it is not the only usage.  It 
is a very fast and powerful serializer for data that is not subject to the 
overhead or safety concerns of the general pickle protocol.  This is 
illustrated by the following code (2.7):

case TYPE_CODE:
if (PyEval_GetRestricted()) {
PyErr_SetString(PyExc_RuntimeError,
"cannot unmarshal code objects in "
"restricted execution mode");
Obviously, this shows that marshal is still expected to work and be useful even 
if not for pickling code objects.

It is good to know that you care about the size of the .pyc files, Martin.  But 
we should bear in mind that this size difference is directly reflected in the 
memory use of the loaded data.  A reduction by 25% of the .pyc size is roughly 
equivalent to a 25% memory use reduction by the loaded code object.

I haven't produced data about the savings of general object reuse because it 
relies on my "recode" code optimizer module which is still work in progress.  
However, I will do some tests and let you know.  Suffice to say that it is 
enormously frustrating to re-generate code objects with an optimization tool, 
sharing common or identical sub-objects and so on, and then finding that the 
marshal module undoes all of that.

I'll report back with additional figures.

--

___
Python tracker 

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



[issue16510] Using appropriate checks in tests

2012-11-19 Thread R. David Murray

R. David Murray added the comment:

Thanks for the work, but we don't generally make bulk changes like this.  It 
generates churn in the codebase, and has the risk of inadvertently changing the 
meaning of the tests, to little actual benefit.  Instead we modernize tests 
when we touch them for other reasons and are in a position to confirm that the 
changes do not change the meaning of the tests.  (I realize that for most of 
your changes the meaning is trivially preserved...but when you make a lot of 
changes you are almost certain to make some mistakes...thus the resistance to 
doing bulk updates.)

--
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



[issue16506] devguide should have table of contents

2012-11-19 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Attaching patch.  Out-of-the-box at least, Sphinx seems to have the constraint 
that the "home page" (what the link in the upper-left corner points to) needs 
to be the same as the table of contents (what the "table of contents" link in 
the left column points to).

Retaining the same home page seems to be the most important, so for now at 
least, I'm proposing putting the table of contents at the bottom of the home 
page (with the home page itself not part of the contents).

I also re-did the header formatting for a few pages to make the nesting levels 
match the page list.

--
keywords: +needs review, patch
stage:  -> patch review
Added file: http://bugs.python.org/file28042/issue-16506-1.patch

___
Python tracker 

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



[issue16506] devguide should have table of contents

2012-11-19 Thread Nick Coghlan

Nick Coghlan added the comment:

Sounds good to me - I was looking for a link to the maintainer list the other 
day, and there doesn't appear to be one at the moment. Having a reasonably 
complete ToC/site map deals with that kind of problem, and putting it at the 
bottom helps avoid overwhelming newcomers.

--

___
Python tracker 

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



[issue16475] Support object instancing and recursion in marshal

2012-11-19 Thread Christian Heimes

Changes by Christian Heimes :


--
nosy: +christian.heimes

___
Python tracker 

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



[issue16475] Support object instancing and recursion in marshal

2012-11-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is no many sense to use references for TYPE_INT whose representation size 
not greater then a reference representation size.  I doubt about references to 
mutable objects.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue16510] Using appropriate checks in tests

2012-11-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I understand this.  I checked the patch few times, with long (more than a 
month) intervals between inspections.  If someone wants to modernize some 
tests, he can turn to this patch for reference.

--

___
Python tracker 

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



[issue9613] Python considers pid longs under 64-bit Windows

2012-11-19 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

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



[issue3580] failures in test_os

2012-11-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Is this reproduced on modern Python versions?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue16491] try-except-raise-bug

2012-11-19 Thread Ezio Melotti

Changes by Ezio Melotti :


--
nosy: +ezio.melotti
status: open -> pending

___
Python tracker 

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



[issue16475] Support object instancing and recursion in marshal

2012-11-19 Thread Kristján Valur Jónsson

Kristján Valur Jónsson added the comment:

Ok, I did some tests with my recode module.  The following are the sizes of the 
marshal data:

test2To3 ... 24748 24748 212430 212430
test3To3 ... 18420 17848 178969 174806
test4To3 ... 18425 18411 178969 178550

The columns:
a) test_marshal.py without transform
b) test_marshal.py with recode.intern() (folding common objects)
c) and d): decimal.py module (the largest one in lib)

The lines:
1) Version 2 of the protocol.
2) Version 3 of the protocol (object instancing and the works)
3) Version 4, an dummy version that only instances strings)

As expected, there is no difference between version 3 and 4 unless I employ the 
recode module to fold common subobjects.  This brings an additional saving of 
some 3% bringing the total reduction up to 28% and 
18% respectively.

Note that the transform is a simple recursive folding of objects.  common 
argument lists, such as (self) are subject to this.  No renaming of local 
variables or other stripping is performed.
So, although the "recode" module is work in progress, and not the subject of 
this "defect", its use shows how it is important to be able to support proper 
instancing in serialization protocols.

Implementation note:  The trick of using a bit flag on the type to indicate a 
slot reservation in the instance list is one that has been in use in CCP´s own 
"Marshal" format, a proprietary serialization format based on marshal back in 
2002 (adding many more special opcodes and other stuff)

Serhiy: There is no reason _not_ to reuse INT objects if we are doing it for 
other immutables to.  As you note, the size of the data is the same. This will 
ensure that integers that are not cached can be folded into the same object, 
e.g. the value 123, if used in two functions, can be the same int object.

I should also point out that the marshal protocol takes care to be able to 
serialize lists, sets and frozensets correctly, the latter being added in 
version 2.4.  This despite the fact that code objects don't make use of these.

--

___
Python tracker 

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



[issue16475] Support object instancing and recursion in marshal

2012-11-19 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> The following are the sizes of the marshal data:

Can you please measure the time of unmarshalling? It would be interesting. If 
you can count the statistics about marshalled types (what percent of shared and 
non shared integers, strings, etc), it would also be very interesting.

> There is no reason _not_ to reuse INT objects if we are doing it for other 
> immutables to.

There is at least one reason. This increases size of the refs table.

--

___
Python tracker 

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



[issue16475] Support object instancing and recursion in marshal

2012-11-19 Thread Antoine Pitrou

Antoine Pitrou added the comment:

> I should also point out that the marshal protocol takes care to be
> able to serialize lists, sets and frozensets correctly, the latter
> being added in version 2.4.  This despite the fact that code objects
> don't make use of these.

Code objects do use frozensets:

>>> def f(x):
... return x in {1,2,3,4,5,6}
... 
>>> dis.dis(f)
  2   0 LOAD_FAST0 (x) 
  3 LOAD_CONST   7 (frozenset({1, 2, 3, 4, 5, 6})) 
  6 COMPARE_OP   6 (in) 
  9 RETURN_VALUE 

I don't think marshal supports any type that isn't (or hasn't been)
used in code objects.

> Obviously, this shows that marshal is still expected to work and be
> useful even if not for pickling code objects.

The module officially intended for general-purpose serialization is
pickle; if you use marshal for such a purpose, you're on your own.
If you think pickle is not good enough, your improvements are welcome.

> As expected, there is no difference between version 3 and 4 unless
> I employ the recode module to fold common subobjects.  This brings
> an additional saving of some 3% bringing the total reduction up to
> 28% and 18% respectively.

3% doesn't sound like a worthwhile improvement at all.

> The trick of using a bit flag on the type to indicate a slot
> reservation in the instance list is one that has been in use in
> CCP´s own "Marshal" format, a proprietary serialization format
> based on marshal back in 2002 (adding many more special opcodes
> and other stuff)

Why don't you release your "proprietary marshal" on pypi? You would
get feedback and a sense of whether people are interested in your
approach.

--

___
Python tracker 

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



[issue16496] Simplify and optimize random_seed()

2012-11-19 Thread Mark Dickinson

Changes by Mark Dickinson :


--
assignee:  -> mark.dickinson

___
Python tracker 

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



[issue16499] CLI option for isolated mode

2012-11-19 Thread Christian Heimes

Changes by Christian Heimes :


Removed file: http://bugs.python.org/file28024/isolatemode.patch

___
Python tracker 

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



[issue16499] CLI option for isolated mode

2012-11-19 Thread Christian Heimes

Changes by Christian Heimes :


Removed file: http://bugs.python.org/file28036/isolatemode2.patch

___
Python tracker 

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



[issue16499] CLI option for isolated mode

2012-11-19 Thread Christian Heimes

Christian Heimes added the comment:

New patch with typo fixes and update for recent modification in the 
make_flags() function.

Marc:
The patch was motivated by use cases like Barry's issue with 3rd party software 
that accidentally messes with Python scripts like lsb_release. Your use case 
(testing) is valid but not the main focus here. Unmodified mode doesn't fit the 
bill either, Python can still import system wide packages or modifications from 
a venv.

Apropos venv, I need to check how the option is affected by venv.

--
Added file: http://bugs.python.org/file28043/isolatemode3.patch

___
Python tracker 

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



[issue16506] devguide should have table of contents

2012-11-19 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 996b72dd1e31 by Chris Jerdonek in branch 'default':
Unhide and move table of contents to bottom of home page (issue #16506).
http://hg.python.org/devguide/rev/996b72dd1e31

--
nosy: +python-dev

___
Python tracker 

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



[issue16506] devguide should have table of contents

2012-11-19 Thread Chris Jerdonek

Changes by Chris Jerdonek :


--
resolution:  -> fixed
stage: patch review -> 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



[issue16500] Add an 'afterfork' module

2012-11-19 Thread Christian Heimes

Christian Heimes added the comment:

Thanks Richard!

My first reaction was YAGNI but after I read the two tickets I now understand 
the need for three different hooks. I suggest that we implement our own hooks 
like the http://linux.die.net/man/3/pthread_atfork function, especially the 
order of function calls:

The parent and child fork handlers shall be called in the order in which they 
were established by calls to pthread_atfork().  The prepare fork handlers shall 
be called in the opposite order.

I like to focus on three hooks + the Python API and leave the usage of the 
hooks to other developers.

Proposal:
* Introduce a new module called atfork (Modules/atforkmodule.c) that is build 
into the core.
* Move PyOS_AfterFork to Modules/atforkmodule.c.
* Add PyOS_BeforeFork() (or PyOS_PrepareFork() ?) and PyOS_AfterForkParent() 
* call the two new methods around the calls to fork() in the stdlib.

I'm not yet sure how to implement the Python API. I could either implement six 
methods:

  atfork.register_before_fork(callable, *args, **kwargs)
  atfork.register_after_fork_child(callable, *args, **kwargs)
  atfork.register_after_fork_parent(callable, *args, **kwargs)
  atfork.unregister_before_fork(callable)
  atfork.unregister_after_fork_child(callable)
  atfork.unregister_after_fork_parent(callable)

or two:

  atfork.register(prepare=None, parent=None, child=None, *args, **kwargs)
  atfork.unregister(prepare=None, parent=None, child=None)

--
nosy: +gregory.p.smith, twouters

___
Python tracker 

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



[issue16482] pdb.set_trace() clobbering traceback on error

2012-11-19 Thread Xavier de Gaye

Xavier de Gaye added the comment:

The top level frame line number is not updated because it has a local
trace function while the global trace function is None. This is
related to issue 7238.

The following patch fixes the issue. The patch removes the local trace
at the top level frame and makes sure it is not reinstalled when
returning from the current trace function.

diff --git a/Lib/bdb.py b/Lib/bdb.py
--- a/Lib/bdb.py
+++ b/Lib/bdb.py
@@ -64,6 +64,10 @@
 if self.stop_here(frame) or self.break_here(frame):
 self.user_line(frame)
 if self.quitting: raise BdbQuit
+# Do not re-install the local trace when we are finished debugging,
+# see issues 16482 and 7238.
+if not sys.gettrace():
+return None
 return self.trace_dispatch
 
 def dispatch_call(self, frame, arg):
@@ -231,8 +235,10 @@
 # no breakpoints; run without debugger overhead
 sys.settrace(None)
 frame = sys._getframe().f_back
-while frame and frame is not self.botframe:
+while frame:
 del frame.f_trace
+if frame is self.botframe:
+break
 frame = frame.f_back
 
 def set_quit(self):


The following code is a minimum implementation of pdb with the patch
applied and the associated code to test it.

class Bdb:

def trace_dispatch(self, frame, event, arg):
self.set_continue()
if sys.gettrace():
return self.trace_dispatch

def set_trace(self, frame):
self.botframe = frame
frame.f_trace = self.trace_dispatch
sys.settrace(self.trace_dispatch)

def set_continue(self):
sys.settrace(None)
del self.botframe.f_trace

frame = sys._getframe()
d = Bdb()
d.set_trace(frame)

y = "line of code not triggering an error"
x = 1
assert x != 1

--
nosy: +xdegaye

___
Python tracker 

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



[issue7238] frame.f_lineno doesn't get updated after local trace function assigned to it

2012-11-19 Thread Xavier de Gaye

Xavier de Gaye added the comment:

See also the related issue 16482.

--
nosy: +xdegaye

___
Python tracker 

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



[issue16180] cannot quit pdb when there is a syntax error in the debuggee (must kill it)

2012-11-19 Thread rurpy the second

rurpy the second added the comment:

This continues to be a problem on Python-3.3.0

--
nosy: +rurpy2
versions: +Python 3.3 -Python 3.2

___
Python tracker 

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



[issue3580] failures in test_os

2012-11-19 Thread Antoine Pitrou

Antoine Pitrou added the comment:

I don't know. Anyway, it is not really a Python bug, so I suggest we close it.

--
resolution:  -> invalid
status: open -> pending

___
Python tracker 

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



[issue1284316] Win32: Security problem with default installation directory

2012-11-19 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +tim.golden

___
Python tracker 

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



[issue16500] Add an 'afterfork' module

2012-11-19 Thread Richard Oudkerk

Richard Oudkerk added the comment:

Note that Gregory P. Smith has written

http://code.google.com/p/python-atfork/

I also started a pure python patch but did not get round it posting it.  (It 
also implements the fork lock idea.)  I'll attach it here.

How do you intend to handle the propagation of exceptions?  I decided that after

atfork.atfork(prepare1, parent1, child1)
atfork.atfork(prepare2, parent2, child2)
...
atfork.atfork(prepareN, parentN, childN)

calling "pid = os.fork()" should be equivalent to

pid = None
prepareN()
try:
...
prepare2()
try:
prepare1()
try:
pid = posix.fork()
finally:
parent1() if pid != 0 else child1()
finally:
parent2() if pid != 0 else child2()
...
finally:
parentN() if pid != 0 else childN()

--
keywords: +patch
Added file: http://bugs.python.org/file28044/pure-python-atfork.patch

___
Python tracker 

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



[issue16500] Add an 'afterfork' module

2012-11-19 Thread Gregory P. Smith

Gregory P. Smith added the comment:

I would not allow exceptions to propagate. No caller is expecting them.

--

___
Python tracker 

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



[issue16500] Add an 'afterfork' module

2012-11-19 Thread Gregory P. Smith

Gregory P. Smith added the comment:

pthread_atfork() cannot be used to implement this. Another non-python
thread started by a C extension module or the C application that is
embedding Python within it is always free to call fork() on its own with
zero knowledge that Python even exists at all. It's guaranteed that fork
will be called while the Python GIL is held in this situation which would
cause any pre-fork thing registered by Python to deadlock.

At best, this can be implemented manually as we do with some of the before
and after fork stuff today but it must come with the caveat warning that it
cannot guarantee that these things are actually called before and after
fork() other than direct os.fork() calls from Python code or extremely
Python aware C extension modules that may call fork() (very rare, most C &
C++ libraries an extension module may be using assume that they've got the
run of the house).  ie: this problem is unsolvable unless you control 100%
of the code being used by your entire user application.

On Mon, Nov 19, 2012 at 3:59 PM, Gregory P. Smith wrote:

>
> Gregory P. Smith added the comment:
>
> I would not allow exceptions to propagate. No caller is expecting them.
>
> --
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue16500] Add an 'afterfork' module

2012-11-19 Thread Christian Heimes

Christian Heimes added the comment:

Meh! Exception handling takes all the fun of the API and is going to make it 
MUCH more complicated. pthread_atfork() ignores error handling for a good 
reason. It's going to be hard to get it right. :/

IFF we are going to walk the hard and rocky road of exception handling, then we 
are going to need at least four hooks and a register function that takres four 
callables as arguments: register(prepare, error, parent, child). Each prepare() 
call pushes an error handling onto a stack. In case of an exception in a 
prepare handler, the error stack is popped until all error handlers are called. 
This approach allows a prepare handler to actually prevent a fork() call from 
succeeding.

The parent and child hooks are always called no matter what. Exception are 
recorded and a warning is emitted when at least one hook fails. We might raise 
an exception but it has to be a special exception that ships information if 
fork() has succeeded, if the code runs in child or parent and about the child's 
PID.

I fear it's going to be *really* hard to get everything right.

Gregory made a good point, too. We can rely on pthread_atfork() as we are 
unable to predict how third party code is using fork(): "Take cover, dead locks 
ahead!" :) A cooperative design of the C API with three function is my 
preferred way, too. PyOS_AfterForkParent() should take an argument to signal a 
failed fork() call.

--

___
Python tracker 

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



[issue13538] Improve doc for str(bytesobject)

2012-11-19 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Attaching new patch to address Ezio's further comments (for the convenience of 
comparing in Rietveld).  I will be committing this.

--
Added file: http://bugs.python.org/file28045/issue-13538-7-default.patch

___
Python tracker 

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



[issue13538] Improve doc for str(bytesobject)

2012-11-19 Thread Éric Araujo

Éric Araujo added the comment:

I left a few remarks.  The patch is very nice, thanks!

--

___
Python tracker 

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



[issue13538] Improve doc for str(bytesobject)

2012-11-19 Thread Chris Jerdonek

Chris Jerdonek added the comment:

Thanks, Éric!  (And thanks also to Ezio who helped quite a bit with the 
improvements.)  I replied to your comments on Rietveld.

--

___
Python tracker 

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



[issue16508] include the "object" type in the lists of documented types

2012-11-19 Thread Chris Jerdonek

Changes by Chris Jerdonek :


--
assignee: docs@python -> chris.jerdonek

___
Python tracker 

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