[ python-Bugs-1741218 ] string formatter %x problem with indirectly given long

2007-06-25 Thread SourceForge.net
Bugs item #1741218, was opened at 2007-06-21 20:33
Message generated for change (Comment added) made by gagenellina
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1741218&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Interpreter Core
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Kenji Noguchi (kenjinoguchi)
Assigned to: Nobody/Anonymous (nobody)
Summary: string formatter %x problem with indirectly given long 

Initial Comment:
"%x" % v fails if the v is a instance, and its __int__ returns larger than 
0x8000 on 32bit OS.

I've reported the problem at Python ML.
http://mail.python.org/pipermail/python-list/2007-June/446103.html

"%x" % int(v)
"%x" % 0x8000L

above two work fine because string formatter processes a long value 
exceptionally. It looks inconsistent. So I made this patch. 

--- stringobject.c.org  2007-06-21 13:57:54.745877000 -0700
+++ stringobject.c  2007-06-21 13:59:19.576646000 -0700
@@ -4684,6 +4684,15 @@
case 'X':
if (c == 'i')
c = 'd';
+   /* try to convert objects to number*/
+   PyNumberMethods *nb;
+   if ((nb = v->ob_type->tp_as_number) &&
+   nb->nb_int) {
+   v = (*nb->nb_int) (v);
+   if(v == NULL)
+   goto error;
+   }
+
if (PyLong_Check(v)) {
int ilen;
temp = _PyString_FormatLong(v, flags,



--

Comment By: Gabriel Genellina (gagenellina)
Date: 2007-06-25 05:38

Message:
Logged In: YES 
user_id=479790
Originator: NO

Patch #1742669 tries to fix this problem and is a bit more generic.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1741218&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742837 ] Documentation for BaseHTTPServer.HTTPServer

2007-06-25 Thread SourceForge.net
Bugs item #1742837, was opened at 2007-06-25 09:24
Message generated for change (Comment added) made by bmintern
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742837&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Brandon Mintern (bmintern)
Assigned to: Nobody/Anonymous (nobody)
Summary: Documentation for BaseHTTPServer.HTTPServer

Initial Comment:
I have frequently used the BaseHTTPServer.HTTPServer class to create servers to 
perform a variety of tasks. In the past, I have always simply created an 
instance of the class and invoked "serve_forever" (as shown in 
http://docs.python.org/lib/module-BaseHTTPServer.html).

This time around, however, I needed to be able to run the server inside a while 
loop, so that I could eventually terminate the server. The docs.python.org site 
has no real documentation indicating how to do this, since the HTTPServer class 
is not really documented. I found the information I needed at 
http://pydoc.org/2.4.1/BaseHTTPServer.html#HTTPServer.

This is a request to include more information on HTTPServer on the 
docs.python.org site, especially documentation for functions like 
handle_request(). I understand that HTTPServer inherits from 
SocketServer.TCPServer, which inherits from SocketServer.BaseServer, and that 
is where this method comes from. For this reason, it doesn't really make sense 
to duplicate that information. I would simply like to see another use case to 
supplement the first one, i.e.

## What is there already

def run(server_class=BaseHTTPServer.HTTPServer,
handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
httpd.serve_forever()

## I would like to see something like the following added

def run_while_true(keep_running,
   server_class=BaseHTTPServer.HTTPServer,
   handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
"""keep_running is a function of no arguments which is tested initially and
after each request. If its return value evaluates to True, the server
continues."""
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
while keep_running:
httpd.handle_request()

--

>Comment By: Brandon Mintern (bmintern)
Date: 2007-06-25 09:28

Message:
Logged In: YES 
user_id=1827662
Originator: YES

...and of course, "while keep_running:" should actually be "while
keep_running():".  Geez, I hope this is my last comment (at least until
someone else replies).

--

Comment By: Brandon Mintern (bmintern)
Date: 2007-06-25 09:26

Message:
Logged In: YES 
user_id=1827662
Originator: YES

Wow... I'm a first time SourceForge user.  How dumb is it that they don't
wrap comments in pre tags, knowing that there will probably be a lot of
code snippets posted? I hope you can tell what I meant above.  Just pretend
that it's all indented as it should be :)

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742837&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742837 ] Documentation for BaseHTTPServer.HTTPServer

2007-06-25 Thread SourceForge.net
Bugs item #1742837, was opened at 2007-06-25 09:24
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742837&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Brandon Mintern (bmintern)
Assigned to: Nobody/Anonymous (nobody)
Summary: Documentation for BaseHTTPServer.HTTPServer

Initial Comment:
I have frequently used the BaseHTTPServer.HTTPServer class to create servers to 
perform a variety of tasks. In the past, I have always simply created an 
instance of the class and invoked "serve_forever" (as shown in 
http://docs.python.org/lib/module-BaseHTTPServer.html).

This time around, however, I needed to be able to run the server inside a while 
loop, so that I could eventually terminate the server. The docs.python.org site 
has no real documentation indicating how to do this, since the HTTPServer class 
is not really documented. I found the information I needed at 
http://pydoc.org/2.4.1/BaseHTTPServer.html#HTTPServer.

This is a request to include more information on HTTPServer on the 
docs.python.org site, especially documentation for functions like 
handle_request(). I understand that HTTPServer inherits from 
SocketServer.TCPServer, which inherits from SocketServer.BaseServer, and that 
is where this method comes from. For this reason, it doesn't really make sense 
to duplicate that information. I would simply like to see another use case to 
supplement the first one, i.e.

## What is there already

def run(server_class=BaseHTTPServer.HTTPServer,
handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
httpd.serve_forever()

## I would like to see something like the following added

def run_while_true(keep_running,
   server_class=BaseHTTPServer.HTTPServer,
   handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
"""keep_running is a function of no arguments which is tested initially and
after each request. If its return value evaluates to True, the server
continues."""
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
while keep_running:
httpd.handle_request()

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742837&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742837 ] Documentation for BaseHTTPServer.HTTPServer

2007-06-25 Thread SourceForge.net
Bugs item #1742837, was opened at 2007-06-25 09:24
Message generated for change (Comment added) made by bmintern
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742837&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Documentation
Group: Feature Request
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Brandon Mintern (bmintern)
Assigned to: Nobody/Anonymous (nobody)
Summary: Documentation for BaseHTTPServer.HTTPServer

Initial Comment:
I have frequently used the BaseHTTPServer.HTTPServer class to create servers to 
perform a variety of tasks. In the past, I have always simply created an 
instance of the class and invoked "serve_forever" (as shown in 
http://docs.python.org/lib/module-BaseHTTPServer.html).

This time around, however, I needed to be able to run the server inside a while 
loop, so that I could eventually terminate the server. The docs.python.org site 
has no real documentation indicating how to do this, since the HTTPServer class 
is not really documented. I found the information I needed at 
http://pydoc.org/2.4.1/BaseHTTPServer.html#HTTPServer.

This is a request to include more information on HTTPServer on the 
docs.python.org site, especially documentation for functions like 
handle_request(). I understand that HTTPServer inherits from 
SocketServer.TCPServer, which inherits from SocketServer.BaseServer, and that 
is where this method comes from. For this reason, it doesn't really make sense 
to duplicate that information. I would simply like to see another use case to 
supplement the first one, i.e.

## What is there already

def run(server_class=BaseHTTPServer.HTTPServer,
handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
httpd.serve_forever()

## I would like to see something like the following added

def run_while_true(keep_running,
   server_class=BaseHTTPServer.HTTPServer,
   handler_class=BaseHTTPServer.BaseHTTPRequestHandler):
"""keep_running is a function of no arguments which is tested initially and
after each request. If its return value evaluates to True, the server
continues."""
server_address = ('', 8000)
httpd = server_class(server_address, handler_class)
while keep_running:
httpd.handle_request()

--

>Comment By: Brandon Mintern (bmintern)
Date: 2007-06-25 09:26

Message:
Logged In: YES 
user_id=1827662
Originator: YES

Wow... I'm a first time SourceForge user.  How dumb is it that they don't
wrap comments in pre tags, knowing that there will probably be a lot of
code snippets posted? I hope you can tell what I meant above.  Just pretend
that it's all indented as it should be :)

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742837&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742889 ] Pickling of exceptions broken

2007-06-25 Thread SourceForge.net
Bugs item #1742889, was opened at 2007-06-25 14:43
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jim Fulton (dcjim)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pickling of exceptions broken

Initial Comment:

Exceptions with required initialization arguments can't be unpickled:

>>> class E(Exception):
... def __init__(self, x):
... self.x = x
... 
>>> import pickle
>>> e = E(1)
>>> p = pickle.dumps(e, 1)
>>> pickle.loads(p)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1374, in loads
return Unpickler(file).load()
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 858, in load
dispatch[key](self)
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1133, in 
load_reduce
value = func(*args)
TypeError: __init__() takes exactly 2 arguments (1 given)

This is because __reduce__ defined in exceptions.c returns the type and the 
args variable, which an exception subclass might not populate.

Also, the reduce implementation doesn't properly serialize the message 
attribute.

I assume that the need for a custom reduce is due to the micro-optimization to 
store arge and message in C slots.  Is this really necessary?


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742901 ] shlex handles 'None' poorly

2007-06-25 Thread SourceForge.net
Bugs item #1742901, was opened at 2007-06-25 15:09
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742901&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Seth Vidal (skvidal)
Assigned to: Nobody/Anonymous (nobody)
Summary: shlex handles  'None' poorly

Initial Comment:

If you pass shlex.split() None for any reason it will run forever waiting for 
input, w/o outputting anything.

That seems like the wrong behavior.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742901&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742901 ] shlex handles 'None' poorly

2007-06-25 Thread SourceForge.net
Bugs item #1742901, was opened at 2007-06-25 15:09
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742901&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.5
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Private: No
Submitted By: Seth Vidal (skvidal)
Assigned to: Nobody/Anonymous (nobody)
Summary: shlex handles  'None' poorly

Initial Comment:

If you pass shlex.split() None for any reason it will run forever waiting for 
input, w/o outputting anything.

That seems like the wrong behavior.


--

>Comment By: Georg Brandl (gbrandl)
Date: 2007-06-25 15:22

Message:
Logged In: YES 
user_id=849994
Originator: NO

This won't fix, because that comes from split() creating a shlex()
instance, which takes None as sys.stdin.

But I've added a documentation note in rev. 56084, 56085 (2.5).

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742901&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742889 ] Pickling of exceptions broken

2007-06-25 Thread SourceForge.net
Bugs item #1742889, was opened at 2007-06-25 14:43
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jim Fulton (dcjim)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pickling of exceptions broken

Initial Comment:

Exceptions with required initialization arguments can't be unpickled:

>>> class E(Exception):
... def __init__(self, x):
... self.x = x
... 
>>> import pickle
>>> e = E(1)
>>> p = pickle.dumps(e, 1)
>>> pickle.loads(p)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1374, in loads
return Unpickler(file).load()
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 858, in load
dispatch[key](self)
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1133, in 
load_reduce
value = func(*args)
TypeError: __init__() takes exactly 2 arguments (1 given)

This is because __reduce__ defined in exceptions.c returns the type and the 
args variable, which an exception subclass might not populate.

Also, the reduce implementation doesn't properly serialize the message 
attribute.

I assume that the need for a custom reduce is due to the micro-optimization to 
store arge and message in C slots.  Is this really necessary?


--

>Comment By: Georg Brandl (gbrandl)
Date: 2007-06-25 15:26

Message:
Logged In: YES 
user_id=849994
Originator: NO

AFAIR we were told that filling args and message is part of the exception
contract...

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742889 ] Pickling of exceptions broken

2007-06-25 Thread SourceForge.net
Bugs item #1742889, was opened at 2007-06-25 14:43
Message generated for change (Comment added) made by dcjim
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jim Fulton (dcjim)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pickling of exceptions broken

Initial Comment:

Exceptions with required initialization arguments can't be unpickled:

>>> class E(Exception):
... def __init__(self, x):
... self.x = x
... 
>>> import pickle
>>> e = E(1)
>>> p = pickle.dumps(e, 1)
>>> pickle.loads(p)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1374, in loads
return Unpickler(file).load()
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 858, in load
dispatch[key](self)
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1133, in 
load_reduce
value = func(*args)
TypeError: __init__() takes exactly 2 arguments (1 given)

This is because __reduce__ defined in exceptions.c returns the type and the 
args variable, which an exception subclass might not populate.

Also, the reduce implementation doesn't properly serialize the message 
attribute.

I assume that the need for a custom reduce is due to the micro-optimization to 
store arge and message in C slots.  Is this really necessary?


--

>Comment By: Jim Fulton (dcjim)
Date: 2007-06-25 15:53

Message:
Logged In: YES 
user_id=73023
Originator: YES

I'm not aware of any such contract. Can you point to anything in writing?

See for example:

file:///home/jim/Documentation/Python-Docs-2.4.1/tut/node10.html#SECTION001050

which teaches people to create custom exceptions that:

- don't set args ro message and

- won't be unpicklable in Python 2.5.

Also, as I mentioned, the reduce implementation doesn't preserve the
message, so even if that was the contract, the contract is broken.


--

Comment By: Georg Brandl (gbrandl)
Date: 2007-06-25 15:26

Message:
Logged In: YES 
user_id=849994
Originator: NO

AFAIR we were told that filling args and message is part of the exception
contract...

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742889 ] Pickling of exceptions broken

2007-06-25 Thread SourceForge.net
Bugs item #1742889, was opened at 2007-06-25 14:43
Message generated for change (Comment added) made by dcjim
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jim Fulton (dcjim)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pickling of exceptions broken

Initial Comment:

Exceptions with required initialization arguments can't be unpickled:

>>> class E(Exception):
... def __init__(self, x):
... self.x = x
... 
>>> import pickle
>>> e = E(1)
>>> p = pickle.dumps(e, 1)
>>> pickle.loads(p)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1374, in loads
return Unpickler(file).load()
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 858, in load
dispatch[key](self)
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1133, in 
load_reduce
value = func(*args)
TypeError: __init__() takes exactly 2 arguments (1 given)

This is because __reduce__ defined in exceptions.c returns the type and the 
args variable, which an exception subclass might not populate.

Also, the reduce implementation doesn't properly serialize the message 
attribute.

I assume that the need for a custom reduce is due to the micro-optimization to 
store arge and message in C slots.  Is this really necessary?


--

>Comment By: Jim Fulton (dcjim)
Date: 2007-06-25 15:57

Message:
Logged In: YES 
user_id=73023
Originator: YES

I'll note that I think the right thing to do is to:

- Take args and message out of the C struct.

- inherit the default reduce behavior from object.


--

Comment By: Jim Fulton (dcjim)
Date: 2007-06-25 15:53

Message:
Logged In: YES 
user_id=73023
Originator: YES

I'm not aware of any such contract. Can you point to anything in writing?

See for example:

file:///home/jim/Documentation/Python-Docs-2.4.1/tut/node10.html#SECTION001050

which teaches people to create custom exceptions that:

- don't set args ro message and

- won't be unpicklable in Python 2.5.

Also, as I mentioned, the reduce implementation doesn't preserve the
message, so even if that was the contract, the contract is broken.


--

Comment By: Georg Brandl (gbrandl)
Date: 2007-06-25 15:26

Message:
Logged In: YES 
user_id=849994
Originator: NO

AFAIR we were told that filling args and message is part of the exception
contract...

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742889 ] Pickling of exceptions broken

