[issue2844] int() lies about base parameter

2010-05-27 Thread Mark Dickinson

Mark Dickinson  added the comment:

For py3k, this was fixed in r81557.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue7171] Add inet_ntop and inet_pton support for Windows

2010-05-27 Thread kookwekker

Changes by kookwekker :


--
nosy: +kookwekker

___
Python tracker 

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



[issue8831] recv and recvfrom on UDP socket do not return/throw exception after a close()

2010-05-27 Thread Alessandro Roat

New submission from Alessandro Roat :

A thread blocked on a recv or a recvfrom method on a UDP socket (waiting for a 
datagram) can not be unlocked calling a .close() from a different thread.
This is in contrast with the standard C++/C behavior, where a close() on a 
socket causes an asynchronous and immediate exception/return with error on the 
functions that are using the socket at the same time (but in another thread).
Thus, it is impossible to unlock a waiting recv/recvfrom calling a close() or a 
shutdown() if no more datagrams are coming.

--
components: IO
messages: 106596
nosy: Alessandro.Roat
priority: normal
severity: normal
status: open
title: recv and recvfrom on UDP socket do not return/throw exception after a 
close()
type: behavior
versions: Python 2.6

___
Python tracker 

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



[issue8831] recv and recvfrom on UDP socket do not return/throw exception after a close()

2010-05-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue7171] Add inet_ntop and inet_pton support for Windows

2010-05-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue8831] recv and recvfrom on UDP socket do not return/throw exception after a close()

2010-05-27 Thread Martin v . Löwis

Martin v. Löwis  added the comment:

Can you provide a patch?

--
nosy: +loewis

___
Python tracker 

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



[issue8831] recv and recvfrom on UDP socket do not return/throw exception after a close()

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

And maybe also a short example? :)

--
nosy: +haypo

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +tarek

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

A first implementation can be:

if os.name in ('nt', 'ce'):
   def atomic_rename(a, b):
  if os.path.exists(b):
 unlink(b)
  rename(a, b)
else:
   atomic_rename = os.rename

This implementation is atomic on POSIX, and not atomic on Windows. Tell me if I 
am wrong.

It can be improved later by adding the support of better Windows functions.

--

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread Giampaolo Rodola'

Changes by Giampaolo Rodola' :


--
nosy: +giampaolo.rodola

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

See issue #8604: proposal of a new "with atomic_write(filename) as fp: ..." 
context manager.

--

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

Begin by removing the dest file is maybe not the safer approach :-) Here is a 
new try: begin by renaming the dest file to a new file.

--
# use maybe a PRNG instead of a dummy counter or tempfile
def _create_old_filename(filename):
   old = filename + '.old'
   index = 2
   while os.path.exists(old):
  old = filename + '-%s.old' % index
  index += 1
   return old

if os.name in ('nt', 'ce'):
   def atomic_rename(src, dst):
  if os.path.exists(dst):
 old = _create_old_filename(dst)
 rename(dst, old)
 rename(src, dst)
 unlink(old)
  else:
 rename(src, dst)
else:
   atomic_rename = os.rename
--

What can we do if "rename(src, dst)" fails?

--

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread Trundle

Changes by Trundle :


--
nosy: +Trundle

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

> This implementation is atomic on POSIX, ...

Wrong :-)


"On how rename is broken in Mac OS X"
http://www.weirdnet.nl/apple/rename.html

"Update January 8, 2010: ... the original bug (5398777) was resolved in Snow 
Leopard but the issue I reported was not fixed. ..."

--

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

We have to think about network file systems like NFS. Gnome (nautilus) had a 
bug on rename because NFS emitted a delete notification on a rename:
http://linux-nfs.org/pipermail/nfsv4/2009-March/010134.html
https://bugzilla.gnome.org/show_bug.cgi?id=575684

It looks like rename is atomic, it's just a bug about notification. But other 
virtual file systems may not implement atomic rename (eg. is rename atomic with 
sshfs?). Should Python detect the file system type to choose the algorithm? I 
would like to say no, because I consider that as a file system (or kernel) bug, 
not a Python bug.

--

