[issue4260] ctypes.xFUNCTYPE are decorators.

2008-11-04 Thread David W. Lambert

New submission from David W. Lambert <[EMAIL PROTECTED]>:

http://docs.python.org/dev/3.0/library/ctypes.html#callback-functions

ctypes.xFUNCTYPE are another opportunity to advertise decorators.  
Please consider inserting yet another qsort example written as a 
decorator, perhaps as follows.  Or---it could be that I'm slow and the 
average pythonista will figure this out on first read.


@CFUNCTYPE(c_int, POINTER(c_int), POINTER(c_int))
def py_cmp_func(*args):
(a,b,) = (t[0] for t in args)
print("py_cmp_func", a, b)
return a-b

qsort(ia,len(ia),sizeof(c_int),py_cmp_func)

--
assignee: georg.brandl
components: Documentation
messages: 75515
nosy: LambertDW, georg.brandl
severity: normal
status: open
title: ctypes.xFUNCTYPE are decorators.
type: feature request
versions: Python 3.0

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4233] open(0, closefd=False) prints 3 warnings

2008-11-04 Thread Christian Heimes

Christian Heimes <[EMAIL PROTECTED]> added the comment:

Here is a new patch with doc and NEWS updates.

Added file: http://bugs.python.org/file11944/fileio_closefd4.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4258] Use 30-bit digits instead of 15-bit digits for Python integers.

2008-11-04 Thread Christian Heimes

Changes by Christian Heimes <[EMAIL PROTECTED]>:


--
nosy: +christian.heimes
priority: normal -> 

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4258] Use 30-bit digits instead of 15-bit digits for Python integers.

2008-11-04 Thread Gregory P. Smith

Gregory P. Smith <[EMAIL PROTECTED]> added the comment:

oh yay, thanks.  it looks like you did approximately what i had started
working on testing a while back but have gone much further and added
autoconf magic to try and determine when which size should be used.  good.

(i haven't reviewed your autoconf stuff yet)

As for marhsalled data and pyc compatibility, yes that is important to
consider.

We should probably base the decision on which digit size to use
internally on benchmarks, not just if the platform can support 64bit
ints.  Many archs support 64bit numbers as a native C type but require
multiple instructions or are very slow when doing it.

(embedded arm, mips or ppc come to mind as obvious things to test that on)

--
nosy: +gregory.p.smith
priority:  -> normal

___
Python tracker <[EMAIL PROTECTED]>

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



[issue416670] MatchObjects not deepcopy()able

2008-11-04 Thread Andrew McNamara

Changes by Andrew McNamara <[EMAIL PROTECTED]>:


--
versions: +Python 2.5.3, Python 2.6

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4258] Use 30-bit digits instead of 15-bit digits for Python integers.

2008-11-04 Thread STINNER Victor

Changes by STINNER Victor <[EMAIL PROTECTED]>:


Removed file: http://bugs.python.org/file11935/30bit_longdigit.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4258] Use 30-bit digits instead of 15-bit digits for Python integers.

2008-11-04 Thread STINNER Victor

STINNER Victor <[EMAIL PROTECTED]> added the comment:

> Note that to avoid "bad marshal data" errors, 
> you'll probably need to do a 'make distclean' 
> before rebuilding with this patch.

I saw that you choosed to use the base 2^30 for marshal. For a better 
portability (be able to use .pyc generated without your patch), you 
may keep the base 2^15. I implemented that in my GMP patch (manual 
conversion from/to base 2^15).

If we change the marshal format of long, the magic number should be 
different (we might use a tag like the "full unicode" tag used in 
Python3 magic number) and/or the bytecode (actual bytecode is 'l'). 
The base should be independent of the implementation, like Python does 
with text: UTF-8 for files and UCS-4 in memory. We may use the base 
2^8 (256) or another power or 2^8 (2^16, 2^32, 2^64?). The base 256 
sounds interresting because any CPU is able to process 8 bits digits.

