[issue1395] py3k: duplicated line endings when using read(1)

2007-11-06 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

Some thoughts:
- is it ok to call replacenl multiple times on the same string? \r\r\n
and other combinations like this.
- I wonder if it is possible to correctly handle \r\n at the CHUNK_SIZE
limit without an incremental decoder. it seems that we need at least a
flag saying "\r was previously read, ignore the next \n"

__
Tracker <[EMAIL PROTECTED]>

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



[issue1396] py3k-pep3137: patch for mailbox

2007-11-06 Thread Christian Heimes

New submission from Christian Heimes:

Hi Yhg1s!

svn praise shows your name for Lib/mailbox.py more often then other
names. Can you look at my patch and see if it's correct? It fixes most
of the errors in test_mailbox.py and all tests in test_old_mailbox. I'm
unsure about the patch.

Crys

--
assignee: twouters
components: Library (Lib)
files: py3k-pep3137_fix_mailbox.patch
keywords: patch, py3k
messages: 57158
nosy: tiran, twouters
priority: normal
severity: normal
status: open
title: py3k-pep3137: patch for mailbox
type: behavior
versions: Python 3.0
Added file: http://bugs.python.org/file8702/py3k-pep3137_fix_mailbox.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/mailbox.py
===
--- Lib/mailbox.py	(Revision 58874)
+++ Lib/mailbox.py	(Arbeitskopie)
@@ -333,7 +333,7 @@
 
 def get_file(self, key):
 """Return a file-like representation or raise a KeyError."""
-f = open(os.path.join(self._path, self._lookup(key)), 'rb')
+f = open(os.path.join(self._path, self._lookup(key)), 'r')
 return _ProxyFile(f)
 
 def iterkeys(self):
@@ -936,7 +936,7 @@
 def get_file(self, key):
 """Return a file-like representation or raise a KeyError."""
 try:
-f = open(os.path.join(self._path, str(key)), 'rb')
+f = open(os.path.join(self._path, str(key)), 'r')
 except IOError as e:
 if e.errno == errno.ENOENT:
 raise KeyError('No message with key: %s' % key)
Index: Lib/test/test_mailbox.py
===
--- Lib/test/test_mailbox.py	(Revision 58874)
+++ Lib/test/test_mailbox.py	(Arbeitskopie)
@@ -170,9 +170,9 @@
 key1 = self._box.add(_sample_message)
 data0 = self._box.get_file(key0).read()
 data1 = self._box.get_file(key1).read()