2007-06-25 Thread SourceForge.net
Bugs item #1742889, was opened at 2007-06-25 14:43
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Jim Fulton (dcjim)
Assigned to: Nobody/Anonymous (nobody)
Summary: Pickling of exceptions broken

Initial Comment:

Exceptions with required initialization arguments can't be unpickled:

>>> class E(Exception):
... def __init__(self, x):
... self.x = x
... 
>>> import pickle
>>> e = E(1)
>>> p = pickle.dumps(e, 1)
>>> pickle.loads(p)
Traceback (most recent call last):
  File "", line 1, in 
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1374, in loads
return Unpickler(file).load()
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 858, in load
dispatch[key](self)
  File "/usr/local/python/2.5.1/lib/python2.5/pickle.py", line 1133, in 
load_reduce
value = func(*args)
TypeError: __init__() takes exactly 2 arguments (1 given)

This is because __reduce__ defined in exceptions.c returns the type and the 
args variable, which an exception subclass might not populate.

Also, the reduce implementation doesn't properly serialize the message 
attribute.

I assume that the need for a custom reduce is due to the micro-optimization to 
store arge and message in C slots.  Is this really necessary?


--

>Comment By: Georg Brandl (gbrandl)
Date: 2007-06-25 15:57

Message:
Logged In: YES 
user_id=849994
Originator: NO