Cons: Use a different bases makes Python slower for loading/writing 
from/to .pyc.

--
nosy: +haypo

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3588] sysconfig variable LINKFORSHARED has wrong value for MacOS X framework build

2008-11-04 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

The solution I found is:

LINKFORSHARED = -u _PyMac_Error -framework Python

as in the Apple included Python Makefile

and

LDFLAGS += -F$(PYTHONFRAMEWORKPREFIX)

that makes linker use the right framework (not sure, but works with
MacPython installed)

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3166] Make conversions from long to float correctly rounded.

2008-11-04 Thread STINNER Victor

STINNER Victor <[EMAIL PROTECTED]> added the comment:

You may use "if (nbits == (size_t)-1 && PyErr_Occurred())" to check 
_PyLong_NumBits() error (overflow). Well, "if (numbits > DBL_MAX_EXP)" 
should already catch overflow, but I prefer explicit test to check the 
error case.

Anyway, interresting patch! Python3 vanilla:
>>> n = 295147905179352891391; int(float(n)) - n
-65535

Python3 + your patch:
>>> int(float(n)) - n
1

--
stage:  -> patch review

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3166] Make conversions from long to float correctly rounded.

2008-11-04 Thread STINNER Victor

Changes by STINNER Victor <[EMAIL PROTECTED]>:


--
nosy: +haypo

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4259] Update pydoc URLs

2008-11-04 Thread A.M. Kuchling

New submission from A.M. Kuchling <[EMAIL PROTECTED]>:

The URL for module documentation generated by pydoc is no longer valid.
 The attached patch corrects it for Python 2.5.3 by assembling the URL
using the Python version.

This patch shouldn't be forward-ported to 2.6 or 2.7; Sphinx changes the
URL pattern further, and 2.6 and 2.7 take this into account and get
their URLs correct.

--
files: pydoc-patch.txt
messages: 75509
nosy: akuchling
severity: normal
status: open
title: Update pydoc URLs
versions: Python 2.5.3
Added file: http://bugs.python.org/file11943/pydoc-patch.txt

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3203] sphinx - table of contents doesn't render correctly (html)

2008-11-04 Thread Georg Brandl

Georg Brandl <[EMAIL PROTECTED]> added the comment:

Now tracked in
http://www.bitbucket.org/birkenfeld/sphinx/issue/6/fix-html-generation-for-tocs.

--
resolution:  -> duplicate
status: open -> closed

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4166] extra "\fi" in sphinx.sty, line 62

2008-11-04 Thread Georg Brandl

Georg Brandl <[EMAIL PROTECTED]> added the comment:

This is already tracked in
http://www.bitbucket.org/birkenfeld/sphinx/issue/26/sphinxsty-incompatible-with-texlive-sphinx.

--
resolution:  -> duplicate
status: open -> closed

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4167] Inline Markup :const: shows up in Documentation

2008-11-04 Thread Georg Brandl

Georg Brandl <[EMAIL PROTECTED]> added the comment:

Thanks, fixed in r67101.

--
resolution:  -> fixed
status: open -> closed

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4204] Cannot build _multiprocessing, math, mmap and readline of Python 2.6 on FreeBSD 4.11 w/ gcc 2.95.4

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

Martin v. Löwis <[EMAIL PROTECTED]> added the comment:

Thanks for the patch. Committed as r67098, r67099, and r67100.

--
status: open -> closed

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4203] adapt sphinx-quickstart for windows

2008-11-04 Thread Georg Brandl

Changes by Georg Brandl <[EMAIL PROTECTED]>:


--
resolution:  -> duplicate
status: open -> closed

___
Python tracker <[EMAIL PROTECTED]>

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



[issue2608] manpages for sphinx-build & sphinx-quickstart

2008-11-04 Thread Georg Brandl

Georg Brandl <[EMAIL PROTECTED]> added the comment:

Moved to http://www.bitbucket.org/birkenfeld/sphinx/issue/33.