-self.assertEqual(data0.decode().replace(os.linesep, '\n'),
+self.assertEqual(data0.replace(os.linesep, '\n'),
  self._template % 0)
-self.assertEqual(data1.decode().replace(os.linesep, '\n'),
+self.assertEqual(data1.replace(os.linesep, '\n'),
  _sample_message)
 
 def test_iterkeys(self):
___
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-06 Thread Joachim Wagner

Joachim Wagner added the comment:

Thanks. Looks great! Also thanks for the hint to rfc 4321. This 
answers the questions how my application can identify whether the 
right python version is running. JJ

__
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-06 Thread Christian Heimes

Christian Heimes added the comment:

Applied to py3k in r58875. I'm doing a svnmerge later. Thanks again for
your help, pal!

--
components: +Windows
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



[issue1392] py3k-pep3137: issue warnings / errors on str(bytes()) and similar operations

2007-11-06 Thread Christian Heimes

Christian Heimes added the comment:

Applied to py3k-pep3137 in r 58876

--
resolution:  -> fixed
status:  -> closed
title: py3k-pep3137: str(bytes()) and str(buffer()) should raise TypeError 
patch -> py3k-pep3137: issue warnings / errors on str(bytes()) and similar 
operations

__
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

2007-11-06 Thread Christian Heimes

Christian Heimes added the comment:

Correction:

The unit test isn't marked as failing but the failing assertion don't
look good.

__
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

2007-11-06 Thread Christian Heimes

New submission from Christian Heimes:

Exception in thread writer 2:
Traceback (most recent call last):
  File "/home/heimes/dev/python/py3k-pep3137/Lib/threading.py", line
485, in _bootstrap_inner
self.run()
  File "/home/heimes/dev/python/py3k-pep3137/Lib/threading.py", line
445, in run
self._target(*self._args, **self._kwargs)
  File
"/home/heimes/dev/python/py3k-pep3137/Lib/bsddb/test/test_thread.py",
line 80, in writerThread
self._writerThread(*args, **kwargs)
  File
"/home/heimes/dev/python/py3k-pep3137/Lib/bsddb/test/test_thread.py",
line 254, in _writerThread
self.assertEqual(data, self.makeData(key))
  File "/home/heimes/dev/python/py3k-pep3137/Lib/unittest.py", line 325,
in failUnlessEqual
raise self.failureException(msg or '%r != %r' % (first, second))
AssertionError: None != b'2226-2226-2226-2226-2226'

Exception in thread writer 1:
Traceback (most recent call last):
  File "/home/heimes/dev/python/py3k-pep3137/Lib/threading.py", line
485, in _bootstrap_inner
self.run()
  File "/home/heimes/dev/python/py3k-pep3137/Lib/threading.py", line
445, in run
self._target(*self._args, **self._kwargs)
  File
"/home/heimes/dev/python/py3k-pep3137/Lib/bsddb/test/test_thread.py",
line 80, in writerThread
self._writerThread(*args, **kwargs)
  File
"/home/heimes/dev/python/py3k-pep3137/Lib/bsddb/test/test_thread.py",
line 269, in _writerThread
self.assertEqual(data, self.makeData(key))
  File "/home/heimes/dev/python/py3k-pep3137/Lib/unittest.py", line 325,
in failUnlessEqual
raise self.failureException(msg or '%r != %r' % (first, second))
AssertionError: None != b'1007-1007-1007-1007-1007'

Exception in thread writer 0:
Traceback (most recent call last):
  File "/home/heimes/dev/python/py3k-pep3137/Lib/threading.py", line
485, in _bootstrap_inner
self.run()
  File "/home/heimes/dev/python/py3k-pep3137/Lib/threading.py", line
445, in run
self._target(*self._args, **self._kwargs)
  File
"/home/heimes/dev/python/py3k-pep3137/Lib/bsddb/test/test_thread.py",
line 80, in writerThread
self._writerThread(*args, **kwargs)
  File
"/home/heimes/dev/python/py3k-pep3137/Lib/bsddb/test/test_thread.py",
line 269, in _writerThread
self.assertEqual(data, self.makeData(key))
  File "/home/heimes/dev/python/py3k-pep3137/Lib/unittest.py", line 325,
in failUnlessEqual
raise self.failureException(msg or '%r != %r' % (first, second))
AssertionError: None != b'0004-0004-0004-0004-0004'

Ubuntu Linux 7.10, i386, db 4.4.20

--
components: Tests
keywords: py3k
messages: 57161
nosy: gvanrossum, tiran
priority: normal
severity: normal
status: open
title: py3k-pep3137: failing unit test test_bsddb
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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-06 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

I am attaching the patch io.diff that does the following:

- If a chunk ends in "\r", read the next chunk to check if it starts
with "\n". This is obviously a very simplified solution that can be
optimized.

- invoke _replacenl on the complete string read instead of what is being
returned in each read call.

I also incorporated the test case by Amaury and added one more.

With this patch in place, the following tests failed (on SuSE 10.1):

test_doctest test_mailbox test_nis test_old_mailbox
test_pickletools test_pty test_sys

The failures (other than known test_mailbox and test_old_mailbox) didn't
look like they are caused by this fix.

Added file: http://bugs.python.org/file8703/io.diff

__
Tracker <[EMAIL PROTECTED]>

__Index: Lib/io.py
===
--- Lib/io.py	(revision 58880)
+++ Lib/io.py	(working copy)
@@ -1248,13 +1248,19 @@
 self._snapshot = None
 return self._replacenl(res)
 else:
-while len(res) < n:
+nl = False
+while nl or len(res) < n:
 readahead, pending = self._read_chunk()
+if pending and pending[-1] == "\r":
+nl = True
+else:
+nl = False
 res += pending
 if not readahead:
 break
+res = self._replacenl(res)
 self._pending = res[n:]
-return self._replacenl(res[:n])
+return res[:n]
 
 def __next__(self):
 self._telling = False
Index: Lib/test/test_io.py
===
--- Lib/test/test_io.py	(revision 58880)
+++ Lib/test/test_io.py	(working copy)
@@ -741,7 +741,28 @@
 print("Reading using readline(): %6.3f seconds" % (t3-t2))
 print("Using readline()+tell():  %6.3f seconds" % (t4-t3))
 
+def testReadOneByOne(self):
+txt = io.TextIOWrapper(io.BytesIO(b"AA\r\nBB"))
+reads = ""
+while True:
+c = txt.read(1)
+if not c:
+break
+reads += c
+self.assertEquals(reads, "AA\nBB")
 
+# read in amounts equal to TextIOWrapper._CHUNK_SIZE which is 128.
+def testReadByChunk(self):
+# make sure "\r\n" straddles 128 char boundary.
+txt = io.TextIOWrapper(io.BytesIO(b"A" * 127 + b"\r\nB"))
+reads = ""
+while True:
+c = txt.read(128)
+if not c:
+break
+reads += c
+self.assertEquals(reads, "A"*127+"\nB")
+
 # XXX Tests for open()
 
 class MiscIOTest(unittest.TestCase):
___
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-06 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc added the comment:

This patch goes in the right direction, but has several problems IMO:

- it reads a complete chunk for just one more byte
- the re-read should be disabled when lineends are not translated
these two are minor annoyance and can be easily corrected, but:

- there is no limit to the re-read; it can exhaust the memory if the
source is a big file with many \r (like a Mac text file)

- How does this behave if the underlying stream has not yet available
data (a socket, a terminal, or an opened file): will the re-read block
at the 129th byte until more data is available? If so, it is annoying
for a simple call to read(1).

I will try to write these test cases if you want.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

IMO you shouldn't read another chunk when the last character you've seen
is \r; instead, you should set a flag so that on the next read, you'll
ignore an initial \n. The flag should be made of the tell/seek state as
well.

(The problem with reading another character is that in interactive input
mode, this might force the user to type an entire second line.)

__
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

2007-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

I've seen this too occasionally.  Greg, can you look at this?

--
assignee:  -> gregory.p.smith
nosy: +gregory.p.smith

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-06 Thread Raghuram Devarakonda

Raghuram Devarakonda added the comment:

On 11/6/07, Amaury Forgeot d'Arc <[EMAIL PROTECTED]> wrote:
> - it reads a complete chunk for just one more byte
> - the re-read should be disabled when lineends are not translated
> these two are minor annoyance and can be easily corrected, but:
>
> - there is no limit to the re-read; it can exhaust the memory if the
> source is a big file with many \r (like a Mac text file)

Yes. reading another chunk is not an optimal solution but after seeing
Guido's comment, I now agree that I shouldn't try to read at all. I
will work on modifications.

> I will try to write these test cases if you want.

That will definitely be useful.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1396] py3k-pep3137: patch for mailbox

2007-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

If Yhgls is twouters, I think he's on vacation.  Possibly Thomas appears
on the blame list because he did some big integrations.  Is he on the
blame list for the trunk as well?

Anyway I want this over with so I'll look into it.

--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1394] simple patch, improving unreachable bytecode removing

