[issue2986] difflib.SequenceMatcher not matching long sequences

2010-07-02 Thread Eli Bendersky

Eli Bendersky  added the comment:

The new "junk heuristic" has been added to difflib.py in SVN revision 26661 in 
2002 (which is, incidentally, the last revision to modify difflib.py). Its 
commit log says:

-
Mostly in SequenceMatcher.{__chain_b, find_longest_match}:
This now does a dynamic analysis of which elements are so frequently
repeated as to constitute noise.  The primary benefit is an enormous
speedup in find_longest_match, as the innermost loop can have factors
of 100s less potential matches to worry about, in cases where the
sequences have many duplicate elements.  In effect, this zooms in on
sequences of non-ubiquitous elements now.

While I like what I've seen of the effects so far, I still consider
this experimental.  Please give it a try!
-

--

___
Python tracker 

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



[issue9136] RuntimeError when profiling Decimal

2010-07-02 Thread Mark Dickinson

Mark Dickinson  added the comment:

2.5 compatibility is fine for the 2.x version of decimal.py.

For the 3.x version of decimal.py, I don't see what it buys us.

--

___
Python tracker 

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



[issue9137] x.update(red=5, blue=6, other=7) doesn't work, where x is a MutableMapping

2010-07-02 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue9137] x.update(red=5, blue=6, other=7) doesn't work, where x is a MutableMapping

2010-07-02 Thread Mark Dickinson

Mark Dickinson  added the comment:

Here's a fix.

--
keywords: +patch
nosy: +rhettinger
Added file: http://bugs.python.org/file17834/issue9137.patch

___
Python tracker 

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



[issue9136] RuntimeError when profiling Decimal

2010-07-02 Thread Stefan Krah

Changes by Stefan Krah :


Removed file: http://bugs.python.org/file17831/unnamed

___
Python tracker 

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



[issue9137] x.update(red=5, blue=6, other=7) doesn't work, where x is a MutableMapping

2010-07-02 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

And what about this?
>>> x.update(self=5)

--
nosy: +amaury.forgeotdarc

___
Python tracker 

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



[issue9137] x.update(red=5, blue=6, other=7) doesn't work, where x is a MutableMapping

2010-07-02 Thread Mark Dickinson

Mark Dickinson  added the comment:

Ah.  Good point.

--

___
Python tracker 

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



[issue9137] x.update(red=5, blue=6, other=7) doesn't work, where x is a MutableMapping

2010-07-02 Thread Mark Dickinson

Mark Dickinson  added the comment:

Updated patch, to deal with 'self' correctly too.

--
stage: needs patch -> patch review
Added file: http://bugs.python.org/file17835/issue9137_v2.patch

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Éric Araujo

Éric Araujo  added the comment:

The examples seem good to me after a quick reading. There’s not too much but 
still enough.

I find the phrasing of the versionchanged not easily understandable:
“The position of the arguments can now be omitted.”
Clearer and probably too verbose:
“When using numeric placeholders that follow the order of the positional 
arguments, you can omit the numbers: '{} {!s}' is equivalent to '{0} {1!s}'”

--
nosy: +merwok

___
Python tracker 

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



[issue9136] RuntimeError when profiling Decimal

2010-07-02 Thread Stefan Krah

Stefan Krah  added the comment:

In the new patches I reinstated the ternary construct. I think it
would be nice to use dict comprehensions in py3k. People read the
stdlib for guidance, and it would help if ultimately only the most
concise idioms remained in py3k.

If I'm not mistaken, quite often the unit tests already use the latest
constructs available.


That said, there are always issues that only become apparent after
maintaining a module for years, so I guess I'll wait for a decision.

--
Added file: http://bugs.python.org/file17836/issue9136-py3k-3.patch

___
Python tracker 

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



[issue9136] RuntimeError when profiling Decimal

2010-07-02 Thread Stefan Krah

Changes by Stefan Krah :


Added file: http://bugs.python.org/file17837/issue9136-trunk-3.patch

___
Python tracker 

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



[issue1152248] Enhance file.readlines by making line separator selectable

2010-07-02 Thread Éric Araujo

Éric Araujo  added the comment:

Ralph, core developers have not rejected this idea. It needs a patch now (even 
rough) to get the discussion further.

--
components: +Library (Lib) -Interpreter Core

___
Python tracker 

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



[issue9141] Allow objects to decide if they can be collected by GC

2010-07-02 Thread Kristján Valur Jónsson

New submission from Kristján Valur Jónsson :

The GC module currently relies only on the presence of a __del__ method to 
decide if an object can be safely collected at all.  Also, there is a special 
case for generator objects.

This patch allows any object to call an api during its traversal,
PyObject_GC_Collectable(), to indicate whether it is fit to be collected at 
this time, overriding any presence of a __del__ method or not.

This mechanism is being put in place in stackless python 2.7 because tasklets 
cannot always be collected depending on their runtime state, and I thought this 
might be a useful addition for regular python, especially since there already 
is such a dynamic special case for generator objects.

--
components: Interpreter Core
files: gc_collectable.patch
keywords: needs review, patch, patch
messages: 109099
nosy: krisvale
priority: normal
severity: normal
status: open
title: Allow objects to decide if they can be collected by GC
type: feature request
versions: Python 3.2
Added file: http://bugs.python.org/file17838/gc_collectable.patch

___
Python tracker 

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



[issue9141] Allow objects to decide if they can be collected by GC

2010-07-02 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

First, what's the use case? Just backporting an internal Stackless API isn't a 
reasonable request.
Second, this tells that there *is* a finalization function, but not what the 
function is. How is the GC supposed to find it?
Third, the implementation looks quite suboptimal. Better define a new slot 
method, such as tp_needs_finalizing, or tp_get_finalizer.

--
nosy: +pitrou, tim_one

___
Python tracker 

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



[issue5468] urlencode does not handle "bytes", and could easily handle alternate encodings

2010-07-02 Thread Senthil Kumaran

Senthil Kumaran  added the comment:

I see no problem in going ahead with the suggestion proposed and the patch.

- I checked with RFC3986 Section 2.5
http://labs.apache.org/webarch/uri/rfc/rfc3986.html#identifying-data

Relevant line:
When a new URI scheme defines a component that represents textual data 
consisting of characters from the Universal Character Set [UCS], the data 
should first be encoded as octets according to the UTF-8 character encoding 
[STD63]; then only those octets that do not correspond to characters in the 
unreserved set should be percent-encoded.

- This is done already in quote and quote_plus. 
- It just boils down to urlencode also providing the same facility for query 
strings and that was the point of this bug report.

Jeremy, I shall go ahead with this and do the modifications, if required.

--
assignee: jhylton -> orsenthil
nosy: +orsenthil

___
Python tracker 

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



