[ python-Bugs-1734723 ] Repr class from repr module ignores maxtuple attribute

2007-06-11 Thread SourceForge.net
Bugs item #1734723, was opened at 2007-06-10 19:32
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1734723&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: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Jason Roberts (jasonjroberts)
>Assigned to: Neal Norwitz (nnorwitz)
Summary: Repr class from repr module ignores maxtuple attribute

Initial Comment:
The Repr class from the repr module is supposed limit the number of tuple items 
dumped to the value of the maxtuple attribute. But it uses the value of the 
maxlist attribute instead:

def repr_tuple(self, x, level):
return self._repr_iterable(x, level, '(', ')', self.maxlist, ',')

As a result:

>>> import sys
>>> sys.version
'2.5 (r25:51908, Sep 19 2006, 09:52:17) [MSC v.1310 32 bit (Intel)]'
>>> import repr
>>> r = repr.Repr()
>>> r.maxtuple
6
>>> r.maxlist
6
>>> r.maxtuple = 3
>>> r.repr((1,2,3,4,5,6,7,8,9)) # Will print 6 items, not 3
'(1, 2, 3, 4, 5, 6, ...)'
>>> r.maxlist = 3
>>> r.repr((1,2,3,4,5,6,7,8,9)) # Now will print 3 items
'(1, 2, 3, ...)'

The implementation of repr_tuple should be changed to:

def repr_tuple(self, x, level):
return self._repr_iterable(x, level, '(', ')', self.maxtuple, ',')

Obviously this is not a major issue if nobody has noticed it by now. But it 
would be nice to correct the implementation to match the documentation.

In my scenario, I want to dump out all of the items of a tuple but only three 
items from any embedded list. Something like this:

>>> x = (..)
>>> import repr
>>> r = repr.Repr()
>>> r.maxtuple = 255
>>> r.maxlist = 3
>>> print r.repr(x)

But because maxlist controls both the dumping of lists and of tuples, I have to 
choose between only dumping a few items of the tuple and having small lists, or 
dumping all of the items in the tuple and having large lists.


--

>Comment By: Neal Norwitz (nnorwitz)
Date: 2007-06-11 00:34

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

Thanks for the report Jason!

Committed revision 55887.
Committed revision 55888. (2.5)


--

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



[ python-Bugs-1733757 ] RuntimeWarning: tp_compare didn't return -1 or -2

2007-06-11 Thread SourceForge.net
Bugs item #1733757, was opened at 2007-06-08 18:58
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1733757&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: Fabio Zadrozny (fabioz)
Assigned to: Nobody/Anonymous (nobody)
Summary: RuntimeWarning: tp_compare didn't return -1 or -2 

Initial Comment:
The code attached is giving the error below

D:\bin\Python251\Lib\threading.py:697: RuntimeWarning: tp_compare didn't return 
-1 or -2 for exception
  return _active[_get_ident()]
Exception exceptions.SystemError: 'error return without exception set' in 
 ignored
Ok, I have no clues why there could be an error here...




--

>Comment By: Georg Brandl (gbrandl)
Date: 2007-06-11 08:28

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

Note that there is already a call_trace_protected in ceval.c which
saves/restores the exception,
it just doesn't seem to be called in this instance.

--

Comment By: Eyal Lotem (peaker)
Date: 2007-06-09 08:48

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

Bug #1733973 is related.

What is happening in this bug, is that tokenize.tokenize is using
generate_tokens to generate the tokens. Since tokeneater() fails while the
iteration is occuring, the exception is raised and it unwinds the
tokenize() call. This garbage collects the generate_tokens generator --
which throws a GeneratorExit into the generator.

This time, sysmodule.c's trace_trampoline is the one assuming it can
overwrite PyErr_*.

Maybe the correct way of fixing the bug is saving+clearing/restoring
PyErr_* in ceval.c:call_trace, rather than in each trace/profile handler.

The upside is that they all seem to assume that they can overwrite PyErr_*
and this will fix them all.
The downside is that the PyErr_* that's been set in the frame will not be
accessible to the trace function. This can be fixed by storing it in some
global.