No, I haven't anything written -- and this should be fixed anyway.

--

Comment By: Jim Fulton (dcjim)
Date: 2007-06-25 15:57

Message:
Logged In: YES 
user_id=73023
Originator: YES

I'll note that I think the right thing to do is to:

- Take args and message out of the C struct.

- inherit the default reduce behavior from object.


--

Comment By: Jim Fulton (dcjim)
Date: 2007-06-25 15:53

Message:
Logged In: YES 
user_id=73023
Originator: YES

I'm not aware of any such contract. Can you point to anything in writing?

See for example:

file:///home/jim/Documentation/Python-Docs-2.4.1/tut/node10.html#SECTION001050

which teaches people to create custom exceptions that:

- don't set args ro message and

- won't be unpicklable in Python 2.5.

Also, as I mentioned, the reduce implementation doesn't preserve the
message, so even if that was the contract, the contract is broken.


--

Comment By: Georg Brandl (gbrandl)
Date: 2007-06-25 15:26

Message:
Logged In: YES 
user_id=849994
Originator: NO

AFAIR we were told that filling args and message is part of the exception
contract...

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742889&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742940 ] can't run single lamba funcs as unittest

2007-06-25 Thread SourceForge.net
Bugs item #1742940, was opened at 2007-06-25 10:28
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742940&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: timmeh (tctimmeh)
Assigned to: Nobody/Anonymous (nobody)
Summary: can't run single lamba funcs as unittest

