[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Two things that haven't come up so far:

(1) What about parentheses? The current complex repr and str have
parentheses in them, for reasons that I still don't really understand.

I'd suggest leaving them out altogether;  except that I have
the impression (perhaps wrongly) that an empty type code is
supposed to correspond to str.  And given that I don't understand
why the parens were in there in the first place, I'm probably
not a good person to judge whether they should stay in a
formatted complex number.

(2) What about zeros?  The current repr and str leave out the real
part (and the enclosing parens) if it's equal to zero.  Should
format do the same?  I'd say not, except possibly again in the
case where there's no type code.

--

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

Mark Dickinson wrote:
 (1) What about parentheses? The current complex repr and str have
 parentheses in them, for reasons that I still don't really understand.
 
 I'd suggest leaving them out altogether;  except that I have
 the impression (perhaps wrongly) that an empty type code is
 supposed to correspond to str.  And given that I don't understand
 why the parens were in there in the first place, I'm probably
 not a good person to judge whether they should stay in a
 formatted complex number.

The rule is that if that x.__format__('') is equivalent to str(x). All 
of the built-in objects have a test for a zero-length format string and 
delegate to str(). But (3).__format__('-') does not call str(), despite 
the fact that it's the identical output. That's because the format 
string isn't zero-length. Instead, this is the case of the missing 
format presentation type.

I couldn't find a case with any built-in objects where this really makes 
a difference (although I can't say I spent a lot of time at it). Complex 
would be the first one. But that doesn't really bother me.

format(1+1j, '')  - '(1+1j)'
format(1+1j, '-') - '1+1j'

Although I guess if we wanted to, we could say that the empty 
presentation type is equivalent to 'g', but gives you parens. This would 
fit in nicely with issue 5858, if it's accepted. Floats do something 
similar and special case the empty presentation type: '' is like 'g', 
but with at least one digit after the decimal point.

 (2) What about zeros?  The current repr and str leave out the real
 part (and the enclosing parens) if it's equal to zero.  Should
 format do the same?  I'd say not, except possibly again in the
 case where there's no type code.

I agree. Again, we could say that the empty presentation type is 
different in this regard.

--

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

 Complex would be the first one. But that doesn't really bother me.

It bothers me a little.  I see '' as a special case of the empty
presentation type, even if that's not what a strict reading of
PEP 3101 says, so I expect '', '' '20' all to format the
number in the same way, and only differ in their treatment of
alignment and padding.  That is, adding a '' to the start of a
format specifier shouldn't change the formatting of the number
itself.  So from this perspective, it seems better if format(x, '')
ends up doing the same thing as str(x) as a result of the
choices made for the empty presentation type, rather than
as a result of special-casing ''.

 Although I guess if we wanted to, we could say that the empty 
 presentation type is equivalent to 'g', but gives you parens.

This works for me.

[about suppressing real zeros...]
 Again, we could say that the empty presentation type is 
 different in this regard.

Makes sense.  Does treating the empty presentation type as special this
way add much extra complication to the implementation?

--

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



[issue5858] Make complex repr and str more like float repr and str

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

I'm still flip-flopping on this one.  On the minus side, this change
risks breaking doctests without any enormous gain to show for it.

On the plus side, Eric Smith is currently working on implementing
sensible formatting for complex numbers (issue 1588), and again the
current form of complex formatting is going to cause (minor,
surmountable, but still ugly) difficulties for that implementation
when the empty presentation type is being used (e.g., format(3j, '')
or format(3j, '20')).

I'll come up with a patch and see how much breaks in core Python.

--

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

See the attached patch. Comments welcome.

I'm not sure I'm doing the right thing with 'g' and appending zeros:
 format(3+4j, '.2')
'(3+4j)'
 format(3+4j, '.2g')
'3.0+4.0j'
 format(3+0j, '.2')
'(3+0j)'
 format(3+0j, '.2g')
'3.0+0.0j'
 format(1j, '.2')
'(1j)'
 format(1j, '.2g')
'0.0+1.0j'

--
keywords: +patch
stage: test needed - patch review
Added file: http://bugs.python.org/file13801/issue-1588-0.patch

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

I'll take a look.

The trailing zeros thing is heavily bound up with issue 5858, of course;
I think we need a decision on that, one way or the other.  One problem
is that I'm only proposing the issue 5858 change for py3k, not trunk.

--
stage: patch review - test needed

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

Mark Dickinson wrote:
 The trailing zeros thing is heavily bound up with issue 5858, of course;
 I think we need a decision on that, one way or the other.  One problem
 is that I'm only proposing the issue 5858 change for py3k, not trunk.

I don't have a problem with trunk's complex.__format__ not agreeing with 
trunk's complex.__str__. If it's a big deal, we can just take 
complex.__format__ completely out of trunk with a #define. In any event, 
there's lots of time before 2.7 and not so much before 3.1, so let's 
concentrate on trunk. Which is what I should have done with starting 
this issue (but forward porting is easier for me that back porting).

--

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

 I'm also going to disallow the '%' format code.

Sounds good to me.

 I don't think it makes any sense to convert a complex number to a
 percentage.

Well, I think it's clear what the numbers would be (just scale both real
and imaginary parts by 100 before using fixed-point formatting).  The
real issue whether to have two trailing '%'s or one.

Just being difficult:  I completely agree that '%' should be disallowed
for complex numbers.

--

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

Here's a patch against py3k, with one slight change with non-empty
presentation types.

--
Added file: http://bugs.python.org/file13802/issue-1588-1-py3k.patch

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



[issue5864] format(1234.5, '.4') gives misleading result

2009-04-28 Thread Mark Dickinson

New submission from Mark Dickinson dicki...@gmail.com:

In all versions of Python from 2.6 up, I get the following behaviour:

 format(123.456, '.4')
'123.5'
 format(1234.56, '.4')
'1235.0'
 format(12345.6, '.4')
'1.235e+04'

The first and third results are as I expect, but the second is somewhat
misleading: it gives 5 significant digits when only 4 were requested,
and moreover the last digit is incorrect.

I propose that Python 2.7 and Python 3.1 be changed so that the output
for the second line above is '1.235e+03'.

Note that in both Python and C, '%.precisiong' formatting switches to
exponential notation at 1eprecision precisely to avoid the problem of
producing more significant digits than were requested;  I'm proposing
that the same solution be applied for '' formatting, except that since
the empty format code is always required to produce at least one digit
after the decimal point, the switch should happen at 1eprecision-1
instead of 1eprecision.

This change should not be backported to 2.6 or 3.0 since there's a small
risk of breakage (particular in doctests).

--
components: Interpreter Core
messages: 86728
nosy: eric.smith, marketdickinson
severity: normal
stage: needs patch
status: open
title: format(1234.5, '.4') gives misleading result
type: behavior
versions: Python 2.7, Python 3.1

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



[issue2245] aifc cannot handle unrecognised chunk type CHAN

2009-04-28 Thread Santiago Peresón

Santiago Peresón y...@yaco.net added the comment:

the attached file triggers the bug.

--
Added file: http://bugs.python.org/file13803/Sine-1000Hz-300ms.aif.zip

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

Mark Dickinson wrote:
 Although I guess if we wanted to, we could say that the empty 
 presentation type is equivalent to 'g', but gives you parens.
 
 This works for me.

Me, too.

 [about suppressing real zeros...]
 Again, we could say that the empty presentation type is 
 different in this regard.
 
 Makes sense.  Does treating the empty presentation type as special this
 way add much extra complication to the implementation?

No. I'm basically finished with it. Before I check it in, I'll attach a 
patch (against trunk) so you can look at how it works.

--

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

I'm also going to disallow the '%' format code. I don't think it makes
any sense to convert a complex number to a percentage.

--

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



[issue5862] multiprocessing 'using a remote manager' example errors and possible 'from_address' code leftover

2009-04-28 Thread Jesse Noller

Jesse Noller jnol...@gmail.com added the comment:

Ugh, I do think this is a doc bug; I think there was an amount of shear 
when we performed the merge into core and subsequent bug fixes. I'll take 
a look when I get a chance.

--

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

With your patch, I'm getting quite strange results when using alignment
specifiers:

 z = 123+4j
 format(z, '=20')
'( 123+  4j)'
 format(z, '^20')
'(123  +4 j)'
 format(z, '20')
'(123 +4  j)'
 len(format(z, '20'))
43

Is this intentional?  I was expecting to get strings of length 20,
with the substring '(123+4j)' positioned either in the middle
or on the left or right.

--

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

...

 Is this intentional?  I was expecting to get strings of length 20,
 with the substring '(123+4j)' positioned either in the middle
 or on the left or right.

No, not intentional. I'll fix it and add some tests. Thanks.

--

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Alan Hourihane

New submission from Alan Hourihane al...@fairlite.co.uk:

mathmodule.c fails to compile because math_log1p() is missing in
mathmodule.c...

gcc -fno-strict-aliasing -DNDEBUG -O2 -pipe -fomit-frame-pointer  -I.
-IInclude -I./Include   -DPy_BUILD_CORE  -c ./Modules/mathmodule.c -o
Modules/mathmodule.o
./Modules/mathmodule.c: In function 'math_log1p':
./Modules/mathmodule.c:353: error: 'log1p' undeclared (first use in this
function)
./Modules/mathmodule.c:353: error: (Each undeclared identifier is
reported only once
./Modules/mathmodule.c:353: error: for each function it appears in.)
./Modules/mathmodule.c: In function 'math_fsum':
./Modules/mathmodule.c:574: warning: passing argument 1 of 'PyFPE_dummy'
discards qualifiers from pointer target type

--
components: Extension Modules
messages: 86733
nosy: alanh
severity: normal
status: open
title: mathmodule.c fails to compile due to missing math_log1p() function
versions: Python 2.6

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



[issue5668] file stdin on disk creates garbage output in stack trace

2009-04-28 Thread Daniel Diniz

Daniel Diniz aja...@gmail.com added the comment:

Duplicate of #1514420.

--
nosy: +ajaksu2
resolution:  - duplicate
stage:  - committed/rejected
status: open - closed

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



[issue1514420] Missing module code does spurious file search

2009-04-28 Thread Zbyszek Szmek

Zbyszek Szmek zbys...@in.waw.pl added the comment:

The bug is certainly not catastrophic, but creates
a slight security risk:

ln -s /etc/shadow 'stdin'
some-suid-program -with-error

or whatever.

--
nosy: +zbysz

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



[issue3672] Ill-formed surrogates not treated as errors during encoding/decoding

2009-04-28 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

We could fix it for 3.1, and perhaps leave 2.7 unchanged if some people
rely on this (for whatever reason).

--
nosy: +pitrou
priority:  - high
stage:  - test needed
versions: +Python 3.1

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



[issue1514420] Missing module code does spurious file search

2009-04-28 Thread Ronald Oussoren

Changes by Ronald Oussoren ronaldousso...@mac.com:


--
nosy:  -ronaldoussoren

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



[issue2571] cmd.py always uses raw_input, even when another stdin is specified

2009-04-28 Thread Daniel Diniz

Daniel Diniz aja...@gmail.com added the comment:

Changing into a RFE: automatically set use_rawinput when 'stdin' is
not None. Will be closed unless someone voices interest.

--
components: +Library (Lib) -Extension Modules
keywords: +easy
priority:  - low
stage:  - test needed
status: open - pending
type: behavior - feature request
versions: +Python 2.7 -Python 2.4

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Thanks for the report.

Could you please tell me what platform you're on?

And does the configure script detect that log1p is available?  (There
should be a line in the (stdout) output of the configure script that
looks something like:

checking for log1p... yes

except that in your case I'm guessing that you get a 'no' there rather
than a 'yes'.  Is that true?

--
assignee:  - marketdickinson
nosy: +marketdickinson

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Alan Hourihane

Alan Hourihane al...@fairlite.co.uk added the comment:

I do have log1p() available...

checking for log1p... yes

And it's in math.h and libm.a on my system.

I still can't see any reference to math_log1p() in mathmodule.c which is
why it's barfing.

--

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

math_log1p should be produced by the line

FUNC1(log1p, log1p, 1, ...

FUNC1 is a macro that (in this instance) creates the math_log1p function.

The original error message that you posted seems to say that it's log1p
that's undeclared, not math_log1p.

It's strange that log1p isn't being picked up.

What's your operating system?

--

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



[issue5866] cPickle defect with tuples and different from pickle output

2009-04-28 Thread Jelle

New submission from Jelle jelleroozenb...@gmail.com:

Python 2.5.2 (r252:60911, Oct  5 2008, 19:24:49) 
[GCC 4.3.2] on linux2

 print cPickle.dumps(('a','b')) == cPickle.dumps(('a', str('b')))
False
 print pickle.dumps(('a','b')) == pickle.dumps(('a', str('b')))
True
 print pickle.dumps(('a','b')) == cPickle.dumps(('a', str('b')))
False
 print pickle.dumps(('a','b')) == cPickle.dumps(('a', 'b'))
False

--
components: Library (Lib)
messages: 86741
nosy: jelle
severity: normal
status: open
title: cPickle defect with tuples and different from pickle output
versions: Python 2.5

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



[issue5864] format(1234.5, '.4') gives misleading result

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

I agree this should be changed.

This:
 format(1234.56, '.4')
'1235.0'
is definitely a problem.

--

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



[issue5866] cPickle defect with tuples and different from pickle output

2009-04-28 Thread Jelle

Changes by Jelle jelleroozenb...@gmail.com:


--
type:  - behavior

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

It might also be helpful if you could tell me how you're building
Python (what configure options, etc.), and which version of the
source you have---is this the 2.6.2 tarball from python.org, or
a recent svn;  if the latter, which revision?

Thanks!

--

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



[issue5867] No way to create an abstract classmethod

2009-04-28 Thread Matteo Dell'Amico

New submission from Matteo Dell'Amico de...@linux.it:

Is there a way to define an abstract classmethod? The two obvious ways
don't seem to work properly.

Python 3.0.1+ (r301:69556, Apr 15 2009, 17:25:52) 
[GCC 4.3.3] on linux2
Type help, copyright, credits or license for more information.
 import abc
 class C(metaclass=abc.ABCMeta):
... @abc.abstractmethod
... @classmethod
... def f(cls): print(42)
... 
Traceback (most recent call last):
  File stdin, line 1, in module
  File stdin, line 3, in C
  File /usr/lib/python3.0/abc.py, line 24, in abstractmethod
funcobj.__isabstractmethod__ = True
AttributeError: 'classmethod' object has no attribute '__isabstractmethod__'
 class C(metaclass=abc.ABCMeta):
... @classmethod
... @abc.abstractmethod
... def f(cls): print(42)
... 
 class D(C): pass
... 
 D.f()
42

--
components: Library (Lib)
messages: 86744
nosy: della
severity: normal
status: open
title: No way to create an abstract classmethod
type: behavior
versions: Python 3.0

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Alan Hourihane

Alan Hourihane al...@fairlite.co.uk added the comment:

Ah. right. I see what you mean about the macro expansion.

So I'm on an Atari FreeMiNT platform which is an m68k box which has no
shared libraries so I'm setting up for static only via Setup.dist.

Note that cmathmodule.c compiles fine and that does reference log1p() too.

This is basic 2.6.2 from the tarball.

--

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

 Note that cmathmodule.c compiles fine and that does reference
 log1p() too.

Now that's *really* peculiar.  I can't imagine why one would work and
the other not.  Some ideas about how to proceed from here:

- try doing a debug build (./configure --with-pydebug) to see if
  the errors still occur.  (They probably will, but you never know...)

- What happens if you add an

#include float.h

after the line

#include Python.h

in mathmodule.c?  I'm clutching at straws here, but that's the only
difference I can see between cmathmodule.c and mathmodule.c that might
be affecting this.  Your error output from gcc looks as though either:

- math.h isn't being included, or
- you've got more than one version of math.h, and the wrong one's
  being included, or
- math.h doesn't declare log1p (but you've already said that it does).

What *should* be happening is that the line

#include Python.h

includes Python.h, which in turn includes pyport.h, which in turn
includes math.h.

It's also odd that this is the first function that fails.  If math.h
isn't being included somehow, then I'd also expect acosh, etc. to be
failing to build.

Do people really still use m68k. :-)

--

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



[issue5868] mimetypes.MAGIC_FUNCTION initialization not thread-safe in Python 2.6.2

2009-04-28 Thread Alain Poirier

New submission from Alain Poirier alain.poir...@net-ng.com:

In Python 2.6.2, the fix for the issue 5401 changed the way the
mimetypes module is initialized.

But now the initialization is not thread-safe : a thread can set
``inited`` to ``True`` and then be preempted before to overwrite the
functions guess_type(), guess_extension() ...

With such a partial initialization, the next thread will raise an 
excessive recursion exception when calling one of this functions.

A fix could be to wrap ``mimetypes.init()`` with a thread lock.

--
components: Library (Lib)
messages: 86747
nosy: apoirier, benjamin.peterson
severity: normal
status: open
title: mimetypes.MAGIC_FUNCTION initialization not thread-safe in Python 2.6.2
type: behavior
versions: Python 2.6

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



[issue5868] mimetypes.MAGIC_FUNCTION initialization not thread-safe in Python 2.6.2

2009-04-28 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Already fixed in r72048.
If you try the fix and find out it has some problems, please reopen the bug.

--
nosy: +pitrou
resolution:  - duplicate
status: open - closed
superseder:  - mimetypes.guess_type() hits recursion limit

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



[issue5864] format(1234.5, '.4') gives misleading result

2009-04-28 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

I think the change should be deemed a bug and backported.  Nothing good
can come from having version differences persist or from having the odd
looking output.

--
nosy: +rhettinger

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



[issue3143] development docs waste a lot of horizontal space on left nav bar

2009-04-28 Thread Éric Araujo

Changes by Éric Araujo mer...@netwok.org:


--
nosy: +Merwok

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Alan Hourihane

Alan Hourihane al...@fairlite.co.uk added the comment:

It's ok, I see what the problem is. It's GCC's headers that are causing
trouble.

Closing.

--
status: open - closed

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



[issue5862] multiprocessing 'using a remote manager' example errors and possible 'from_address' code leftover

2009-04-28 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

OK, so I made the obvious changes to the second remote client example
and tried running the three.  They all run now, but the output is not as
expected.  I've attached a composite debug log of what happened for your
reference.  (I think I ran either t2 or t3 twice, which is why the t1
log shows three sets of messages).  You will note that this reveals a
logging bug of some sort, as well.

I checked the obvious fixups to the second remote client example in with
my other doc fixes in r72060.

--
Added file: http://bugs.python.org/file13804/log.txt

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

I'm glad you sorted it out. :)

Any chance you could tell us what the fix was, in case anyone else runs 
into something similar?  Or is that unlikely to happen?

Also, while you're there, I have a favour to ask:  could you tell me
what the result of doing 

 1e16 + 2.9

is on that platform?  It's not often I get to find out much about Python 
on m68k, and I'm curious to know whether it has the same double rounding 
problems as x86.

Thanks!

--

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Alan Hourihane

Alan Hourihane al...@fairlite.co.uk added the comment:

GCC was munging math.h when it did fixincludes. I'm fixing the GCC port now.

Result of 1e16+2.9 is...

10002.00

--

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



[issue3672] Ill-formed surrogates not treated as errors during encoding/decoding

2009-04-28 Thread Antoine Pitrou

Changes by Antoine Pitrou pit...@free.fr:


--
nosy: +lemburg, loewis

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



[issue1492860] Integer bit operations performance improvement.

2009-04-28 Thread Daniel Diniz

Daniel Diniz aja...@gmail.com added the comment:

Mark: it was just my cluelessness showing :)