Should we also implement a atomic version of shutil.move()? Support rename if 
the source and the destination are on different file systems. Or is 
shutil.move() already atomic?

Note: this issue is only about renaming a *file*. Atomic rename of a directory 
is much more complex :-)

--

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

It seems you are proposing to call "atomic" something which isn't atomic:

   def atomic_rename(src, dst):
  if os.path.exists(dst):
 old = _create_old_filename(dst)
 rename(dst, old)
 rename(src, dst)
 unlink(old)

--
nosy: +pitrou

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

@pitrou: Yes, as I wrote: it's not possible to write an atomic function for all 
OS. The documentation must give a list of the OS on which the function is 
atomic. Would you prefer to not define the function instead of writing a 
pseudo-atomic function?

--

Java bug opened in 1996, closed with "Will Not Fix", last comment ("i am facing 
similar issue...") in 2008:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4017593

"How to do atomic writes in a file" in a MSDN blog:
http://blogs.msdn.com/b/adioltean/archive/2005/12/28/507866.aspx

Extract: "Sometimes shell operations like Delete, Rename can fail for various 
reasons. For example, it might just happen that an antivirus or content 
indexing application randomly scans the whole file system once in a while. So, 
potentially, the file Foo.Tmp.txt will be opened for a short period which will 
cause ... failed delete. And, not only that, but also Rename can fail if the 
old file already exists, and someone has an open handle on it."

To avoid that "antivirus or content indexing application" open the file, we may 
need to use a lock on the files.

--

___
Python tracker 

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



[issue8831] recv and recvfrom on UDP socket do not return/throw exception after a close()

2010-05-27 Thread Alessandro Roat

Alessandro Roat  added the comment:

This is an example, test it with netcat (nc -u localhost ) on linux (ubuntu 
9.10).
Lauch it with python , a prompt will appear.
Type "start" to launch the server, test the server sending UDP packets with 
netcat, the lenght of packet will be correctly printed.
However, when you'll type "stop" the close will be invoked but the receiving 
thread wont stop and the join in the stop() wont never return and you will need 
to kill the python interpreter.


import socket
import threading
import sys
import select


class UDPServer:
def __init__(self):
self.s=None
self.t=None
def start(self,port=):
if not self.s:
self.s=socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
self.s.bind(("",port))
self.t=threading.Thread(target=self.run)
self.t.start()
def stop(self):
if self.s:
self.s.close()
self.t.join()
self.t=None
def run(self):
while True:
try:
data,addr=self.s.recvfrom(1024)
print "recv done"
if len(data)<=0:
raise
self.onPacket(addr,data)
except:
break
#chiusura socket
print "server is no more running"
self.s=None
def onPacket(self,addr,data):
print len(data)


us=UDPServer()
while True:
sys.stdout.write("UDP server> ")
cmd=sys.stdin.readline()
if cmd=="start\n":
print "starting server..."
us.start()
print "done"
elif cmd=="stop\n":
print "stopping server..."
us.stop()
print "done"
elif cmd=="quit\n":
print "Quitting ..."
us.stop()
break;

print "bye bye"

--

___
Python tracker 

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



[issue8831] recv and recvfrom on UDP socket do not return/throw exception after a close()

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

> This is in contrast with the standard C++/C behavior, where a close()
> on a socket causes an asynchronous and immediate exception/return with
> error on the functions that are using the socket at the same time (but
> in another thread).

Are you sure of that? I don't see how Python behaviour would be different to a 
the same program written in C. Could you write a short example written in C to 
prove that?

--

To avoid this issue (Python blocks on recv() whereas a thread closed the 
socket), you should check that there is data on the socket before reading the 
data. Eg. TCPServer.serve_forever() uses select.select() to avoid this issue. 
Extract:

   while not self.__shutdown_request:
   # XXX: Consider using another file descriptor or
   # connecting to the socket to wake this up instead of
   # polling. Polling reduces our responsiveness to a
   # shutdown request and wastes cpu at all other times.
   r, w, e = select.select([self], [], [], poll_interval)
   if self in r:
   self._handle_request_noblock()

--

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> Would you prefer to not define the function instead of writing a pseudo-
> atomic function?

Your current implementation is useless, since it doesn't achieve anything new.
Besides, if the function isn't atomic, don't name it atomic_XXX.

--

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

> Antoine Pitrou  added the comment:
> > Would you prefer to not define the function instead of writing a pseudo-
> > atomic function?
> 
> Your current implementation is useless, since it doesn't achieve anything
> new. Besides, if the function isn't atomic, don't name it atomic_XXX.

Someone may reimplement it with unlink+rename which is worse :-)