Initial Comment:
I have some code that adds new test funtions to a TestCase class as lambda 
functions:

ExmplTests.myTest = lambda: 1+2

When I run the app and specify my lamba test to run, as in:

myTestProg ExmplTests.mytest

I get:

Traceback (most recent call last):
  File "C:\work\CTTS\o-ticket\scOmniCTTS\test\otfbatch_test.py", line 188, in ?
unittest.main(defaultTest = 'suite')
  File "C:\Python24\lib\unittest.py", line 761, in __init__
self.parseArgs(argv)
  File "C:\Python24\lib\unittest.py", line 788, in parseArgs
self.createTests()
  File "C:\Python24\lib\unittest.py", line 794, in createTests
self.module)
  File "C:\Python24\lib\unittest.py", line 559, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
  File "C:\Python24\lib\unittest.py", line 543, in loadTestsFromName
return parent(obj.__name__)
  File "C:\Python24\lib\unittest.py", line 211, in __init__
raise ValueError, "no such test method in %s: %s" % \
ValueError: no such test method in : 

It seems this is the case because lamba functions are always named ''.  
If I change unittest.py ln543 from:
  return parent(obj.__name__)
to:
  return parent(part)

it fixes my problem because part has the function name as a string, instead of 
getting it from obj, which returns '' in my case.