Basically, the fix is to call PyErr_Fetch before the trace/profile func,
and PyErr_Restore after it. The problem is that the trace/profile func is a
function ptr in the PyThreadState that's used by more than Python's
ceval.c. It seems to be liberally used by pyexpat and others. This means
that this function pointer should always point at the wrapper function
rather than the given function, which means storing more information in the
thread state, and then extracting it from the thread state again.

This got more complicated and intricate than I intended, and the whole
thing has a wrong feel to it - as it seems to me that all calls to the
trace/profile func should be in one centralized place, and that place
should be wrapped.

I hope someone else will implement the fix or at least comment on this. If
anyone is not clear on what the fix is, please post questions (and if this
bug system has mailing notifications) and I'll further explain.

--

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



[ python-Bugs-1734164 ] sqlite3 causes memory read error

2007-06-11 Thread SourceForge.net
Bugs item #1734164, was opened at 2007-06-10 03:46
Message generated for change (Comment added) made by ishimoto
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1734164&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: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: atsuo ishimoto (ishimoto)
Assigned to: Nobody/Anonymous (nobody)
Summary: sqlite3 causes memory read error

Initial Comment:
Attached script causes memory read error at sqlite3.pyd.
Tested on Python 2.5.1/Windows XP.

--

>Comment By: atsuo ishimoto (ishimoto)
Date: 2007-06-11 17:31

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

Purify is not needed to find this problem, since python aborts 
by running test script. VisualC++ reports memory read error occurred.

Problem might be in the sqlite, not sqlite3. I'm not sure which is. 
I failed to find this problem at sqlite's trac.

Here's stack trace::

sqlite3.dll!60931bb0()  
_sqlite3.pyd!00ac5887() 
_sqlite3.pyd!00ac589e() 
_sqlite3.pyd!00ac3e6f() 
_sqlite3.pyd!00ac4251() 
python25.dll!PyCFunction_Call(_object * func=0x00bedd78, _object *
arg=0x00be66f0, _object * kw=0x)  行 73 + 0x8C
python25.dll!call_function(_object * * * pp_stack=0x0021fdc0, int oparg=0)
 行 3564 + 0x8f  C
python25.dll!PyEval_EvalFrameEx(_frame * f=0x00ba89e8, int throwflag=0) 
行 2270  C
python25.dll!PyEval_EvalCodeEx(PyCodeObject * co=0x00bcae30, _object *
globals=0x00ba89e8, _object * locals=0x00b7cdb0, _object * *
args=0x, int argcount=0, _object * * kws=0x, int kwcount=0,
_object * * defs=0x, int defcount=0, _object * closure=0x) 
行 2831 + 0x8C
python25.dll!PyEval_EvalCode(PyCodeObject * co=0x00bcae30, _object *
globals=0x00b7cdb0, _object * locals=0x00b7cdb0)  行 499 + 0x22  C
python25.dll!run_mod(_mod * mod=0x00c48538, const char *
filename=0x00bec770, _object * globals=0x00b7cdb0, _object *
locals=0x00b7cdb0, PyCompilerFlags * flags=0xbdf20da3, _arena *
arena=0x)  行 1271 + 0x11C
python25.dll!PyRun_FileExFlags(_iobuf * fp=0x7c3ab698, const char *
filename=0x00ab3e4b, int start=257, _object * globals=0x00b7cdb0, _object *
locals=0x00b7cdb0, int closeit=1, PyCompilerFlags * flags=0x0021ff1c)  行
1258C
python25.dll!PyRun_SimpleFileExFlags(_iobuf * fp=0x7c3ab698, const char *
filename=0x00ab3e4b, int closeit=1, PyCompilerFlags * flags=0x0021ff1c) 
行 878 + 0x18C
python25.dll!PyRun_AnyFileExFlags(_iobuf * fp=0x7c3ab698, const char *
filename=0x00ab3e4b, int closeit=1, PyCompilerFlags * flags=0x0021ff1c) 
行 696 + 0x11C
python25.dll!Py_Main(int argc=2, char * * argv=0x0001)  行 526 +
0x21C
python.exe!1d0011a5()   
kernel32.dll!7c816fd7() 


