[issue1968] Unused number magic methods leaked into Py2.6

2008-01-29 Thread Jeffrey Yasskin

Jeffrey Yasskin added the comment:

Will do.

--
components: +Library (Lib)
resolution:  -> accepted

__
Tracker <[EMAIL PROTECTED]>

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



[issue1968] Unused number magic methods leaked into Py2.6

2008-01-29 Thread Raymond Hettinger

Raymond Hettinger added the comment:

For 2.6, they should be omitted from rational.py.  The code that is 
there is not the code that is run -- that impairs its value as a demo 
module.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1968] Unused number magic methods leaked into Py2.6

2008-01-29 Thread Jeffrey Yasskin

Jeffrey Yasskin added the comment:

I can't find the __round__, __ceil__, and __floor__ methods in int,
long, and float. I left them in Rational on purpose, thinking that there
might be a module that provided the new behaviors for 2.6 code, but
you're probably right that these should be rolled back until such a
module appears. They do have the benefit of demonstrating that it's
possible to write a numeric class that does the right thing in both 2.6
and 3.0 without many code changes. (I should check that 2to3 does the
right thing on it.)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1948] Cant open python gui using VISTA

2008-01-29 Thread Martin v. Löwis

Martin v. Löwis added the comment:

Make explorer show all hidden files, then don't search for it, but
directly navigate to .idlerc; note the leading dot.

Please understand that this tracker is not a means you to request help,
but for you to provide help, by reporting bugs. If you seek help, use
[EMAIL PROTECTED] (aka news:comp.lang.python) instead, or
[EMAIL PROTECTED] or [EMAIL PROTECTED]

--
nosy: +loewis

__
Tracker <[EMAIL PROTECTED]>

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



[issue1960] test_gdbm.py converted to unittest

2008-01-29 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola':


Added file: http://bugs.python.org/file9323/test_gdbm.py

__
Tracker <[EMAIL PROTECTED]>

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



[issue1960] test_gdbm.py converted to unittest

2008-01-29 Thread Giampaolo Rodola'

Giampaolo Rodola' added the comment:

Updated version in attachment. 
Changes:

- Added "if self.g is not None: self.g.close()" clause in tearDown.
- Used "test.test_support.unlink(filename)" instead of the try/except
statement.
- Added tests for the flag clause in the open() statement by trying all
supported mode flags. I also called the method "test_flags" instead of
"test_modes" since "mode" is a kwarg for open().
- Added tests for trying to open non existing database with flag == 'r'
and 'w'.

Untested methods which are now tested:
- keys().
- firstkey().
- nextkey().
- reorganize()

The only method currently not tested yet is sync(). I'm not sure how to
test it, maybe I'm misunderstanding its purpose.

Added file: http://bugs.python.org/file9322/test_gdbm.diff

__
Tracker <[EMAIL PROTECTED]>

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



[issue1969] split and rsplit in bytearray are inconsistent

2008-01-29 Thread Guido van Rossum

Guido van Rossum added the comment:

Yeah, that looks like a bug.

--
keywords: +easy
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1970] Speedup unicode whitespace and linebreak detection

2008-01-29 Thread Antoine Pitrou

New submission from Antoine Pitrou:

Currently the PyUnicode type uses a function call and several lookups
per character to detect whitespace and linebreaks. This slows down
considerably the split(), rsplit() and splitlines() methods. Since the
overwhelming majority of whitespace and linebreaks are ASCII characters,
it makes sense to have a fast lookup table for the common case. Patch
attached (also with another tiny change which helps compiler
optimization of split/rsplit here).

(this may also help other methods like strip() a bit, but in that case
the impact of whitespace detection is probably negligible)

Some numbers:

# With patch
$ ./python -m timeit -s "s=open('LICENSE', 'r').read()" "s.splitlines()"
1 loops, best of 3: 127 usec per loop
$ ./python -m timeit -s "s=open('LICENSE', 'r').read()" "s.split()"
1000 loops, best of 3: 457 usec per loop

# Without patch
$ ./python-orig -m timeit -s "s=open('LICENSE', 'r').read()"
"s.splitlines()"
1 loops, best of 3: 175 usec per loop
$ ./python-orig -m timeit -s "s=open('LICENSE', 'r').read()" "s.split()"
1000 loops, best of 3: 571 usec per loop