--
resolution:  -> duplicate
status: open -> closed

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4203] adapt sphinx-quickstart for windows

2008-11-04 Thread Georg Brandl

Georg Brandl <[EMAIL PROTECTED]> added the comment:

Moved to http://www.bitbucket.org/birkenfeld/sphinx/issue/32.

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4189] Tilde compression isn't applied in TOC

2008-11-04 Thread Georg Brandl

Georg Brandl <[EMAIL PROTECTED]> added the comment:

Moved to http://www.bitbucket.org/birkenfeld/sphinx/issue/31.

--
resolution:  -> duplicate
status: open -> closed

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

2008-11-04 Thread STINNER Victor

STINNER Victor <[EMAIL PROTECTED]> added the comment:

Le Tuesday 04 November 2008 00:59:02 Barry A. Warsaw, vous avez écrit :
> The assertion on line 813 is indented incorrectly. Please fix that.

Ooops. I'm using the following command because my editor is configured to 
remove the trailing spaces:
   svn diff --diff-cmd="/usr/bin/diff" -x "-ub"

The line 813 was an assertion. I added many assertions to check types (for 
easier debug) but there are not needed anymore (my code is bugfreee, haha, no 
it's a joke). The new attached patch has no more assertion.

Added file: http://bugs.python.org/file11942/imaplib_bytes-4.patch

___
Python tracker <[EMAIL PROTECTED]>

___Index: Doc/library/imaplib.rst
===
--- Doc/library/imaplib.rst (révision 67094)
+++ Doc/library/imaplib.rst (copie de travail)
@@ -75,7 +75,7 @@
 
This is a subclass derived from :class:`IMAP4` that connects to the
``stdin/stdout`` file descriptors created by passing *command* to
-   ``os.popen2()``.
+   ``subprocess.Popen()``.
 
 
 The following utility functions are defined:
@@ -468,13 +468,6 @@
 
Allow simple extension commands notified by server in ``CAPABILITY`` 
response.
 
-Instances of :class:`IMAP4_SSL` have just one additional method:
-
-
-.. method:: IMAP4_SSL.ssl()
-
-   Returns SSLObject instance used for the secure connection with the server.
-
 The following attributes are defined on instances of :class:`IMAP4`:
 
 
Index: Lib/imaplib.py
===
--- Lib/imaplib.py  (révision 67094)
+++ Lib/imaplib.py  (copie de travail)
@@ -22,14 +22,14 @@
 
 __version__ = "2.58"
 
-import binascii, os, random, re, socket, sys, time
+import binascii, random, re, socket, subprocess, sys, time
 
 __all__ = ["IMAP4", "IMAP4_stream", "Internaldate2tuple",
"Int2AP", "ParseFlags", "Time2Internaldate"]
 
 #   Globals
 
-CRLF = '\r\n'
+CRLF = b'\r\n'
 Debug = 0
 IMAP4_PORT = 143
 IMAP4_SSL_PORT = 993
@@ -81,19 +81,19 @@
 
 #   Patterns to match server responses
 
-Continuation = re.compile(r'\+( (?P.*))?')
-Flags = re.compile(r'.*FLAGS \((?P[^\)]*)\)')
-InternalDate = re.compile(r'.*INTERNALDATE "'
-r'(?P[ 
0123][0-9])-(?P[A-Z][a-z][a-z])-(?P[0-9][0-9][0-9][0-9])'
-r' (?P[0-9][0-9]):(?P[0-9][0-9]):(?P[0-9][0-9])'
-r' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])'
-r'"')
-Literal = re.compile(r'.*{(?P\d+)}$', re.ASCII)
-MapCRLF = re.compile(r'\r\n|\r|\n')
-Response_code = re.compile(r'\[(?P[A-Z-]+)( (?P[^\]]*))?\]')
-Untagged_response = re.compile(r'\* (?P[A-Z-]+)( (?P.*))?')
+Continuation = re.compile(br'\+( (?P.*))?')
+Flags = re.compile(br'.*FLAGS \((?P[^\)]*)\)')
+InternalDate = re.compile(br'.*INTERNALDATE "'
+br'(?P[ 
0123][0-9])-(?P[A-Z][a-z][a-z])-(?P[0-9][0-9][0-9][0-9])'
+br' (?P[0-9][0-9]):(?P[0-9][0-9]):(?P[0-9][0-9])'
+br' (?P[-+])(?P[0-9][0-9])(?P[0-9][0-9])'
+br'"')
+Literal = re.compile(br'.*{(?P\d+)}$', re.ASCII)
+MapCRLF = re.compile(br'\r\n|\r|\n')
+Response_code = re.compile(br'\[(?P[A-Z-]+)( (?P[^\]]*))?\]')
+Untagged_response = re.compile(br'\* (?P[A-Z-]+)( (?P.*))?')
 Untagged_status = re.compile(
-r'\* (?P\d+) (?P[A-Z-]+)( (?P.*))?', re.ASCII)
+br'\* (?P\d+) (?P[A-Z-]+)( (?P.*))?', re.ASCII)
 
 
 