--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742940&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1742940 ] can't run single lamba funcs as unittest

2007-06-25 Thread SourceForge.net
Bugs item #1742940, was opened at 2007-06-25 10:28
Message generated for change (Comment added) made by tctimmeh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742940&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: timmeh (tctimmeh)
Assigned to: Nobody/Anonymous (nobody)
Summary: can't run single lamba funcs as unittest

Initial Comment:
I have some code that adds new test funtions to a TestCase class as lambda 
functions:

ExmplTests.myTest = lambda: 1+2

When I run the app and specify my lamba test to run, as in:

myTestProg ExmplTests.mytest

I get:

Traceback (most recent call last):
  File "C:\work\CTTS\o-ticket\scOmniCTTS\test\otfbatch_test.py", line 188, in ?
unittest.main(defaultTest = 'suite')
  File "C:\Python24\lib\unittest.py", line 761, in __init__
self.parseArgs(argv)
  File "C:\Python24\lib\unittest.py", line 788, in parseArgs
self.createTests()
  File "C:\Python24\lib\unittest.py", line 794, in createTests
self.module)
  File "C:\Python24\lib\unittest.py", line 559, in loadTestsFromNames
suites = [self.loadTestsFromName(name, module) for name in names]
  File "C:\Python24\lib\unittest.py", line 543, in loadTestsFromName
