[issue1377] test_import breaks on Linux

2007-11-04 Thread Christian Heimes

Christian Heimes added the comment:

I'm going to disable the test for now.

--
keywords: +py3k
resolution:  -> accepted
superseder:  -> Crash on Windows if Python runs from a directory with umlauts

__
Tracker <[EMAIL PROTECTED]>

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



[issue1342] Crash on Windows if Python runs from a directory with umlauts

2007-11-04 Thread Christian Heimes

Christian Heimes added the comment:

I've checked in part of the patch in r58837. It doesn't solve the
problem but at least it prevents Python from seg faulting on Windows.

--
keywords: +py3k, rfe
priority:  -> high
resolution:  -> accepted

__
Tracker <[EMAIL PROTECTED]>

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



[issue1379] reloading imported modules sometimes fail with 'parent not in sys.modules' error

2007-11-04 Thread Christian Heimes

Christian Heimes added the comment:

Why are you using PyUnicode_AsUTF32String(parentname)?
PyUnicode_AsString() is the correct method (although it's not yet in the
docs).

The rest looks fine. PyModule_GetName() returns a char* from
PyUnicode_AsString(). Fixed in r58838.

--
keywords: +py3k
nosy: +tiran
resolution:  -> fixed
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



[issue1379] reloading imported modules sometimes fail with 'parent not in sys.modules' error

2007-11-04 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Thank you for the commit.

I just had a problem with my package, and since I was not sure if it was
a bug in Py3k or the package, I went to debugging the former and found
this.  I just didn't know how to work with Unicode strings properly.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1772916] xmlrpclib crash when PyXML installed - sgmlop is available

2007-11-04 Thread Grzegorz Makarewicz

Grzegorz Makarewicz added the comment:

Minimalistic test crash (python 2.5 cvs, sgmlop cvs(pyxml)) - compiled
with msvc 2005, where after 10 loops ms-debugger is invoked:
data='''\


  mws.ScannerLogout
  

  
7
  

  

'''

import xmlrpclib

def main():
i = 1
while 1:
print i
params, method = xmlrpclib.loads(data)
i+=1
main()

--
components: +Extension Modules -Library (Lib)
nosy: +mak -alanmcintyre, effbot, ldeller, loewis
title: xmlrpclib crash when PyXML installed -> xmlrpclib crash when PyXML 
installed - sgmlop is available
versions: +3rd party -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



[issue1378] fromfd() and dup() for _socket on WIndows

2007-11-04 Thread roudkerk

Changes by roudkerk:


--
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



[issue1210] imaplib does not run under Python 3

2007-11-04 Thread Christian Heimes

Changes by Christian Heimes:


--
keywords: +py3k
priority:  -> normal
resolution:  -> accepted

__
Tracker <[EMAIL PROTECTED]>

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



[issue1381] cmath is numerically unsound

2007-11-04 Thread Mark Dickinson

Mark Dickinson added the comment:

I took a look at this a while back, and got as far as writing a pure 
Python drop-in replacement for cmath, based on Kahan's "branch cuts for 
elementary functions" paper.  This fixes a variety of problems in cmath, 
including the buggy branch cuts for asinh.  File attached, in case it's 
of any use.

As Tim Peters pointed out, the real problem here is a lack of decent 
unit tests for these functions.  I have tests for the file above, but 
they assume IEEE754 floats, which is probably not an acceptable 
assumption in general.

--
nosy: +marketdickinson
Added file: http://bugs.python.org/file8685/cmath_py.py

__
Tracker <[EMAIL PROTECTED]>