--
dependencies:  -long int bitwise ops speedup (patch included)

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

This is a patch against py3k, including tests in test_complex.py. It
should deal with the padding, but let me know.

--
stage: test needed - patch review
Added file: http://bugs.python.org/file13805/issue-1588-2-py3k.patch

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



[issue5866] cPickle defect with tuples and different from pickle output

2009-04-28 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

As long as the different pickle outputs unpickle to the same objects
(which they do, since they only differ in pushing objects to the memo),
I can't see why this would be a bug.

--
nosy: +georg.brandl
resolution:  - wont fix
status: open - pending

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



[issue5850] Full example for emulating a container type

2009-04-28 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

May I add that the given example is flawed:

1. it shares the data dictionary between all instances
2. just delegating all container interfaces to a dictionary does not
really show how to customize your own container.

--

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



[issue5865] mathmodule.c fails to compile due to missing math_log1p() function

2009-04-28 Thread Mark Dickinson

Mark Dickinson dicki...@gmail.com added the comment:

Many thanks.  Looks like no double rounding then;  that's good news.
(32-bit Linux on x86 typically produces 10...0004.0 for this example).

--

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



[issue5867] No way to create an abstract classmethod

2009-04-28 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
priority:  - normal
type: behavior - feature request
versions: +Python 3.1 -Python 3.0

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