But ok, you prefer to not define the function if no real atomic implementation 
can be written.

--

___
Python tracker 

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



[issue8832] automate minidom.unlink() with a context manager

2010-05-27 Thread Kristján Valur Jónsson

New submission from Kristján Valur Jónsson :

It is all to easy to forget to "unlink()" minidom documents resulting in huge 
memory usage.
This patch allows to automate that process with a context manager, similar to 
how files can be closed in the same way:

with xml.dom.minidom.parse() as dom:
workwith(dom)

will automatically call dom.unlink() when context manager is exited.
Patch provided.

--
components: Library (Lib)
files: minidomcontext.patch
keywords: easy, needs review, patch, patch
messages: 106610
nosy: krisvale
priority: normal
severity: normal
status: open
title: automate minidom.unlink() with a context manager
type: feature request
versions: Python 3.2
Added file: http://bugs.python.org/file17472/minidomcontext.patch

___
Python tracker 

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



[issue8828] Atomic function to rename a file

2010-05-27 Thread Raghuram Devarakonda

Changes by Raghuram Devarakonda :


--
nosy: +draghuram

___
Python tracker 

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



[issue8405] Improve test_os._kill (failing on slow machines)

2010-05-27 Thread Brian Curtin

Brian Curtin  added the comment:

I just noticed the other day that a buildbot failed because of this issue. 
Attached is a patch which removes the unconditional 0.5 sleep, and increases 
the loop to run 100 times. It should cover the worst case of a super slow 
buildbot, but is still typically complete in tenths of a second in the common 
case.

--
Added file: http://bugs.python.org/file17473/issue8405.diff

___
Python tracker 

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



[issue8833] tarfile: broken hardlink handling and testcase.

2010-05-27 Thread Justin Bronder

New submission from Justin Bronder :

When adding hardlinks to an archive, tarfile does not set the size
of each additional link to zero as specified by the tar format [1].

In addition, the current test case hardlinks is also broken.
Instead of testing that the size of a hardlink to a non-empty file
is 0, it tests that the size to a empty file is zero, which cannot
fail.

A patch against current svn trunk is attached and was tested with
'python -m test.regrtest  -v test_tarfile'


1. http://www.gnu.org/software/tar/manual/tar.html#SEC170

--
components: Library (Lib)
files: python-2.7-tarfile-hardlinks.patch
keywords: patch
messages: 106612
nosy: jsbronder
priority: normal
severity: normal
status: open
title: tarfile:  broken hardlink handling and testcase.
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file17474/python-2.7-tarfile-hardlinks.patch

___
Python tracker 

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



[issue8579] Add missing tests for FlushKey, LoadKey, and SaveKey in winreg

2010-05-27 Thread Brian Curtin

Brian Curtin  added the comment:

LoadKey and SaveKey require special privileges which need to manually acquired, 
likely via ctypes. #1578269 has some code which does this for os.symlink 
privileges and it's about to go into py3k, so I'll try to piggyback off of that.

--

___
Python tracker 

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



[issue8822] datetime naive and aware types should have a well-defined definition that can be cross-referenced

2010-05-27 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
nosy: +belopolsky
stage:  -> needs patch
versions: +Python 2.6, Python 2.7, Python 3.1, Python 3.2

___
Python tracker 

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



[issue8822] datetime naive and aware types should have a well-defined definition that can be cross-referenced

2010-05-27 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

> 'naive' and 'aware' are key datetime types - they need a proper
> definition and anchor for crossrefences.

The definition is given in the introductory section:
"""
There are two kinds of date and time objects: “naive” and “aware”. This 
distinction refers to whether the object has any notion of time zone, daylight 
saving time, or other kind of algorithmic or political time adjustment. 
"""