[issue6507] Enhance dis.dis to autocompile codestrings

2010-07-02 Thread Scott Dial

Scott Dial  added the comment:

> disassemble_str should be private with an underscore.

disassemble_string should've been private as well, while we are editing this 
module.

--
nosy: +scott.dial

___
Python tracker 

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



[issue9142] while executing python

2010-07-02 Thread rajesh

New submission from rajesh :

while executing the python file:
python sercon.py

It Displays the below error.kindly provide me the solution.

Updated the Configparser log
Exception in Tkinter callback
Traceback (most recent call last):
  File "/usr/local/lib/python2.3/lib-tk/Tkinter.py", line 1345, in __call__
return self.func(*args)
  File 
"/ug6/RAJESH/finacle/TParty/lib/python2.3/site-packages/Pmw/Pmw_1_1/lib/PmwPanedWidget.py",
 line 307, in _handleConfigure
self._getNaturalSizes()
  File 
"/ug6/RAJESH/finacle/TParty/lib/python2.3/site-packages/Pmw/Pmw_1_1/lib/PmwPanedWidget.py",
 line 338, in _getNaturalSizes
bw = string.atoi(self.cget('hull_borderwidth'))
  File "/usr/local/lib/python2.3/string.py", line 220, in atoi
return _int(s, base)
TypeError: int() can't convert non-string with explicit base
Traceback (most recent call last):
  File "sercon.py", line 264, in ?
prodname,primaryIP,flag1 = displayScreen1(prodname,primaryIP)
  File "sercon.py", line 141, in displayScreen1
widget = screen1.screen1(root,prodname,prodprimaryIP)
  File "/ug6/RAJESH/finacle/app/base/sercon/tools/screen1.py", line 228, in 
__init__
self.panes.configurepane('IPAddresses',size = 0.35)
  File 
"/ug6/RAJESH/finacle/TParty/lib/python2.3/site-packages/Pmw/Pmw_1_1/lib/PmwPanedWidget.py",
 line 521, in configurepane
self._handleConfigure()
  File 
"/ug6/RAJESH/finacle/TParty/lib/python2.3/site-packages/Pmw/Pmw_1_1/lib/PmwPanedWidget.py",
 line 307, in _handleConfigure
self._getNaturalSizes()
  File 
"/ug6/RAJESH/finacle/TParty/lib/python2.3/site-packages/Pmw/Pmw_1_1/lib/PmwPanedWidget.py",
 line 338, in _getNaturalSizes
bw = string.atoi(self.cget('hull_borderwidth'))
  File "/ug6/RAJESH/finacle/TParty/lib/python2.3/string.py", line 220, in atoi
return _int(s, base)
TypeError: int() can't convert non-string with explicit base

--
messages: 109103
nosy: rajesh.chandran
priority: normal
severity: normal
status: open
title: while executing python
type: compile error
versions: Python 2.5

___
Python tracker 

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



[issue9142] while executing python

2010-07-02 Thread Mark Dickinson

Mark Dickinson  added the comment:

Sorry;  this tracker is for reporting bugs in Python, not for getting help with 
your own Python code.

There are other places you might be able to get help, for example the 
python-list mailing list[1], which is also available as a newsgroup[2], or the 
#python IRC channel on freenode.net[3].

[1] http://mail.python.org/mailman/listinfo/python-list
[2] news:comp.lang.python
[3] irc://irc.freenode.net  #python

--
nosy: +mark.dickinson
resolution:  -> invalid
stage:  -> 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



[issue9140] SocketServer.BaseRequestHandler not a new-style class?

2010-07-02 Thread Eric Smith

Eric Smith  added the comment:

We can't change this for 2.6 since it's not a bug fix, and it's too late for 
2.7. I doubt we would ever change it for 2.x, since it's likely to break other 
code is subtle ways.

In 3.x all classes are new-style, so it's not at issue there.

--
nosy: +eric.smith
resolution:  -> wont fix
stage:  -> committed/rejected
status: open -> closed
type: behavior -> feature request
versions: +Python 2.7 -Python 2.6

___
Python tracker 

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



[issue9140] SocketServer.BaseRequestHandler not a new-style class?

2010-07-02 Thread Éric Araujo

Éric Araujo  added the comment:

To address the OP’s problem, super can be removed:

-super(Handler, self).do_GET()
+Handler.do_GET(self)

--
nosy: +merwok

___
Python tracker 

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



[issue9143] test_ctypes: fails on sparc64 long double

2010-07-02 Thread Jan Engelhardt

New submission from Jan Engelhardt :

When python is compiled with sparc64 settings (i.e. -m64), test_ctypes fails. I 
am not sure why this does not show up with -m32.

ares:/usr/src/packages/BUILD/Python-2.6.5> 
LD_LIBRARY_PATH=/usr/src/packages/BUILD/Python-2.6.5 ./python -E -tt 
./Lib/test/regrtest.py -s test_ctypes
test_ctypes
test test_ctypes failed -- Traceback (most recent call last):
  File 
"/usr/src/packages/BUILD/Python-2.6.5/Lib/ctypes/test/test_callbacks.py", line 
81, in test_longdouble
self.check_type(c_longdouble, 3.14)
  File 
"/usr/src/packages/BUILD/Python-2.6.5/Lib/ctypes/test/test_callbacks.py", line 
30, in check_type
self.failUnlessEqual(self.got_args, (-3, arg))
AssertionError: (-3, 0.0) != (-3, 3.1401)

When using "long double x = 3.14", the constant 3.14 is taken as a double, 
which is then converted to long double. Of course it isn't accurate. There must 
be something in python that doesn't generate this correctly; it should have 
been "long double x = 3.14L", since only the constant 3.14L expands to the full 
longdouble pi.

--
components: Tests
messages: 109107
nosy: jengelh
priority: normal
severity: normal
status: open
title: test_ctypes: fails on sparc64 long double
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



[issue459007] Document sys.path on Windows

2010-07-02 Thread Catalin Iacob

Changes by Catalin Iacob :


--
nosy: +catalin

___
Python tracker 

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



[issue9140] SocketServer.BaseRequestHandler not a new-style class?

2010-07-02 Thread Peter Froehlich

Peter Froehlich  added the comment:

On Fri, Jul 2, 2010 at 8:50 AM, Éric Araujo  wrote:
> -    super(Handler, self).do_GET()
> +    Handler.do_GET(self)

Yep, that's how I solved it. :-D

--

___
Python tracker 

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



[issue9144] Import error for multiprocessing in 2.7rc2 on Windows

2010-07-02 Thread Giuseppe Ottaviano

New submission from Giuseppe Ottaviano :

With a fresh install from python-2.7rc2.amd64.msi (rc1 is also affected) 
multiprocessing gives the following error:

Python 2.7rc2 (r27rc2:82154, Jun 22 2010, 21:22:29) [MSC v.1500 64 bit (AMD64)] 
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import multiprocessing
>>> multiprocessing.Pool()
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Python27\lib\multiprocessing\__init__.py", line 227, in Pool
return Pool(processes, initializer, initargs, maxtasksperchild)
  File "C:\Python27\lib\multiprocessing\pool.py", line 89, in __init__
self._setup_queues()
  File "C:\Python27\lib\multiprocessing\pool.py", line 181, in _setup_queues
from .queues import SimpleQueue
  File "C:\Python27\lib\multiprocessing\queues.py", line 22, in 
from multiprocessing.synchronize import Lock, BoundedSemaphore, Semaphore, 
Condition
  File "C:\Python27\lib\multiprocessing\synchronize.py", line 22, in 
from multiprocessing.forking import assert_spawning, Popen
  File "C:\Python27\lib\multiprocessing\forking.py", line 158, in 
from ._multiprocessing import win32, Connection, PipeConnection
ImportError: No module named _multiprocessing

I noticed that _multiprocessing.lib is not in Lib/multiprocessing/ but in 
libs/, so I don't know why there is a relative import here.
Changing all the occurrences to
  from _multiprocessing import ...
everything works fine.

--
components: Library (Lib)
messages: 109109
nosy: ot
priority: normal
severity: normal
status: open
title: Import error for multiprocessing in 2.7rc2 on Windows
type: crash
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



[issue9143] test_ctypes: fails on sparc64 long double

2010-07-02 Thread Mark Dickinson

Mark Dickinson  added the comment:

I think this is a duplicate of issue 6029.

--
nosy: +mark.dickinson
resolution:  -> duplicate
status: open -> closed
superseder:  -> FAIL: test_longdouble (ctypes.test.test_callbacks.Callbacks) 
[SPARC/64-bit]

___
Python tracker 

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



[issue6029] FAIL: test_longdouble (ctypes.test.test_callbacks.Callbacks) [SPARC/64-bit]

2010-07-02 Thread Mark Dickinson

Mark Dickinson  added the comment:

Closed issue 9143 as a duplicate of this one.

--
nosy: +jengelh, mark.dickinson

___
Python tracker 

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



[issue9141] Allow objects to decide if they can be collected by GC

2010-07-02 Thread Kristján Valur Jónsson

Kristján Valur Jónsson  added the comment:

1. The use case is any C extension that may need to run non-trivial code when 
being deleted, but where this can not be statically known.  An example in the 
code today is generators, and the PyGen_NeedsFinalizing() function, doing 
exactly this.  This is an attempt to make this functionality available to any C 
extension.

2. No, this gives a C extension the oppertunity to say: It's okay to delete me 
from GC, or it's not okay to delete me from GC.  There is no need to specify 
any particular finalizing function, it will be invoked when the refcount goes 
to 0, just as it happens with __del__(), or as it happens with PyGen objects.

3. This code is only invoked for garbage deemed collectable.  As such it is not 
on any critical path, most gc collections don't actually find any garbage. The 
cost of a few extra indirect function calls is likely to drown in the memory 
allocator overhead when the objects are released. 

Also, this is designed to be a minimum impact patch.  We really shouldn't be 
creating new slot methods when it can be avoided.

--

___
Python tracker 

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



[issue9144] Import error for multiprocessing in 2.7rc2 on Windows

2010-07-02 Thread Georg Brandl

Changes by Georg Brandl :


--
assignee:  -> benjamin.peterson
nosy: +benjamin.peterson
priority: normal -> high

___
Python tracker 

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



[issue9144] Import error for multiprocessing in 2.7rc2 on Windows

2010-07-02 Thread Georg Brandl

Changes by Georg Brandl :


--
priority: high -> release blocker

___
Python tracker 

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



[issue9144] Import error for multiprocessing in 2.7rc2 on Windows

2010-07-02 Thread Éric Araujo

Changes by Éric Araujo :


--
components: +Build -Library (Lib)
nosy: +merwok
resolution:  -> accepted

___
Python tracker 

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



[issue9141] Allow objects to decide if they can be collected by GC

2010-07-02 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> 1. The use case is any C extension that may need to run non-trivial
> code when being deleted, but where this can not be statically known.

tp_del is IMO a bad place to do it. I'd recommend tp_dealloc instead,
precisely so that you don't end up with uncollectable objects tied to
internal OS structures or other non-trivial resources.

(also, tp_del seems to have problems with subclassing. I don't remember
the specifics)

> 3. This code is only invoked for garbage deemed collectable.  As such
> it is not on any critical path, most gc collections don't actually
> find any garbage. The cost of a few extra indirect function calls is
> likely to drown in the memory allocator overhead when the objects are
> released.

Ok.

--

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Eric Smith

Eric Smith  added the comment:

Thanks for taking the lead on this.

In this sentence:
+The new format syntax also supports new and different options, showed in the
+follow examples.
"showed" should be "shown".

I like to use an example showing attribute access on named types. Barry Warsaw 
suggested using "self", which is a great tip. It's hard to come up with a 
complete example, but something that ends up like:
  "x is {self.x}, y is {self.y}".format(self=self)

I think it would be a good idea to show comma formatting (even with its 
limitations), since there's not another easy way to do that in Python:
>>> '{:,}'.format(1234567890)
'1,234,567,890'

For datetime, something like:
>>> import datetime
>>> d = datetime.datetime(2010, 7, 4, 12, 15, 58)
>>> '{:%Y-%m-%d %H:%M:%S}'.format(d)
'2010-07-04 12:15:58'

--

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Eric Smith

Eric Smith  added the comment:

Instead of "named types", I meant "named arguments", of course.

--

___
Python tracker 

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



[issue1152248] Enhance file.readlines by making line separator selectable

2010-07-02 Thread Douglas Alan

Douglas Alan  added the comment:

Until this feature gets built into Python, you can use a Python-coded generator 
such as this one to accomplish the same effect:

def fileLineIter(inputFile,
 inputNewline="\n",
 outputNewline=None,
 readSize=8192):
   """Like the normal file iter but you can set what string indicates newline.
   
   The newline string can be arbitrarily long; it need not be restricted to a
   single character. You can also set the read size and control whether or not
   the newline string is left on the end of the iterated lines.  Setting
   newline to '\0' is particularly good for use with an input file created with
   something like "os.popen('find -print0')".
   """
   if outputNewline is None: outputNewline = inputNewline
   partialLine = ''
   while True:
   charsJustRead = inputFile.read(readSize)
   if not charsJustRead: break
   partialLine += charsJustRead
   lines = partialLine.split(inputNewline)
   partialLine = lines.pop()
   for line in lines: yield line + outputNewline
   if partialLine: yield partialLine