[issue5850] Full example for emulating a container type

2009-04-28 Thread Raymond Hettinger

Changes by Raymond Hettinger rhettin...@users.sourceforge.net:


--
resolution:  - rejected
status: open - closed

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



[issue5869] 100th character truncation in 2.4 tarfile.py

2009-04-28 Thread Neville Bagnall

New submission from Neville Bagnall neville.bagn...@propylon.com:

When tarinfo.name is exactly 100 characters long, the last character is
truncated in the tarfile

Attached patch contains the extremely simple fix.

--
components: Library (Lib)
files: tarfile.patch
keywords: patch
messages: 86759
nosy: neville.bagnall
severity: normal
status: open
title: 100th character truncation in 2.4 tarfile.py
type: behavior
versions: Python 2.4
Added file: http://bugs.python.org/file13806/tarfile.patch

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



[issue5869] 100th character truncation in 2.4 tarfile.py

2009-04-28 Thread Neville Bagnall

Neville Bagnall neville.bagn...@propylon.com added the comment:

Lars, for information. I'm closing as 2.4 isn't being maintained I
presume, and while I believe it also affects 2.5, I don't think its a
security issue, just data loss

--
nosy: +lars.gustaebel
status: open - closed
versions: +Python 2.5

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



[issue5870] subprocess.DEVNULL