2007-11-06 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



[issue1393] function comparing lacks NotImplemented error

2007-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

Odd. I'll look into it.

--
assignee:  -> gvanrossum
nosy: +gvanrossum
priority:  -> normal

__
Tracker <[EMAIL PROTECTED]>

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



[issue1396] py3k-pep3137: patch for mailbox

2007-11-06 Thread Christian Heimes

Christian Heimes added the comment:

Yes, Yhg1s is Thomas nick on #python.

On the trunk svn annotate shows Andrew as the author of most lines.
Maybe he can shed some light on the problem. I'm not familiar with the
details of the mailbox format.

--
assignee: twouters -> akuchling
nosy: +akuchling

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-06 Thread Christian Heimes

Christian Heimes added the comment:

Guido van Rossum wrote:
> IMO you shouldn't read another chunk when the last character you've seen
> is \r; instead, you should set a flag so that on the next read, you'll
> ignore an initial \n. The flag should be made of the tell/seek state as
> well.

In my opinion the check for \r should only happen when os.linesep or
newline starts with \r. On Unix with standard newline the \r should be
treated as every other char.

Christian

__
Tracker <[EMAIL PROTECTED]>

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



[issue1396] py3k-pep3137: patch for mailbox

2007-11-06 Thread A.M. Kuchling