--
nosy: +Douglas.Alan

___
Python tracker 

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



[issue9145] test_coercion fails in refleak runs

2010-07-02 Thread Antoine Pitrou

New submission from Antoine Pitrou :

$ ./python -m test.regrtest -uall -R 2:3 -v test_coercion
== CPython 2.7rc2+ (trunk, Jul 2 2010, 18:50:24) [GCC 4.3.2]
==   Linux-2.6.27.10-grsec--grs-ipv4-64-x86_64-with-debian-lenny-sid 
little-endian
==   /home/antoine/cpython/debug/build/test_python_19672
test_coercion
test_cmptypes (test.test_coercion.CoercionTest) ... ok
test_infinite_rec_classic_classes (test.test_coercion.CoercionTest) ... ok
test_infix_binops (test.test_coercion.CoercionTest) ... ok
test_prefix_binops (test.test_coercion.CoercionTest) ... ok

--
Ran 4 tests in 0.122s

OK
beginning 5 repetitions
12345
test test_coercion crashed -- : local 
variable 'res' referenced before assignment
Traceback (most recent call last):
  File "/home/antoine/cpython/debug/Lib/test/regrtest.py", line 873, in 
runtest_inner
huntrleaks)
  File "/home/antoine/cpython/debug/Lib/test/regrtest.py", line 1003, in dash_R
run_the_test()
  File "/home/antoine/cpython/debug/Lib/test/regrtest.py", line 989, in 
run_the_test
indirect_test()
  File "/home/antoine/cpython/debug/Lib/test/test_coercion.py", line 339, in 
test_main
process_infix_results()
  File "/home/antoine/cpython/debug/Lib/test/test_coercion.py", line 215, in 
process_infix_results
if isinstance(res[i][6], tuple):
UnboundLocalError: local variable 'res' referenced before assignment
1 test failed:
test_coercion
[55121 refs]

--
components: Library (Lib), Tests
messages: 109118
nosy: ezio.melotti, flox, pitrou
priority: normal
severity: normal
status: open
title: test_coercion fails in refleak runs
type: behavior
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



[issue6507] Enhance dis.dis to autocompile codestrings

2010-07-02 Thread Daniel Urban

Daniel Urban  added the comment:

> disassemble_string should've been private as well, while we are editing this 
> module.

Attached the updated patch.

--
Added file: http://bugs.python.org/file17839/issue6507_3.diff

___
Python tracker 

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



[issue9137] x.update(red=5, blue=6, other=7) doesn't work, where x is a MutableMapping

2010-07-02 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: stutzbach -> mark.dickinson
resolution:  -> accepted

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Ezio Melotti

Ezio Melotti  added the comment:

Here is a new patch.
I fixed the typos, removed the examples from the first section and added a link 
to the examples section.
I also added the examples suggested by Eric plus an example about {:%}, and 
followed the suggestion of Éric and clarified the versionchanged message.

--
Added file: http://bugs.python.org/file17840/issue9139v2.diff

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue6507] Enhance dis.dis to autocompile codestrings

2010-07-02 Thread Mark Dickinson

Changes by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue9146] Segfault in hashlib in OpenSSL FIPS mode using non-FIPS-compliant hashes, if "ssl" imported before "hashlib"

2010-07-02 Thread Dave Malcolm

New submission from Dave Malcolm :

Having run:
  prelink --undo --all
the following works OK:
 OPENSSL_FORCE_FIPS_MODE=1 python -c "import hashlib; m = m = hashlib.md5(); 
m.update('abc')"

but the following segfaults:
 OPENSSL_FORCE_FIPS_MODE=1 python -c "import ssl; import hashlib; m = m = 
hashlib.md5(); m.update('abc')"

and the following gives the same segfault, in a simpler way (strictly speaking 
one shouldn't directly import _ssl, but this most directly reproduces the 
crash):
 OPENSSL_FORCE_FIPS_MODE=1 python -c "import _ssl; import hashlib; m = m = 
hashlib.md5(); m.update('abc')"

(gdb) bt
#0  0x in ?? ()
#1  0x7fffee978736 in EVP_hash (self=0xaed3c0, vp=0x95b6a4, len=3) at 
/home/david/coding/python-svn/trunk-fips/Modules/_hashopenssl.c:112
#2  0x7fffee978cb5 in EVP_update (self=0xaed3c0, args=('abc',)) at 
/home/david/coding/python-svn/trunk-fips/Modules/_hashopenssl.c:247
#3  0x00567faa in PyCFunction_Call (func=, arg=('abc',), kw=0x0)
at Objects/methodobject.c:81
and the segfault is due to EVP_DigestUpdate calling through the ctx->update 
function pointer, which in this case is NULL.

(gdb) p self->ctx
$2 = {digest = 0x70c955a0, engine = 0x0, flags = 0, md_data = 0x0, pctx = 
0x0, update = 0}

self->ctx->update == NULL and self->ctx->digest == &bad_md, as set up by:

The setup is here: (different run of gdb, so different addresses):

(gdb) bt
#0  EVP_DigestInit_ex (ctx=0x7fffecdc7b80, type=0x7fffefc6fc60, impl=0x0) at
digest.c:249
#1  0x7fffecbc53ce in init_hashlib () at
/usr/src/debug/Python-2.6.2/Modules/_hashopenssl.c:513

#ifdef OPENSSL_FIPS
  if (FIPS_mode())
  {
  if (!(type->flags & EVP_MD_FLAG_FIPS)
   && !(ctx->flags & EVP_MD_CTX_FLAG_NON_FIPS_ALLOW))
  {
  EVPerr(EVP_F_EVP_DIGESTINIT_EX,
EVP_R_DISABLED_FOR_FIPS);
  =>  ctx->digest = &bad_md;
  return 0;
  }
  }
#endif

(seen on x86_64 Linux; Fedora 13, with openssl-1.0.0-1.fc13.x86_64 on SVN 
trunk, and on other builds)

Clearly, the Python process should not segfault or abort.

I don't think it's clear what the behavior should be here, though - how is the 
Python standard library to be used in conjunction with OpenSSL's FIPS mode?

>From page 18 of the OpenSSL's FIPS guide: 
>http://ftp.openssl.org/docs/fips/UserGuide.pdf
"By design, the OpenSSL API attempts to disable non­FIPS algorithms, when in FIPS mode, at the 
EVP level and via most low level function calls.  Failure to check the return code from low level 
functions could result in unexpected behavior.  Note also that sufficiently creative or unusual use of 
the API may still allow the use of non­FIPS algorithms.  The non­FIPS algorithm disabling is 
intended as a aid to the developer in preventing the accidental use of non­FIPS algorithms in FIPS 
mode, and not as an absolute guarantee. It is the responsibility of the application developer to 
ensure that no non­FIPS algorithms are used when in FIPS mode."