2009-04-28 Thread Jean Brouwers

New submission from Jean Brouwers mrje...@gmail.com:

The subprocess module exposes the PIPE and STDOUT constants to be used 
for the stdin, stdout or stderr keyword arguments.

Often, stderr needs to be redirected to /dev/null (on posix).  It would 
nice if another constant was available for that purpose, e.g. 
subprocess.DEVNULL.

Perhaps, that might be as simple as

DEVNULL = os.open(os.devnull, os.OS_RDWR)

and re-use the same, single file descriptor.

--
components: Extension Modules
messages: 86761
nosy: MrJean1
severity: normal
status: open
title: subprocess.DEVNULL
type: feature request
versions: Python 2.7

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



[issue4305] ctypes fails to build on mipsel-linux-gnu (detects mips instead of mipsel)

2009-04-28 Thread Thomas Heller

Thomas Heller thel...@ctypes.org added the comment:

I've applied py-issue-4305.patch and reran configure 2.61. Committed as
rev 72081 (trunk), 72082 (py3k branch), 72083 (release26-maint branch),
72084 (release30-maint branch).

Can someone please confirm that it works now, so that I can close this
issue?

--
resolution:  - accepted
stage:  - committed/rejected
title: ctypes fails to build on mipsel-linux-gnu (detects mips  instead of 
mipsel) - ctypes fails to build on mipsel-linux-gnu (detects mips instead of 
mipsel)
type:  - compile error
versions: +Python 3.0, Python 3.1

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