@@ -147,7 +147,7 @@
 class abort(error): pass# Service errors - close and retry
 class readonly(abort): pass # Mailbox status changed to READ-ONLY
 
-mustquote = re.compile(r"[^\w!#$%&'*+,.:;<=>?^`|~-]", re.ASCII)
+mustquote = re.compile(br"[^\w!#$%&'*+,.:;<=>?^`|~-]", re.ASCII)
 
 def __init__(self, host = '', port = IMAP4_PORT):
 self.debug = Debug
@@ -167,9 +167,9 @@
 # and compile tagged response matcher.
 
 self.tagpre = Int2AP(random.randint(4096, 65535))
-self.tagre = re.compile(r'(?P'
+self.tagre = re.compile(br'(?P'
 + self.tagpre
-+ r'\d+) (?P[A-Z]+) (?P.*)', re.ASCII)
++ br'\d+) (?P[A-Z]+) (?P.*)', re.ASCII)
 
 # Get server welcome message,
 # request and store CAPABILITY response.
@@ -193,7 +193,9 @@
 typ, dat = self.capability()
 if dat == [None]:
 raise self.error('no CAPABILITY response from server')
-self.capabilities = tuple(dat[-1].upper().split())
+dat = str(dat[-1], "ASCII")
+dat = dat.upper()
+self.capabilities = tuple(dat.split())
 
 if __debug__:
 if self.debug >= 3:
@@ -219,6 +221,11 @@
 #   Overridable methods
 
 
+def _create_socket(self):
+sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
+sock.connect((self.host, self.port))
+return sock
+
 def open(self, host = '', port = IMAP4_PORT):

[issue1210] imaplib does not run under Python 3

2008-11-04 Thread Raghuram Devarakonda

Changes by Raghuram Devarakonda <[EMAIL PROTECTED]>:


--
nosy:  -draghuram

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

2008-11-04 Thread Jean-Paul Calderone

Changes by Jean-Paul Calderone <[EMAIL PROTECTED]>:


--
nosy:  -exarkun

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3714] nntplib module broken by str to unicode conversion

2008-11-04 Thread STINNER Victor

STINNER Victor <[EMAIL PROTECTED]> added the comment:

Le Tuesday 04 November 2008 01:08:25 Barry A. Warsaw, vous avez écrit :
> Please fix the test as Benjamin suggests ("network")

Done: see new attached patch.

Added file: http://bugs.python.org/file11941/nntp-bytes-2.patch

___
Python tracker <[EMAIL PROTECTED]>

___Index: Lib/nntplib.py
===
--- Lib/nntplib.py  (révision 67094)
+++ Lib/nntplib.py  (copie de travail)
@@ -7,7 +7,7 @@
 >>> resp, count, first, last, name = s.group('comp.lang.python')
 >>> print('Group', name, 'has', count, 'articles, range', first, 'to', last)
 Group comp.lang.python has 51 articles, range 5770 to 5821
