[issue14814] Implement PEP 3144 (the ipaddress module)

2012-06-18 Thread Terry J. Reedy

Terry J. Reedy tjre...@udel.edu added the comment:

 the interfaces of the v4 and v6 variants are deliberately very similar

I am hoping that means 'identical, once the obvious translations are made': v4 
to v6, xxx.xxx.xxx.xxx to whatever the v6 notation is, and anything else?

 documenting everything twice seems like a rather user hostile thing to do.

Agreed. Please factor out common stuff. I see two choices.

1. Document in parallel after an intro explaining the translations

4(args)
6(args)
Return ... (either in 4 terms which user translate for 6 or generic terms).

# This might be better if you expect people to be doing one type of thing with 
both v4 and v6.


2. Document serially, first v4 stuff then v6 stuff (at present, though order 
might be reversed in the future ;-).

v4 stuff
---
4(args)
Return ...

v6 stuff
---
The following v6 functions are the same as the v4 functions above, except that 
ipv4address'es become ipv6address'es etc.
6(args)

# This might be better if you expect people to be doing multiple things with 
either v4 or v6, but not both.

--

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



[issue14814] Implement PEP 3144 (the ipaddress module)

2012-06-18 Thread Nick Coghlan

Nick Coghlan ncogh...@gmail.com added the comment:

My current thoughts are to avoid the usual approach of embedding the method and 
property definitions in the class definitions, and instead have separate 
sections under [1] for

IP Addresses
IP Interfaces
IP Networks

Inside each of those sections, document the constructors directly under the 
section heading, and then separate out these subsections:

Common IP kind properties and methods
IPv4 kind properties and methods (if any)
IPv6 kind properties and methods (if any)

[1] 
http://docs.python.org/dev/library/ipaddress#representing-ip-addresses-and-networks

--

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



[issue4489] shutil.rmtree is vulnerable to a symlink attack

2012-06-18 Thread Hynek Schlawack

Hynek Schlawack h...@ox.cx added the comment:

Martin, what exactly is the intended proceeding now? Are you going to fix your 
patch and tests as soon as you have time or was that just a PoC and expect 
me/us to bring it into shape? (- troll-free question, I have no idea what to 
do next here and would like to see a safe rmtree in 3.3)

--

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



[issue15036] mailbox.mbox fails to pop two items in a row, flushing in between

2012-06-18 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 8b38a81ba3bf by Petri Lehtinen in branch '2.7':
Fix NEWS entry for #15036
http://hg.python.org/cpython/rev/8b38a81ba3bf

New changeset 38e2a87c9051 by Petri Lehtinen in branch '3.2':
Fix NEWS entry for #15036
http://hg.python.org/cpython/rev/38e2a87c9051

New changeset 072b08989731 by Petri Lehtinen in branch 'default':
Fix NEWS entry for #15036
http://hg.python.org/cpython/rev/072b08989731

--

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



[issue15036] mailbox.mbox fails to pop two items in a row, flushing in between

2012-06-18 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Perfect, fixed.

--

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



[issue4489] shutil.rmtree is vulnerable to a symlink attack

2012-06-18 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 Martin, what exactly is the intended proceeding now? Are you going to
 fix your patch and tests as soon as you have time or was that just a
 PoC and expect me/us to bring it into shape? (- troll-free question,
 I have no idea what to do next here and would like to see a safe
 rmtree in 3.3)

I still plan to work on this, but I'm also really really short on time.
I still favor my own approach (obviously), so if you want to bring it
into shape - that would be appreciated.

--

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



[issue9559] mailbox.mbox creates new file when adding message to mbox

2012-06-18 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

This is actually not true. When calling add(), mbox (and MMDF and Babyl) append 
the message to the file without rewriting it.

It's the following flush() call that rewrites the whole mailbox contents. I 
think this could be changed to work correctly by not setting self._pending = 
True in _singlefileMailbox.add. This way, the file wouldn't be rewritten by 
flush() if messages are only appended.

OTOH, flush() should still fsync the mailbox file (if we want to ensure that 
the changes are really written to disk). This would probably require a new flag 
in addition to self._pending, to indicate that there are unsynced changes.

--
nosy: +petri.lehtinen

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



[issue3665] Support \u and \U escapes in regexes

2012-06-18 Thread Serhiy Storchaka

Serhiy Storchaka storch...@gmail.com added the comment:

I forgot about byte patterns. Here is an updated patch.

--
Added file: http://bugs.python.org/file26040/re_unicode_escapes-3.patch

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