[issue5413] urllib ctypes error on Mac OS X Server 10.5

2009-04-28 Thread Thomas Heller

Thomas Heller thel...@ctypes.org added the comment:

Seems ronald takes care of this issue.

--
assignee: theller - ronaldoussoren

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



[issue5507] ctypes configuration fails on mips-linux (and probably Irix)

2009-04-28 Thread Thomas Heller

Thomas Heller thel...@ctypes.org added the comment:

Duplicate of issue 4305.

--
resolution:  - duplicate
status: open - closed

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



[issue4538] ctypes could include data type limits

2009-04-28 Thread Thomas Heller

Thomas Heller thel...@ctypes.org added the comment:

Isn't is easy to find these limits by using ctypes?

Something like ctypes.sizeof(ctypes.c_uint32)...

--
resolution:  - rejected
status: open - closed

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



[issue4875] find_library can return directories instead of files

2009-04-28 Thread Thomas Heller

Changes by Thomas Heller thel...@ctypes.org:


--
versions: +Python 2.7, Python 3.0, Python 3.1

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

I also propose to disallow the '=' alignment flag. It means put the
padding between the sign and the digits, and since there are 2 signs,
it's not clear what this would mean.

Remember, by using .real and .imag, you can achieve this level of
control in the formatting, anyway.