->>> resp, subs = s.xhdr('subject', first + '-' + last)
+>>> resp, subs = s.xhdr('subject', '{0}-{1}'.format(first, last))
 >>> resp = s.quit()
 >>>
 
@@ -15,7 +15,7 @@
 Error responses are turned into exceptions.
 
 To post an article from a file:
->>> f = open(filename, 'r') # file containing article, including header
+>>> f = open(filename, 'rb') # file containing article, including header
 >>> resp = s.post(f)
 >>>
 
@@ -81,11 +81,11 @@
 
 
 # Response numbers that are followed by additional text (e.g. article)
-LONGRESP = ['100', '215', '220', '221', '222', '224', '230', '231', '282']
+LONGRESP = [b'100', b'215', b'220', b'221', b'222', b'224', b'230', b'231', 
b'282']
 
 
 # Line terminators (we always output CRLF, but accept any of CRLF, CR, LF)
-CRLF = '\r\n'
+CRLF = b'\r\n'
 
 
 
@@ -128,7 +128,7 @@
 # error 500, probably 'not implemented'
 pass
 except NNTPTemporaryError as e:
-if user and e.response[:3] == '480':
+if user and e.response.startswith(b'480'):
 # Need authorization before 'mode reader'
 readermode_afterauth = 1
 else:
@@ -148,13 +148,13 @@
 # Perform NNRP authentication if needed.
 if user:
 resp = self.shortcmd('authinfo user '+user)
-if resp[:3] == '381':
+if resp.startswith(b'381'):
 if not password:
 raise NNTPReplyError(resp)
 else:
 resp = self.shortcmd(
 'authinfo pass '+password)
-if resp[:3] != '281':
+if not resp.startswith(b'281'):
 raise NNTPPermanentError(resp)
 if readermode_afterauth:
 try:
@@ -196,6 +196,7 @@
 def putcmd(self, line):
 """Internal: send one command to the server (through putline())."""
 if self.debugging: print('*cmd*', repr(line))
+line = bytes(line, "ASCII")
 self.putline(line)
 
 def getline(self):
@@ -205,8 +206,10 @@
 if self.debugging > 1:
 print('*get*', repr(line))
 if not line: raise EOFError
-if line[-2:] == CRLF: line = line[:-2]
-elif line[-1:] in CRLF: line = line[:-1]
+if line[-2:] == CRLF:
+line = line[:-2]
+elif line[-1:] in CRLF:
+line = line[:-1]
 return line
 
 def getresp(self):
@@ -215,11 +218,11 @@
 resp = self.getline()
 if self.debugging: print('*resp*', repr(resp))
 c = resp[:1]
-if c == '4':
+if c == b'4':
 raise NNTPTemporaryError(resp)
-if c == '5':
+if c == b'5':
 raise NNTPPermanentError(resp)
-if c not in '123':
+if c not in b'123':
 raise NNTPProtocolError(resp)
 return resp
 
@@ -239,12 +242,12 @@
 list = []
 while 1:
 line = self.getline()
-if line == '.':
+if line == b'.':
 break
-if line[:2] == '..':
+if line.startswith(b'..'):
 line = line[1:]
 if file:
-file.write(line + "\n")
+file.write(line + b'\n')
 else:
 list.append(line)
 finally:
@@ -312,16 +315,16 @@
 
 resp, lines = self.descriptions(group)
 if len(lines) == 0:
-return ""
+return b''
 else:
 return lines[0][1]
 
 def descriptions(self, group_pattern):
 """Get descriptions for a range of groups."""
-line_pat = re.compile("^(?P[^ \t]+)[ \t]+(.*)$")
+line_pat = re.compile(b'^(?P[^ \t]+)[ \t]+(.*)$')
 # Try the more std (acc. to RFC2980) LIST NEWSGROUPS first
 resp, raw_lines = self.longcmd('LIST NEWSGROUPS ' + group_pattern)