[issue1590744] mail message parsing glitch

2012-06-18 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

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



[issue15099] exec of function doesn't call __getitem__ or __missing__ on undefined global

2012-06-18 Thread John Firestone

New submission from John Firestone jo...@freenet.de:

exec(source, Dict()) doesn't call Dict().__getitem__ or Dict().__missing__ if 
the source string contains a function and the function references an undefined 
global.

class Dict1(dict):
def __getitem__(self, key):
print '__getitem__', repr(key)
if key == 's':
return None
return dict.__getitem__(self, key)

class Dict2(dict):
def __missing__(self, key):
print '__missing__', repr(key)
return None

source = if 1:
print '  1'
s
def f():
print '  2'
s
print '  3'
f()

print 'Dict1.__getitem__'
try:
exec(source, Dict1())
except NameError as exc_value:
print '  %s: %s' % (exc_value.__class__.__name__, exc_value)

print 'Dict2.__missing__'
try:
exec(source, Dict2())
except NameError as exc_value:
print '%s: %s' % (exc_value.__class__.__name__, exc_value)


Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:32:06) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
 import curiosity
Dict1.__getitem__
  1
__getitem__ 's'
__getitem__ 'f'
  2
NameError: global name 's' is not defined
Dict2.__missing__
  1
__missing__ 's'
  2
NameError: global name 's' is not defined


--
components: Interpreter Core
files: curiosity.py
messages: 163095
nosy: johnf
priority: normal
severity: normal
status: open
title: exec of function doesn't call __getitem__ or __missing__ on undefined 
global
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file26041/curiosity.py

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



[issue15100] Race conditions in shutil.copy, shutil.copy2 and shutil.copyfile

2012-06-18 Thread Radoslaw A. Zarzynski

New submission from Radoslaw A. Zarzynski 
radoslaw.zarzyn...@student.put.poznan.pl:

shutil.copy and shutil.copy2 first copy a file content and afterwards
change permissions of a destination file. Unfortunately, the sequence isn't 
atomical and may lead to disclosure of matter of any file that is being 
duplicated.

Additionally, shutil.copyfile procedure seems to have a problem with symlinks 
that could result in the corruption of content of any file on filesystem (in 
favorable conditions).

Some functions from shutil module that depend on copy[2] (and thus copyfile) 
are vulnerable too.
For example, shutil.move is using copy2 when os.rename fails because of file 
transfer between filesystems.

I have attached listing from strace(1) system utility below that illustrates 
the disclosure problem.

# ls -l ./shutil_test
-r 1 root root 10 06-18 11:42 shutil_test