I am not sure what you propose to add to this.  Do you wan't to dedicate a 
separate subsection to naive and aware time and datetime? I feel that would be 
an overkill.  Would simply adding index entries for naive and aware 
time/datetime objects be enough?

> It is not said how to make non-naive object, 

This may be due to the fact that there is no concrete tzinfo implementation in 
stdlib.  See issue 5094.

I think it can be added in datetime constructor section that providing a tzinfo 
argument results in an aware object.  this is already so for 
datetime.fromtimestamp.

> how to detect if object of naive or aware.

This is already clear IMO:

"""
An object d of type time or datetime may be naive or aware. d is aware if 
d.tzinfo is not None and d.tzinfo.utcoffset(d) does not return None. If 
d.tzinfo is None, or if d.tzinfo is not None but d.tzinfo.utcoffset(d) returns 
None, d is naive.
"""

--

___
Python tracker 

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



[issue7171] Add inet_ntop and inet_pton support for Windows

2010-05-27 Thread Brian Curtin

Changes by Brian Curtin :


--
components: +Windows
versions:  -Python 2.7

___
Python tracker 

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



[issue8834] Define order of Misc/ACKS entries

2010-05-27 Thread Alexander Belopolsky

New submission from Alexander Belopolsky :

This is a semi-serious feature request following a brief discussion on 
#python-dev IRC.

Brett Cannon pointed out on python-checkins list [1] that the names should be 
alphabetized.  However, given that the names are international, it is not 
obvious what it means.

I propose to add a comment at the top of Misc/ACKS that the list is maintained 
in "rough alphabetical order" but not define it any further.

[1] http://mail.python.org/pipermail/python-checkins/2010-May/093650.html

--
assignee: d...@python
components: Documentation
messages: 106615
nosy: belopolsky, d...@python
priority: normal
severity: normal
status: open
title: Define order of Misc/ACKS entries
type: feature request

___
Python tracker 

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



[issue8834] Define order of Misc/ACKS entries

2010-05-27 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
keywords: +patch
stage:  -> patch review
Added file: http://bugs.python.org/file17475/issue8834.diff

___
Python tracker 

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



[issue8833] tarfile: broken hardlink handling and testcase.

2010-05-27 Thread Lars Gustäbel

Changes by Lars Gustäbel :


--
assignee:  -> lars.gustaebel
nosy: +lars.gustaebel

___
Python tracker 

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



[issue8598] test/support: don't use localhost as IPv6 host name

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

I consider that the bug is in my /etc/hosts configuration, not in Python. So I 
close the issue as "invalid".

--
resolution:  -> invalid
status: open -> closed

___
Python tracker 

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



[issue8835] buildbot: support.transient_internet() doesn't catch DNS socket.gaierror

2010-05-27 Thread STINNER Victor

New submission from STINNER Victor :

The nameserver responsible of sha2.hboeck.de is down and this hostname is used 
in test_ssl. The result is that all trunk buildbots are red (error).

support.transient_internet() should catch socket.gaierror.

--

One example: 
http://www.python.org/dev/buildbot/all/builders/amd64%20gentoo%20trunk/builds/1007

Traceback (most recent call last):
  File ".../Lib/test/test_ssl.py", line 261, in test_algorithms
s.connect(remote)
  ...
gaierror: [Errno -2] Name or service not known

--
components: Tests
messages: 106617
nosy: haypo
priority: normal
severity: normal
status: open
title: buildbot: support.transient_internet() doesn't catch DNS socket.gaierror
versions: Python 2.7, Python 3.2

___
Python tracker 

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



[issue7150] datetime operations spanning MINYEAR give bad results

2010-05-27 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

Committed in r81566 (trunk), r81568 (py3k), r81569 (release26-maint), r81570 
(release31-maint).

--
stage: commit review -> committed/rejected
status: open -> closed

___
Python tracker 

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



[issue1289118] timedelta multiply and divide by floating point

2010-05-27 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
stage:  -> commit review
Added file: http://bugs.python.org/file17476/issue1289118-withdoc.diff

___
Python tracker 

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