-if resp[:3] != "215":
+if not resp.startswith(b'215'):
 # Now the deprecated XGTITLE.  This either raises an error
 # or succeeds

[issue1210] imaplib does not run under Python 3

2008-11-04 Thread STINNER Victor

Changes by STINNER Victor <[EMAIL PROTECTED]>:


Removed file: http://bugs.python.org/file11796/imaplib_bytes-3.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3727] poplib module broken by str to unicode conversion

2008-11-04 Thread STINNER Victor

STINNER Victor <[EMAIL PROTECTED]> added the comment:

Le Tuesday 04 November 2008 01:03:42 Barry A. Warsaw, vous avez écrit :
> Benjamin's reviewed this and the only thing that jumps out at me is some
> funky indentation at about line 331

It's not related to my patch (I did'nt change POP3_SSL comment). But well, as 
you want: a new patch re-indent the "See the methods of the parent (...)" 
line (331).

Added file: http://bugs.python.org/file11940/poplib-bytes-3.patch

___
Python tracker <[EMAIL PROTECTED]>

___Index: Lib/test/test_poplib.py
===
--- Lib/test/test_poplib.py (révision 67094)
+++ Lib/test/test_poplib.py (copie de travail)
@@ -1,43 +1,284 @@
+"""Test script for poplib module."""
+
+# Modified by Giampaolo Rodola' to give poplib.POP3 and poplib.POP3_SSL
+# a real test suite
+
+import poplib
+import threading
+import asyncore
+import asynchat
 import socket
-import threading
-import poplib
+import os
 import time
 
 from unittest import TestCase
-from test import support
+from test import support as test_support
 
-HOST = support.HOST
+HOST = test_support.HOST
+PORT = 0
 
-def server(evt, serv):
-serv.listen(5)
-try:
-conn, addr = serv.accept()
-except socket.timeout:
-pass
-else:
-conn.send(b"+ Hola mundo\n")
-conn.close()
-finally:
-serv.close()
-evt.set()
+# the dummy data returned by server when LIST and RETR commands are issued
+LIST_RESP = b'1 1\r\n2 2\r\n3 3\r\n4 4\r\n5 5\r\n.\r\n'
+RETR_RESP = b"""From: [EMAIL PROTECTED]
+\r\nContent-Type: text/plain\r\n\
+MIME-Version: 1.0\r\n\
+Subject: Dummy\r\n\
+\r\n\
+line1\r\n\
+line2\r\n\
+line3\r\n\
+.\r\n"""
 
-class GeneralTests(TestCase):
 