return parent(obj.__name__)
  File "C:\Python24\lib\unittest.py", line 211, in __init__
raise ValueError, "no such test method in %s: %s" % \
ValueError: no such test method in : 

It seems this is the case because lamba functions are always named ''.  
If I change unittest.py ln543 from:
  return parent(obj.__name__)
to:
  return parent(part)

it fixes my problem because part has the function name as a string, instead of 
getting it from obj, which returns '' in my case.


--

>Comment By: timmeh (tctimmeh)
Date: 2007-06-25 15:57

Message:
Logged In: YES 
user_id=1827855
Originator: YES

Here is code that causes the problem:

import unittest
class Exmpl(unittest.TestCase):
  pass
Exmpl.testBug = lambda self: 1+2
if (__name__ == '__main__'):
  unittest.main()

Running "program.py" with no args is an error free run.  Running
"program.py Exmpl.testBug" dies with the stack trace mentioned above.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1742940&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1740599 ] python: Modules/gcmodule.c:240: update_refs: Assertion `gc->

2007-06-25 Thread SourceForge.net
Bugs item #1740599, was opened at 2007-06-20 16:24
Message generated for change (Comment added) made by stuffduff
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1740599&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Extension Modules
Group: Python 2.4
>Status: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: Sean (stuffduff)
Assigned to: Nobody/Anonymous (nobody)
Summary: python: Modules/gcmodule.c:240: update_refs: Assertion `gc->

Initial Comment:
Extension module loads and runs correctly.
When exiting python the following error occurrs:

GNU gdb Red Hat Linux (6.5-15.fc6rh)
Copyright (C) 2006 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are 
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...Using host
libthread_db library "/lib/libthread_db.so.1".

(gdb) run
Starting program: python2.4