It seems odd that the behavior of "md5" within "hashlib" can vary depending on 
whether "_ssl" was imported first.  Reducing surprises for the programmer 
suggests to me that the behavior for these two cases should be harmonized.

It also seems odd that SSL can refuse the usage of MD5 whilst other 
implementations exist and are available; my understanding of FIPS mode is that 
it's intended for locked-down environments that wish to ensure that only 
known-good crypto is used (and e.g. MD5 is known to be be broken for some uses, 
see: http://www.kb.cert.org/vuls/id/836068)

Possible approaches:
  (A) change hashlib so that it continues to support md5 if ssl/_ssl is 
imported first, even in FIPS mode
  (B) change hashlib so that in FIPS mode, it fails to support md5 even if 
ssl/_ssl is not imported first
(B.1) by not recognizing "md5" as a digest, leading to NameError exceptions 
and similar (I dislike this approach, as it leads to obscure failures)
(B.2) by raising a new exception e.g. "ProhibitedInFIPSMode" or somesuch 
(so that the failure is obvious and searchable)
  (C.*) as per (B.*), but support an explicit override: 
hashlib.md5(non_fips_allow=True)

Thoughts?

--
components: Library (Lib)
messages: 109121
nosy: dmalcolm
priority: normal
severity: normal
status: open
title: Segfault in hashlib in OpenSSL FIPS mode using non-FIPS-compliant 
hashes, if "ssl" imported before "hashlib"
type: crash
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



[issue9146] Segfault in hashlib in OpenSSL FIPS mode using non-FIPS-compliant hashes, if "ssl" imported before "hashlib"

2010-07-02 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

First, is it only with 2.7 or 2.6?
Second, I don't really get the point of the FIPS mode. The PDF you linked to 
seems full of bureaucratic jargon.
Third, I can't reproduce under Mandriva, but perhaps it's because it's using 
OpenSSL 1.0.0 (which the PDF says isn't supported).
Fourth, if MD5 is insecure and FIPS disables insecure algorithm, then why 
should hashlib allow MD5 hashing when FIPS mode is enabled?
Fifth, please take a look at the OpenSSL initialization routine in _sslmodule.c 
and try to transplant it to the hashlib initialization routine:

/* Init OpenSSL */
SSL_load_error_strings();
SSL_library_init();
OpenSSL_add_all_algorithms();

--
nosy: +gps, pitrou

___
Python tracker 

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



[issue9146] Segfault in hashlib in OpenSSL FIPS mode using non-FIPS-compliant hashes, if "ssl" imported before "hashlib"

2010-07-02 Thread Dave Malcolm

Dave Malcolm  added the comment:

Thanks

> First, is it only with 2.7 or 2.6?
I've seen this with both 2.6 tarball builds and SVN trunk; in both cases 
against openssl-1.0.0-1.[

> Second, I don't really get the point of the FIPS mode. The PDF you linked to 
> seems full of bureaucratic jargon.
Agreed.

> Third, I can't reproduce under Mandriva, but perhaps it's because it's using 
> OpenSSL 1.0.0 (which the PDF says isn't supported).
Thanks for the info.  This is my fault, sorry.  I'm using openssl-1.0.0-1 on 
Fedora; on doublechecking I see that we appear to be carrying various patches 
in our openssl packages, which I assume are a backport from a more recent 
version of the FIPS support:
(see http://cvs.fedoraproject.org/viewvc/devel/openssl/ ); I'll see if I can 
get more information from other Fedorans to verify this, and on what version of 
openssl upstream this is equivalent to.

> Fourth, if MD5 is insecure and FIPS disables insecure algorithm, then why 
> should hashlib allow MD5 hashing when FIPS mode is enabled?
My understanding is that some sites wish to prohibit the use of MD5 as an 
authentication mechanism, but don't need to prohibit it where the use is not 
"cryptography", e.g. to compute an index into a hash table where intentionally 
induced hash collisions can not break the application's security.

> Fifth, please take a look at the OpenSSL initialization routine in 
> _sslmodule.c and try to transplant it to the hashlib initialization routine:
[snip]

Done; with the attached patch to SVN trunk, I don't need the initial "import 
ssl" to reproduce the segfault; the following will segfault (in the same place):
OPENSSL_FORCE_FIPS_MODE=1 gdb --args ./python -c "import hashlib; m = m = 
hashlib.md5(); m.update('abc')"

--
keywords: +patch
Added file: http://bugs.python.org/file17841/add_ssl_init_to_hashlib.patch

___
Python tracker 

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



[issue9146] Segfault in hashlib in OpenSSL FIPS mode using non-FIPS-compliant hashes, if "ssl" imported before "hashlib"

2010-07-02 Thread Antoine Pitrou

Antoine Pitrou  added the comment:

> with the attached patch to SVN trunk, I don't need the initial "import 
> ssl" to reproduce the segfault

Nice, so at least that oddity is eliminated :)

So I guess it's down to the A, B, and C approaches you suggested.
Of course, if we choose to allow MD5, we must find a way for OpenSSL to accept 
running an MD5 hash...

--

___
Python tracker 

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



[issue9144] Import error for multiprocessing in 2.7rc2 on Windows

2010-07-02 Thread Benjamin Peterson

Benjamin Peterson  added the comment:

Martin, any ideas?

--
nosy: +loewis

___
Python tracker 

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



[issue7829] dis module documentation gives no indication of the dangers of bytecode inspection

2010-07-02 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Brett, should this be reassigned to d...@python? I gave a suggested text change 
months ago. The need for a change like this was mentioned again today on pydev 
in the thread "Can Python implementations reject semantically invalid 
expressions?". Since the current deficiency has been noted repeatedly, I think 
the priority should be at least normal.

Unless someone suggests something even better, I think my proposed replacememt 
should be accepted, formatted, and applied. I think it is definitely better 
than the current text.

--
priority: low -> normal

___
Python tracker 

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



[issue6507] Enhance dis.dis to autocompile codestrings

2010-07-02 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

Just today, someone posted the result of dis.dis('somebytes') and did not 
notice the error because dis blithely disassembles bytes as bytecodes, even in 
3.x. (The person actually dissed a 2.x string).

>>> from dis import dis
>>> dis(b'cat')
  0 DUP_TOPX29793

It is a natural thing to do, so I hope this is put in 3.2. 

Since the undocumented 'disassemble_string' now disassembles bytes, I think it 
should be renamed '_disassemble_bytes' instead of '_disassemble_string'. This 
would accord with the general effort to remove 2.x fossils from 3.x.

Aside from that, it looks ready, from a reading review, to apply and test: doc 
addition, added tests, new function and else case, and rename.

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

> - I find the _cmp() and __cmp() indirection poor style in 3.x,
> especially when you simply end up comparing self._getstate() and
> other._getstate() (it is also suboptimal because it can do more
> comparisons than needed)

The best I could come up with is issue7989-cmp.diff - basically replacing 
_cmp(self, other) with _normalize(self, other) that returns a pair of objects 
that compare the same as self and other.

I am not committing this in sandbox because I don't see this a big improvement.

Datetime comparisons are tricky due to date/datetime inheritance.  I think it 
is best not to touch it.

--
Added file: http://bugs.python.org/file17842/issue7989-cmp.diff

___
Python tracker 

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



[issue6507] Enhance dis.dis to autocompile codestrings

2010-07-02 Thread Éric Araujo

Changes by Éric Araujo :


--
resolution:  -> accepted
stage: commit review -> patch review

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

> I am talking specifically about this kind of assert:
> 
>assert 1 <= month <= 12, 'month must be in 1..12'
>
> I think it should be replaced with:
>
>if month < 1 or month > 12:
>raise ValueError('month must be in 1..12')

I reviewed the asserts.  Value range checking asserts appear in non-public 
functions which are not called with out-of-range values by the module code.  
Therefore they can only be triggered if there is a bug in the future version of 
datetime.py.  This is expressly what asserts are for.

There is another type of asserts that should be either removed or modified:

assert daysecondswhole == int(daysecondswhole)  # can't overflow   

Since int is long in 3.x, this assert does not check anything. We can replace 
this with

assert daysecondswhole.bit_length() <= 32

--

___
Python tracker 

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



[issue6824] help for a module should list supported platforms

2010-07-02 Thread Terry J. Reedy

Terry J. Reedy  added the comment:

>WIth the help output that they provide, how am I supposed to know that
os.fork is only supported on Unix.

On windows, os.fork does not exist, so help(os.fork) fails, so it is obvious to 
me that it is not available on Windows ;-).

help(winreg) returns
"help(winreg)
Help on built-in module winreg:

NAME
winreg - This module provides access to the Windows registry API."

One could, for example, suggest "add 'Windows-only' between 'This' and 'module' 
in the module doc string that follows the name." This is not needed here 
because 'Windows' appears later. 

However, if you want to move this issue forward, use the quoted example as a 
model for a list of specific suggestions for objects specific to platforms you 
have access to. (For instance, I cannot easily get the os.fork doc string to 
see what it now says.) User suggestions are the main way existing docs get 
improved.

In other words, check the existing doc string and see if it is deficient. If it 
is, quote is and suggest a change. If the suggested change is the same for 
several objects, list and quote several and then make the suggestion, such as 
"insert 'unix-only' before 'module'."

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

> If they abuse the _ methods and complain that the C version doesn't
> work, we just say "we *told* you not to do that".  It is not the Python
> philosophy to try to protect users from mistakes that they willfully
> make.

OK. +0 from me.  Patches welcome. :-)

--

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Eric Smith

Eric Smith  added the comment:

This looks like a definite improvement to me.

When you merge to py3k, don't forget to change the versionchanged tag to 3.1.

--

___
Python tracker 

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



[issue7829] dis module documentation gives no indication of the dangers of bytecode inspection

2010-07-02 Thread Brett Cannon

Brett Cannon  added the comment:

Sorry, Terry, I didn't even notice the corrections in the issue since they were 
inlined in a comment instead of as an attached file. I will have a look right 
now.

--
keywords: +needs review
stage: needs patch -> patch review

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Amaury Forgeot d'Arc

Amaury Forgeot d'Arc  added the comment:

> assert daysecondswhole == int(daysecondswhole)  # can't overflow   
> Since int is long in 3.x, this assert does not check anything

Even with 2.5 int(x) cannot overflow, and returns a long when needed!
This assert probably checks that the number has no fractional part.

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

This comment in datetime.__new__ makes me +0.5 on s/__/_/:


self = date.__new__(cls, year, month, day)
# XXX This duplicates __year, __month, __day for convenience :-(

 
self.__year = year
self.__month = month
self.__day = day

Tim,

Do you remember why it was a good idea to derive datetime from date?

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

On Fri, Jul 2, 2010 at 5:23 PM, Amaury Forgeot d'Arc
 wrote:
..
> Even with 2.5 int(x) cannot overflow, and returns a long when needed!
> This assert probably checks that the number has no fractional part.

Yes I've realized that.  I thought x was coming from integer
arithmetics, but apparently datetime.py loves floats!

--
title: Add pure Python implementation of datetime module to CPython -> Add 
pure Python implementation of datetime module to CPython

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Éric Araujo

Éric Araujo  added the comment:

I’m not sure it’s good style to say “now” twice (in the versionchanged block).

I almost feel bad pointing that there is one line with bad whitespace:
+   >>> for align,text in ...
(Space after comma)

Otherwise great patch :)

--
resolution:  -> accepted

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Eric Smith

Eric Smith  added the comment:

I think I'd just delete both instances of "now". And now that I read it more 
critically, "position" should be "positional". How's this rewording:

.. versionchanged:: 2.7
   The positional argument specifiers can be omitted, so ``'{} {}'`` is
   equivalent to ``'{0} {1}'``.

--

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Ezio Melotti

Ezio Melotti  added the comment:

Here is another patch.
I also added another example that uses the fillchar.

--
Added file: http://bugs.python.org/file17843/issue9139v3.diff

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Tim Peters

Tim Peters  added the comment:

> I thought x was coming from integer
> arithmetics, but apparently datetime.py loves floats!

The arguments to __new__ can be floats, so it's necessary to deal with floats 
there.

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Tim Peters

Tim Peters  added the comment:

> I thought x was coming from integer
> arithmetics, but apparently datetime.py loves floats!

The arguments to __new__ can be floats, so it's necessary to deal with floats 
there.

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Tim Peters

Changes by Tim Peters :


--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Tim Peters

Tim Peters  added the comment:

> Do you remember why it was a good idea to
> derive datetime from date?

Why not?  A datetime is a date, but with additional behavior.  Makes 
inheritance conceptually natural.

--

___
Python tracker 

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



[issue7829] dis module documentation gives no indication of the dangers of bytecode inspection

2010-07-02 Thread Brett Cannon

Brett Cannon  added the comment:

Fixed in r82456. I decided to make a warning directive so that it's really 
obvious that people should not consider the dis module and bytecode as stable.

Once Python 2.7.0final is out the door I will backport the patch.

--
resolution:  -> fixed
stage: patch review -> committed/rejected
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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

On Fri, Jul 2, 2010 at 6:00 PM, Tim Peters  wrote:
>
> Tim Peters  added the comment:
>
>> Do you remember why it was a good idea to
>> derive datetime from date?
>
> Why not?  A datetime is a date, but with additional behavior.  Makes 
> inheritance conceptually natural.

It is also time with additional behavior.  In the face of ambiguity ...

Why not?  See issue #5516.  Most of datetime comparison code is
devoted to fighting inheritance from date.   There is hardly any
non-trivial method that benefits from this inheritance.

To me,  conceptually, datetime is a container of date, time and
optionally time zone, it is not a date.

--

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Eric Smith

Eric Smith  added the comment:

Looks good.

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Tim Peters

Tim Peters  added the comment:

I'm not going to argue about whether datetime "should have been" subclassed 
from date - fact is that it was, and since it was Guido's idea from the start, 
he wouldn't change it now even if his time machine weren't out for repairs ;-)

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