--
components: Interpreter Core
files: unispace.patch
messages: 61837
nosy: pitrou
severity: normal
status: open
title: Speedup unicode whitespace and linebreak detection
versions: Python 3.0
Added file: http://bugs.python.org/file9321/unispace.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1969] split and rsplit in bytearray are inconsistent

2008-01-29 Thread Antoine Pitrou

New submission from Antoine Pitrou:

In the bytearray type, the split and rsplit methods use a different
definition of what is a whitespace character. split_whitespace calls
ISSPACE(), while rsplit_whitespace calls Py_UNICODE_ISSPACE(). The
latter is probably an error since it is also inconsistent with behaviour
of the bytes type:

>>> s = b"\x09\x0A\x0B\x0C\x0D\x1C\x1D\x1E\x1F"
>>> s.split()
[b'\x1c\x1d\x1e\x1f']
>>> s.rsplit()
[b'\x1c\x1d\x1e\x1f']
>>> b = bytearray(s)
>>> b.split()
[bytearray(b'\x1c\x1d\x1e\x1f')]
>>> b.rsplit()
[]

--
components: Interpreter Core
messages: 61836
nosy: pitrou
severity: normal
status: open
title: split and rsplit in bytearray are inconsistent
type: behavior
versions: Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue1968] Unused number magic methods leaked into Py2.6

2008-01-29 Thread Raymond Hettinger

New submission from Raymond Hettinger:

The Py2.6 code has __round__, __ceil__, and __floor__ methods still in
several objects (int, longs, float, Rational) but they are not invoked
by anything.   For example, round(Rational(22,7)) does not use the
Rational.__round__ code and round(22) does not use the code for
int.__round__; the code is just ignored.  Since the code is not used, it
probably shouldn't be in Py2.6.

I think these backports happened before Guido decided, "I think the
pre-3.0 rule should be: round(), math.floor(), math.ceil()
*always* return a float."  Probably, rev 59731 may have intended to
revert these changes but just missed them.  IIRC, the decision was that
only __trunc__ would be backported and the other three magic methods
would wait for Py3.0 where their invocation functions would get their
new signature and start calling the magic methods.

--
assignee: jyasskin
messages: 61835
nosy: jyasskin, rhettinger
severity: normal
status: open
title: Unused number magic methods leaked into Py2.6
versions: Python 2.6

__
Tracker <[EMAIL PROTECTED]>

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



[issue1967] Backport dictviews to 2.6

2008-01-29 Thread Thomas Wouters

New submission from Thomas Wouters:

Patch to backport dictviews to trunk. Consists of some trickery:

 - new 'viewkeys', 'viewvalues' and 'viewitems' methods of dicts,
returning exactly what 'keys', 'values' and 'items' return in 3.0: three
new types defined in dictobject.c
 - a future import (dictviews) that changes which opcodes are generated
for (some) attribute access
 - special opcodes for getting and setting 'keys', 'values' and 'items'
attributes from an object. These opcodes do nothing special unless a
future import is in effect in the calling code block *and* the type they
are called on is a dict subclass, in which case they translate 'keys',
'values' and 'items' to 'viewkeys', 'viewvalues' and 'viewitems'.
 - similar specialcasing in getattr() and setattr()

--
components: Interpreter Core
files: dictviews_backport.diff
keywords: patch
messages: 61834
nosy: twouters
severity: normal
status: open
title: Backport dictviews to 2.6
versions: Python 2.6
Added file: http://bugs.python.org/file9320/dictviews_backport.diff

__
Tracker <[EMAIL PROTECTED]>

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



[issue400622] Just a test

2008-01-29 Thread Martin v. Löwis

Martin v. Löwis added the comment:

This message links to msg32826

--
nosy: +loewis


Tracker <[EMAIL PROTECTED]>


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



[issue1943] improved allocation of PyUnicode objects

2008-01-29 Thread Antoine Pitrou

Antoine Pitrou added the comment:

FWIW, I tried using the freelist scheme introduced in my patch without
making PyUnicode a PyVarObject and, although it's better than the
standard version, it's still not as good as the PyVarObject version.
Would you be interested in that patch?

__
Tracker <[EMAIL PROTECTED]>

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



[issue1750076] Python 2.5+ skips while statements in debuggers

2008-01-29 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Here is an attempt to correct the problem, with unit tests.