--

Comment By: Neal Norwitz (nnorwitz)
Date: 2007-06-11 05:56

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

I can't reproduce this on Linux with valgrind.  Did you use purify to find
this problem?

Can you provide the complete report that shows the memory read error with
the call stack?  
Are you sure the problem is in the python code?  
Could the problem be in the sqlite code itself?

--

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



[ python-Bugs-1734860 ] sitecustomize.py not found

2007-06-11 Thread SourceForge.net
Bugs item #1734860, was opened at 2007-06-11 11:33
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=1734860&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: Windows
Group: Python 2.5
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: www.spirito.de (openspirito)
Assigned to: Nobody/Anonymous (nobody)
Summary: sitecustomize.py not found

Initial Comment:
Under my configuration (Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC 
v.1310 32 bit (Intel)] on win32) the sitecustomize.py is not found in the 
current directory. I added some testing code into site.def execsitecustomize() 
and found out, that the current path is not part of sys.path, but later on in 
the main program it is.

--

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



[ python-Bugs-1735418 ] file.read() truncating strings under Windows

2007-06-11 Thread SourceForge.net
Bugs item #1735418, was opened at 2007-06-12 00:19
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=1735418&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: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: cgkanchi (cgkanchi)
Assigned to: Nobody/Anonymous (nobody)
Summary: file.read() truncating strings under Windows

Initial Comment:
On Python 2.4.4 and 2.5.1 under Windows, file.read() fails to read a varying 
number of characters from the last line(s) of text files when asked to read 
more than 800 characters from near the end of the file. For example, if the 
last word of a 500kb file is "superlative", file.read() might output 
"erlative". The file pointer at this stage is very close (a few words at most) 
to the end of the file. I ran into this problem while writing a program to 
split .txt ebooks into smaller files so that my ancient iPod could handle them. 
The behaviour is identical on both 2.4.4 and 2.5.1 under Windows, but does not 
appear under Mac OS X. I was unable to test it under Linux. To test the bug, I 
used various books from http://gutenberg.org . The one primarily used was Pride 
and Prejudice by Jane Austen.

--

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



[ python-Feature Requests-1735509 ] Newer reply format for imap commands in imaplib.py

2007-06-11 Thread SourceForge.net
Feature Requests item #1735509, was opened at 2007-06-12 02:48
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1735509&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: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Naoyuki Tai (ntai)
Assigned to: Nobody/Anonymous (nobody)
Summary: Newer reply format for imap commands in imaplib.py

Initial Comment:
If the fetch command does not contain literal, the result is

[ '1 (FLAGS (\\Seen) UID 1 RFC822.SIZE 26435)',
 '2 (FLAGS (\\Seen) UID 1 RFC822.SIZE 26435)']

If the fetch command contains literal, the result is

[ ('1 (FLAGS (\\Seen) UID 1 RFC822.SIZE 26435', 'header literal'),
 ')',
 ('2 (FLAGS (\\Seen) UID 1 RFC822.SIZE 26435', 'header literal'),
 ')']

First off, the number of elements in the reply becomes twice of non-literal 
fetch command.

Secondly, to parse the attribute string like "(FLAGS (\\Seen) UID 1 RFC822.SIZE 
26435)" , one must check the first and last character to be '(' and ')' for the 
correctness of reply.

With the second type of reply / the reply with literal,  the reply string needs 
to be reconstructed out of the first element of tuple in an element, the 
subsequent element by appending them.

If the number of elements in the reply matches with the number of mails 
fetched, I can deal with the reply a lot easier.

As the shape of fetch command output is very different depending on literal, 
the use of fetch() is too hard for its good.

Therefore, I propose the new response format.
fetch_status, [ entry1, entry2, entry3, ... ]

And each entry is
[entry-reply]
or
[entry-reply, [literals]]

This allows that you can get to the entry reply uniformly regardless of whether 
or not the query of fetch with or without literal response.

Since the proposed response format is not compatible with existing format, 
additional proposal is to let the user of imaplib.py to designate the response 
format, as existing format as 1, and the new format as 2.

I have attached a patch for the proposed change.


--

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