A.M. Kuchling added the comment:

I'm not following Py3K development at all, but the patch is pretty short
and seems reasonable.  I think mailboxes should be 7-bit clean in
theory, but have no idea if things are that tidy in practice.

__
Tracker <[EMAIL PROTECTED]>

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



[issue737648] Error on handling nan

2007-11-06 Thread Mike Verdone

Mike Verdone added the comment:

For the benefit of those who stumble here through Google, here's a
workaround I've discovered for NaN testing. This is BAD:

value == float('NaN')

But this seems to work ok:

str(value) == str(float('NaN'))

--
nosy: +mike.verdone
title: Error on handling nan  -> Error on handling nan


Tracker <[EMAIL PROTECTED]>


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



[issue1396] py3k-pep3137: patch for mailbox

2007-11-06 Thread Christian Heimes

Christian Heimes added the comment:

Thanks for your insight, Andrew! Applied in r58881. 

I agree with you but I'm not able to test it with real data. I've no
longer access to our old server at my old dormitory. I had a Qmail
system with maildir there. 

Two tests are still failing with the same error:
==
FAIL: test_get (test.test_mailbox.TestMaildir)
--
Traceback (most recent call last):
  File "/home/heimes/dev/python/py3k-pep3137/Lib/test/test_mailbox.py",
line 138, in test_get
self.assertEqual(msg.fp.read(), '1')
AssertionError: '\n\n1' != '1'

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

I see several problems with this, but there's light at the end of the
tunnel.

(1) Don't use s#; it will allow null bytes in the string, which we don't
want.

(2) Put the entire trailing slash removal inside #ifdef MS_WINDOWS.

(3) Careful!  It seems the code you wrote would transform "C:/" into
"C:" which isn't the same thing (the latter refers to the current
directory on the C drive, while the former is the root of the C drive).

--
nosy: +gvanrossum

__
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-06 Thread Guido van Rossum

Changes by Guido van Rossum:


--
resolution: accepted -> 

__
Tracker <[EMAIL PROTECTED]>

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



[issue1396] py3k-pep3137: patch for mailbox

2007-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

I fixed the remaining two errors in r58882.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1395] py3k: duplicated line endings when using read(1)

2007-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

> In my opinion the check for \r should only happen when os.linesep or
> newline starts with \r. On Unix with standard newline the \r should be
> treated as every other char.

No: it is not dependent on os.linesep but on the newline parameter
passed to open().
It's perfectly valid to want to read a file with CRLF endings on Unix
(Amaury's patches end up in my /tmp directory like that.)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-06 Thread Christian Heimes

Christian Heimes added the comment:

Guido van Rossum wrote:
> (1) Don't use s#; it will allow null bytes in the string, which we don't
> want.
> 
> (2) Put the entire trailing slash removal inside #ifdef MS_WINDOWS.

Done aand done

> (3) Careful!  It seems the code you wrote would transform "C:/" into
> "C:" which isn't the same thing (the latter refers to the current
> directory on the C drive, while the former is the root of the C drive).

Oh, good catch! I haven't thought of C:/

How do you like
#ifdef MS_WINDOWS
/* Remove trailing / and \ - Windows' stat doesn't like them - 
but
 * keep the trailing slash of C:/
 */

Py_ssize_t i;
char mangled[MAXPATHLEN+1];

if (pathlen > MAXPATHLEN) {
PyErr_SetString(PyExc_OverflowError,
"path is too long");
return -1;
}
strcpy(mangled, path);

for (i = pathlen-1; i > 3; i--) {
if (mangled[i] != '/' && mangled[i] != '\\') {
break;
}
mangled[i] = '\0';
}
rv = stat(mangled, &statbuf);
#else
rv = stat(path, &statbuf);
#endif

i > 3 should take care of C:/ and C:\

Christian

__
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

> How do you like
> #ifdef MS_WINDOWS
> /* Remove trailing / and \ - Windows' stat doesn't like them 
> - but
>  * keep the trailing slash of C:/
>  */
>
> Py_ssize_t i;
> char mangled[MAXPATHLEN+1];
>
> if (pathlen > MAXPATHLEN) {
> PyErr_SetString(PyExc_OverflowError,
> "path is too long");
> return -1;
> }
> strcpy(mangled, path);
>
> for (i = pathlen-1; i > 3; i--) {
> if (mangled[i] != '/' && mangled[i] != '\\') {
> break;
> }
> mangled[i] = '\0';
> }
> rv = stat(mangled, &statbuf);
> #else
> rv = stat(path, &statbuf);
> #endif
>
> i > 3 should take care of C:/ and C:\