I removed half of the trick marked by a "XXX(nnorwitz)", by adding an
attribute to "struct instr" (this attribute is a bitfield and does not
increase the memory usage). FOR_ITER is no more special-cased in
assemble_lnotab.
Note that the attribute is not always set: only when the target block
has already been filled with instructions. Hopefully this is the case
for the beginning of loops (while & for).

Then the second part of the trick (c->u->u_lineno_set = false, already
used in compiler_for) can be applied to compiler_while. Don't know how
to write this better.

Nir's examples now correctly generate the 3 offsets, and the unit test
checks that a "line" event is repeatedly emitted for the "while" condition.

--
nosy: +amaury.forgeotdarc
Added file: http://bugs.python.org/file9319/while_lnotab.patch

_
Tracker <[EMAIL PROTECTED]>

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



[issue1391] Adds the .compact() method to bsddb db.DB objects

2008-01-29 Thread Jesús Cea Avión

Jesús Cea Avión added the comment:

I can reproduce the crash from a pure C program, so this library seems
buggy. Posting a report in
http://forums.oracle.com/forums/thread.jspa?threadID=611821

__
Tracker <[EMAIL PROTECTED]>

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



[issue606733] Docstring formatter.

2008-01-29 Thread Raghuram Devarakonda

Changes by Raghuram Devarakonda:


--
resolution:  -> rejected
status: open -> closed


Tracker <[EMAIL PROTECTED]>


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



[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-29 Thread Antoine Pitrou

Antoine Pitrou added the comment:

By the way, if we really wanted to be complete in the unit tests, we
should also test the case where either src or dst is a symlink to a
directory. But it's still much better than originally - there was hardly
any unit test for shutil.move().

__
Tracker <[EMAIL PROTECTED]>

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



[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-29 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

We are back to square 1 :-). Your patch incorporates Facundo's
suggestion which is 'rename(src_file, dst_dir/`basename src_file`). It
is not clear to me from rereading the earlier comments whether Guido
rejected this approach or not. I would personally prefer this approach.
If this change is not going to be considered, we will be left with
making a doc change; something to the effect:

"If the destination is a file and is on same file system as that of
src, then simply use rename."

An additional doc change will be needed to correct the statement "If dst
is a directory, OSError will be raised". As you found out, this is not
entirely true on Linux and perhaps on other versions of unix. 

I don't think any other changes are needed. I did not go through the
test cases in the patch but I think we can certainly use some of them
even if no code change is done.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1935] test_descr.py converted to unittest

2008-01-29 Thread Brett Cannon

Brett Cannon added the comment:

On Jan 29, 2008 12:24 PM, Amaury Forgeot d'Arc <[EMAIL PROTECTED]> wrote:
>
> Amaury Forgeot d'Arc added the comment:
>
> Did he misunderstand the last comment in this post of yours?
> http://code.google.com/p/google-highly-open-participation-psf/issues/detail?id=291#c24

Ah, I see what you mean.

So docstrings are not used in testing methods because unittest outputs
those as the name of the test and they are not always useful. The
convention is to make them comments instead and let the method test
name be what unittest outputs.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1397] py3k-pep3137: failing unit test test_bsddb

2008-01-29 Thread Jesús Cea Avión

Changes by Jesús Cea Avión:


--
nosy: +jcea

__
Tracker <[EMAIL PROTECTED]>

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



[issue1935] test_descr.py converted to unittest

2008-01-29 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Did he misunderstand the last comment in this post of yours?
http://code.google.com/p/google-highly-open-participation-psf/issues/detail?id=291#c24

__
Tracker <[EMAIL PROTECTED]>

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



[issue1750076] Python 2.5+ skips while statements in debuggers

2008-01-29 Thread Georgij Kondratjev

Changes by Georgij Kondratjev:


--
nosy: +orivej

_
Tracker <[EMAIL PROTECTED]>

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



[issue1935] test_descr.py converted to unittest

2008-01-29 Thread Brett Cannon

Brett Cannon added the comment:

On Jan 29, 2008 3:11 AM, Amaury Forgeot d'Arc <[EMAIL PROTECTED]> wrote:
>
> Amaury Forgeot d'Arc added the comment:
>
> On the contrary, Jeff's version is better in many aspects.
> I happily withdraw my submission.
>
> Just a question: why were the docstrings removed?

Beats me. =) I didn't even notice when I did the initial review.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1965] Move trunc() to math module