...



Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread -1208243504 (LWP 12884)]
collect (generation=2) at Modules/gcmodule.c:241
241 Modules/gcmodule.c: No such file or directory.
in Modules/gcmodule.c
(gdb) bt
#0  collect (generation=2) at Modules/gcmodule.c:241
#1  0x080e1ec5 in PyGC_Collect () at Modules/gcmodule.c:1196
#2  0x080da88a in Py_Finalize () at Python/pythonrun.c:353
#3  0x08055176 in Py_Main (argc=0, argv=0xbfb8dae4) at Modules/main.c: 513
#4  0x08054962 in main (argc=-1208273400, argv=0x812ed68) at Modules/python.c:23

Debug build of python2.4.4 gives:

python: Modules/gcmodule.c:240: update_refs: Assertion `gc->gc.gc_refs == (-3)' 
failed. 



--

>Comment By: Sean (stuffduff)
Date: 2007-06-25 20:18

Message:
Logged In: YES 
user_id=1093262
Originator: YES

Close this. I found the error.  Sorry.

--

Comment By: Sean (stuffduff)
Date: 2007-06-21 15:55

Message:
Logged In: YES 
user_id=1093262
Originator: YES

Very stripped down, but complex instructions.  See the README file. 
PUTENV replaces the need for an environment variable.
File Added: pyGTMbug.tar.gz

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-06-21 00:41

Message:
Logged In: YES 
user_id=33168
Originator: NO

I forgot to mention about the putenv()s.  Are those necessary?  The
directories won't exist on any one else's box.  If those are not necessary
to cause the assertion, remove those too from the minimal test case.

--

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-06-21 00:40

Message:
Logged In: YES 
user_id=33168
Originator: NO

I looked at the attachment and it's not clear how you are using this given
there is a main().  The main() doesn't have a Py_Initialize() either.  So
I'm guessing that was left over and you are really using this as a module. 
Can you reduce it to the minimal test case?  Remove the main() and all the
methods that are not used and will cause the crash.  Also what is the
python code that you execute.  Basically can you demonstrate a complete
scenario (how to build and execute) to cause the problem.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1740599&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[ python-Bugs-1738441 ] shutil.move doesn't work when only case changes

2007-06-25 Thread SourceForge.net
Bugs item #1738441, was opened at 2007-06-16 15:25
Message generated for change (Comment added) made by ggambett
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1738441&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.4
>Status: Closed
Resolution: None
Priority: 5
Private: No
Submitted By: Gabriel Gambetta (ggambett)
Assigned to: Nobody/Anonymous (nobody)
Summary: shutil.move doesn't work when only case changes

Initial Comment:
shutil.move() appears to fail silently when the source and destination 
filenames only differ in case (ie "SomeFile" and "Somefile"). This is with 
python 2.4.3-18.fc6, on a case-sensitive filesystem (ext3), so this rename *is* 
meaningful.

--

>Comment By: Gabriel Gambetta (ggambett)
Date: 2007-06-26 00:51

Message:
Logged In: YES 
user_id=517400
Originator: YES

Sorry, my bad. This happened in a FAT volume mounted somewhere in an ext3
tree so the rename wasn't meaningful within the volume. Still doing
shutil.move(source, "__temp__") and shutil.move("__temp__", dest) did
achieve the result I wanted.

--

Comment By: Georg Brandl (gbrandl)
Date: 2007-06-19 09:40

Message:
Logged In: YES 
user_id=849994
Originator: NO

This is quite strange.

Gabriel, could you try to use another Python version provided by Fedora,
or
even a self-compiled one?

--

Comment By: O.R.Senthil Kumaran (orsenthil)
Date: 2007-06-17 02:08

Message:
Logged In: YES 
user_id=942711
Originator: NO

I guess, this should be very much python 2.4.3-18.fc6 specific. While I
have python 2.3.4, python 2.5, python 2.6a0. I am unable to reproduce this
defect. Having said that, help(shutil.move) mentions about the various
issues of moving the implementation glosses over.
Please provide some more details or anyone with python 2.4.3-18 should be
able to verify it.

--

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1738441&group_id=5470
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com