But the C: is optional. You will need to do more parsing. Some more
examples (all with slashes; but backslashes work the same):

//share/  -> //share/
//share/x/ -> //share/x
/x/ -> /x
/ -> /
// -> // (probably illegal but doesn't matter)
C:/ -> C:/
x/ -> x
C:x/ -> C:x

Isn't it easier to handle this at the Python level? There probably
already is code for parsing Windows paths. (Hm, maybe we have it in C
too somewhere?)

__
Tracker <[EMAIL PROTECTED]>

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



[issue1372] zlibmodule.c: int overflow in PyZlib_decompress

2007-11-06 Thread Guido van Rossum

Changes by Guido van Rossum:


--
keywords: +64bit
resolution: accepted -> 

__
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-06 Thread Brett Cannon

Brett Cannon added the comment:

On 11/6/07, Guido van Rossum <[EMAIL PROTECTED]> wrote:
>
> Guido van Rossum added the comment:
>
> > Another patch that uses os.path.normpath.
>
> Sorry, I really don't like to be importing os.path in order to be able
> to process the path used for an import.

Modules/getpath.c:joinpath() I think does what you want in C.

__
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-06 Thread Thomas Conway

Thomas Conway added the comment:

The W3 guys had some information that helps.

The DOM3 Core specification contains the following

  No lexical check is done on the content of a comment and it is
  therefore possible to have the character sequence "--"
  (double-hyphen) in the content, which is illegal in a comment
  per section 2.5 of [XML 1.0]. The presence of this character
  sequence must generate a fatal error during serialization.

This suggest that toxml is does not comply with DOM3 at any rate.

cheers,
Tom

__
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-06 Thread Guido van Rossum

Guido van Rossum added the comment:

> Another patch that uses os.path.normpath.

Sorry, I really don't like to be importing os.path in order to be able
to process the path used for an import.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1293] Trailing slash in sys.path cause import failure

2007-11-06 Thread Christian Heimes

Christian Heimes added the comment:

Another patch that uses os.path.normpath.

Added file: http://bugs.python.org/file8704/trailing_slash3.patch

__
Tracker <[EMAIL PROTECTED]>

__Index: Python/import.c
===
--- Python/import.c	(revision 58883)
+++ Python/import.c	(working copy)
@@ -2918,6 +2918,11 @@
 PyObject_HEAD
 } NullImporter;
 
