Re: [Python-Dev] cpython: Fixed out-of-bounce write to rawmode buffer. The fixed size buffer wasn't

2012-09-10 Thread Christian Heimes
Am 10.09.2012 03:50, schrieb christian.heimes:
> http://hg.python.org/cpython/rev/85cb90f79cbf
> changeset:   78946:85cb90f79cbf
> user:Christian Heimes 
> date:Mon Sep 10 03:50:48 2012 +0200
> summary:
>   Fixed out-of-bounce write to rawmode buffer. The fixed size buffer wasn't 
> enlarged for the new 'x' flag. The buffer may contain the 5 flags xrwa+ and 
> the \0 byte
> 
> files:
>   Modules/_io/_iomodule.c |  2 +-
>   1 files changed, 1 insertions(+), 1 deletions(-)
> 
> 
> diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
> --- a/Modules/_io/_iomodule.c
> +++ b/Modules/_io/_iomodule.c
> @@ -229,7 +229,7 @@
>  int creating = 0, reading = 0, writing = 0, appending = 0, updating = 0;
>  int text = 0, binary = 0, universal = 0;
>  
> -char rawmode[5], *m;
> +char rawmode[6], *m;
>  int line_buffering, isatty;
>  
>  PyObject *raw, *modeobj = NULL, *buffer = NULL, *wrapper = NULL;

Georg,

this looks rather severe and should be included in the next release, too.

Christian

___
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] creating Lib/tests/cmath_testcases.txt for 64 bit complex numbers

2012-09-10 Thread Matti Picus

  
  
Hi. I am implementing complex numbers for pypy's version of numpy. 
Numpy has both 128 bit (based on 64 bit floats) and 64 bit (based on
32 bit floats) complex numbers, where afaict cmath uses strictly 128
bit complex numbers. I made sure the 128 bit numpy complex numbers
in pypy pass the tests in Lib/tests/cmath_testcases.txt.
I would like to generate a similar file to cmath_testcases.txt for
64 bit complex numbers. I found the earliest commit of the file at
http://hg.python.org/cpython/file/b69f443ef480/Lib/test/cmath_testcases.txt
Can the authors of the original file help me reconstruct the scripts
or programs used to generate it, and reformulate them for 32 bit
floats?
Since there are more than 2000 cases, and many need rewriting, I
prefer an automated method to error-prone hand coding.
By the way, the level of testing is most impressive.
Thanks for any help or tips,
Matti Picus
  

___
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] creating Lib/tests/cmath_testcases.txt for 64 bit complex numbers (text)

2012-09-10 Thread Matti Picus

(I apologize for posting HTML mail. Retrying.)
Hi. I am implementing complex numbers for pypy's version of numpy.

Numpy has both 128 bit (based on 64 bit floats) and 64 bit (based on 32
bit floats) complex numbers, where afaict cmath uses strictly 128 bit
complex numbers. I made sure the 128 bit numpy complex numbers in pypy
pass the tests in Lib/tests/cmath_testcases.txt.
I would like to generate a similar file to cmath_testcases.txt for 64
bit complex numbers. I found the earliest commit of the file at
http://hg.python.org/cpython/file/b69f443ef480/Lib/test/cmath_testcases.txt

Can the authors of the original file help me reconstruct the scripts or
programs used to generate it, and reformulate them for 32 bit floats?
Since there are more than 2000 cases, and many need rewriting, I prefer
an automated method to error-prone hand coding.

By the way, the level of testing is most impressive.

Thanks for any help or tips,
Matti Picus
___
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] creating Lib/tests/cmath_testcases.txt for 64 bit complex numbers (text)

2012-09-10 Thread Mark Dickinson
On Mon, Sep 10, 2012 at 9:06 PM, Matti Picus  wrote:
> Can the authors of the original file help me reconstruct the scripts or
> programs used to generate it, and reformulate them for 32 bit floats?

I used a ctypes wrapper around the MPFR library for most of the
testcases, though some were generated by hand.  I later pushed a
version of the MPFR wrapper to PyPI under the name 'bigfloat', but
unfortunately haven't had time to maintain it;  it may or may not work
right now.  (IIRC, version 0.2 should work okay;  I'd started a
rewrite using Cython instead of ctypes and then got bogged down in
Python 2 / Python 3 distribution fun.  The source at
https://bitbucket.org/dickinsm/bigfloat/src is functional, but doesn't
have distribution sorted out.)

I also used Pari/GP to spot check some of the results.

And that only gets you halfway there, since MPFR only does the real
parts;  it's still necessary to implement the formulas for the real
and imaginary parts in each case, using as much additional precision
as necessary to compute intermediate results.  I used a simple
'peeling the onion' approach, computing lower and upper bounds for the
values in each case and extending precision until both the lower and
upper values gave the same result when rounded to 53 bit precision.

At the time I did this, I don't think the MPC library[1] existed in
usable form;  that may make life easier.

You should also look at Gmpy2 [2];  I believe the most recent release
supports MPC and MPFR.  That's probably the simplest way forward.

Note that MPFR doesn't support IEEE subnormals out of the box, though
it provides some convenience functions to make it relatively easy to
add subnormal support.  That was one of my motivations for writing
bigfloat.

I'm afraid I don't have the exact scripts that I used any more;
they're sitting on the hard drive of a defunct computer that's
awaiting resurrection.

Mark

[1] http://www.multiprecision.org/
[2] http://code.google.com/p/gmpy/
___
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