2008-01-29 Thread Jeffrey Yasskin

Changes by Jeffrey Yasskin:


--
resolution:  -> accepted

__
Tracker <[EMAIL PROTECTED]>

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



[issue1966] infinite loop in httplib

2008-01-29 Thread Mike Klaas

New submission from Mike Klaas:

There are a small number of sites that do not send the trailing \r\n when 
using chunked transfer encoding (say 1 in 500,000).  This unfortunately, 
causes httplib to go into an infinite loop.

Fixed by checking for EOF (3 line patch)

--
components: Library (Lib)
files: httplib_chunked.patch
messages: 61824
nosy: klaas
severity: major
status: open
title: infinite loop in httplib
type: behavior
versions: Python 2.3, Python 2.4, Python 2.5, Python 2.6, Python 3.0
Added file: http://bugs.python.org/file9318/httplib_chunked.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1965] Move trunc() to math module

2008-01-29 Thread Raymond Hettinger

New submission from Raymond Hettinger:

http://mail.python.org/pipermail/python-dev/2008-January/076626.html

Also, the docstring doesn't seem correct or clear.

--
assignee: jyasskin
components: Extension Modules
messages: 61823
nosy: jyasskin, rhettinger
severity: normal
status: open
title: Move trunc() to math module
versions: Python 2.6, Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue1391] Adds the .compact() method to bsddb db.DB objects

2008-01-29 Thread Jesús Cea Avión

Changes by Jesús Cea Avión:


--
nosy: +jcea

__
Tracker <[EMAIL PROTECTED]>

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



[issue1954] SocketServer.ForkingMixIn creates a zombie

2008-01-29 Thread Guido van Rossum

Changes by Guido van Rossum:


--
resolution:  -> wont fix
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

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



[issue1961] possible error with json format for sphinx

2008-01-29 Thread Georg Brandl

Georg Brandl added the comment:

Please run a make clean (or just remove the build/html/searchindex.json
file) and this should go away.

--
nosy: +georg.brandl
resolution:  -> works for me
status: open -> closed

__
Tracker <[EMAIL PROTECTED]>

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



[issue1595] Probable extra semicolon in Py_LeaveRecursiveCall macro

2008-01-29 Thread Georgij Kondratjev

Changes by Georgij Kondratjev:


--
nosy: +orivej

__
Tracker <[EMAIL PROTECTED]>

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



[issue1685] linecache .updatecache fails on utf8 encoded files

2008-01-29 Thread Georgij Kondratjev

Changes by Georgij Kondratjev:


--
nosy: +orivej

__
Tracker <[EMAIL PROTECTED]>

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



[issue1964] Slight adjustment to sphinx print-media stylesheet

2008-01-29 Thread Tim Golden

New submission from Tim Golden:

My previous patch to the print stylesheet used by Sphinx was a little
overenthusiastic and resulted in the right edge of the text truncating
on some printers. This version reverts a part of that and gives a useful
result on the printers I've tried.

Patch attached against r60407 of Sphinx

--
components: Documentation tools (Sphinx)
files: sphinx-r60407.patch
messages: 61821
nosy: tim.golden
severity: minor
status: open
title: Slight adjustment to sphinx print-media stylesheet
versions: Python 2.6, Python 3.0
Added file: http://bugs.python.org/file9317/sphinx-r60407.patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue780024] Makefile.pre.in ignores CPPFLAGS from environment

2008-01-29 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

The latest Makefile.pre.in does have this change (@CPPFLAGS@ is appended).

--
nosy: +draghuram
resolution:  -> fixed
status: open -> closed
versions: +Python 2.6 -Python 2.3


Tracker <[EMAIL PROTECTED]>


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



[issue1962] ctypes feature request: Automatic type conversion of input arguments to C functions

2008-01-29 Thread Christian Heimes

Christian Heimes added the comment:

Feature request -> RFE (request for enhancement)

--
assignee:  -> theller
nosy: +theller, tiran
priority:  -> normal
type: behavior -> rfe
versions: +Python 2.6 -Python 2.5

__
Tracker <[EMAIL PROTECTED]>

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



[issue1946] re.search hangs on this

2008-01-29 Thread Georgij Kondratjev

Changes by Georgij Kondratjev:


--
nosy: +orivej

__
Tracker <[EMAIL PROTECTED]>

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



[issue1297193] Search is to long with regex like ^(.+|dontmatch)*$