--
priority: low - normal

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



[issue3297] Python interpreter uses Unicode surrogate pairs only before the pyc is created

2009-04-28 Thread Lino Mastrodomenico

Changes by Lino Mastrodomenico l.mastrodomen...@gmail.com:


--
nosy: +l.mastrodomenico

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



[issue5871] email.header.Header allow to embed raw newlines into a message

2009-04-28 Thread Jakub Wilk

New submission from Jakub Wilk uba...@users.sf.net:

 from email.mime.text import MIMEText
 from email.header import Header
 msg = MIMEText('dummy')
 h = Header('dummy\nX-Injected-Header: yes')
 msg['Subject'] = h
 print msg.as_string()
Content-Type: text/plain; charset=us-ascii
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Subject: dummy
X-Injected-Header: yes

dummy

--
components: Library (Lib)
messages: 86767
nosy: jwilk, pl
severity: normal
status: open
title: email.header.Header allow to embed raw newlines into a message
versions: Python 2.5, Python 2.6

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



[issue5871] email.header.Header allow to embed raw newlines into a message

2009-04-28 Thread Benjamin Peterson

Changes by Benjamin Peterson benja...@python.org:


--
assignee:  - barry
nosy: +barry

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



[issue1492860] Integer bit operations performance improvement.

2009-04-28 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