On Fri, Jul 2, 2010 at 6:26 PM, Tim Peters  wrote:
..
> I'm not going to argue about whether datetime "should have been" subclassed 
> from date - fact is that it was, and since it was
> Guido's idea from the start, he wouldn't change it now even if his time 
> machine weren't out for repairs ;-)

I know, he will probably accept the fact that 23:59:60 is valid time
first. :-)  I still very much appreciate your insights.

I think I mentioned that in my other posts, but I find datetime design
very elegant and when I find things that I would have done differently
my first reaction is that I am probably missing something.

datetime(date) inheritance is one of those things.  Another is tzinfo
attribute of time.  With time t, t.utcoffset() is kid of useless given
that you cannot subtract it from t and unless tzinfo is a fixed offset
timezone, there is not enough information in t to compute the offset
to begin with.

Do you have any historical insight on this one?

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Marc-Andre Lemburg

Marc-Andre Lemburg  added the comment:

Alexander Belopolsky wrote:
> 
> Alexander Belopolsky  added the comment:
> 
> On Fri, Jul 2, 2010 at 6:00 PM, Tim Peters  wrote:
>>
>> Tim Peters  added the comment:
>>
>>> Do you remember why it was a good idea to
>>> derive datetime from date?
>>
>> Why not?  A datetime is a date, but with additional behavior.  Makes 
>> inheritance conceptually natural.
> 
> It is also time with additional behavior.  In the face of ambiguity ...
> 
> Why not?  See issue #5516.  Most of datetime comparison code is
> devoted to fighting inheritance from date.   There is hardly any
> non-trivial method that benefits from this inheritance.
> 
> To me,  conceptually, datetime is a container of date, time and
> optionally time zone, it is not a date.