# strace -- python -c import shutil; shutil.move('./shutil_test', '/tmp')
many irrelevant lines
open(./shutil_test, O_RDONLY) = 3
fstat(3, {st_mode=S_IFREG|0400, st_size=10, ...}) = 0
open(/tmp/shutil_test, O_WRONLY|O_CREAT|O_TRUNC, 0666) = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
fstat(3, {st_mode=S_IFREG|0400, st_size=10, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7fd82e13e000
read(3, blablabla\n, 16384)   = 10
read(3, , 12288)  = 0
fstat(4, {st_mode=S_IFREG|0644, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x7fd82e13d000
read(3, , 16384)  = 0
write(4, blablabla\n, 10) = 10
close(4)= 0
munmap(0x7fd82e13d000, 4096)= 0
close(3)= 0
munmap(0x7fd82e13e000, 4096)= 0
stat(./shutil_test, {st_mode=S_IFREG|0400, st_size=10, ...}) = 0
utimes(/tmp/shutil_test, {{1340012952, 0}, {1340012539, 0}}) = 0
chmod(/tmp/shutil_test, 0400) = 0

Quick fix for the first issue could rely on os.umask but much more elegant and 
composite solution might use combination of os.open, os.fchmod and os.fdopen 
instead of open(dst, 'wb') in shutil.copyfile procedure which additionally 
rectifies the problem with symlink attack.
However, I am not sure that the last one is portable and won't mess with 
another code.
I have prepared *untested* patches for both propositions.

Best regards,
Radoslaw A. Zarzynski

--
components: Library (Lib)
files: python_shutil_copyfile.diff
keywords: patch
messages: 163096
nosy: radoslaw.zarzynski
priority: normal
severity: normal
status: open
title: Race conditions in shutil.copy, shutil.copy2 and shutil.copyfile
type: security
versions: Python 2.7, Python 3.2
Added file: http://bugs.python.org/file26042/python_shutil_copyfile.diff

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



[issue15100] Race conditions in shutil.copy, shutil.copy2 and shutil.copyfile

2012-06-18 Thread Radoslaw A. Zarzynski

Changes by Radoslaw A. Zarzynski radoslaw.zarzyn...@student.put.poznan.pl:


Added file: http://bugs.python.org/file26043/python_shutil_copy_with_umask.diff

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



[issue15100] Race conditions in shutil.copy, shutil.copy2 and shutil.copyfile

2012-06-18 Thread Florent Xicluna

Changes by Florent Xicluna florent.xicl...@gmail.com:


--
components: +IO
nosy: +flox

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



[issue15099] exec of function doesn't call __getitem__ or __missing__ on undefined global

2012-06-18 Thread Mark Dickinson

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

This looks like a documentation issue:  it's well documented that in the exec 
statement, the globals dictionary must be a dict.  What's not so clear from the 
documentation (AFAICT) is that it must actually have *type* dict, rather than 
merely being an instance of dict.  (Or, from experimentation, it *can* be an 
instance of a dict subclass, but the underlying C-implemented dict methods are 
called directly, so overloads for __getitem__ and the like don't have any 
effect.)

--
assignee:  - docs@python
components: +Documentation -Interpreter Core
nosy: +docs@python, mark.dickinson
stage:  - needs patch
type: behavior - 
versions: +Python 3.2, Python 3.3

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



[issue15100] Race conditions in shutil.copy, shutil.copy2 and shutil.copyfile

2012-06-18 Thread Hynek Schlawack

Changes by Hynek Schlawack h...@ox.cx:


--
nosy: +hynek

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



[issue15099] exec of function doesn't call __getitem__ or __missing__ on undefined global

2012-06-18 Thread John Firestone

John Firestone jo...@freenet.de added the comment:

I find the behavior inconsistent. As you can see from this example, the 
exec'uted code *does* call the instance's overloaded __getitem__ and 
__missing__ methods when outside a function, but doesn't when inside.

--

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



[issue15099] exec of function doesn't call __getitem__ or __missing__ on undefined global

2012-06-18 Thread Mark Dickinson

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

 As you can see from this example, the exec'uted code *does* call the 
 instance's overloaded __getitem__ and __missing__ methods when outside a 
 function, but doesn't when inside.

Yep;  that's because the 's' and 'f' lookups at top level are *local* lookups, 
and the 's' lookup from inside the body of 'f' is done as a *global* lookup (as 
explained in the docs here: [1]).  In the exec statement, the locals can be any 
mapping-like object.  The behaviour's a bit clearer if you pass separate 
globals and locals dictionaries:

 source = \
... print s
... def f():
... print s
... f()
... 
 locals = {'s': 1729}
 globals = {'s': 31415}
 exec source in globals, locals
1729
31415


[1] 
http://docs.python.org/reference/executionmodel.html#interaction-with-dynamic-features

--

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



[issue15099] exec of function doesn't call __getitem__ or __missing__ on undefined global

2012-06-18 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc amaur...@gmail.com added the comment:

With Python3 though, __getitem__ seems called though.
OTOH the 'print' symbol is not found, even though the Dict1 got a 
'__builtins__' entry added.

--
nosy: +amaury.forgeotdarc

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



[issue15101] multiprocessing pool finalizer can fail if triggered in background pool thread

2012-06-18 Thread Richard Oudkerk

New submission from Richard Oudkerk shibt...@gmail.com:

Multiprocessing's process pool originally used a finalizer to shutdown the pool 
when the pool object is garbage collected.

Since the maxtasksperchild feature was added, the worker_handler thread holds a 
reference to the pool, preventing garbage collection at least until that thread 
finished.

In some cases the last reference to the pool is owned by the worker_handler 
thread, and as it exits, the finalizer is triggered.  Since the finalizer tries 
to join the worker_handler thread, an error will be raised since a thread 
cannot join itself.

It would have been better if pools had used the context manager protocol rather 
than using RAII -- see Issue #15064.

Unless/until RAII usage is fixed, a quick fix would be to just make the 
finalizer skip trying to join the current thread.

--
messages: 163101
nosy: sbt
priority: normal
severity: normal
status: open
title: multiprocessing pool finalizer can fail if triggered in background pool 
thread
type: behavior

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



[issue15102] Fix 64-bit building for buildbot scripts

2012-06-18 Thread Jeremy Kloth

New submission from Jeremy Kloth jeremy.kloth+python-trac...@gmail.com:

The buildbot scripts do not work for the 64-bit targets.

Firstly, the /p:UseEnv=True parameter to msbuild causes the 32-bit only 
projects (make_buildinfo and make_versioninfo) to fail due to architecture 
mismatch.  The scripts now unconditionally build those projects using the 
32-bit command-line tools.

The make_versioninfo project wasn't completely converted to be 32-bit only 
(issue9981); it would work correctly only from the IDE.  This fixes that and 
removes the Debug configuration as that was already #ifdef'd in the generated 
.h file.

--
components: Build, Cross-Build, Windows
hgrepos: 136
messages: 163102
nosy: jkloth
priority: normal
severity: normal
status: open
title: Fix 64-bit building for buildbot scripts
type: compile error
versions: Python 3.3

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



[issue15052] Outdated comments in build_ssl.py

2012-06-18 Thread Jeremy Kloth

Jeremy Kloth jeremy.kloth+python-trac...@gmail.com added the comment:

In addition to the fixes from issue15102, the only way I could get the ssl 
project to build successfully was to add the Perl installation (C:\Perl\bin) to 
my PATH.

--

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



[issue15040] stdlib compatibility with pypy: mailbox module

2012-06-18 Thread Éric Araujo

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


--
title: stdlib compatability with pypy: mailbox.py - stdlib compatibility with 
pypy: mailbox module

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



[issue15052] Outdated comments in build_ssl.py

2012-06-18 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

Again: installing Perl should not be necessary. That it is currently necessary 
is a bug in the sources.

--

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



[issue15052] Outdated comments in build_ssl.py

2012-06-18 Thread Jeremy Kloth

Jeremy Kloth jeremy.kl...@gmail.com added the comment:

Should I then open another issue just to track that bug?  Have you
even tried using build_ssl.py *without* Perl?  The changes required to
get that to work seem fairly extensive.

--

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



[issue15101] multiprocessing pool finalizer can fail if triggered in background pool thread

2012-06-18 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 4c07b9c49b75 by Richard Oudkerk in branch '2.7':
Issue #15101: Make pool finalizer avoid joining current thread
http://hg.python.org/cpython/rev/4c07b9c49b75

New changeset e1cd1f430ff1 by Richard Oudkerk in branch '3.2':
Issue #15101: Make pool finalizer avoid joining current thread.
http://hg.python.org/cpython/rev/e1cd1f430ff1

New changeset 59e0a51c5fc3 by Richard Oudkerk in branch 'default':
Issue #15101: Make pool finalizer avoid joining current thread.
http://hg.python.org/cpython/rev/59e0a51c5fc3

--
nosy: +python-dev

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



[issue15064] multiprocessing should use more context manager

2012-06-18 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 6d2a773d8e00 by Richard Oudkerk in branch 'default':
Issue #15064: Implement context manager protocol for multiprocessing types
http://hg.python.org/cpython/rev/6d2a773d8e00

--
nosy: +python-dev

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



[issue14814] Implement PEP 3144 (the ipaddress module)

2012-06-18 Thread pmoody

pmoody pyt...@hda3.com added the comment:

I'm not sure if this is still an issue, but returning the address in a packed 
format was an early issue 
(http://code.google.com/p/ipaddr-py/issues/detail?id=14). No objections from me 
for removing it from the network objects or for removing the packed constructor 
(I'm assuming there isn't any python-ism about being able to copy-construct an 
object from any valid representation of said object)

--

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



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2012-06-18 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Can this be closed?

--
nosy: +petri.lehtinen

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



[issue5346] mailbox._singlefileMailbox.flush doesn't preserve file rights

2012-06-18 Thread Petri Lehtinen

Changes by Petri Lehtinen pe...@digip.org:


--
nosy: +petri.lehtinen

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



[issue15099] exec of function doesn't call __getitem__ or __missing__ on undefined global

2012-06-18 Thread John Firestone

John Firestone jo...@freenet.de added the comment:

Thank you all for the quick and interesting responses!

Here is another example, this time showing a simple
s
sometimes behaves like
globals()['s']
and sometimes doesn't.

class Dict(dict):
def __getitem__(self, key):
if key == 's':
return 'got s'
return dict.__getitem__(self, key)

dct = Dict()
dct['the_dict'] = dct
print 0, id(dct)

source = if 1:
print '1', id(globals()), globals() is the_dict
print ' ', globals()['s']
print ' ', s
def f():
print '2', id(globals()), globals() is the_dict
print ' ', globals()['s']
print ' ', s
print '3'
f()

exec(source, dct)


Python 2.7.3 (v2.7.3:70274d53c1dd, Apr  9 2012, 20:32:06) 
[GCC 4.0.1 (Apple Inc. build 5493)] on darwin
 import curiosity2
0 2459928
1 2459928 True
  got s
  got s
2 2459928 True
  got s
 
Traceback (most recent call last):
  File stdin, line 1, in module
  File curiosity2.py, line 22, in module
exec(source, dct)
  File string, line 10, in module
  File string, line 8, in f
NameError: global name 's' is not defined


--
Added file: http://bugs.python.org/file26044/curiosity2.py

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



[issue7360] [mailbox] race: mbox may lose data with concurrent access

2012-06-18 Thread R. David Murray

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

Probably.  Unless I'm mistaken, the issue with concurrent rewrite (as opposed 
to append) exists for single-file-mailboxes in the general case, not just in 
Python.  And as far as I know failure is never noisy, the last writer wins.

--
nosy: +r.david.murray

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



[issue7359] mailbox cannot modify mailboxes in system mail spool

2012-06-18 Thread Petri Lehtinen

Petri Lehtinen pe...@digip.org added the comment:

Every program that accesses mailboxes in the system-wide mail spool directory 
needs to have write access to it. This is because dot-locking is achieved by 
creating additional files to that directory, and it must be used (in addition 
to fcntl() locking) to avoid messing up the mailboxes because of concurrent 
access.

In Debian, /var/mail is owned by root:mail with mode 2755, and every MUA is 
setgid mail. See the Debian Policy Manual section 11.6 for more information:


http://www.debian.org/doc/debian-policy/ch-customized-programs.html#s-mail-transport-agents

If you write a MUA or MTA using Python's mailbox module, your program needs to 
have write access to /var/mail. That's the only way to do it correctly. It also 
makes the mailbox module's renaming behavior possible.

--
nosy: +petri.lehtinen
resolution:  - invalid
stage:  - committed/rejected
status: open - closed

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



[issue15099] exec of function doesn't call __getitem__ or __missing__ on undefined global

2012-06-18 Thread Mark Dickinson

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

Yes, this is definitely a dark corner of Python, and one that it seems worth 
trying to illuminate a bit in the documentation.

--

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



[issue15052] Outdated comments in build_ssl.py

2012-06-18 Thread Jeremy Kloth

Jeremy Kloth jeremy.kloth+python-trac...@gmail.com added the comment:

OK, I have discovered my issue(s) building OpenSSL.  When I first downloaded 
the openssl-1.0.1c external, the timestamps for the .asm files ended up being 
older than their corresponding .pl sources therefore triggering the rules in 
the makefile.

I then decided to fix those Perl related issues by installing ActivePerl but 
*without* having it added to my PATH (as build_ssl.py finds it in the default 
location).  This causes build_ssl.py to no longer use the generated .asm files 
as a Perl executable has been found (line 221).

The attached patch ensures that the Perl executable is actually runnable.

--
keywords: +patch
Added file: http://bugs.python.org/file26045/build_ssl.patch

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



[issue15042] Implemented PyState_AddModule, PyState_RemoveModule

2012-06-18 Thread Robin Schreiber

Robin Schreiber robin.schrei...@me.com added the comment:

Added missing documentation. Also added documentation of PyState_FindModule() 
which still happened to be missing.

--
Added file: http://bugs.python.org/file26046/PyState_add-remove_module_v2.patch

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



[issue15052] Outdated comments in build_ssl.py

2012-06-18 Thread Jeremy Kloth

Jeremy Kloth jeremy.kloth+python-trac...@gmail.com added the comment:

I forgot to add that with the patch the comment wrt Perl is truly correct.

--

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



[issue15096] Drop support for the ur string prefix

2012-06-18 Thread Arfrever Frehtes Taifersar Arahesis

Changes by Arfrever Frehtes Taifersar Arahesis arfrever@gmail.com:


--
nosy: +Arfrever

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



[issue15102] Fix 64-bit building for buildbot scripts

2012-06-18 Thread Antoine Pitrou

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


--
keywords: +patch
Added file: http://bugs.python.org/file26047/2a20cee18add.diff

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



[issue13512] ~/.pypirc created insecurely

2012-06-18 Thread Antoine Pitrou

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

Eric, do you plan to fix this soon? Linux distributions have started patched 
their Pythons manually.

--
nosy: +pitrou

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



[issue14684] zlib set dictionary support inflateSetDictionary

2012-06-18 Thread Jesús Cea Avión

Jesús Cea Avión j...@jcea.es added the comment:

Sam, the window for Python 3.3 integration is almost close. Could you possibly 
update your patch with Nadeem's feedback?.

--

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



[issue15064] multiprocessing should use more context manager

2012-06-18 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 198382b4bcd0 by Richard Oudkerk in branch 'default':
Issue #15064: Make BaseManager.__enter__() start server if necessary.
http://hg.python.org/cpython/rev/198382b4bcd0

New changeset 836d712461b3 by Richard Oudkerk in branch 'default':
Issue #15064: Use with-blocks for some examples in docs.
http://hg.python.org/cpython/rev/836d712461b3

--

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



[issue15038] Optimize python Locks on Windows

2012-06-18 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 978326f98316 by Kristján Valur Jónsson in branch 'default':
Issue #15038: Optimize python Locks on Windows
http://hg.python.org/cpython/rev/978326f98316

--
nosy: +python-dev

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



[issue15102] Fix 64-bit building for buildbot scripts

2012-06-18 Thread Stefan Krah

Stefan Krah stefan-use...@bytereef.org added the comment:

There's some unrelated stuff in the patch that reverts commits in
mpdecimal.c and multiprocessing. Maybe a Rietveld issue.

--
nosy: +skrah

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



[issue15102] Fix 64-bit building for buildbot scripts

2012-06-18 Thread Jeremy Kloth

Jeremy Kloth jeremy.kl...@gmail.com added the comment:

The unrelated changes do seem to be an issue with the diff generated by Rietveld

--
nosy: +jeremy.kloth

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



[issue15102] Fix 64-bit building for buildbot scripts

2012-06-18 Thread Antoine Pitrou

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

If I understand, the proposed changes are the following:
https://bitbucket.org/jkloth/cpython-buildbot-amd64/changeset/2a20cee18add
?

I'm not a Windows specialist, but they do seem a bit weird:
- the pcbuild.sln changes remove Debug|x64.Build and replaces Debug with 
Release
- build-common.bat doesn't allow to distinguish between x86 and x64
- build.bat does not call build-common.bat

--
nosy: +pitrou

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



[issue15103] Solaris compiler chokes on importlib.h

2012-06-18 Thread Antoine Pitrou

New submission from Antoine Pitrou pit...@free.fr:

The Solaris compiler chokes on the embedded NUL character. Perhaps we can find 
another way to remove the importlib.h diffs from the notification e-mails 
(simply hardcode the filename?).

http://www.python.org/dev/buildbot/all/builders/x86%20Solaris%2011%203.x/builds/21/steps/compile/logs/stdio

/opt/solarisstudio/bin/cc -c  -O-I. -I./Include-DPy_BUILD_CORE -o 
Python/frozen.o Python/frozen.c
Python/importlib.h, line 3847: null character in input
cc: acomp failed for Python/frozen.c

--
components: Interpreter Core
messages: 163124
nosy: georg.brandl, pitrou
priority: normal
severity: normal
status: open
title: Solaris compiler chokes on importlib.h
type: compile error
versions: Python 3.3

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



[issue15052] Outdated comments in build_ssl.py

2012-06-18 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 Should I then open another issue just to track that bug?  Have you
 even tried using build_ssl.py *without* Perl?  The changes required to
 get that to work seem fairly extensive.

The 3.3 tree works fine for me without Perl, I'm confident that changing
the other trees will be trivial. I just haven't found the time to do
that.

No need to open other bug reports; I'm aware of the issue.

--

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



[issue15038] Optimize python Locks on Windows

2012-06-18 Thread Antoine Pitrou

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

There's a problem here:

Fatal Python error: PyCOND_SIGNAL(gil_cond) failed

http://www.python.org/dev/buildbot/all/builders/x86%20XP-4%203.x/builds/6859/steps/test/logs/stdio

--

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



[issue15102] Fix 64-bit building for buildbot scripts

2012-06-18 Thread Jeremy Kloth

Jeremy Kloth jeremy.kl...@gmail.com added the comment:

On Mon, Jun 18, 2012 at 3:27 PM, Antoine Pitrou rep...@bugs.python.org wrote:
 If I understand, the proposed changes are the following:
 https://bitbucket.org/jkloth/cpython-buildbot-amd64/changeset/2a20cee18add

That seems to be correct, yes.

 I'm not a Windows specialist, but they do seem a bit weird:
 - the pcbuild.sln changes remove Debug|x64.Build and replaces Debug with 
 Release

That change is related to the make_versioninfo project which doesn't
use the Debug build (like make_buildinfo)

 - build-common.bat doesn't allow to distinguish between x86 and x64

Correct as make_buildinfo and make_versioninfo are only ever built as
32-bit (see issue9981)

 - build.bat does not call build-common.bat

Oops, an oversight on my part.  It didn't show up in testing as the
solution already is built in 32-bit mode.  The call should in the same
location as in build-amd64.bat

--

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



[issue15038] Optimize python Locks on Windows

2012-06-18 Thread Richard Oudkerk

Richard Oudkerk shibt...@gmail.com added the comment:

Py_LOCAL_INLINE(int)
_PyCOND_WAIT_MS(PyCOND_T *cv, PyMUTEX_T *cs, DWORD ms)
{
DWORD wait;
cv-waiting++;
PyMUTEX_UNLOCK(cs);
/* lost wakeup bug would occur if the caller were interrupted here,
 * but we are safe because we are using a semaphore wich has an internal
 * count.
 */
wait = WaitForSingleObject(cv-sem, ms);
PyMUTEX_LOCK(cs);
if (wait != WAIT_OBJECT_0)
--cv-waiting;
/* Here we have a benign race condition with PyCOND_SIGNAL.
 * When failure occurs or timeout, it is possible that
 * PyCOND_SIGNAL also decrements this value
 * and signals releases the mutex.  This is benign because it
 * just means an extra spurious wakeup for a waiting thread.
 */
...

Are you really sure this race is benign?

If cv-waiting gets double decremented then it can become negative.  
PyCOND_SIGNAL() is defined as

Py_LOCAL_INLINE(int)
PyCOND_SIGNAL(PyCOND_T *cv)
{
if (cv-waiting) {
cv-waiting--;
return ReleaseSemaphore(cv-sem, 1, NULL) ? 0 : -1;
}
return 0;
}

While cv-waiting is negative, each call of PyCOND_SIGNAL() decrements 
cv-waiting, and increments the semaphore, while each call of PyCOND_WAIT() 
will increment cv-waiting and decrement the semaphore.

So if calls of PyCOND_SIGNAL() outnumber calls of PyCOND_WAIT() then we can 
have cv-waiting becoming very negative and the semaphore overflowing.

Maybe just changing the test in PyCOND_SIGNAL() to

if (cv-waiting  0) {

would be enough, but I am not convinced.

--
nosy: +sbt

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



[issue14772] Return destination values in some shutil functions

2012-06-18 Thread Roundup Robot

Roundup Robot devn...@psf.upfronthosting.co.za added the comment:

New changeset 8281233ec648 by Brian Curtin in branch 'default':
Fix #14772: Return the destination from some shutil functions.
http://hg.python.org/cpython/rev/8281233ec648

--
nosy: +python-dev

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



[issue14772] Return destination values in some shutil functions

2012-06-18 Thread Brian Curtin

Changes by Brian Curtin br...@python.org:


--
resolution:  - fixed
stage: commit review - committed/rejected
status: open - closed

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



[issue15103] Solaris compiler chokes on importlib.h

2012-06-18 Thread Jesús Cea Avión

Changes by Jesús Cea Avión j...@jcea.es:


--
nosy: +jcea

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



[issue14684] zlib set dictionary support inflateSetDictionary

2012-06-18 Thread Sam Rushing

Sam Rushing rushing@gmail.com added the comment:

I think other than the disagreement about whether the dictionary constructor 
arg should be a buffer object, it's good to go.
To restate my position: the need is for an immutable string of bytes, and 
that's exactly what PyBytes_Type is for.  I see no advantage to allowing a 
buffer object, which will require extra code to check that it is both a buffer 
object and set to be readonly.  I believe the argument for aesthetics does not 
apply, as the constant dictionary constructor argument is a morally different 
kind of parameter, comparable to (say) the compression level.

You folks are of course welcome to change it, though. 8^)

--

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



[issue15103] Solaris compiler chokes on importlib.h

2012-06-18 Thread Justin Venus

Justin Venus justin.ve...@gmail.com added the comment:

What is the purpose of the comment at the end of Python/importlib.h?  If I 
remove the comment that states binary marker for mercurial (something to that 
effect anyhow) the code compiles and only the tests fail.

--
nosy: +Justin.Venus

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



[issue3173] external strftime for Python?

2012-06-18 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

IANA is now distributing Olson's timezone database software which includes an 
implementation of strftime():

http://www.iana.org/time-zones/repository/releases/tzcode2012b.tar.gz

The code was designated as public domain by Arthur David Olson, but it seems to 
be based on code copyrighted by UCB and distributed under the BSD license.  The 
code does seem to include some locale support.

--

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



[issue15008] PEP 362 Signature Objects reference implementation

2012-06-18 Thread Yury Selivanov

Yury Selivanov yseliva...@gmail.com added the comment:

New version (pep363.4.patch)

Summary:

1. Removed 'Signature.implemented'
2. No more patching built-ins - no issues with shared interpreters
3. Removed 'Signature.format()'. If needed we'll reintroduce it in 3.4 
(although we still have 'Signature.__str__')
4. Signature now implements just __copy__ - creates a shallow copy 
(__deepcopy__ has been removed, as it wasn't deep)
5. Signature.__eq__ fixed to ignore order of keyword-only arguments.

Thanks and please review!

--
Added file: http://bugs.python.org/file26048/pep362.4.patch

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



[issue15008] PEP 362 Signature Objects reference implementation

2012-06-18 Thread Yury Selivanov

Yury Selivanov yseliva...@gmail.com added the comment:

Eric,

I personally prefer simple 'signature()' more than 'get_signature()'.  But I'll 
ask this question on python-dev on the next PEP update.

--

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



[issue7584] datetime.rfcformat() for Date and Time on the Internet

2012-06-18 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

I have reviewed RFC 3339 and it looks like the following produces a fully 
compliant timestamp:
 
 print(datetime(2000,1,1, tzinfo=timezone.utc).isoformat('T'))
2000-01-01T00:00:00+00:00

I see the following remaining issues:

1. It is often desired to get RFC 3339 timestamp in local timezone instead of 
UTC.  This will be addressed in issue 9527.

2. If UTC timestamp is produced by a computer in non-UTC timezone, the offset 
should be specified as '-00:00'.  If this is important, an application can 
replace '+' with '-', but most likely specifying the correct local offset is a 
better option.

3. RFC 3339 requires support for leap seconds.  This limitation cannot be 
solved by adding a method to datetime.

Most importantly, given that there are several RFCs describing different  date 
formats, a datetime.rfcformat() method will be ambiguous.  (GNU date has 
--rfc-2822 and --rfc-3339 options and the later allows output of three 
different precisions.)

I am going to reject this RFE.  I don't think adding datetime.rfcformat() 
method will solve any real deficiency and whatever limitations datetime has 
with respect to producing RFC compliant timestamps should be addressed in 
future specific proposals.

--
resolution:  - rejected
stage: needs patch - committed/rejected
status: open - pending

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



[issue9527] Add aware local time support to datetime module

2012-06-18 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

On Mon, Jun 11, 2012 at 11:18 PM, James Henstridge rep...@bugs.python.org 
wrote:
 One problem I can see with using a fixed offset
 tzinfo for localtime is that it might confuse people
 when doing date arithmetic.

Yes, this is the issue that I discussed in my first python-ideas/python-dev 
post.  (See msg162631 above.)

     d = datetime.localtime() + timedelta(days=7)

 While it will give a correct answer as a point in time it
 will have the wrong time zone offset if run just before a
 daylight saving transition, which could be just as confusing.

I think my latest proposal will fare slightly better in this scenario.  I am 
now propose implementing local timezone info discovery in datetime.astimezone() 
method.  Obtaining local time will now be a little more verbose:

local_time = datetime.now(timezone.utc).astimezone()

but (local_time + timedelta(7)).astimezone() will give you correctly adjusted 
aware datetime seven days later.

If we also implement astimezone() for naive instances, we can even support 
naive local time arithmetics:  (datetime.now() + timedelta(7)).astimezone() 
will produce the same time of day as now unless it falls into a non-existing 
hour.

 I'm not sure how you'd solve this without e.g. importing
 pytz into the standard library though.

Importing pytz will not help.  Pytz fudges the issue by extending tzinfo 
methods to accept isdst flag, but there is no place in datetime to store this 
flag.  Doing time calculations in local time is inherently ambiguous in 
presence of DST.  On the other hand, producing tz aware local time from any 
unambiguous absolute time specification (UTC, time_t, local time + tz offset, 
etc.) is a well-defined problem which does not have an adequate solution.

--

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



[issue9527] Add aware local time support to datetime module

2012-06-18 Thread Alexander Belopolsky

Alexander Belopolsky alexander.belopol...@gmail.com added the comment:

 ... is a well-defined problem which does not have an adequate solution.

I meant to say does not have an adequate solution *in the current datetime 
module*.  I think the enhanced datetime.astimezone() method will  solve this 
problem.

--

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