I don't think it's a good thing to special-case bitwise operations in
the ceval loop. It will make the whole thing less instruction
cache-friendly, just for the purpose of speeding up some very uncommon
operations.

--
nosy: +pitrou

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



[issue1524938] PEP MemoryError with a lot of available memory gc not called

2009-04-28 Thread Antoine Pitrou

Antoine Pitrou pit...@free.fr added the comment:

Lowering priority since, as Martin said, it shouldn't be needed in
real-life situations.

--
nosy: +pitrou
priority: high - low
stage:  - needs patch
type: feature request - resource usage

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



[issue5861] test_urllib fails on windows

2009-04-28 Thread Roumen Petrov

Roumen Petrov bugtr...@roumenpetrov.info added the comment:

Or another workaround is to change line path = '///' + drive + '|' 
from file ./Lib/nturl2path.py, i.e. '|' - ':' .

--
nosy: +rpetrov

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Eric Smith e...@trueblade.com added the comment:

I think these patches are complete. One for py3k, one for trunk. If no
complaints, I'll apply them before this weekend's py3k beta.

--
Added file: http://bugs.python.org/file13807/issue-1588-trunk.patch

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Changes by Eric Smith e...@trueblade.com:


Added file: http://bugs.python.org/file13808/issue-1588-py3k.patch

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Changes by Eric Smith e...@trueblade.com:


Removed file: http://bugs.python.org/file13801/issue-1588-0.patch

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Changes by Eric Smith e...@trueblade.com:


Removed file: http://bugs.python.org/file13802/issue-1588-1-py3k.patch

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



[issue1588] str.format() wrongly formats complex() numbers (Py30a2)

2009-04-28 Thread Eric Smith

Changes by Eric Smith e...@trueblade.com:


Removed file: http://bugs.python.org/file13805/issue-1588-2-py3k.patch

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



[issue5753] CVE-2008-5983 python: untrusted python modules search path

2009-04-28 Thread Glyph Lefkowitz

Changes by Glyph Lefkowitz gl...@divmod.com:


--
nosy: +glyph

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



[issue5857] Return namedtuples from tokenize token generator

2009-04-28 Thread Georg Brandl

Georg Brandl ge...@python.org added the comment:

Note that in tokenize.diff, TokenInfo should be in __all__ instead of
Token.  I agree with Raymond on the inner tuples.

--
nosy: +georg.brandl

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



[issue5857] Return namedtuples from tokenize token generator

2009-04-28 Thread Raymond Hettinger

Raymond Hettinger rhettin...@users.sourceforge.net added the comment:

Committed in r72086.
Needs backporting to 2.7.

--
resolution:  - fixed
status: open - closed

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



[issue5872] New C API for declaring Python types

2009-04-28 Thread Larry Hastings

New submission from Larry Hastings la...@hastings.org:

EXECUTIVE SUMMARY

I've written a patch against py3k trunk creating a new function-based
API for creating  extension types in C.  This allows PyTypeObject to
become a (mostly) private structure.


THE PROBLEM

Here's how you create an extension type using the current API.

  * First, find some code that already has a working type declaration.
Copy and paste their fifty-line PyTypeObject declaration, then
hack it up until it looks like what you need.

  * Next--hey!  There *is* no next, you're done.  You can immediately
create an object using your type and pass it into the Python
interpreter and it would work fine.  You are encouraged to call
PyType_Ready(), but this isn't required and it's often skipped.