2008-01-29 Thread Georgij Kondratjev

Changes by Georgij Kondratjev:


--
nosy: +orivej

_
Tracker <[EMAIL PROTECTED]>

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



[issue1963] marshal module is leaking references

2008-01-29 Thread Christian Heimes

New submission from Christian Heimes:

Hello Raymond!

Your changes have introduced a ref leak:

test_marshal leaked [32, 32, 32, 32] references, sum=128

--
assignee: rhettinger
messages: 61818
nosy: rhettinger, tiran
priority: high
severity: normal
status: open
title: marshal module is leaking references
type: behavior
versions: Python 2.6, Python 3.0

__
Tracker <[EMAIL PROTECTED]>

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



[issue1577] shutil.move() does not use os.rename() if dst is a directory

2008-01-29 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Hi Raghuram,

I'm confused, because I can't reproduce it either. I'm afraid I had
drunk too much or too little coffee when typing that. Perhaps the
patch's semantics should be reconsidered then... What do you think?

__
Tracker <[EMAIL PROTECTED]>

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



[issue1935] test_descr.py converted to unittest

2008-01-29 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

On the contrary, Jeff's version is better in many aspects.
I happily withdraw my submission.

Just a question: why were the docstrings removed?

--
resolution:  -> duplicate

__
Tracker <[EMAIL PROTECTED]>

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



[issue1962] ctypes feature request: Automatic type conversion of input arguments to C functions

2008-01-29 Thread mattbaas

New submission from mattbaas:

This is rather a feature request instead of a bug report. 
Below is the mail I posted to the ctypes-users mailing list. In short: 
When ctypes checks input argument types using the "argtypes" attribute, 
it would be useful if it would try to convert the input value 
automatically if it isn't already an appropriate ctypes type (but a 
"compatible" Python type).

Here is the full mail with some examples:

I'm wrapping a couple of C functions from a DLL and I'm using the 
argtypes attribute to declare the types of the input arguments. I can 
call the functions just fine, but I was wondering why I have to provide 
the exact ctypes type as input when using more complex types such as 
arrays or callbacks (whereas Python floats are automatically converted).

Here is an example code snippet (I was using Python 2.5 on WinXP). The 
library ri.dll contains the functions RiColor() which takes an array of 
3 floats as input and a function RiErrorHandler() which takes a pointer 
to a function as input:

   # Create the required types...
   RtColor = 3*c_float
   RtErrorHandler = CFUNCTYPE(None, c_int, c_int, c_char_p)

   # Load the library and declare the input arguments...
   ri = cdll.LoadLibrary("ri.dll")
   ri.RiColor.argtypes = [RtColor]
   ri.RiErrorHandler.argtypes = [RtErrorHandler]

Now I can call the color function like this:

   ri.RiColor(RtColor(1,0,0))

But sometimes it would be more convenient to work with other types like 
tuples, lists or, in this case, a special vector type (that may come 
from another module but that behaves like a list of 3 floats).
But when I try to pass in just a Python tuple or list I get the 
following errors:

   ri.RiColor((1,0,0))

   --> ctypes.ArgumentError: argument 1: : 
Don't know how to convert parameter 1

   ri.RiColor([1,0,0])

   --> ctypes.ArgumentError: argument 1: : 
expected c_float_Array_3 instance instead of list

Similarly with the error handler function. I have to wrap a Python 
function with the RtErrorHandler type, otherwise ctypes won't accept it:

   def errHandler(code, severity, message):
   pass

   ri.RiErrorHandler(RtErrorHandler(errHandler)) # works
   ri.RiErrorHandler(errHandler) # produces a TypeError


So whenever an input type doesn't match what was specified in argtypes, 
couldn't ctypes try to convert the value before issuing an error? (it 
works with floats, so why not with other types as well?)
The conversion could just be done by passing the value to the 
constructor of the required type. In the color example this also means 
that array types should also accept sequences as input (i.e. anything 
that supports iteration and has the right number of elements).

I think this modification to ctypes would make the wrapped functions 
more flexible without having to write additional wrapper functions in 
Python.

--
components: Extension Modules
messages: 61815
nosy: mattbaas
severity: normal
status: open
title: ctypes feature request: Automatic type conversion of input arguments to 
C functions
type: behavior
versions: Python 2.5

__
Tracker <[EMAIL PROTECTED]>

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