[issue8835] buildbot: support.transient_internet() doesn't catch DNS socket.gaierror

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

Patch to catch gaierror(EAI_NODATA) and gaierror(EAI_NONAME).

--
keywords: +patch
Added file: http://bugs.python.org/file17477/transilient_internet_dns.patch

___
Python tracker 

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



[issue8835] buildbot: support.transient_internet() doesn't catch DNS socket.gaierror

2010-05-27 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Looks ok to me.

--
nosy: +pitrou

___
Python tracker 

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



[issue8836] Conflicting default values of parameter to __import__

2010-05-27 Thread Anthony Foglia

New submission from Anthony Foglia :

Looking at the documentation for the __import__ builtin, the default value of 
the level parameter is unclear.  Two different values are mentioned.  The 
function signature is written:

__import__(name, globals={}, locals={}, fromlist=[], level=-1)

But the third paragraph begins: "level specifies whether to use absolute or 
relative imports. 0 (the default) means only perform absolute imports."

So which is it, -1 or 0?

I'm guessing 0.  If -1 is still a valid value, it needs to be described.

--
assignee: d...@python
components: Documentation
messages: 106621
nosy: afoglia, d...@python
priority: normal
severity: normal
status: open
title: Conflicting default values of parameter to __import__
versions: Python 3.1

___
Python tracker 

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



[issue8835] buildbot: support.transient_internet() doesn't catch DNS socket.gaierror

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

I commited the patch as r81571 in trunk. Wait for the buildbot before porting 
it to other branches.

--

___
Python tracker 

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



[issue8836] Conflicting default values of parameter to __import__

2010-05-27 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Fixed in r81572.

--
nosy: +benjamin.peterson
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue8837] PyArg_ParseTuple(): remove old and unused "O?" format

2010-05-27 Thread STINNER Victor

New submission from STINNER Victor :

"O?" format was introduced by r4301 (15 years, 9 months ago). 
PyArg_ParseTuple() was first documented in Python 2.2, but without the full 
list of all formats. The format list was added to Python 2.3, but "O?" was 
never documented. So I get that no third party progam use it.

In Python trunk, "O?" is no more used and so I propose to remove it to simplify 
getarg.c (simplify getarg cannot be a bad thing). PyArg_ParseTuple() has now 
better formats than "O?".

--

"O&" calls a callback: if the callback returns 0, raise an error; otherwise 
gets the object. Example of callbacks: PyXXX_Check() function (eg. 
PyInt_Check()).

--

The full Python test suite pass without any error on a patched Python (trunk).

--
components: Interpreter Core
files: getarg_oquestion.patch
keywords: patch
messages: 106624
nosy: haypo
priority: normal
severity: normal
status: open
title: PyArg_ParseTuple(): remove old and unused "O?" format
versions: Python 2.7, Python 3.2
Added file: http://bugs.python.org/file17478/getarg_oquestion.patch

___
Python tracker 

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



[issue8837] PyArg_ParseTuple(): remove old and unused "O?" format

2010-05-27 Thread STINNER Victor

Changes by STINNER Victor :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue8837] PyArg_ParseTuple(): remove old and unused "O?" format

2010-05-27 Thread STINNER Victor

Changes by STINNER Victor :


--
versions:  -Python 2.7

___
Python tracker 

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



[issue8838] Remove codecs.readbuffer_encode() and codecs.charbuffer_encode()

2010-05-27 Thread STINNER Victor

New submission from STINNER Victor :

readbuffer_encode() and charbuffer_encode() are not really encoder nor related 
to encodings: they are related to PyBuffer. readbuffer_encode() uses "s#" 
format and charbuffer_encode() uses "t#" format to parse their arguments. Both 
functions were introduced by the creation of the _codecs module 10 years ago 
(r14660).

I think that these functions should be removed. memoryview() should be used 
instead.