This approach causes two problems.

  1) The Python interpreter *must support* and *cannot change*
 the PyTypeObject structure, forever.  Any meaningful change to
 the structure will break every extension.   This has many
 consequences:
   a) Fields that are no longer used must be left in place,
  forever, as ignored placeholders if need be.  Py3k cleaned
  up a lot of these, but it's already picked up a new one
  (tp_compare is now tp_reserved).
   b) Internal implementation details of the type system must
  be public.
   c) The interpreter can't even use a different structure
  internally, because extensions are free to pass in objects
  using PyTypeObjects the interpreter has never seen before.

  2) As a programming interface this lacks a certain gentility.  It
 clearly *works*, but it requires programmers to copy and paste
 with a large structure mostly containing NULLs, which they must
 pick carefully through to change just a few fields.


THE SOLUTION

My patch creates a new function-based extension type definition API.
You create a type by calling PyType_New(), then call various accessor
functions on the type (PyType_SetString and the like), and when your
type has been completely populated you must call PyType_Activate()
to enable it for use.

With this API available, extension authors no longer need to directly
see the innards of the PyTypeObject structure.  Well, most of the
fields anyway.  There are a few shortcut macros in CPython that need
to continue working for performance reasons, so the tp_flags and
tp_dealloc fields need to remain publically visible.

One feature worth mentioning is that the API is type-safe.  Many such
APIs would have had one generic PyType_SetPointer, taking an
identifier for the field and a void * for its value, but this would
have lost type safety.  Another approach would have been to have one
accessor per field (PyType_SetAddFunction), but this would have
exploded the number of functions in the API.  My API splits the
difference: each distinct *type* has its own set of accessors
(PyType_GetSSizeT) which takes an identifier specifying which
field you wish to get or set.


SIDE-EFFECTS OF THE API

The major change resulting from this API: all PyTypeObjects must now
be *pointers* rather than static instances.  For example, the external
declaration of PyType_Type itself changes from this:
PyAPI_DATA(PyTypeObject) PyType_Type;
to this:
PyAPI_DATA(PyTypeObject *) PyType_Type;

This gives rise to the first headache caused by the API: type casts
on type objects.  It took me a day and a half to realize that this,
from Modules/_weakref.c:
PyModule_AddObject(m, ref,
   (PyObject *) _PyWeakref_RefType);
really needed to be this:
PyModule_AddObject(m, ref,
   (PyObject *) _PyWeakref_RefType);

Hopefully I've already found most of these in CPython itself, but
this sort of code surely lurks in extensions yet to be touched.

(Pro-tip: if you're working with this patch, and you see a crash,
and gdb shows you something like this at the top of the stack:
#0  0x081056d8 in visit_decref (op=0x8247aa0, data=0x0)
   at Modules/gcmodule.c:323
323 if (PyObject_IS_GC(op)) {
your problem is an errant , likely on a type object you're passing
in to the interpreter.  Think--what did you touch recently?  Or debug
it by salting your code with calls to collect(NUM_GENERATIONS-1).)


Another irksome side-effect of the API: because of tp_flags and
tp_dealloc, I now have two declarations of PyTypeObject.  There's
the externally-visible one in Include/object.h, which lets external
parties see tp_dealloc and tp_flags.  Then there's the internal
one in Objects/typeprivate.h which is the real structure.  Since
declaring a type twice is a no-no, the external one is gated on
#ifndef PY_TYPEPRIVATE
If you're a normal Python extension programmer, you'd include Python.h
as normal:
#include Python.h
Python implementation files that need to see the real PyTypeObject
structure now look like this:
#define 

[issue5872] New C API for declaring Python types

2009-04-28 Thread Brett Cannon

Changes by Brett Cannon br...@python.org:


--
nosy: +brett.cannon

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



[issue5873] Minidom: parsestring() error

2009-04-28 Thread Nicolas Frantzen

New submission from Nicolas Frantzen n.frant...@gmail.com:

Hi,

I'm pretty new to the community but I get an error using the minidom
parseString() method. Here is my code (ulta simple!):

import xml.dom.minidom
xml = taghello/tag
doc = xml.dom.minidom.parsString(xml)

And here is my error trace:

Traceback (most recent call last):
  File C:\test.py, line 6, in module
doc = xml.dom.minidom.parsString(xml)
AttributeError: 'str' object has no attribute 'dom'

I get this error no what string I gave it. I use python 2.6 (latest
stable release).

Can someone point in the right direction...google has not been very helpful.

Thanks!

Nico

--
components: XML
messages: 86776
nosy: naf305
severity: normal
status: open
title: Minidom: parsestring() error
type: crash
versions: Python 2.6

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