+class DummyPOP3Handler(asynchat.async_chat):
+
+def __init__(self, conn):
+asynchat.async_chat.__init__(self, conn)
+self.set_terminator(b"\r\n")
+self.in_buffer = []
+self.push('+OK dummy pop3 server ready.')
+
+def collect_incoming_data(self, data):
+self.in_buffer.append(data)
+
+def found_terminator(self):
+line = b''.join(self.in_buffer)
+line = str(line, 'ISO-8859-1')
+self.in_buffer = []
+cmd = line.split(' ')[0].lower()
+space = line.find(' ')
+if space != -1:
+arg = line[space + 1:]
+else:
+arg = ""
+if hasattr(self, 'cmd_' + cmd):
+method = getattr(self, 'cmd_' + cmd)
+method(arg)
+else:
+self.push('-ERR unrecognized POP3 command "%s".' %cmd)
+
+def handle_error(self):
+raise
+
+def push(self, data):
+asynchat.async_chat.push(self, data.encode("ISO-8859-1") + b'\r\n')
+
+def cmd_echo(self, arg):
+# sends back the received string (used by the test suite)
+self.push(arg)
+
+def cmd_user(self, arg):
+if arg != "guido":
+self.push("-ERR no such user")
+self.push('+OK password required')
+
+def cmd_pass(self, arg):
+if arg != "python":
+self.push("-ERR wrong password")
+self.push('+OK 10 messages')
+
+def cmd_stat(self, arg):
+self.push('+OK 10 100')
+
+def cmd_list(self, arg):
+if arg:
+self.push('+OK %s %s' %(arg, arg))
+else:
+self.push('+OK')
+asynchat.async_chat.push(self, LIST_RESP)
+
+cmd_uidl = cmd_list
+
+def cmd_retr(self, arg):
+self.push('+OK %s bytes' %len(RETR_RESP))
+asynchat.async_chat.push(self, RETR_RESP)
+
+cmd_top = cmd_retr
+
+def cmd_dele(self, arg):
+self.push('+OK message marked for deletion.')
+
+def cmd_noop(self, arg):
+self.push('+OK done nothing.')
+
+def cmd_rpop(self, arg):
+self.push('+OK done nothing.')
+
+
+class DummyPOP3Server(asyncore.dispatcher, threading.Thread):
+
+handler = DummyPOP3Handler
+
+def __init__(self, address, af=socket.AF_INET):
+threading.Thread.__init__(self)
+asyncore.dispatcher.__init__(self)
+self.create_socket(af, socket.SOCK_STREAM)
+self.bind(address)
+self.listen(5)
+self.active = False
+self.active_lock = threading.Lock()
+self.host, self.port = self.socket.getsockname()[:2]
+
+def start(self):
+assert not self.active
+self.__flag = threading.Event()
+threading.Thread.start(self)
+self.__flag.wait()
+
+def run(self):
+self.active = True
+self.__flag.set()
+while self.active and asyncore.socket_map:
+self.active_lock.acquire()
+asyncore.loop(timeout=0.1, count=1)
+self.active_lock.release()
+asyncore.close_all(ignore_all=True)
+
+def stop(self):
+assert self.active
+self.active = Fal

[issue3727] poplib module broken by str to unicode conversion

2008-11-04 Thread STINNER Victor

Changes by STINNER Victor <[EMAIL PROTECTED]>:


Removed file: http://bugs.python.org/file11813/poplib-bytes-2.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3714] nntplib module broken by str to unicode conversion

2008-11-04 Thread STINNER Victor

Changes by STINNER Victor <[EMAIL PROTECTED]>:


Removed file: http://bugs.python.org/file11913/nntp-bytes.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3439] create a numbits() method for int and long types

2008-11-04 Thread STINNER Victor

STINNER Victor <[EMAIL PROTECTED]> added the comment:

> It would be nicer if the OverflowError from _PyLong_NumBits 
> were propagated, so that the second case raises OverflowError
> instead of giving an incorrect result

Why not, but I prefer your second proposition: return a long integer. 
Attached patch implements this solution.

>>> x=1<<(2**31-1)
>>> n=x.numbits(); n, n.numbits()
(2147483648L, 32L)
>>> x<<=(2**31-1)
>>> n=x.numbits(); n, n.numbits()
(4294967295L, 32L)
>>> x<<=1
>>> n=x.numbits(); n, n.numbits()
(4294967296L, 33L) # yeah!

With my patch, there are two functions:
 - _PyLong_NumBits(long)->size_t: may overflow
 - long_numbits(long)->long: don't raise overflow error, but may raise 
other errors like memory error

Added file: http://bugs.python.org/file11939/numbits-2.diff

___
Python tracker <[EMAIL PROTECTED]>

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



[issue1814] Victor Stinner's GMP patch for longs

2008-11-04 Thread STINNER Victor

STINNER Victor <[EMAIL PROTECTED]> added the comment:

Since it's hard to compare patches, I will now attach the 
longobject.c. But it would be better to use a DVCS with a branch to 
test it...

Added file: http://bugs.python.org/file11938/longobject.c

___
Python tracker <[EMAIL PROTECTED]>

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



[issue1814] Victor Stinner's GMP patch for longs

2008-11-04 Thread STINNER Victor

STINNER Victor <[EMAIL PROTECTED]> added the comment:

Updated patch, changes:
 - fix mashal module
 - fix all conversion from/to small integer (long, unsigned long, long 
long, unsigned long long, size_t, ssize_t)
 - create numbits() method for the long type (see also issue #3439)
 - catch memory allocation failure
 - fix many other bugs to fix most tests

Failing tests:
 - decimal: long_hash() is broken (doesn't use MSB)
 - io, pickle, pickletools, sqlite, tarfile: null byte in argument for 
int()
 - random: use old files from pickle whih contains '2147483648L\n' 
(trailing L)
 - sys: sizeof is invalid

To do: 
- raise OverflowError in numbits() for integer 2**(2**k) where 2**k
doesn't fit in an integer
- fix last tests

This version is slower than previous version, but it has less bugs :-)

Added file: http://bugs.python.org/file11937/py3k-long_gmp-v11.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3944] faster long multiplication

2008-11-04 Thread Mark Dickinson

Changes by Mark Dickinson <[EMAIL PROTECTED]>:


Removed file: http://bugs.python.org/file11724/30bit.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3944] faster long multiplication

2008-11-04 Thread Mark Dickinson

Mark Dickinson <[EMAIL PROTECTED]> added the comment:

I've opened a separate issue (issue 4258) for the idea of using 30-bit
long digits instead of 15-bit ones.  I'll remove the patch from this 
issue.

Pernici Mario's idea applies even better to base 2**30 longs:  one can
clump together 16 (!) of the multiplications at once, essentially
eliminating the overhead of shifts almost completely.

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4258] Use 30-bit digits instead of 15-bit digits for Python integers.

2008-11-04 Thread Mark Dickinson

Mark Dickinson <[EMAIL PROTECTED]> added the comment:

Here's an updated patch, with the following changes from the original:

- make the size of a digit (both the conceptual size
in bits and actual size in bytes) available to Python
via a new structseq sys.int_info.  This information
is useful for the sys.getsizeof tests.

- fix a missing cast in long_hash

- better fast path for 1-by-1 multiplication that
doesn't go via PyLong_FromLongLong.

Added file: http://bugs.python.org/file11936/30bit_longdigit2.patch

___
Python tracker <[EMAIL PROTECTED]>

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



[issue3588] sysconfig variable LINKFORSHARED has wrong value for MacOS X framework build

2008-11-04 Thread Matteo Bertini

Matteo Bertini <[EMAIL PROTECTED]> added the comment:

I confirm this issue, some handy workaround available?

--
nosy: +naufraghi

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4258] Use 30-bit digits instead of 15-bit digits for Python integers.

2008-11-04 Thread Mark Dickinson

Mark Dickinson <[EMAIL PROTECTED]> added the comment:

Note that to avoid "bad marshal data" errors, you'll probably need to do a 
'make distclean' before rebuilding with this patch.

___
Python tracker <[EMAIL PROTECTED]>

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



[issue4258] Use 30-bit digits instead of 15-bit digits for Python integers.

2008-11-04 Thread Mark Dickinson

New submission from Mark Dickinson <[EMAIL PROTECTED]>:

Here's an experimental patch, against the py3k branch, that makes Python 
represent its long integers internally in base 2**30 instead of base 
2**15, on platforms that have 32-bit and 64-bit integers available.

On platforms for which autoconf is unable to find both 32-bit and 64-bit 
integers, the representation falls back to the usual one.


See also issue 1814 (GMP for longs), and the discussion at

http://mail.python.org/pipermail/python-dev/2008-November/083315.html

(note particularly Tim Peter's message at:

http://mail.python.org/pipermail/python-dev/2008-November/083355.html
)

--
components: Interpreter Core
files: 30bit_longdigit.patch
keywords: patch
messages: 75491
nosy: marketdickinson
severity: normal
status: open
title: Use 30-bit digits instead of 15-bit digits for Python integers.
type: performance
versions: Python 3.1
Added file: http://bugs.python.org/file11935/30bit_longdigit.patch

___
Python tracker <[EMAIL PROTECTED]>

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