Just an aside:

Conceptually, you don't need date and time, only an object to
reference a point in time and another one to describe the
difference between two points in time. In mxDateTime I
called them DateTime and DateTimeDelta.

What we commonly refer to as date is really the combination of
a DateTime value pointing to the start of the day together with
a DateTimeDelta value representing one full turn of the Earth.

That said, I don't think redesigning the datetime module is part
of this ticket, just adding a second implementation of what we
already have in CPython :-)

--
title: Add pure Python implementation of datetime module to CPython -> Add pure 
Python implementation of datetime module to CPython

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

On Fri, Jul 2, 2010 at 6:52 PM, Marc-Andre Lemburg
 wrote:
..
> That said, I don't think redesigning the datetime module is part
> of this ticket, just adding a second implementation of what we
> already have in CPython :-)

I agree.  I am just looking for an excuse not to change attributes
like __year to _year.  :-)

--
title: Add pure Python implementation of datetime module to CPython -> Add 
pure Python implementation of datetime module to CPython

___
Python tracker 

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



[issue9139] Add examples for str.format()

2010-07-02 Thread Ezio Melotti

Ezio Melotti  added the comment:

Committed in r82457 and r82459 (trunk), r82460 (release26-maint), r82462 
(py3k), r82463 (release31-maint). Thanks for the reviews!

--
resolution: accepted -> fixed
stage: patch 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



[issue5288] tzinfo objects with sub-minute offsets are not supported (e.g. UTC+05:53:28)

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

I am attaching a patch against sandbox version of datetime.py.  With this 
patch, there is a single place where subminute offset is rejected, 
_check_utc_offset() function.  I have also added "whole minute" asserts in 
places where sub-minute part of the offset is discarded or assumed 0.

--
keywords: +patch
Added file: http://bugs.python.org/file17844/issue5288-proto.diff

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

I am attaching a patch from issue 5288 as an example of a change that I would 
favor more than issue7989-cmp.diff.  This patch eliminates _utcoffset and _dst 
methods that duplicate utcoffset and dst, but return integer minutes rather 
than a timedelta.

I am not checking these changes in sandbox because these are examples of how I 
plan to improve C implementation when datetime.py makes it into the main tree.  
I envision such changes to be discussed within context of datetime.py and if 
approved, implemented in C and committed simultaneously.

Improving datetime.py implementation and making it diverge from C 
implementation defeats the purpose I see in having datetime.py in the first 
place.

Antoine?

--
Added file: http://bugs.python.org/file17845/issue5288-proto.diff

___
Python tracker 

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



[issue9146] Segfault in hashlib in OpenSSL FIPS mode using non-FIPS-compliant hashes, if "ssl" imported before "hashlib"

2010-07-02 Thread Dave Malcolm

Dave Malcolm  added the comment:

Attached patch checks for errors in the initialization of _hashlib, and only 
registers the names that are actually available.

It also contains the ssl init from the first patch.

I added a _hashlib._errors dict, containing errors, so that you can examine 
them at runtime:

$ OPENSSL_FORCE_FIPS_MODE=1 ./python
Python 2.7rc2+ (trunk:82445, Jul  2 2010, 14:00:30) 
[GCC 4.4.3 20100422 (Red Hat 4.4.3-18)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import _hashlib
[35786 refs]
>>> _hashlib._errors
{'md5': '_hashopenssl.c:541: error:060800A0:digital envelope 
routines:EVP_DigestInit_ex:unknown cipher'}
[35825 refs]
>>> dir (_hashlib)
['__doc__', '__file__', '__name__', '__package__', '_errors', 'new', 
'openssl_sha1', 'openssl_sha224', 'openssl_sha256', 'openssl_sha384', 
'openssl_sha512']
[35838 refs]
(note the absence of openssl_md5)

Note that hashlib (as opposed to _hashlib) seems to gracefully fall back to 
Python's _md5 module when in this state:
>>> import hashlib
[36107 refs]
>>> m = m = hashlib.md5(); m.update('abc\n'); print m.hexdigest()
0bee89b07a248e27c83fc3d5951213c1
[36109 refs]

This seems to be option (A) from my initial message.

--
stage:  -> patch review
Added file: 
http://bugs.python.org/file17846/remove-unusable-hashes-from-hashopenssl.patch

___
Python tracker 

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



[issue9146] Segfault in hashlib in OpenSSL FIPS mode using non-FIPS-compliant hashes, if "ssl" imported before "hashlib"

2010-07-02 Thread Dave Malcolm

Dave Malcolm  added the comment:

Not quite ready yet:

Named methods work:
$ OPENSSL_FORCE_FIPS_MODE=1 ./python -c "import hashlib; m = hashlib.md5(); 
m.update('abc\n'); print m.hexdigest()"0bee89b07a248e27c83fc3d5951213c1
[15741 refs]

but lookup by name still fails:
OPENSSL_FORCE_FIPS_MODE=1 ./python -c "import hashlib; m = hashlib.new('md5'); 
m.update('abc\n'); print m.hexdigest()"
Segmentation fault (core dumped)

--

___
Python tracker 

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



[issue8271] str.decode('utf8', 'replace') -- conformance with Unicode 5.2.0

2010-07-02 Thread Ezio Melotti

Ezio Melotti  added the comment:

I've found a subtle corner case about 3- and 4-bytes long sequences.
For example, according to http://www.unicode.org/versions/Unicode5.2.0/ch03.pdf 
(pages 94-95, table 3.7) the sequences in range \xe0\x80\x80-\xe0\x9f\xbf are 
invalid.
I.e. if the first byte is \xe0 and the second byte is between \x80 (included) 
and \xA0 (excluded), then the second byte is invalid (this is because sequences 
< \xe0\xa0\x80 will result in codepoints < U+0800 and these codepoints are 
already represented by two-bytes-long sequences (\xdf\xbf decodes to U+07FF)).

Assume that we want to decode the string b'\xe0\x61\x80\x61' (where \xe0 is the 
start byte of a 3-bytes-long sequence, \x61 is the letter 'a' and \x80 a valid 
continuation byte).
This actually results in:
>>> b'\xe0\x61\x80\x61'.decode('utf-8', 'replace')
'�a�a'
since \x61 is not a valid continuation byte in the sequence:
 * \xe0 is converted to �;
 * \x61 is displayed correctly as 'a';
 * \x80 is valid only as a continuation byte and invalid alone, so it's 
replaced by �;
 * \x61 is displayed correctly as 'a';

Now, assume that we want to do the same with b'\xe0\x80\x81\x61':
This actually results in:
>>> b'\xe0\x80\x81\x61'.decode('utf-8', 'replace')
'��a'
in this case \x80 would be a valid continuation byte, but since it's preceded 
by \xe0 it's not valid.
Since it's not valid, the result might be similar to the previous case, i.e.:
 * \xe0 is converted to �;
 * \x80 is valid as a continuation byte but not in this specific case, so it's 
replaced by �;
 * \x81 is valid only as a continuation byte and invalid alone, so it's 
replaced by �;
 * \x61 is displayed correctly as 'a';
However for this case (and the other similar cases), the invalid bytes wouldn't 
be otherwise valid because they are still in range \x80-\xbf (continuation 
bytes), so the current behavior might be fine.

This happens because the current algorithm just checks that the second byte 
(\x80) is in range \x80-\xbf (i.e. it's a continuation byte) and if it is it 
assumes that the invalid byte is the third (\x81) and replaces the first two 
bytes (\xe0\x80) with a single �.

That said, the algorithm could be improved to check what is the wrong byte with 
better accuracy (and that could also be used to give a better error message 
about decoding surrogates). This shouldn't affect the speed of regular 
decoding, because the extra check will happen only in case of error.
Also note the Unicode standard doesn't seem to mention this case, and that 
anyway this doesn't "eat" any of the following characters as it was doing 
before the patch -- the only difference would be in the number of �.

--

___
Python tracker 

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



[issue8810] TZ offset description is unclear in docs

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

Benjamin,

Is it too late to do anything about this.  Apparently Sean committed wrong 
patch and as a result 2.7 is about to be released with an error in 
tzinfo.fromutc docstring.  This method is confusing enough without 
documentation bugs.  Would you mind if I revert r81681?  This is a docstring 
only change.

--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue8810] TZ offset description is unclear in docs

2010-07-02 Thread Alexander Belopolsky

Alexander Belopolsky  added the comment:

Reverted r81681 and r81682 in r82466 and r82467.

It looks like docstring changes intended for utcoffset() landed in a docstring 
for fromutc().  Given that we are very close to 2.7 release, I am not 
attempting to improve the docs - just reverting an obvious error.

--
assignee: d...@python -> belopolsky
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



[issue9144] Import error for multiprocessing in 2.7rc2 on Windows

2010-07-02 Thread Nick Coghlan

Changes by Nick Coghlan :


--
nosy: +jnoller

___
Python tracker 

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



[issue6818] remove/delete method for zipfile/tarfile objects

2010-07-02 Thread Troy Potts

Troy Potts  added the comment:

I have attempted to implement a ZipFile.remove function.  It seems to work 
fine.  I have submitted a patch.

The method of implementation is: find the file's index in the file list, then 
sum the lengths of the file entries before it to find its location in the 
archive.  Then simply read in all the bytes after it, write them out at that 
location, and truncate the file x bytes shorter, where x is the length of the 
record.  This works because the directory listing is created when the file is 
closed, so there's no harm in truncating.

I've also made it truncate the zip file after reading in the existing files 
upon creation, because the directory information is not used after this point.

This could use some testing on large files.

This is my first patch, so let me know if I've done anything wrong.

--
keywords: +patch
nosy: +chroipahtz
Added file: http://bugs.python.org/file17847/zipfile_remove.patch

___
Python tracker 

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



[issue8271] str.decode('utf8', 'replace') -- conformance with Unicode 5.2.0

2010-07-02 Thread Ezio Melotti

Ezio Melotti  added the comment:

Backported to 2.6 and 3.1 in r82470 and r82469.
I'll leave this open for a while to see if anyone has any comment on my 
previous message.

--
resolution:  -> fixed
stage: patch review -> committed/rejected

___
Python tracker 

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



[issue6818] remove/delete method for zipfile/tarfile objects

2010-07-02 Thread Troy Potts

Changes by Troy Potts :


Removed file: http://bugs.python.org/file17847/zipfile_remove.patch

___
Python tracker 

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



[issue6818] remove/delete method for zipfile/tarfile objects

2010-07-02 Thread Troy Potts

Troy Potts  added the comment:

My patch had some bugs, I'll need to do some more testing.  Sorry about that.

--

___
Python tracker 

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



[issue7989] Add pure Python implementation of datetime module to CPython

2010-07-02 Thread Alexander Belopolsky

Changes by Alexander Belopolsky :


--
stage: needs patch -> patch review
Added file: http://bugs.python.org/file17848/issue7989.diff

___
Python tracker 

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