+#ifdef MS_WINDOWS
+/* Cached os.path import for NullImporter_init() */
+static PyObject *nullimporter_ospath = NULL;
+#endif
+
 static int
 NullImporter_init(NullImporter *self, PyObject *args, PyObject *kwds)
 {
@@ -2936,8 +2941,36 @@
 	} else {
 		struct stat statbuf;
 		int rv;
+#ifdef MS_WINDOWS
+		/* normalize the path on Windows. Windows's stat doesn't like trailing
+		 * slashes and backslashes. I'm leaking one reference of os.path to
+		 * avoid an import dead lock.
+		 */
+		PyObject *r;
+		char *mangled;
 
+		if (nullimporter_ospath == NULL) {
+			nullimporter_ospath = PyImport_ImportModule("os.path");
+			if (nullimporter_ospath == NULL) {
+return -1;
+			}
+		}
+
+		r = PyObject_CallMethod(nullimporter_ospath, "normpath", "s", path);
+		if (r == NULL) {
+			return -1;
+		}
+
+		mangled = PyString_AsString(r);
+		if (mangled == NULL) {
+			return -1;
+		}
+
+		rv = stat(mangled, &statbuf);
+		Py_DECREF(r);
+#else
 		rv = stat(path, &statbuf);
+#endif
 		if (rv == 0) {
 			/* it exists */
 			if (S_ISDIR(statbuf.st_mode)) {
___
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

2007-11-06 Thread Christian Heimes

Christian Heimes added the comment:

I've mentioned the platform and db version in the last line. You surely
have missed it:

Ubuntu Linux 7.10, i386, db 4.4.20

__
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

2007-11-06 Thread Gregory P. Smith

Gregory P. Smith added the comment:

yeah i've seen this at random times as well.  I don't believe its
related to py3k or the pep3137 branch at all, i believe seen it on trunk
but its rare.

For reference, what platform (OS) and BerkeleyDB version did you build
python with when this happened?

The reason the test doesn't fail is that these exceptions occur in
worker threads.  The bsddb thread tests could clearly use some work.

__
Tracker <[EMAIL PROTECTED]>

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



[issue1742669] "%d" format handling for long values

2007-11-06 Thread Facundo Batista

Facundo Batista added the comment:

I'm positive that this shouldn't happen. There should NOT be any
difference between longs and ints in nowadays Python, so you never
should say to an user to call that long() before the %d.

And, you have some strange behaviours... for example:

>>> "%d" % 9e8
'9'
>>> "%d" % 9e9
Traceback (most recent call last):
  File "", line 1, in 
TypeError: int argument required

Why the first is ok and in the second you should have called it through
long()?

Gabriel, could you please take a look to the recommendations that Travis
is doing? Maybe the patch could be simpler... In any case, please
confirm if yes or no, :)

_
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-06 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Looks like bad design on W3 part: postponing an error happening, though
it wouldn't be difficult to check right in createComment().  But I guess
minidom should still be changed to conform to standard.

--
nosy: +_doublep

__
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-06 Thread Martin v. Löwis

Martin v. Löwis added the comment:

Would anybody want to provide a patch, then?

__
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-06 Thread Paul Pogonyshev

Paul Pogonyshev added the comment:

Well, it seems that allows createComment() in minidom to raise something
implementation/language specific.  I personally would prefer this (e.g.
a ValueError) instead of raising on serialization step, as I prefer
early error checks, when these checks obviously relate to some place in
the code.  In any way, I think that either createComment() should raise
or toxml(), but generating non-well formed output is a bug.

__
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-06 Thread Thomas Conway

Thomas Conway added the comment:

FWIW, the DOM guys considered mandating a check in createComment, but
decided that the performance penalty was too great.  I'm not sure I
agree with them, but there you have it.

Here are links to my query about the issue:
http://lists.w3.org/Archives/Public/www-dom/2007OctDec/0017.html
http://lists.w3.org/Archives/Public/www-dom/2007OctDec/0018.html

__
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-06 Thread Martin v. Löwis

Martin v. Löwis added the comment:

It may the intention that these functions may raise exceptions in other
cases as well - but can you also support that possibility from the text
of the DOM spec itself?

Adding an exception there may break existing applications, which already
have except clauses to deal with all "possible" exceptions; now they
break if additional exceptions become possible.

__
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-06 Thread Thomas Conway

Thomas Conway added the comment:

I think the specification is reasonably clear: createComment may not
throw an exception. The serializer must throw an exception. (Personally,
I think they have it round the wrong way - every time you write a
serializer you have to write code to do the check; if it was in
createComment, you'd only have to do it once. Never mind!)

The problem of compatibility is, as always, a nasty one: whether or not
to  potentially break code that previously worked.

In this case, I think modifying toxml (and the other serializing
functions in the same library) to throw an exception is pretty unlikely
to break existing code. The *only* way to trigger the error is if you
call createComment with bad text. Moreover, the programs which
"succeeded" before which now fail were almost certainly producing wrong
output before, which if it did not break downstream processing, would at
least produce strange bits of extra character data.

If the library is changed to throw an exception, at least it will alert
the author/maintainer to the problem.

I would estimate the expected number of programs to be broken by such a
change to be about 0. :-)

This is certainly not the first time in the history of software
development the break or not to break issue has come up. Is there a
precedent in the python libraries for how to deal with this kind of
issue? Can we add a quickAndBuggy = True default parameter to toxml,
then in a couple of releases make it mandatory, then in a couple of
further releases remove it and the old behaviour?

cheers,
Tom

__
Tracker <[EMAIL PROTECTED]>

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



[issue1705170] contextmanager eats StopIteration

2007-11-06 Thread Neal Norwitz

Neal Norwitz added the comment:

Nick, can you backport this and add a NEWS entry?  Thanks.

--
nosy: +nnorwitz

_
Tracker <[EMAIL PROTECTED]>

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