__
"""This module provides exponential, logarithmic, trigonometric,
inverse trigonometric, hyperbolic and inverse hyperbolic functions for
complex numbers.  It is intended as a drop-in replacement for the
cmath module in the standard library.  For the most part, it uses
formulas and methods described by W. Kahan in his `Branch cuts for
elementary functions' paper.

Design goals


 - make all functions numerically sound;  both the real part and the
   imaginary part should be within a few ulps of the true result,
   where this is reasonable.  (But see the note on accuracy below.)
 - avoid unnecessary overflows in intermediate expressions, when
   the final result is representable.
 - fix buggy branch cuts in asinh
 - do the 'right thing' with respect to signed zeros on platforms that
   follow IEEE754 and C99/IEC 60559.  In particular, all branch cuts
   should be continuous from both sides in this case.
 - don't do anything unreasonable on platforms that don't support
   signed zeros, or have signed zero support that doesn't comply fully
   with the above standards.  With no signed zeros, continuity at branch cuts
   should match the documentation.  Behaviour here is untested.
 
Non-design goals


 - do the right thing with NaNs and infinities.  It's hard to do this portably.
   I believe that many of the routines below do actually do the right thing
   in the presence of NaNs, but this is mostly accidental.
 - (related to the above): give sensible and consistent exceptions.  Again,
   it seems difficult to do this across platforms.
 - produce results that are provably accurate to within 1ulp.

Note on accuracy


In an ideal world, the complex-valued function f(z) would return the
closest representable complex number to the true mathematical value of
f(z): that is, both the real and imaginary part of the result would be
accurate to within <= 0.5ulp.  Achieving this level of accuracy is
very hard---most C math libraries don't manage it.  (But see the
crlibm and MPFR libraries.)  A slightly more realistic goal is <1ulp.

In practice, one might hope that the returned real and imaginary parts
are always within a few ulps (say 10 or 20) of those of the closest
representable value.  But even this is an unrealistic goal in some
situtations.  For example let z be the complex number:

0.79993338661852249060757458209991455078125 +
0.600088817841970012523233890533447265625j

which is exactly representable, assuming IEEE doubles are being used
for the real and imaginary parts.  The nearest representable complex
number to the natural logarithm of z is:

6.16297582203915472977912941627176741932192527428924222476780414581298828125e-33
+ 2.4980915447965088560522417537868022918701171875j

It would take a lot of effort to get the real part anywhere near
correct here.  Other problems occur in computing trigonometric
functions for complex numbers z with large real part, or hyperbolic
trig functions for z with large imaginary part.

Notes on signed zeros  
-

There are many subtle difficulties here: for example, the expression
"1 + z" should add 1 to the real part of z and leave the imaginary
part untouched.  But in Python, if the imaginary part of z is -0.
then the imaginary part of 1+z will be +0: 1 gets coerced to the
complex number 1 + 0j, and then the imaginary parts get added to give
-0j + 0j = 0j.

But z - 1 always does the right thing:  subtracting +0. won't
change the sign of zero.  Similarly, z + (-1.) is fine.

So we can either work with the underlying reals directly, or rewrite
the erroneous 1+z as -(-z-1), which works.  Similarly, 1-z should be
rewritten as -(z-1).  An alternative fix is to use the complex
number 1 - 0j (note negative sign) in place of 1 in the expressions
1+z and 1-z.

Similarly, the expression i*z is special-cased so that
 i*(x+i*y) = -y + i*x;  see the function mul_by_j.

The code below should `do the right thing'
regardless of whether signed zeros are present.  In particular:

- on a platform (hardware + C math library) that supports signed
zeros, so that for example:

  atan2(-0., positive) gives -0.
  atan2(0., positive) gives 0.

[issue1382] py3k-pep3137: patch for test_ctypes

2007-11-04 Thread Amaury Forgeot d'Arc

New submission from Amaury Forgeot d'Arc:

This patch corrects test_ctypes in the py3k-pep3137 branch.
Replacing PyBytes_* by PyString_* was 99% of the task.

Also had to modify binascii, which used to return buffers instead of
bytes strings.

Tested on winXP.

--
components: Tests
files: ctypes3.diff
messages: 57099
nosy: amaury.forgeotdarc, gvanrossum, tiran
severity: normal
status: open
title: py3k-pep3137: patch for test_ctypes
versions: Python 3.0
Added file: http://bugs.python.org/file8686/ctypes3.diff

__
Tracker <[EMAIL PROTECTED]>

__

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



[issue1744580] cvs.get_dialect() return a class object

2007-11-04 Thread Skip Montanaro

Skip Montanaro added the comment:

I changed the documentation for 2.5 and 2.6 to reflect the change in 
semantics.  r58840 and r58841.  Have a look and let me know if that looks 
reasonable.

--
status: open -> pending
title: cvs.get_dialect() return a class object  -> cvs.get_dialect() return a 
class object

_
Tracker <[EMAIL PROTECTED]>

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



[issue1431091] CSV Sniffer fails to report mismatch of column counts

2007-11-04 Thread Skip Montanaro

Skip Montanaro added the comment:

This appears to work better in 2.5 and 2.6 (it doesn't crash, though it 
gets the delimiter wrong) but does indeed fail in 2.4.

--
nosy: +skip.montanaro

_
Tracker <[EMAIL PROTECTED]>

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



[issue1382] py3k-pep3137: patch for test_ctypes

2007-11-04 Thread Christian Heimes

Christian Heimes added the comment:

Applied in r58843.

Thank you very much!

--
keywords: +patch, py3k
resolution:  -> fixed
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



[issue1378] fromfd() and dup() for _socket on WIndows

2007-11-04 Thread Guido van Rossum

Changes by Guido van Rossum:


--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1381] cmath is numerically unsound

2007-11-04 Thread Martin v. Löwis

Martin v. Löwis added the comment:

It would be ok if a test is only run on a system with IEEE floats, and
skipped elsewhere. For all practical purposes, Python assumes that all
systems have IEEE float.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1384] Windows fix for inspect tests

2007-11-04 Thread Christian Heimes

New submission from Christian Heimes:

The patch lower()s the file names on Windows. The tests break on my
system because C:\\... != c:\\...

--
files: py3k_inspect.patch
keywords: patch, py3k
messages: 57105
nosy: tiran
severity: normal
status: open
title: Windows fix for inspect tests
versions: Python 3.0
Added file: http://bugs.python.org/file8688/py3k_inspect.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/test/test_inspect.py
===
--- Lib/test/test_inspect.py	(revision 58843)
+++ Lib/test/test_inspect.py	(working copy)
@@ -1,3 +1,4 @@
+import os
 import sys
 import types
 import unittest
@@ -4,6 +5,7 @@
 import inspect
 import datetime
 import collections
+import __builtin__
 
 from test.test_support import TESTFN, run_unittest
 
@@ -21,8 +23,16 @@
 if modfile.endswith(('c', 'o')):
 modfile = modfile[:-1]
 
-import __builtin__
+# On Windows some functions may return C:\\path\\to\\file with a lower case
+# 'c:\\'.
+if os.name == 'nt':
+modfile = modfile.lower()
 
+def revise(*args):
+if os.name == 'nt':
+return (args[0].lower(),) + args[1:]
+return args
+
 try:
 1/0
 except:
@@ -88,22 +98,22 @@
 
 def test_stack(self):
 self.assert_(len(mod.st) >= 5)
-self.assertEqual(mod.st[0][1:],
+self.assertEqual(revise(*mod.st[0][1:]),
  (modfile, 16, 'eggs', ['st = inspect.stack()\n'], 0))
-self.assertEqual(mod.st[1][1:],
+self.assertEqual(revise(*mod.st[1][1:]),
  (modfile, 9, 'spam', ['eggs(b + d, c + f)\n'], 0))
-self.assertEqual(mod.st[2][1:],
+self.assertEqual(revise(*mod.st[2][1:]),
  (modfile, 43, 'argue', ['spam(a, b, c)\n'], 0))
-self.assertEqual(mod.st[3][1:],
+self.assertEqual(revise(*mod.st[3][1:]),
  (modfile, 39, 'abuse', ['self.argue(a, b, c)\n'], 0))
 
 def test_trace(self):
 self.assertEqual(len(git.tr), 3)
-self.assertEqual(git.tr[0][1:], (modfile, 43, 'argue',
+self.assertEqual(revise(*git.tr[0][1:]), (modfile, 43, 'argue',
  ['spam(a, b, c)\n'], 0))
-self.assertEqual(git.tr[1][1:], (modfile, 9, 'spam',
+self.assertEqual(revise(*git.tr[1][1:]), (modfile, 9, 'spam',
  ['eggs(b + d, c + f)\n'], 0))
-self.assertEqual(git.tr[2][1:], (modfile, 18, 'eggs',
+self.assertEqual(revise(*git.tr[2][1:]), (modfile, 18, 'eggs',
  ['q = y / 0\n'], 0))
 
 def test_frame(self):
@@ -198,8 +208,8 @@
 self.assertSourceEqual(mod.StupidGit, 21, 46)
 
 def test_getsourcefile(self):
-self.assertEqual(inspect.getsourcefile(mod.spam), modfile)
-self.assertEqual(inspect.getsourcefile(git.abuse), modfile)
+self.assertEqual(inspect.getsourcefile(mod.spam).lower(), modfile)
+self.assertEqual(inspect.getsourcefile(git.abuse).lower(), modfile)
 
 def test_getfile(self):
 self.assertEqual(inspect.getfile(mod.StupidGit), mod.__file__)
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1385] hmac module violates RFC for some hash functions, e.g. sha512

2007-11-04 Thread Joachim Wagner

New submission from Joachim Wagner:

(First time submitting a patch to this system.)
The hmac module uses a fixed blocksize of 64 bytes. This is fine for 
many hash functions like md5, sha1 and sha256, but not for sha512 or 
in the general case. The RFC referenced in the python documentation 
specifies that the blocksize has to match the hash function. The 
attached patch is the first of three proposed solutions:

1. use the undocumented block_size attribute of the hashing objects 
provided in the hashlib modules and fallback to 64 bytes if the 
attribute is missing (maybe a depreciated warning would be better); in 
this case it would be a good idea to document to block_size attribute 
(not included in the patch attached); performance could be improved by 
making block_size a class attribute

2. document that the blocksize is 64 and that the RFC is only 
correctly implemented if the hash function also has a blocksize of 64 
bytes; optionally include the workaround to subclass hmac.HMAC and 
overwrite the blocksize (this is documented in the source code, but 
unfortunately not in the python docu)

3. make the blocksize a keyword argument to the constructor and 
document that it has to match the hash function's blocksize for full 
RFC compliance

Regards,
Joachim

--
components: None
files: hmac_1.patch
messages: 57106
nosy: jowagner
severity: normal
status: open
title: hmac module violates RFC for some hash functions, e.g. sha512
type: behavior
versions: Python 3.0
Added file: http://bugs.python.org/file8689/hmac_1.patch

__
Tracker <[EMAIL PROTECTED]>

__--- hmac.orig	2007-11-04 17:44:46.0 +
+++ hmac.py	2007-11-04 18:31:39.0 +
@@ -48,7 +48,15 @@
 self.inner = self.digest_cons()
 self.digest_size = self.inner.digest_size
 
-blocksize = self.blocksize
+try:
+blocksize = self.digest_cons().block_size
+if blocksize < 16:
+# very low blocksize
+# probably a legacy value like in Lib/sha.py
+blocksize = self.blocksize
+except AttributeError:
+blocksize = self.blocksize
+
 if len(key) > blocksize:
 key = self.digest_cons(key).digest()
 
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1383] Backport abcoll to 2.6

2007-11-04 Thread Martin v. Löwis

Changes by Martin v. Löwis:


--
keywords: +patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1385] hmac module violates RFC for some hash functions, e.g. sha512

2007-11-04 Thread Martin v. Löwis

Changes by Martin v. Löwis:


--
keywords: +patch

__
Tracker <[EMAIL PROTECTED]>

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



[issue1383] Backport abcoll to 2.6

2007-11-04 Thread Georg Brandl

Georg Brandl added the comment:

Is this a successor or a companion to #1026?

--
nosy: +georg.brandl

__
Tracker <[EMAIL PROTECTED]>

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



[issue1383] Backport abcoll to 2.6

2007-11-04 Thread Benjamin Aranguren

Benjamin Aranguren added the comment:

This is a companion to #1026.

On 11/4/07, Georg Brandl <[EMAIL PROTECTED]> wrote:
>
> Georg Brandl added the comment:
>
> Is this a successor or a companion to #1026?
>
> --
> nosy: +georg.brandl
>
> __
> Tracker <[EMAIL PROTECTED]>
> 
> __
>

__
Tracker <[EMAIL PROTECTED]>

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



[issue1386] py3k-pep3137: patch to ensure that all codecs return bytes

2007-11-04 Thread Amaury Forgeot d'Arc

New submission from Amaury Forgeot d'Arc:

Most codecs return buffer objects, when the rule is now to return bytes.
This patch adds a test, and corrects failing codecs.
(more PyBytes_* -> PyString_* replacements)

--
components: Unicode
files: codecs.diff
messages: 57109
nosy: amaury.forgeotdarc, tiran
severity: normal
status: open
title: py3k-pep3137: patch to ensure that all codecs return bytes
versions: Python 3.0
Added file: http://bugs.python.org/file8690/codecs.diff

__
Tracker <[EMAIL PROTECTED]>

__

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



[issue1387] py3k-pep3137: patch for hashlib on Windows

2007-11-04 Thread Amaury Forgeot d'Arc

New submission from Amaury Forgeot d'Arc:

On Windows, openssl is not always available, in this case python uses
its own implementation of md5, sha1 &co.
This patch correct the failing tests (test_hashlib and test_uuid), by
returning bytes instead of buffers.

--
components: Windows
files: hashlib.diff
messages: 57110
nosy: amaury.forgeotdarc, tiran
severity: normal
status: open
title: py3k-pep3137: patch for hashlib on Windows
versions: Python 3.0
Added file: http://bugs.python.org/file8691/hashlib.diff

__
Tracker <[EMAIL PROTECTED]>

__

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



[issue1386] py3k-pep3137: patch to ensure that all codecs return bytes

2007-11-04 Thread Christian Heimes

Christian Heimes added the comment:

Applied in r58848. Thanks for removing the annoying warnings!

A small request: Please use self.assert_() and its friends instead of
assert() in unit tests.

--
keywords: +patch, py3k
resolution:  -> fixed
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



[issue1387] py3k-pep3137: patch for hashlib on Windows

2007-11-04 Thread Christian Heimes

Christian Heimes added the comment:

Thanks!

Applied in r58847.

--
keywords: +patch, py3k
resolution:  -> fixed
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



[issue1388] py3k-pep3137: possible ref leak in ctypes

2007-11-04 Thread Christian Heimes

New submission from Christian Heimes:

~/dev/python/py3k-pep3137$ ./python Lib/test/regrtest.py -R 3:5 test_ctypes
test_ctypes
beginning 8 repetitions
12345678

test_ctypes leaked [39, -31, 33, -33, 0] references, sum=8
1 test OK.
[101762 refs]

--
assignee: theller
components: Library (Lib)
keywords: py3k
messages: 57113
nosy: theller, tiran
priority: normal
severity: normal
status: open
title: py3k-pep3137: possible ref leak in ctypes
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



[issue1389] py3k-pep3137: struct module is leaking references

2007-11-04 Thread Christian Heimes

New submission from Christian Heimes:

~/dev/python/py3k-pep3137$ ./python Lib/test/regrtest.py -R 2:4 test_struct
test_struct
beginning 6 repetitions
123456
..
test_struct leaked [12, 7, 20, 10] references, sum=49
1 test OK.
[65353 refs]

--
components: Extension Modules
keywords: py3k
messages: 57114
nosy: tiran
priority: normal
severity: normal
status: open
title: py3k-pep3137: struct module is leaking references
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



[issue1390] toxml generates output that is not well formed

2007-11-04 Thread Thomas Conway

Changes by Thomas Conway:


--
components: Library (Lib)
nosy: drtomc
severity: normal
status: open
title: toxml generates output that is not well formed
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



[issue1390] toxml generates output that is not well formed

2007-11-04 Thread Thomas Conway

New submission from Thomas Conway:

The attached script yields a non-well-formed xml document.

Added file: http://bugs.python.org/file8692/bug.py

__
Tracker <[EMAIL PROTECTED]>

__from xml.dom.minidom import parseString

d = parseString("wibble")
d.documentElement.appendChild(d.createComment("-->"))

print d.toxml()
___
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

2007-11-04 Thread Gregory P. Smith

New submission from Gregory P. Smith:

I'm attaching the patch to add this method here just as a place to track
it for now.  It compiles and it looks right, but it causes a crash
within BerkeleyDB when the test case runs using BerkeleyDB 4.6.21.  It
passes as expected when using 4.4.20 or 4.5.20.

I won't commit this until the 4.6 crash issue is resolved.

python bindings for the compact method were requested here:

http://sourceforge.net/tracker/index.php?func=detail&aid=1724985&group_id=13900&atid=363900

--
assignee: gregory.p.smith
components: Extension Modules
files: add-bsddb-db_compact-gps01.patch.txt
keywords: patch, rfe
messages: 57116
nosy: gregory.p.smith
severity: normal
status: open
title: Adds the .compact() method to bsddb db.DB objects
versions: Python 2.6
Added file: http://bugs.python.org/file8693/add-bsddb-db_compact-gps01.patch.txt

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/bsddb/test/test_basics.py
===
--- Lib/bsddb/test/test_basics.py   (revision 58846)
+++ Lib/bsddb/test/test_basics.py   (working copy)
@@ -564,7 +564,31 @@
 
 #
 
+def test_compact(self):
+if db.version() < (4,4):
+# compact is a feature of BerkeleyDB 4.4 and above
+return
 
+d = self.d
+if verbose:
+print '\n', '-=' * 30
+print "Running %s.test_compact..." % self.__class__.__name__
+
+self.assertEqual(0, d.compact(flags=db.DB_FREELIST_ONLY))
+self.assertEqual(0, d.compact(flags=db.DB_FREELIST_ONLY))
+d.put("abcde", "ABCDE");
+d.put("bcde", "BCDE");
+d.put("abc", "ABC");
+d.put("monty", "python");
+d.delete("abc")
+d.delete("bcde")
+d.compact(start='abcde', stop='monty', txn=None,
+  compact_fillpercent=42, compact_pages=1,
+  compact_timeout=5000,
+  flags=db.DB_FREELIST_ONLY|db.DB_FREE_SPACE)
+
+
+
 #--
 
 
Index: Modules/_bsddb.c
===
--- Modules/_bsddb.c(revision 58846)
+++ Modules/_bsddb.c(working copy)
@@ -448,7 +448,8 @@
 unsigned int bytes_left;
 
 switch (err) {
-case 0: /* successful, no error */  break;
+case 0: /* successful, no error */
+return 0;
 
 #if (DBVER < 41)
 case DB_INCOMPLETE:
@@ -1347,7 +1348,63 @@
 RETURN_NONE();
 }
 
+#if DBVER >= 44
+static PyObject*
+DB_compact(DBObject* self, PyObject* args, PyObject* kwargs)
+{
+PyObject* txnobj = NULL;
+PyObject *startobj = NULL, *stopobj = NULL;
+int flags = 0;
+DB_COMPACT c_data = { 0 };
+static char* kwnames[] = { "txn", "start", "stop", "flags",
+   "compact_fillpercent", "compact_pages",
+   "compact_timeout", NULL };
 
+DB_TXN *txn = NULL;
+PyObject *retval;
+DBT *start_p, *stop_p;
+DBT start, stop;
+int err;
+
+if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OOOiiiI:compact", kwnames,
+ &txnobj, &startobj, &stopobj, &flags,
+ &c_data.compact_fillpercent,
+ &c_data.compact_pages,
+ &c_data.compact_timeout))
+return NULL;
+CHECK_DB_NOT_CLOSED(self);
+if (!checkTxnObj(txnobj, &txn)) {
+return NULL;
+}
+if (startobj && make_key_dbt(self, startobj, &start, NULL)) {
+start_p = &start;
+} else {
+start_p = NULL;
+}
+if (stopobj && make_key_dbt(self, stopobj, &stop, NULL)) {
+stop_p = &stop;
+} else {
+stop_p = NULL;
+}
+
+MYDB_BEGIN_ALLOW_THREADS;
+err = self->db->compact(self->db, txn, start_p, stop_p, &c_data,
+flags, NULL);
+MYDB_END_ALLOW_THREADS;
+if (makeDBError(err)) {
+retval = NULL;
+} else {
+retval = PyLong_FromUnsignedLong(c_data.compact_pages_truncated);
+}
+
+if (startobj)
+FREE_DBT(start);
+if (stopobj)
+FREE_DBT(stop);
+return retval;
+}
+#endif
+
 static PyObject*
 DB_fd(DBObject* self, PyObject* args)
 {
@@ -5007,6 +5064,9 @@
 {"associate",   (PyCFunction)DB_associate,  
METH_VARARGS|METH_KEYWORDS},
 #endif
 {"close",   (PyCFunction)DB_close,  METH_VARARGS},
+#if (DBVER >= 44)
+{"compact", (PyCFunction)DB_compact,
METH_VARARGS|METH_KEYWORDS},
+#endif
 {"consume", (PyCFunction)DB_consume,
METH_VARARGS|METH_KEYWORDS},
 {"consume_wait",(PyCFunction)DB_consume_wait,   
METH_VARARGS|METH_KEYWORDS},
  

[issue1744580] cvs.get_dialect() return a class object

2007-11-04 Thread Andrew McNamara

Andrew McNamara added the comment:

Seems okay to me. I had a quick look at the examples section, and it 
shows a use like the one I mention, but I wonder if the section on 
dialects should quote the specific examples I mention?

_
Tracker <[EMAIL PROTECTED]>

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



[issue1390] toxml generates output that is not well formed

2007-11-04 Thread Martin v. Löwis

Martin v. Löwis added the comment:

That's not a bug in Python, but in your script. You should not pass such
a string to createComment.

--
nosy: +loewis

__
Tracker <[EMAIL PROTECTED]>

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



[issue1390] toxml generates output that is not well formed

2007-11-04 Thread Thomas Conway

Thomas Conway added the comment:

Either it is a bug in the DOM implementation, which should reject
comments containing -->, a bug in toxml() which should refuse to
serialize unserializable documents, or it is a bug in the documentation.

cheers,
Tom

__
Tracker <[EMAIL PROTECTED]>

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



[issue1390] toxml generates output that is not well formed

2007-11-04 Thread Martin v. Löwis

Martin v. Löwis added the comment:

It's not a bug in the DOM implementation, as createCommment does not
specify an exception in this case. It may be a bug in the W3 DOM
specification; please report that to the W3 consortium.

It's not a bug in toxml, which should always serialize the DOM tree if
possible.

As for a bug in the documentation: can you propose a change to the
documentation that would make you happy?

__
Tracker <[EMAIL PROTECTED]>

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