Note: charbuffer_encode() is the last function using on of the "t" format (t, 
t#, t*) in Python3.

--
components: Interpreter Core
messages: 106625
nosy: haypo
priority: normal
severity: normal
status: open
title: Remove codecs.readbuffer_encode() and codecs.charbuffer_encode()
versions: Python 3.2

___
Python tracker 

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



[issue8838] Remove codecs.readbuffer_encode() and codecs.charbuffer_encode()

2010-05-27 Thread STINNER Victor

STINNER Victor  added the comment:

A search in Google doesn't show anything interesting: it looks like these 
functions were never used outside Python test suite. I just noticed r41461: 
"Add tests for various error cases and for readbuffer_encode() and
charbuffer_encode(). This increases code coverage in Modules/_codecsmodule.c 
from 83% to 95%." (4 years ago)

--

___
Python tracker 

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



[issue8839] PyArg_ParseTuple(): remove "t# format

2010-05-27 Thread STINNER Victor

New submission from STINNER Victor :

"t#" format was introduced by r11803 (11 years ago): "Implement new format 
character 't#'. This is like s#, accepting an object that implements the buffer 
interface, but requires a buffer that contains 8-bit character data."

Python3 now has a strict separation between byte string (bytes and bytearray 
types) and unicode string (str), and has PyBuffer and PyCapsule APIs. "t#" 
format can be replaced by "y#" or "y*".

Extract of getarg.c:

  /*TEO: This can be eliminated --- here only for backward
compatibility */
case 't': { /* 8-bit character buffer, read-only access */

In Python, the last function using "t#" is _codecs.charbuffer_encode() and I 
proposed to remove this function in #8838. We can also patch this function.

I don't know if third party modules use this format or not. I don't know if it 
can be just removed or if it should raise a deprecation warning (but who will 
notice such warning since there are disabled by default?).

--
components: Interpreter Core
messages: 106627
nosy: haypo
priority: normal
severity: normal
status: open
title: PyArg_ParseTuple(): remove "t# format
versions: Python 3.2

___
Python tracker 

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



[issue8834] Define order of Misc/ACKS entries

2010-05-27 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

Looks good to me.

--
nosy: +pitrou
versions: +Python 2.6, Python 2.7, Python 3.1, Python 3.2

___
Python tracker 

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



[issue8825] int("0",0) throws exception

2010-05-27 Thread Dino Viehland

Dino Viehland  added the comment:

I've opened a bug in the IronPython bug tracker: 
http://ironpython.codeplex.com/WorkItem/View.aspx?WorkItemId=27209

--

___
Python tracker 

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



[issue8840] io.StringIO: truncate+print disabled in 3.1.2

2010-05-27 Thread Terry J. Reedy

New submission from Terry J. Reedy :

Some of my tests use io.StringIO and assert that captured print output equals 
expected output. Until now, I reused one buffer by truncating between tests. I 
recently replaced 3.1.1 with 3.1.2 (WinXP) and the *second* test of each run 
started failing. The following minimal code shows the problem (and should 
suggest a new unit test):

from io import StringIO; s = StringIO(); print(repr(s.getvalue()))
print('abc', file=s); print(repr(s.getvalue()))
s.truncate(0); print(repr(s.getvalue()))
print('abc', file=s); print(repr(s.getvalue()))

prints (both command window and IDLE)

''
'abc\n'
''
'\x00\x00\x00\x00abc\n' 
# should be and previously would have been 'abc\n'

s.truncate(0) zeros the buffer and appears to set the length to 0, but a 
subsequent print sees the length as what it was before the truncate and appends 
after the zeroed characters. Ugh.

I presume the problem is StringIO-emulation specific but have not tested 'real' 
files to be sure.

---
also...

>>> help(s.truncate)
Help on built-in function truncate:

truncate(...)
Truncate size to pos.
...

should be, for greater clarity, something like

truncate([pos])
Truncate the size of the file or buffer to pos
...

--
components: IO, Library (Lib)
messages: 106630
nosy: tjreedy
priority: normal
severity: normal
stage: needs patch
status: open
title: io.StringIO: truncate+print disabled in 3.1.2
type: behavior
versions: Python 3.1

___
Python tracker 

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



[issue8840] io.StringIO: truncate+print disabled in 3.1.2

2010-05-27 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

This was an exceptional API change in 3.1.2: truncate() doesn't move the file 
pointer anymore, you have to do it yourself (with seek(0) in your case). I'm 
sorry for the inconvenience; the change was motivated by the desire of having 
an API more consistent with other file-handling APIs out there.

--
nosy: +pakal, pitrou

___
Python tracker 

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



[issue8840] io.StringIO: truncate+print disabled in 3.1.2

2010-05-27 Thread Antoine Pitrou

Changes by Antoine Pitrou :


--
resolution:  -> rejected
status: open -> closed

___
Python tracker 

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



[issue8841] GetoptError strings should be localized

2010-05-27 Thread Richard Lowe

New submission from Richard Lowe :

The GetoptError exception raised by getopt.getopt() to indicate errors in 
provided arguments seems intended to be displayed to the user[1], but is not 
localized and doesn't contain enough information, short of interpreting the 
error string, for consumers to raise their own, localized, error.

[1] http://docs.python.org/library/getopt.html

--
components: Library (Lib)
messages: 106632
nosy: richlowe
priority: normal
severity: normal
status: open
title: GetoptError strings should be localized
type: feature request
versions: Python 2.6

___
Python tracker 

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



[issue672115] Assignment to __bases__ of direct object subclasses

2010-05-27 Thread Hari Krishna Dara

Hari Krishna Dara  added the comment:

I just hit up on this same bug and the "class object(object): pass" workaround 
worked fine. I too would like to know how safe this workaround is, could 
someone more insightful please comment on this?

--
nosy: +Hari.Krishna.Dara

___
Python tracker 

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



[issue6583] 2to3 fails to fix test.test_support

2010-05-27 Thread Rodrigo Bernardo Pimentel

Rodrigo Bernardo Pimentel  added the comment:

Pascal is correct, trunk Doc/library/test.rst still says: "The 2to3 tool will 
automatically adapt imports when converting your sources to 3.0." Perhaps this 
should simply be changed to "The 2to3 tool will not automatically convert this, 
so make sure you do, manually, if you port your code to Python 3."

Please let me know if you require a patch for this (but I think it's trivial 
enough), or if you think this should raise a -3 warning.

--
nosy: +rbp

___
Python tracker 

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



[issue6583] 2to3 fails to fix test.test_support

2010-05-27 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

r81579

--

___
Python tracker 

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



[issue2394] [Py3k] Finish the memoryview object implementation

2010-05-27 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
nosy: +belopolsky

___
Python tracker 

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



[issue4653] Patch to fix typos for Py3K

2010-05-27 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

I don't run Windows either but I believe sizeof(char) == 1 is guaranteed by the 
C standard, so the first report (Python/dynload_win.c) is invalid.

The last two appear to be valid [1], and a common mistake. [2]  Unit tests are 
needed for these.  I also notice that r81156 does not add a unit test either.  
ISTM, a test case can be crafted by setting sys.stderr to None.

[1] http://msdn.microsoft.com/en-us/library/aa366537(VS.85).aspx
[2] http://blogs.msdn.com/b/oldnewthing/archive/2004/03/02/82639.aspx

--
components: +Windows
nosy: +belopolsky
stage: commit review -> unit test needed

___
Python tracker 

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



[issue4653] Patch to fix typos for Py3K

2010-05-27 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

Strike my comment about Python/dynload_win.c - I was looking at the trunk 
version instead of py3k.  In py3k theInfo is wchar_t and patch seems to be 
valid.

--

___
Python tracker 

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



[issue2651] Strings passed to KeyError do not round trip

2010-05-27 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
assignee:  -> belopolsky
nosy: +belopolsky

___
Python tracker 

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



[issue2651] Strings passed to KeyError do not round trip

2010-05-27 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
versions: +Python 3.2 -Python 2.5

___
Python tracker 

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



[issue2920] Patch to print symbolic value or errno in EnvironmentError.__str__()

2010-05-27 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
assignee:  -> belopolsky
nosy: +belopolsky

___
Python tracker 

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



[issue762920] API Functions for PyArray

2010-05-27 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

Is there still any interest in pursuing this?  Raymond?

--

___
Python tracker 

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



[issue3196] Option in pydoc to show docs from private methods

2010-05-27 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
assignee:  -> belopolsky
nosy: +belopolsky

___
Python tracker 

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