[Python-Dev] Make socket support TIPC

2007-12-18 Thread Alberto Bertogli

Hi!

I wrote a patch adding TIPC support to the socket module, you can find
it in http://bugs.python.org/issue1646.

TIPC (http://tipc.sf.net) is an open protocol designed for use in
clustered computer environments. It currently has an open source
implementation for Linux (>= 2.6.16), and VxWorks.

On #python-dev, a very friendly person (whose name/nick I can't recall,
I had a power cut and lost my IRC session) helped me with the submission
explained that the patch will probably get rejected in order to keep the
core slim, and suggested I should send an email to this mailing list so
it can be discussed.

I already wrote an external module to support TIPC
(http://auriga.wearlab.de/~alb/pytipc/), but given that the socket
module already supports Linux-specific protocols (AF_PACKET and
AF_NETLINK), and the code impact was (IMHO) small, I wrote a patch to
add TIPC support.


The patch consists of adding the TIPC constants, and modifying
makesockaddr(), getsockaddrarg() and getsockaddrlen() to handle the
TIPC addresses. No generic code is changed.

Compilation is completely conditional on having the TIPC headers, and
has no runtime dependencies.

The diff adds 156 new lines and changes 2, and on x86 increases code
size by about 2k:

   textdata bss dec hex filename
  37158   11980  20   49158c006 /tmp/so/wo-tipc.so
  39162   11980  20   51162c7da /tmp/so/w-tipc.so


Thanks a lot,
Alberto


___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] 1-tuple trailing comma

2007-12-18 Thread Calvin Spealman
I just had an issue brought up by another developer who had a  
trailing comma on an assignment causing a 1-tuple he did not expect.  
We were talking about it and came to the conclusion that it is at  
least worth bringing up the idea of enforcing a SyntaxError in the  
case of this. 1-tuple syntax is already an odd-man-out, so requiring  
more explicitness about it would catch some errors and be more  
readable. I think we could agree that a tuple of 2 or more elements  
is much easier to read without parens than a 1-tuple without parens.  
Aside from assignment I can't think of a single place when one would  
construct a 1-tuple without parens.

This is the offending erroneous and hard-to-catch code:

if foo:
bar = 3,
L = [1,
2,
bar]

Would there be any possibility in considering further refining the 1- 
tuple syntax to require parens because of its nature?
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


[Python-Dev] 'with' __exit__ doesn't set sys.exc_info()

2007-12-18 Thread Mike Stall
Can somebody confirm the following behavior is expected: When a 'with' 
statement invokes __exit__(), it looks like sys.exc_info() is not actually set.

I know this may be a very pedantic detail,  but I'm working on IronPython and 
would like to make it consistent with CPython's behavior.

The PEP (http://www.python.org/dev/peps/pep-0343/ ) says that 'With' can be 
substituted as follows:

mgr = (EXPR)
exit = mgr.__exit__  # Not calling it yet
value = mgr.__enter__()
exc = True
try:
try:
VAR = value  # Only if "as VAR" is present
BLOCK
except:
# The exceptional case is handled here
exc = False
if not exit(*sys.exc_info()):
raise
# The exception is swallowed if exit() returns true
finally:
# The normal and non-local-goto cases are handled here
if exc:
exit(None, None, None)

and that "The details of the above translation are intended to prescribe the 
exact semantics.". This implies that sys.exc_info() would be set when exit is 
invoked.

I'm finding in practice that sys.exc_info() is not set when __exit__() is 
invoked in the exceptional case.   I attached a simple repro (repro.py) to 
demonstrate exactly what I mean.

Can somebody confirm this is the expected behavior?

Thanks,
Mike
http://blogs.msdn.com/jmstall




repro.py
Description: repro.py
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] 1-tuple trailing comma

2007-12-18 Thread Guido van Rossum
On Dec 18, 2007 7:31 AM, Calvin Spealman <[EMAIL PROTECTED]> wrote:
> I just had an issue brought up by another developer who had a
> trailing comma on an assignment causing a 1-tuple he did not expect.
> We were talking about it and came to the conclusion that it is at
> least worth bringing up the idea of enforcing a SyntaxError in the
> case of this. 1-tuple syntax is already an odd-man-out, so requiring
> more explicitness about it would catch some errors and be more
> readable. I think we could agree that a tuple of 2 or more elements
> is much easier to read without parens than a 1-tuple without parens.
> Aside from assignment I can't think of a single place when one would
> construct a 1-tuple without parens.
>
> This is the offending erroneous and hard-to-catch code:
>
> if foo:
> bar = 3,
> L = [1,
> 2,
> bar]
>
> Would there be any possibility in considering further refining the 1-
> tuple syntax to require parens because of its nature?

Why don't you try to come up with a patch to see how feasible this is?

-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com


Re: [Python-Dev] 'with' __exit__ doesn't set sys.exc_info()

2007-12-18 Thread Guido van Rossum
Since no actual except clause is used, this is reasonable, and I
wouldn't want it changed. I guess the PEP overstated the exactness of
the translation. Suggestions for better wording are accepted.

On Dec 18, 2007 10:11 AM, Mike Stall <[EMAIL PROTECTED]> wrote:
>
>
>
>
> Can somebody confirm the following behavior is expected: When a 'with'
> statement invokes __exit__(), it looks like sys.exc_info() is not actually
> set.
>
>
>
> I know this may be a very pedantic detail,  but I'm working on IronPython
> and would like to make it consistent with CPython's behavior.
>
>
>
> The PEP (http://www.python.org/dev/peps/pep-0343/ ) says that 'With' can be
> substituted as follows:
>
>
>
> mgr = (EXPR)
>
> exit = mgr.__exit__  # Not calling it yet
>
> value = mgr.__enter__()
>
> exc = True
>
> try:
>
> try:
>
> VAR = value  # Only if "as VAR" is present
>
> BLOCK
>
> except:
>
> # The exceptional case is handled here
>
> exc = False
>
> if not exit(*sys.exc_info()):
>
> raise
>
> # The exception is swallowed if exit() returns true
>
> finally:
>
> # The normal and non-local-goto cases are handled here
>
> if exc:
>
> exit(None, None, None)
>
>
>
> and that "The details of the above translation are intended to prescribe the
> exact semantics.". This implies that sys.exc_info() would be set when exit
> is invoked.
>
>
>
> I'm finding in practice that sys.exc_info() is not set when __exit__() is
> invoked in the exceptional case.   I attached a simple repro (repro.py) to
> demonstrate exactly what I mean.
>
>
>
> Can somebody confirm this is the expected behavior?
>
>
>
> Thanks,
>
> Mike
>
> http://blogs.msdn.com/jmstall
>
>
>
>
> ___
> Python-Dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/python-dev
> Unsubscribe:
> http://mail.python.org/mailman/options/python-dev/guido%40python.org
>
>



-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com