[issue23493] optimize sort_keys in json module by using operator.itemgetter()

2015-02-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

May be there is a time to optimize creating Python frames (at least for the 
case when one frame is created and destroyed multiple times). May be frame 
pool? Or cached one frame per function?

--

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



[issue12026] Support more of MSI api

2015-02-24 Thread Mark Lawrence

Changes by Mark Lawrence breamore...@yahoo.co.uk:


--
components: +Windows
nosy: +steve.dower, tim.golden, zach.ware
versions: +Python 3.5 -Python 3.3

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



[issue21099] Switch applicable importlib tests to use PEP 451 API

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

To echo Brett's question, should this be closed, Eric?

--
status: pending - open

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



[issue23511] Broken code example in email module documentation

2015-02-24 Thread Berker Peksag

Berker Peksag added the comment:

LGTM.

--
nosy: +berker.peksag, r.david.murray
stage:  - commit review
versions: +Python 3.4, Python 3.5

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



Re: Design thought for callbacks

2015-02-24 Thread Gregory Ewing

random...@fastmail.us wrote:

On Tue, Feb 24, 2015, at 00:20, Gregory Ewing wrote:


This is why I suggested registering a listener object
plus a method name instead of a callback. It avoids that
reference cycle, because there is no long-lived callback
object keeping a reference to the listener.


How does that help? Everywhere you would have had a reference to the
callback object, you now have a reference to the listener object.


The point is that the library can keep a weak reference
to the listener object, whereas it can't reliably keep
a weak reference to a bound method.

--
Greg
--
https://mail.python.org/mailman/listinfo/python-list


Bug in timsort!?

2015-02-24 Thread Roy Smith
http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue19711] add test for changed portions after reloading a namespace package

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

To echo Brett's question, do we still need this patch, Eric?

--
status: pending - open

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



Re: Newbie question about text encoding

2015-02-24 Thread Dave Angel

On 02/24/2015 02:57 PM, Laura Creighton wrote:

Dave Angel
are you another Native English speaker living in a world where ASCII
is enough?


I'm a native English speaker, and 7 bits is not nearly enough.  Even if 
I didn't currently care, I have some history:


No.  CDC display code is enough. Who needs lowercase?

No.  Baudot code is enough.

No, EBCDIC is good enough.  Who cares about other companies.

No, the golf-ball only holds this many characters.  If we need more, 
we can just get the operator to switch balls in the middle of printing.


No. 2 digit years is enough.  This world won't last till the millennium 
anyway.


No.  2k is all the EPROM you can have.  Your code HAS to fit in it, and 
only 1.5k RAM.


No.  640k is more than anyone could need.

No, you cannot use a punch card made on a model 26 keypunch in the same 
deck as one made on a model 29.  Too bad, many of the codes are 
different.  (This one cost me travel back and forth between two 
different locations with different model keypunches)


No. 8 bits is as much as we could ever use for characters.  Who could 
possibly need names or locations outside of this region?  Or from 
multiple places within it?


35 years ago I helped design a serial terminal that spoke Chinese, 
using a two-byte encoding.  But a single worldwide standard didn't come 
until much later, and I cheered Unicode when it was finally unveiled.


I've worked with many printers that could only print 70 or 80 unique 
characters.  The laser printer, and even the matrix printer are 
relatively recent inventions.


Getting back on topic:

According to:
   http://support.esri.com/cn/knowledgebase/techarticles/detail/27345

ArcGIS Desktop applications, such as ArcMap, are Unicode based, so 
they support Unicode to a certain level. The level of Unicode support 
depends on the data format.


That page was written about 2004, so there was concern even then.

And according to another, In the header of each shapefile (.DBF), a 
reference to a code page is included.


--
DaveA
--
https://mail.python.org/mailman/listinfo/python-list


Re: Bug in timsort!?

2015-02-24 Thread Zachary Ware
On Tue, Feb 24, 2015 at 3:34 PM, Roy Smith r...@panix.com wrote:
 http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/

http://bugs.python.org/issue23515

Note that the article does mention that Python is not vulnerable due
to this bug (and best I can tell has no behavioral issues); no
computer currently in existence can create a large enough array to
cause a problem.

-- 
Zach
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23491] PEP 441 - Improving Python Zip Application Support

2015-02-24 Thread Paul Moore

Paul Moore added the comment:

Thanks, I'll fix for the next iteration of the patch.

--

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



[issue9985] difflib.SequenceMatcher has slightly buggy and undocumented caching behavior

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

I believe this has been fixed by changesets f02a563ad1bf and ed73c127421c in 
#21635.

--
nosy: +BreamoreBoy

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



Re: Newbie question about text encoding

2015-02-24 Thread Laura Creighton
Dave Angel
are you another Native English speaker living in a world where ASCII
is enough?

Laura

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23509] Speed up Counter operators

2015-02-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

 - in the given patch __add__ uses __iadd__, but __sub__ doesn't use
 __isub__, which seems a bit weird.

If Counters are positive (common case), then the result of addition is not 
less than both summands. a + b is a and may be additional elements from b.
In the case of substraction a - b can be less than a and may be much less than 
a. In this case it is cheaper to create empty Counter and copy only those 
elements from a that are not in b, than copy all a and then remove almost all 
elements.

Relative efficiency depends on input data, and for some input data implementing 
__sub__ via __isub__ can be more efficient.

 - is there place for a non multi-set centric Stats object which is like
 Counter but with + and - actually behaving without the (in my use cases of
 Counter often counter intuitive)  0 stuff? (pun intended ;) ) Counter
 feels like a sub-class of Stats with the added _keep_positive(self).

I'm sure there is such class in third-party modules. Counter wouldn't have 
much benefit from inheriting Stats, because it would need to override almost 
all methods.

--

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



[issue12010] Compile fails when sizeof(wchar_t) == 1

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

Is this effectively superseded by work being done on #23496?

--
nosy: +BreamoreBoy

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



[issue23511] Broken code example in email module documentation

2015-02-24 Thread Baptiste Mispelon

Baptiste Mispelon added the comment:

Patch attached.

--
keywords: +patch
Added file: http://bugs.python.org/file38228/issue23511.diff

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



[issue2142] difflib.unified_diff(...) produces invalid patches

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

Can we have a review on the updated patch please.

--
nosy: +BreamoreBoy
versions: +Python 3.5 -Python 3.3

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



[issue10515] csv sniffer does not recognize quotes at the end of line

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

@David could you check Skip's patch out please.  It seems identical to your own 
other than changing the delimiter from the empty string to a comma.

--
nosy: +BreamoreBoy

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



[issue10954] csv.reader/writer to raise exception if mode is binary or newline is not ''

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

I've changed this issue to reflect what I think it should be saying.

--
nosy: +BreamoreBoy
title: No warning for csv.writer API change - csv.reader/writer to raise 
exception if mode is binary or newline is not ''
type: enhancement - behavior
versions: +Python 3.4, Python 3.5 -Python 3.2

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



Re: Concatenate list values

2015-02-24 Thread loial
Many thanks for those you chose to help me out. Problem solved.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue10197] subprocess.getoutput fails on win32

2015-02-24 Thread Gregory P. Smith

Gregory P. Smith added the comment:

A side effect of the changes made within are that getstatusoutput() on POSIX 
systems now returns a different value for status.

The old implementation present in Python 2 and Python 3.3 before this patch 
returned the raw waitpid() status result as the status value.  ie: 
getstatusoutput(exit 1)[0] == 256.  the lower 8 bits were reserved for the 
signal number the process died with, if any.

Now it returns the sanitized subprocess style returncode: positive numbers are 
the process exit code (so the above example returns 1) and negative numbers are 
the negative signal number the process died with.

I prefer the new behavior, but this API change is not documented anywhere that 
I can find.

--

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



[issue10197] subprocess.getoutput fails on win32

2015-02-24 Thread Gregory P. Smith

Gregory P. Smith added the comment:

http://bugs.python.org/issue23508 to track the fall out of that.

--

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



[issue23507] Tuple creation is too slow

2015-02-24 Thread Ezio Melotti

Changes by Ezio Melotti ezio.melo...@gmail.com:


--
nosy: +ezio.melotti

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



[issue23507] Tuple creation is two slow

2015-02-24 Thread Serhiy Storchaka

New submission from Serhiy Storchaka:

Currently tuples creating uses free lists. But this optimization is not enough. 
When reuse cached tuple for arguments of repeatedly called functions, the 
performance of some builtins can be significantly increased.

$ ./python -m timeit -s f = lambda x: x -s s = list(range(1000)) -- 
list(filter(f, s))
Unpatched: 1000 loops, best of 3: 773 usec per loop
Patched:   1000 loops, best of 3: 558 usec per loop

$ ./python -m timeit -s f = lambda x: x -s s = list(range(1000)) -- 
list(map(f, s))
Unpatched: 1000 loops, best of 3: 689 usec per loop
Patched:   1000 loops, best of 3: 556 usec per loop

$ ./python -m timeit -s f = lambda x: x -s s = list(range(1000)) -- 
sorted(s, key=f)
Unpatched: 1000 loops, best of 3: 758 usec per loop
Patched:   1000 loops, best of 3: 550 usec per loop

The same effect can be achieved for itertools functions.

I don't propose to commit this complicated patch, but these results can be used 
as a guide to the optimization of tuple creating. It is surprising to me that 
this patch has any effect at all.

--
components: Interpreter Core
files: reuse_argtuples.patch
keywords: patch
messages: 236480
nosy: serhiy.storchaka
priority: normal
severity: normal
status: open
title: Tuple creation is two slow
type: performance
versions: Python 3.5
Added file: http://bugs.python.org/file38223/reuse_argtuples.patch

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



Re: Are threads bad? - was: Future of Pypy?

2015-02-24 Thread Marko Rauhamaa
Chris Angelico ros...@gmail.com:

 Actually, you can quite happily have multiple threads messing with the
 underlying file descriptors, that's not a problem. (Though you will
 tend to get interleaved output. But if you always produce output in
 single blocks of text that each contain one line with a trailing
 newline, you should see interleaved lines that are each individually
 correct. I'm also not sure of any sane way to multiplex stdin -
 merging output from multiple threads is fine, but dividing input
 between multiple threads is messy.) The problem is *buffers* for stdin
 and stdout, where you have to be absolutely sure that you're not
 trampling all over another thread's data structures. If you unbuffer
 your output, it's probably going to be thread-safe.

Here's an anecdote describing one real-life threading problem. We had a
largish multithreading framework (in Java, but I'm setting it in Python
and in a much simplified form).

We were mindful of deadlocks caused by lock reversal so we had come up
with a policy whereby objects form a layered hierarchy. An object higher
up in the hierarchy was allowed to call methods of objects below while
holding locks. The opposite was not allowed; if an object desired to
call a method of an object above it (through a registered callback), it
had to relinquish all locks before doing so.

However, a situation like this arose:

class App:
def send_stream(self, sock):
with self.lock:
self.register_socket(sock)

class SocketWrapper:
def read(_, count):
return sock.recv(count)
def close(_):
sock.close()
with self.lock:
self.unregister_socket(sock)

self.transport.forward_and_close(SocketWrapper(sock))

class Transport:
def forward_and_close(self, readable):
with self.lock:
more = readable.read(1000)
if more is WOULDBLOCK:
self.reschedule(readable)
elif more:
... # out of scope for the anecdote
else:
# EOF reached
readable.close()

Now the dreaded lock reversal arises when the App object calls
self.transport.forward_and_close() and Transport calls readable.close()
at the same time.

So why lock categorically like that? Java has a handy synchronized
keyword that wraps the whole method in with self.lock. Ideally, that
handy idiom could be employed methodically. More importantly, to avoid
locking problems, the methodology should be rigorous and mindless. If
the developer must perform a deep locking analysis at every turn, they
are bound to make mistakes, especially when more than one developer is
involved, with differing intuitions.

Unfortunately, that deep locking analysis *is* required at every turn,
and mistakes *are* bound to happen.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about text encoding

2015-02-24 Thread Chris Angelico
On Tue, Feb 24, 2015 at 9:49 PM,  pierrick.brih...@gmail.com wrote:
 Working with pyshp, this is my code :

 import shapefile

 inFile = shapefile.Reader(blah)

 for sr in inFile.shapeRecords():
 rec = sr.record[2]
 print(Output : , rec, type(rec))

 Output:  hippodrome du resto class 'str'
 Output:  b'stade de man\xe9 braz' class 'bytes'

 Why do I get 2 different types ?
 How to get a string object when I have accented characters ?

I don't know what pyshp is doing here, so you may want to seek a
pyshp-specific mailing list for help. My guess is that it's
automatically decoding to str if it's ASCII-only, and giving you back
the raw bytes if there are any that it can't handle. The question is:
What encoding _is_ that? Do you know what character you're expecting
to see there? Before you can turn that into a string, you have to
figure out whether it's Latin-1 (ISO-8859-1), or some other ISO-8859-x
standard, or a Windows codepage, or an ancient thing off a Mac, or
whatever else it might be. Once you know that, it's easy: you just
decode() the bytes objects. But you MUST figure out the encoding
first.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Design thought for callbacks

2015-02-24 Thread Cem Karan
I'm combining two messages into one, 

On Feb 24, 2015, at 12:29 AM, random...@fastmail.us wrote:

 On Tue, Feb 24, 2015, at 00:20, Gregory Ewing wrote:
 Cem Karan wrote:
 I tend to structure my code as a tree or DAG of objects.  The owner refers 
 to
 the owned object, but the owned object has no reference to its owner.  With
 callbacks, you get cycles, where the owned owns the owner.
 
 This is why I suggested registering a listener object
 plus a method name instead of a callback. It avoids that
 reference cycle, because there is no long-lived callback
 object keeping a reference to the listener.
 
 How does that help? Everywhere you would have had a reference to the
 callback object, you now have a reference to the listener object.
 You're just shuffling deck chairs around: if B shouldn't reference A
 because A owns B, then removing C from the B-C-A reference chain does
 nothing to fix this.

On Feb 24, 2015, at 12:45 AM, Gregory Ewing greg.ew...@canterbury.ac.nz wrote:

 Cem Karan wrote:
 On Feb 22, 2015, at 5:15 AM, Gregory Ewing greg.ew...@canterbury.ac.nz
 wrote:
 Perhaps instead of registering a callback function, you should be
 registering the listener object together with a method name.
 I see what you're saying, but I don't think it gains us too much.  If I store
 an object and an unbound method of the object, or if I store the bound method
 directly, I suspect it will yield approximately the same results.
 
 It would be weird and unpythonic to have to register both
 an object and an unbound method, and if you use a bound
 method you can't keep a weak reference to it.


Greg, random832 said what I was thinking earlier, that you've only increased 
the diameter of your cycle without actually fixing it.  Can you give a code 
example where your method breaks the cycle entirely?

Thanks,
Cem Karan
-- 
https://mail.python.org/mailman/listinfo/python-list


RE: Python shell: Arrow keys not working in PuTTY

2015-02-24 Thread David Aldrich
  BUT do *not* run `make install` as that will overwrite your system
  Python and Bad Things will happen. Instead, run `make altinstall`.

Thanks for all the warnings. We did use `make altinstall`, so all is ok.

Recompiling, with readline installed, fixed the arrow keys.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about text encoding

2015-02-24 Thread Dave Angel

On 02/24/2015 05:49 AM, pierrick.brih...@gmail.com wrote:

Hello,

Working with pyshp, this is my code :


What version of Python, what version of pyshp, from where, and what OS? 
 These are the first information to supply in any query that goes 
outside of the standard library.


For example, you might be running CPython 3.2.1 on Ubuntu 14.04.1, and 
installed pyshp 1.2.1 from https://pypi.python.org/pypi/pyshp


Or some other combination.



import shapefile

inFile = shapefile.Reader(blah)

for sr in inFile.shapeRecords():
 rec = sr.record[2]
 print(Output : , rec, type(rec))

Output:  hippodrome du resto class 'str'
Output:  b'stade de man\xe9 braz' class 'bytes'

Why do I get 2 different types ?
How to get a string object when I have accented characters ?

Thank you,

p.b.



From my (cursory) reading of the pyshp docs on the above page, I cannot 
see what the [2] element of the record list should look like.  So I'd 
have to guess.


The bytes object is presumably an encoded version of the character 
string.  I don't see anything on that page about unicode, or decode, so 
you might have to guess the encoding.  Anyway, you can decode the 
bytestring into a regular string if you can correctly guess the encoding 
method, such as utf-8.


If that were the right decoding, you could just use
mystring = rec.decode()

But utf-8 does not seem to be the right encoding for that bytestring. 
So you'll need a form like:

mystring = rec.decode(encoding='xxx')

for some value of xxx.







--
DaveA
--
https://mail.python.org/mailman/listinfo/python-list


Re: Design thought for callbacks

2015-02-24 Thread Cem Karan

On Feb 23, 2015, at 7:29 AM, Frank Millman fr...@chagford.com wrote:

 
 Cem Karan cfkar...@gmail.com wrote in message 
 news:a3c11a70-5846-4915-bb26-b23793b65...@gmail.com...
 
 
 Good questions!  That was why I was asking about 'gotchas' with WeakSets 
 originally.  Honestly, the only way to know for sure would be to write two 
 APIs for doing similar things, and then see how people react to them.  The 
 problem is, how do you set up such a study so it is statistically valid?
 
 
 Just in case you missed Steven's comment on my 'gotcha', and my reply, it is 
 worth repeating that what I reported as a gotcha was not what it seemed.
 
 If you set up the callback as a weakref, and the listening object goes out 
 of scope, it will wait to be garbage collected. However, as far as I can 
 tell, the weakref is removed at the same time as the object is gc'd, so 
 there is no 'window' where the weakref exists but the object it is 
 referencing does not exist.
 
 My problem was that I had performed a cleanup operation on the listening 
 object before letting it go out of scope, and it was no longer in a valid 
 state to deal with the callback, resulting in an error. If you do not have 
 that situation, your original idea may well work.

Thank you Frank, I did read Steve's comment to your reply earlier, but what you 
said in your original reply made sense to me.  I don't have control over user 
code.  That means that if someone wants to write code such that they perform 
some kind of cleanup and are no longer able to handle the callback, they are 
free to do so.  While I can't prevent this from happening, I can make it as 
obvious as possible in my code that before you perform any cleanup, you also 
need to unregister from the library.  That is my main goal in developing 
pythonic/obvious methods of registering callbacks.

Thanks,
Cem Karan
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about text encoding

2015-02-24 Thread random832
On Tue, Feb 24, 2015, at 10:10, Chris Angelico wrote:
 Ah, okay. :) But even with that level of confidence, you still have to
 pick between Latin-1 and CP-1252, which you can't tell based on this
 one snippet. Welcome to untagged encodings.

Or Latin-9 (ISO 8859-15) That was popular on Linux systems for a while
before everyone switched to UTF-8 - it's got the Euro sign, and
(relevant to French) the oe ligature, and uppercase Y with diaeresis,
at the expense of generic currency and fractions.

Or it could be Latin-3, Latin-5 (8859-9), or Latin-8 (8859-14) - they
are not commonly used for French locales, being primarily intended for
other languages, but they do support all characters (at least all from
Latin-1) used in French names. I assume there are likewise several
Windows codepages it could be.
-- 
https://mail.python.org/mailman/listinfo/python-list


Sphinx 1.3 beta 3 released

2015-02-24 Thread Takayuki Shimizukawa
Hi all,

I'm very happy to announce the release of Sphinx 1.3, beta 3,
available on the Python package index at
http://pypi.python.org/pypi/Sphinx/1.3b3.
Please test and report bugs to https://github.com/sphinx-doc/sphinx/issues.

This is the final beta release for Sphinx 1.3 that includes:
- 3 Incompatibilities; requires docutils 0.11, Pygments 2.0
- 10 new features; add 'alabaster' and 'sphinx_rtd_theme' themes.
- 14 bug fixes.

For the full changelog, go to:
https://github.com/sphinx-doc/sphinx/blob/567af23/CHANGES

What is it?
===

Sphinx is a tool that makes it easy to create intelligent and beautiful
documentation for Python projects (or other documents consisting of
multiple reStructuredText source files).

Website: http://sphinx-doc.org/

Enjoy!
--
Takayuki SHIMIZUKAWA
http://about.me/shimizukawa
-- 
https://mail.python.org/mailman/listinfo/python-announce-list

Support the Python Software Foundation:
http://www.python.org/psf/donations/


[issue15753] No-argument super in method with variable arguments raises SystemError

2015-02-24 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +benjamin.peterson

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



[issue14073] allow per-thread atexit()

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

The changes referenced in msg204494 ref: #19466 were reverted via changesets 
9ce58a73b6b5 and 1166b3321012

--
nosy: +BreamoreBoy

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



Re: Newbie question about text encoding

2015-02-24 Thread Laura Creighton
In a message of Tue, 24 Feb 2015 15:55:41 +0100, Laura Creighton writes:
In a message of Tue, 24 Feb 2015 06:25:24 -0500, Dave Angel writes:
But utf-8 does not seem to be the right encoding for that bytestring. 
So you'll need a form like:
 mystring = rec.decode(encoding='xxx')

for some value of xxx.

DaveA

And the xxx you want is latin1

Laura

er, latin1.  You don't want an extra set of quotes.
There are many aliases for latin1. i.e. latin_1, iso-8859-1, iso8859-1,
8859, cp819, latin, latin1, L1
see: https://docs.python.org/2.4/lib/standard-encodings.html

and you might want to read
https://docs.python.org/2/howto/unicode.html

to understand the problem better.

Laura
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Newbie question about text encoding

2015-02-24 Thread Chris Angelico
On Wed, Feb 25, 2015 at 2:07 AM, Laura Creighton l...@openend.se wrote:
Can you be sure it's Latin-1? I'm not certain of that. In any case, I
never advocate fixing encoding problems by just do this and it'll all
go away; you have to understand your data before you can decode it.

ChrisA

 I can, I speak French and I recognise the data.  It's French place names,
 places where sporting events are held. :)

Ah, okay. :) But even with that level of confidence, you still have to
pick between Latin-1 and CP-1252, which you can't tell based on this
one snippet. Welcome to untagged encodings.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue6598] calling email.utils.make_msgid frequently has a non-trivial probability of generating colliding ids

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

Can we have a patch review please.  If nothing else xrange will have to change 
for Python 3.

--
nosy: +BreamoreBoy
versions: +Python 3.4, Python 3.5 -Python 3.1, Python 3.2

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



[issue23476] SSL cert verify fail for www.verisign.com

2015-02-24 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 Python's SSL isn't using that.  Python is taking in one big text file 
 of SSL certs, with no link structure, and feeding it to OpenSSL.  

Python's SSL is not taking anything:

 r = urlopen('https://www.verisign.com')
 r.read(10)
b' !DOCTYPE'

It's only if you feed it that particular CA file that you get the issue:

 cafile = 'cacert.pem'
 r = urlopen('https://www.verisign.com', cafile=cafile)
[...]
urllib.error.URLError: urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] 
certificate verify failed (_ssl.c:600)


You can *also* feed it a CA directory by using the CApath argument (*not* 
CAfile).

Now it remains to be seen why openssl s_client works with the file 
nevertheless.

--

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



[issue23509] Speed up Counter operators

2015-02-24 Thread Jörn Hees

Jörn Hees added the comment:

cool

minor question:
- in the given patch __add__ uses __iadd__, but __sub__ doesn't use __isub__, 
which seems a bit weird.

maybe off-topic, but maybe not, because of _keep_positive(self):
- is there place for a non multi-set centric Stats object which is like 
Counter but with + and - actually behaving without the (in my use cases of 
Counter often counter intuitive)  0 stuff? (pun intended ;) ) Counter feels 
like a sub-class of Stats with the added _keep_positive(self).

--

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



Re: Python shell: Arrow keys not working in PuTTY

2015-02-24 Thread Laura Creighton
In a message of Tue, 24 Feb 2015 11:18:38 +, David Aldrich writes:
  BUT do *not* run `make install` as that will overwrite your system
  Python and Bad Things will happen. Instead, run `make altinstall`.

Thanks for all the warnings. We did use `make altinstall`, so all is ok.

Recompiling, with readline installed, fixed the arrow keys.

Great!  Thank you for letting us know.

Laura (who was worried)

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

2015-02-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The tests are checking that they are the same value (8) and the same type (int)?

--

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



Re: Newbie question about text encoding

2015-02-24 Thread Laura Creighton
In a message of Wed, 25 Feb 2015 02:03:16 +1100, Chris Angelico writes:
On Wed, Feb 25, 2015 at 1:55 AM, Laura Creighton l...@openend.se wrote:
 In a message of Tue, 24 Feb 2015 06:25:24 -0500, Dave Angel writes:
But utf-8 does not seem to be the right encoding for that bytestring.
So you'll need a form like:
 mystring = rec.decode(encoding='xxx')

for some value of xxx.

DaveA

 And the xxx you want is latin1

Can you be sure it's Latin-1? I'm not certain of that. In any case, I
never advocate fixing encoding problems by just do this and it'll all
go away; you have to understand your data before you can decode it.

ChrisA

I can, I speak French and I recognise the data.  It's French place names,
places where sporting events are held. :)

Laura

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23511] Broken code example in email module documentation

2015-02-24 Thread Baptiste Mispelon

New submission from Baptiste Mispelon:

The first code example at 
https://docs.python.org/3.5/library/email-examples.html throws an 
`AttributeError` because `MIMEText`'s constructor expects a `str` object, not a 
`bytes` one:

 # Import smtplib for the actual sending function
... import smtplib
 
 # Import the email modules we'll need
... from email.mime.text import MIMEText
 
 # Open a plain text file for reading.  For this example, assume that
... # the text file contains only ASCII characters.
... fp = open(textfile, 'rb')
 # Create a text/plain message
... msg = MIMEText(fp.read())
Traceback (most recent call last):
  File stdin, line 2, in module
  File /usr/lib/python3.4/email/mime/text.py, line 33, in __init__
_text.encode('us-ascii')
AttributeError: 'bytes' object has no attribute 'encode'

--
assignee: docs@python
components: Documentation
messages: 236503
nosy: bmispelon, docs@python
priority: normal
severity: normal
status: open
title: Broken code example in email module documentation

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



[issue23512] List of builtins is not alphabetical on https://docs.python.org/2/library/functions.html

2015-02-24 Thread Edward D'Souza

New submission from Edward D'Souza:

The list of built-in functions at the top of 
https://docs.python.org/2/library/functions.html is not alphabetical. 
Specifically, (apply, coerce, intern, buffer) allow appear out of order at the 
end of the list, instead of where they should be alphabetically.

--
assignee: docs@python
components: Documentation
messages: 236505
nosy: docs@python, edsouza
priority: normal
severity: normal
status: open
title: List of builtins is not alphabetical on 
https://docs.python.org/2/library/functions.html
type: behavior
versions: Python 2.7

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



Re: Newbie question about text encoding

2015-02-24 Thread Chris Angelico
On Wed, Feb 25, 2015 at 2:24 AM, Laura Creighton l...@openend.se wrote:
 Ah, yes, you are right about that.  I see CP-1252 about 2 times every 10
 years, and latin1 every minute of my life, so I am biased to assume I
 know what I am seeing.

Fair enough. CP-1252 is still a possibility, but the difference can be
dealt with later.

 ChrisA, you come from an English speaking country, right?

Yes (Australia, to be specific).

 For those of us who come from countries whose language doesn't fit in
 ASCII, the notion of 'understand the data' doesn't work very well.  We
 already understand the data -- its a set of words in our native language.
 The hard part isn't understanding the data, but rather understanding how
 the hell Python could be so stupid as to not understand it. :)  The
 notion that Python normally only understands the subset of the
 characters in your native language than English speakers use in their
 language is not the most obvious thing.

Also a reasonable baseline assumption; but the trouble is that if you
automatically assume that text is encoded in your favourite eight-bit
system, you're taking a huge risk.

Now, you have a huge leg up on me, in that you actually recognize the
*words* in that piece of text. That means you can have MUCH greater
confidence in stating that it's Latin-1 than I can. But that's
precisely what I mean by understand the data. If you, being a native
French speaker, pick up a file written in (say) Polish, and encoded
Latin-2, you'll recognize by the ASCII characters that it's not French
text, and probably you'd be able to spot that it ought to be Latin-2
rather than Latin-1. That's understanding the data, that's having more
information than just the byte patterns. A computer can't reliably do
that (just look up the Bush hid the facts bug if you don't believe
me), but a human often can.

 And having taught countless European kids how to write their very first
 program in Python, I can tell you for certain that the sort of deep
 understanding of encoding methods is not what 10 year olds who just
 want to print out the names of their friends, and their favourite
 music titles, and their favourite musicians want to know. :)

Right, so you should be teaching them to use Python 3, and always
saving everything in UTF-8, and basically ignoring the whole mess of
eight-bit encodings :)

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23138] cookiejar parses cookie value as int with empty name-value pair and Expires

2015-02-24 Thread Mark Lawrence

Mark Lawrence added the comment:

@Demian I believe this may be of interest to you.

--
nosy: +BreamoreBoy, demian.brecht
versions:  -Python 3.2, Python 3.3

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



[issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

2015-02-24 Thread Manuel Jacob

Manuel Jacob added the comment:

Maybe I'm missing something, but it seems to me that 
test_int_subclass_with_index() is testing for the exactly wrong behaviour.  
Isn't the point of this issue that operator.index(a) should be equal to 
a.__index__()?  Why are the tests checking that they are different?

--
nosy: +mjacob

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



[issue23476] SSL cert verify fail for www.verisign.com

2015-02-24 Thread Cory Benfield

Changes by Cory Benfield c...@lukasa.co.uk:


--
nosy: +Lukasa

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



[issue23476] SSL cert verify fail for www.verisign.com

2015-02-24 Thread Antoine Pitrou

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


--
resolution:  - not a bug
stage:  - resolved
status: open - closed

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



[issue23476] SSL cert verify fail for www.verisign.com

2015-02-24 Thread Antoine Pitrou

Antoine Pitrou added the comment:

 and it is not reproducible using openssl s_client

I have determined that s_client is buggy. It will always load the system certs 
*if and only if* you also pass it a valid custom CA cert (which is the reverse 
of what's expected).

This is where it happens (in apps/s_client.c):

if ((!SSL_CTX_load_verify_locations(ctx, CAfile, CApath)) ||
(!SSL_CTX_set_default_verify_paths(ctx))) {
/*
 * BIO_printf(bio_err,error setting default verify locations\n);
 */
ERR_print_errors(bio_err);
/* goto end; */
}

This is why I forced SSL_CERT_* to empty locations in the examples above, so 
that only the custom CA bundle is used.

--

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



[issue23476] SSL cert verify fail for www.verisign.com

2015-02-24 Thread Antoine Pitrou

Antoine Pitrou added the comment:

Ok, this is really a bug in the cert bundle provided by requests and Firefox.

With requests 2.5.1:

$ SSL_CERT_DIR=/tmp SSL_CERT_FILE=/tmp openssl s_client -CAfile 
requests/cacert.pem -connect verisign.com:443

= ok

With requests 2.5.2:

$ SSL_CERT_DIR=/tmp SSL_CERT_FILE=/tmp openssl s_client -CAfile 
requests/cacert.pem -connect verisign.com:443

= Verify return code: 20 (unable to get local issuer certificate)

--

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



Re: Newbie question about text encoding

2015-02-24 Thread Chris Angelico
On Wed, Feb 25, 2015 at 3:20 AM, Laura Creighton l...@openend.se wrote:
 People who are asking for help in getting things to work in their
 native language need a 'do this quick' sort of answer.  The deeper
 problems of supporting all languages and language encodings can very
 much wait.

I'm not so sure about that. When supporting all languages is as
simple as use Python 3 and UTF-8 everywhere, the cost is much lower
than it might be, and the benefit is potentially huge. A do this
quick answer might get you by *right now*, but it leaves open the
possibility of subtler errors. That's why Python moved to
Unicode-by-default, even though eight-bit encodings will tend to
produce the right results for simple text.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23476] SSL cert verify fail for www.verisign.com

2015-02-24 Thread Christian Heimes

Christian Heimes added the comment:

John, neither Python nor OpenSSL are shipped with certificates.

Python uses certificates from operating system. We decided against our own 
certificate store because we wanted to avoid exactly this kind of trouble. If 
Python can't verify a certificate then you have to update the certificate 
storage of your OS.

On Linux and BSD Python, curl, wget and most other system tools use the OS's 
cert store. On Windows Python uses the same store as the IE, Chrome and other 
apps. Contrary to IE Python doesn't enforce cert store updates.

You can reproduce the problem with curl, too. The first call uses the OS' 
store, the second overwrite the default store.

$ curl https://www.verisign.com

$ SSL_CERT_DIR=/tmp SSL_CERT_FILE=/tmp curl https://www.verisign.com

--

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



[issue23510] multiprocessing bug SyncManager and 'with'

2015-02-24 Thread Davin Potts

Davin Potts added the comment:

A much simpler example of code triggering the described issue:

import multiprocessing.managers
with multiprocessing.managers.SyncManager() as s:
print here


Running the above code in 2.7.9 results in an exception with the traceback:

Traceback (most recent call last):
  File stdin, line 2, in module
  File /home/somewhere/python/lib/python2.7/multiprocessing/managers.py, 
line 602, in __exit__
self.shutdown()
AttributeError: 'SyncManager' object has no attribute 'shutdown'



This is because the implementation of context manager functionality for 
multiprocessing.managers.BaseManager appears to have a bug.  The above snippet 
of code might as well have been written to use BaseManager instead of 
SyncManager and the resulting behavior would have been the same.

To be fair, nothing in the documentation appears to suggest that BaseManager or 
its subclasses can / should be used with the 'with' statement (as proper 
context managers).  But it is also natural to react to the existence of 
'__enter__' and '__exit__' and think to try using it with a 'with' statement.

Specifically in BaseManager, it looks like self.shutdown should have been set 
via __enter__'s call to start() yet inside __exit__ it's not resolving.

I believe we need:
1) A patch to fix the broken behavior;
2) a test to validate that it works and specifically exercise the use of 
BaseManager with a 'with' statement;
3) an update to the docs to advertise context manager capability in these 
classes.

--
stage:  - needs patch

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



[issue23513] Add support for classes/object model in multiprocessing/pickle

2015-02-24 Thread Davin Potts

Changes by Davin Potts pyt...@discontinuity.net:


--
nosy: +davin

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



[issue23507] Tuple creation is too slow

2015-02-24 Thread Stefan Behnel

Changes by Stefan Behnel sco...@users.sourceforge.net:


--
nosy: +scoder

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



[issue6598] calling email.utils.make_msgid frequently has a non-trivial probability of generating colliding ids

2015-02-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The probability of a collision when generated n numbers from 0 to m-1 is

1 - factorial(m)/factorial(m-n)/m**n

When n  sqrt(m), it is approximately equal to n**2/(2*m). When m = 100, 
we have problems for n about 1000. When increase m to 2**32, the probability of 
collisions is decreased to 0.01%. When increase m to 2**64 as recommended in 
[1], it is decreased to 2.7e-14. I.e. when generate 1000 IDs per second, 
collisions happen one per a million years.

We could also take datetime with larger precision. E.g with 2 digits after the 
dot, as recommended in [1].

When apply both changes, we could generate 10 IDs per second with one 
collision per 1 years or 1 IDs per second with one collision per 
100 years.

[1] https://tools.ietf.org/html/draft-ietf-usefor-message-id-01

--
nosy: +serhiy.storchaka

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



[issue23514] multiprocessing documentation - little more examples for parallel computing

2015-02-24 Thread Cezary Wagner

Changes by Cezary Wagner cezary.wag...@gmail.com:


--
versions: +Python 2.7

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



[issue23476] SSL cert verify fail for www.verisign.com

2015-02-24 Thread Laura Creighton

Laura Creighton added the comment:

Antione closed this, as a not python error, as
if you do not pass a valid certificate to openssl s_client
it will not read the system certificates, which is clearly
utterly surprising and nuts.

The problem, as I see it, is that fixing this clear
absurdity may not fix a different underlying problem.  So this
one may need reopening  when the real error us revealed.  
See if John Nagel's code works ...

--

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



[issue23476] SSL cert verify fail for www.verisign.com

2015-02-24 Thread Aaron Meurer

Changes by Aaron Meurer asmeu...@gmail.com:


--
nosy: +Aaron.Meurer

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



[issue23476] SSL cert verify fail for www.verisign.com

2015-02-24 Thread Cory Benfield

Cory Benfield added the comment:

The problem specifically is that OpenSSL only uses a *root* in the trust store 
as an anchor. That means any certificate that is signed by another certificate 
will not terminate the chain of trust. Browsers do better here, by trusting the 
entirety of the trust store, regardless of whether or not it's a root 
certificate.

Donald is correct: this is not really Python's fault, it's OpenSSL's.

--

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



[issue23510] multiprocessing bug SyncManager and 'with'

2015-02-24 Thread Cezary Wagner

Cezary Wagner added the comment:

Yes it is what is wanted by me and other people I think.

1. enter has not start call.
2. exit has shutdown but it is not supported
3. 'with' is what is need since it is simple to manage

Good analysis.

--

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



[issue23510] multiprocessing bug SyncManager and 'with'

2015-02-24 Thread Davin Potts

Davin Potts added the comment:

Successfully reproduced on OS X 10.10 with 2.7.9.

Changing the issue type to behavior because crash is reserved for Hard 
crashes of the Python interpreter – possibly with a core dump or a Windows 
error box.  In this issue, we do see an exception get raised but the 
interpreter itself is still happy and alive.

--
nosy: +davin
type: crash - behavior

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



[issue23513] Add support for classes/object model in multiprocessing/pickle

2015-02-24 Thread Cezary Wagner

Cezary Wagner added the comment:

I am fighting with multiprocessing and still not won - I need to invent new 
Python coding style to use it and can not reduce ugly code/microcoding. It is 
not because it is not possible to do it in Python easier but because it is not 
improved yet.

--

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



Re: Newbie question about text encoding

2015-02-24 Thread Dave Angel

On 02/24/2015 11:20 AM, Laura Creighton wrote:

In a message of Wed, 25 Feb 2015 02:33:30 +1100, Chris Angelico writes:

Also a reasonable baseline assumption; but the trouble is that if you
automatically assume that text is encoded in your favourite eight-bit
system, you're taking a huge risk.


But, you know, I wasn't assuming this.  I actually read latin1.  I
could read it in ascii, know that \xe9  means 'é', a letter combination
that we have in Swedish, so I am rather used to reading, and then
well, I could read all of his strings, know they were in French,
and know that latin1 was what he needed things to be decoded to.


With a sample of one string, how did you read all his strings.  And 
with one non-ASCII code in that single string, how did you know that 
'latin1' was the only encoding that included a reasonable character at 
that encoding?





Now, you have a huge leg up on me, in that you actually recognize the
*words* in that piece of text. That means you can have MUCH greater
confidence in stating that it's Latin-1 than I can. But that's
precisely what I mean by understand the data. If you, being a native
French speaker, pick up a file written in (say) Polish, and encoded
Latin-2, you'll recognize by the ASCII characters that it's not French
text, and probably you'd be able to spot that it ought to be Latin-2
rather than Latin-1. That's understanding the data, that's having more
information than just the byte patterns. A computer can't reliably do
that (just look up the Bush hid the facts bug if you don't believe
me), but a human often can.


Absolutely correct.  But you must not require that all of the speakers
of non-English languages think about their languages as 'special
encodings'.  Only the monoglot ever think of a foreign language as
a code.


All languages are foreign.  All that can be written to a disk file are 
bytes.  Those have to have been encoded to represent some abstraction 
called a character set, or string.  The question is whether the encoding 
method is specified for the particular file type, or for the particular 
file.


See http://support.esri.com/cn/knowledgebase/techarticles/detail/21106

according to that page, starting at ArcGIS 10.2.1, the default sets the 
code page to UTF-8 (UNICODE) in the shapefile (.DBF)


But in earlier ones, there's supposed to be a reference to the codepage 
used.  From that, one can presumably derive which decoder to use.





That poor guy the original poster just wants to have a nice string
of his sporting event place name.  We should tell him how to get that,
not how to be an expert in all the encodings on the face of this earth.
Chances are, the only thing he needs to talk about are French words.

If not, well, he will come back when things stop working, and have lots
more data to give him.  If, instead, this makes him go away happy, then
this was the very best thing to do.


And having taught countless European kids how to write their very first
program in Python, I can tell you for certain that the sort of deep
understanding of encoding methods is not what 10 year olds who just
want to print out the names of their friends, and their favourite
music titles, and their favourite musicians want to know. :)


Right, so you should be teaching them to use Python 3, and always
saving everything in UTF-8, and basically ignoring the whole mess of
eight-bit encodings :)


Of course this makes sense.  But you seem to be missing the point.
People who are asking for help in getting things to work in their
native language need a 'do this quick' sort of answer.  The deeper
problems of supporting all languages and language encodings can very
much wait.  The OP wants a hunk of bytes that happens to mean
something in French, and is not encodable in the limited English
language to work like a different hunk of bytes that means something
in French but is encodable.

Don't overburden them.


My guess is that this is only appropriate for users who use only locally 
created data.  Since the OP's data is apparently old (if it were current 
versions, it'd have been utf-8), who knows how consistent the encoding is.


--
--
DaveA
--
https://mail.python.org/mailman/listinfo/python-list


[issue23514] multiprocessing documentation - little more examples for parallel computing

2015-02-24 Thread Cezary Wagner

Cezary Wagner added the comment:

Should I add this suggestion to open before issue?

I started doing multiprocessing code in Python so I can have more suggestions 
since I found that documentation can be improved I will report specific problem.

--

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



Re: How to apply python patch for issue9729

2015-02-24 Thread Grant Edwards
On 2015-02-24, Chris Angelico ros...@gmail.com wrote:
 On Tue, Feb 24, 2015 at 8:09 AM, Sada Shirol get2s...@gmail.com wrote:
 Upon some research found that I need to apply below patch:

 http://bugs.python.org/issue9729

 How do I apply a patch to python 2.6.6 on Linux?

 Hmm. You have a bit of a problem there: The patch wasn't designed to
 apply to 2.6. So you may find that it doesn't apply at all, or needs
 some tweaking.

Or worse yet, it applies just fine but doesn't work quite right in
particular cases that you won't run across until later when it's much
more embarassing.

-- 
Grant Edwards   grant.b.edwardsYow! ... I want to perform
  at   cranial activities with
  gmail.comTuesday Weld!!
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue17576] PyNumber_Index() is not int-subclass friendly (or operator.index() docos lie)

2015-02-24 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Ah, it just checks current behavior. So we will know when this will be changed.

--

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



[issue23262] webbrowser module broken with Firefox 36+

2015-02-24 Thread Oleg Broytman

Oleg Broytman added the comment:

I created the attached module to work with new FF in Python 2.7. You can 
convert it to proper patch for webbrowser.py.

--
nosy: +phd
Added file: http://bugs.python.org/file38227/new_firefox.py

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



[issue23496] Steps for Android Native Build of Python 3.4.2

2015-02-24 Thread Ryan Gonzalez

Ryan Gonzalez added the comment:

So...

I know a decent amount of configure scripts, although Python's is easily going 
to be the absolute longest I've ever touched.

Maybe these should be made against the 3.6 Mercurial source? I'm not sure if 
the Python devs would prefer that.

Also, should the configure script be based on the Android target triple?

--
type:  - enhancement

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



[issue23491] PEP 441 - Improving Python Zip Application Support

2015-02-24 Thread Daniel Holth

Daniel Holth added the comment:

Spelling

raise PackError(Cannot spacify entry point if the source has __main__.py)

--

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



[issue23515] Bad logic in timsort's merge_collapse

2015-02-24 Thread Tim Peters

New submission from Tim Peters:

Some researchers found an error in the logic of merge_collapse, explained here, 
and with corrected code shown in section 3.2:

http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/

This affects all current versions of Python.  However, I marked the priority 
low because, as the article also notes, there's currently no machine in 
existence with enough memory to hold an array large enough for a contrived 
input to trigger an overflow of the pending-runs stack. 

It should be fixed anyway, and their suggested fix looks good to me.

--
components: Interpreter Core
messages: 236533
nosy: tim.peters
priority: low
severity: normal
stage: needs patch
status: open
title: Bad logic in timsort's merge_collapse
type: crash

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



[issue23515] Bad logic in timsort's merge_collapse

2015-02-24 Thread Alex Gaynor

Changes by Alex Gaynor alex.gay...@gmail.com:


--
nosy: +alex

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



[issue23517] datetime.utcfromtimestamp parses timestamps incorrectly

2015-02-24 Thread Tommaso Barbugli

New submission from Tommaso Barbugli:

Hi,

I am porting a library from python 2.7 to 3.4 and I noticed that the behaviour 
of datetime.utcfromtimestamp is not consistent between the two versions.

For example on python 2.7.5
datetime.utcfromtimestamp(1424817268.274)
returns a datetime with 274000 microseconds

the same code in python 3.4 returns a datetime with 273999 microseconds.

--
components: Library (Lib)
messages: 236552
nosy: tbarbugli
priority: normal
severity: normal
status: open
title: datetime.utcfromtimestamp parses timestamps incorrectly
type: behavior
versions: Python 3.4

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



Re: strip bug?

2015-02-24 Thread Ian Kelly
On Tue, Feb 24, 2015 at 4:05 PM,  bayk...@gmail.com wrote:
 'http://xthunder'.strip('http://')
 'xthunder'
 'http://thunder'.strip('http://')
 'under'


This removes all leading and trailing occurrences of the characters in
the string 'http://', not the exact substring 'http://'. For that, use
either the str.replace method or slicing.

 I could understand backslash but forward slash?

I don't understand the question.
-- 
https://mail.python.org/mailman/listinfo/python-list


Pyston 0.3 self-hosting

2015-02-24 Thread Steven D'Aprano
Pyston 0.3, the latest version of a new high-performance Python 
implementation, has reached self-hosting sufficiency:


http://blog.pyston.org/2015/02/24/pyston-0-3-self-hosting-sufficiency/



-- 
Steve

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are threads bad? - was: Future of Pypy?

2015-02-24 Thread Marko Rauhamaa
Marcos Almeida Azevedo marcos.al.azev...@gmail.com:

 Synchronized methods in Java really makes programming life simpler.
 But I think it is standard practice to avoid this if there is a
 lighter alternative as synchronized methods are slow. Worse case I
 used double checked locking.

I have yet to see code whose performance suffers from too much locking.
However, I have seen plenty of code that suffers from anomalies caused
by incorrect locking.


Marko
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are threads bad? - was: Future of Pypy?

2015-02-24 Thread Marcos Almeida Azevedo
On Wed, Feb 25, 2015 at 1:46 PM, Marko Rauhamaa ma...@pacujo.net wrote:

 Marcos Almeida Azevedo marcos.al.azev...@gmail.com:

  Synchronized methods in Java really makes programming life simpler.
  But I think it is standard practice to avoid this if there is a
  lighter alternative as synchronized methods are slow. Worse case I
  used double checked locking.

 I have yet to see code whose performance suffers from too much locking.
 However, I have seen plenty of code that suffers from anomalies caused
 by incorrect locking.



Of course code with locking is slower than one without. The locking
mechanism itself is the overhead.  So use it only when necessary.  There is
a reason why double checked locking was invented by clever programmers.



 Marko
 --
 https://mail.python.org/mailman/listinfo/python-list




-- 
Marcos | I love PHP, Linux, and Java
http://javadevnotes.com/java-integer-to-string-examples
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are threads bad? - was: Future of Pypy?

2015-02-24 Thread Ian Kelly
On Tue, Feb 24, 2015 at 10:54 PM, Chris Angelico ros...@gmail.com wrote:
 On Wed, Feb 25, 2015 at 4:46 PM, Marko Rauhamaa ma...@pacujo.net wrote:
 Marcos Almeida Azevedo marcos.al.azev...@gmail.com:

 Synchronized methods in Java really makes programming life simpler.
 But I think it is standard practice to avoid this if there is a
 lighter alternative as synchronized methods are slow. Worse case I
 used double checked locking.

 I have yet to see code whose performance suffers from too much locking.
 However, I have seen plenty of code that suffers from anomalies caused
 by incorrect locking.

 Uhh, I have seen *heaps* of code whose performance suffers from too
 much locking. At the coarsest and least intelligent level, a database
 program that couldn't handle concurrency at all, so I wrote an
 application-level semaphore that stopped two people from running it at
 once. You want to use that program? Ask the other guy to close it.
 THAT is a performance problem. And there are plenty of narrower cases,
 where it ends up being a transactions-per-second throughput limiter.

Is the name of that database program Microsoft Access perchance?
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are threads bad? - was: Future of Pypy?

2015-02-24 Thread Chris Angelico
On Wed, Feb 25, 2015 at 4:46 PM, Marko Rauhamaa ma...@pacujo.net wrote:
 Marcos Almeida Azevedo marcos.al.azev...@gmail.com:

 Synchronized methods in Java really makes programming life simpler.
 But I think it is standard practice to avoid this if there is a
 lighter alternative as synchronized methods are slow. Worse case I
 used double checked locking.

 I have yet to see code whose performance suffers from too much locking.
 However, I have seen plenty of code that suffers from anomalies caused
 by incorrect locking.

Uhh, I have seen *heaps* of code whose performance suffers from too
much locking. At the coarsest and least intelligent level, a database
program that couldn't handle concurrency at all, so I wrote an
application-level semaphore that stopped two people from running it at
once. You want to use that program? Ask the other guy to close it.
THAT is a performance problem. And there are plenty of narrower cases,
where it ends up being a transactions-per-second throughput limiter.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23516] requests: parse_url() mishandles special characters when the URL specifies authentication credentials

2015-02-24 Thread Demian Brecht

Demian Brecht added the comment:

 I can't tell how to label this bug report because I don't know where pip 
 comes from: as far as I knew this is a bug in something called urllib3, which 
 seemed to me that was related to Python itself, or maybe in the way pip is 
 calling it, and I assumed pip was part of the Python project too.

What you’re seeing in your stack trace is an issue with packages developed 
independently of the Python standard library. pip 
(https://github.com/pypa/pip), requests 
(https://github.com/kennethreitz/requests) and urllib3 
(https://github.com/shazow/urllib3) are all maintained externally and hosted on 
PyPI (https://pypi.python.org/pypi). Issues here are for bugs, enhancements and 
such for the Python standard library. Each one of the aforementioned projects 
(with the caveat of pip in Python 3.4+) maintain their own sets of issues on 
Github.

 Thank you for mentioning issue 23328, which did not come up in a search I did 
 previous to filing my report: it does seem quite related.
 And that issue is marked as Library (Lib) and nobody complained about it so 
 maybe this issue should be marked like that too.

Indeed it does seem related and it’s possible that urllib3 took parts of the 
code from urllib, which /is/ part of the standard library and is what 23328 was 
reported against, hence the “Lib” tag for that one.

 Please somebody who knows what's the best way to move this forward relabel it 
 as necessary.

I’ll add a few people who may be interested in this issue, but I imagine that 
the issue would likely be moved to the urllib3 project.

Hope that all makes sense.

--

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



[issue23516] requests: parse_url() mishandles special characters when the URL specifies authentication credentials

2015-02-24 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy: +Marcus.Smith, dstufft, ncoghlan, pmoore

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



progress bar

2015-02-24 Thread Swapnil Pande
i want to call another tkinter window after completing the progress bar
an n e one help me
-- 
https://mail.python.org/mailman/listinfo/python-list


py.test can't resolve imports

2015-02-24 Thread Mario Figueiredo
I cannot seem to solve this problem from either the pytest
documentation or from other places on the web which provide tutorials
on pytest, such as http://pythontesting.net/start-here/

I have the following project setup:

/project
/project/project-- script files (with __init__.py)
/project/test-- test files
/project/docs   -- Sphinx

I cannot seem to be able to have py.test resolve imports by running
the following command from within the /project/project directory:

$ py.test ../


Example scripts:

/project/project/example.py
def func():
pass

/project/test/test_example.py
from example import *
def test_example():
assert 0

I get an error:

$ py.test ../

from example import *
E   ImportError: No module named 'example'

I can run the tests fine with $ python -m pytest ../

So how do I properly setup if I wish to use the less verbose py.test?
-- 
https://mail.python.org/mailman/listinfo/python-list


Running Idle on Windows 8 (.1)

2015-02-24 Thread Terry Reedy

On 2/24/2015 3:13 PM, blakemal...@gmail.com wrote:


I too can not get idle to run on win 8.1 using python3.4.2 installed from the 
python-3.4.2.amd64.msi.


What experience have others had with Idle and Windows 8?

The OP for
https://stackoverflow.com/questions/28633690/python-installation-troubleshooting

wrote in a comment I am invoking it from a win8 startmenu program, so I 
tried to do it via the normal windows 8 interface and it works from there,


I do not know what 'normal windows 8 interface' means, but does it work 
for anyone else?



pythonw.exe appears in the task manager but no gui is displayed.


pythonw.exe should appear *twice* in task manager.
Please try 3.4.3rc1 and 3.5.0a1
https://www.python.org/downloads/windows/

If the Idle does not start correctly on Win 8, perhaps we could fix it 
before 3.4.3 final (which should be soon).


--
Terry Jan Reedy

--
https://mail.python.org/mailman/listinfo/python-list


[issue23486] Enum member lookup is 20x slower than normal class attribute lookup

2015-02-24 Thread Ethan Furman

Ethan Furman added the comment:

This isn't a change to the API or any visible user behavior (besides 
performance), so I don't see a reason to not add it to 3.4.

--
nosy: +barry, eli.bendersky

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



Re: Bug in timsort!?

2015-02-24 Thread Dave Angel

On 02/24/2015 07:07 PM, Chris Angelico wrote:

On Wed, Feb 25, 2015 at 10:50 AM, Skip Montanaro
skip.montan...@gmail.com wrote:

Even if/when we get to the point where machines can hold an array of
2**49 elements, I suspect people won't be using straight Python to
wrangle them.


Looking just at CPython, what is the absolute minimum storage space
for a massive list like that? My guess is that a 64-bit CPython might
get as good as eight bytes per element; playing around with smaller
figures (up to circa a million elements) shows it ranging from 8 to 9
bytes per element, bottoming out at just a smidge over 8, presumably
at the moments when there's no slack space (there's a fixed overhead,
which gets diminishingly significant). So an array of 2**49 elements
would take 2**52 bytes (4 petabytes) of storage - addressable, to be
sure, but an awful lot to be sorting.

Would it be sufficient to stick a comment into the source saying This
may have problems with lists in excess of 2**49 elements, and leave
it until that's actually likely to happen?

ChrisA



One could do much better than that.  Put in a test for the length of the 
list, and if it's too large for the current implementation, throw an 
exception.  Much better than a comment.


--
DaveA
--
https://mail.python.org/mailman/listinfo/python-list


[issue23517] datetime.utcfromtimestamp parses timestamps incorrectly

2015-02-24 Thread Ethan Furman

Ethan Furman added the comment:

This seems to have changed in 3.3 (versions up to 3.2 return 274000).

--
nosy: +ethan.furman

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



Re: strip bug?

2015-02-24 Thread Irmen de Jong
On 25-2-2015 0:05, bayk...@gmail.com wrote:
 'http://xthunder'.strip('http://')
 'xthunder'
 'http://thunder'.strip('http://')
 'under'

 
 I could understand backslash but forward slash?
 




 help(.strip)
Help on built-in function strip:

strip(...) method of builtins.str instance
S.strip([chars]) - str

Return a copy of the string S with leading and trailing
whitespace removed.
If chars is given and not None, remove characters in chars instead.
^^



It strips any chars given in the argument, not as a prefix/suffix to remove.

Irmen

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: strip bug?

2015-02-24 Thread Chris Kaynor
On Tue, Feb 24, 2015 at 3:05 PM, bayk...@gmail.com wrote:

  'http://xthunder'.strip('http://')
 'xthunder'
  'http://thunder'.strip('http://')
 'under'
 

 I could understand backslash but forward slash?


I believe the issue is that str.strip does not do quite what you are
thinking it does, however your message is very unspecific about what you
expect to get. It seems that you except str.strip to remove a sub-string,
while it actually removes the list of specified characters (see
https://docs.python.org/3.4/library/stdtypes.html?highlight=str.strip#str.strip).
As such, you would get the same result from 'http://thunder'.strip('htp:/')
and 'http://thunder'.strip('/thp:') as from your samples.

To get what I am guessing you want (xthunder for the first and thunder
for the second), you should use splicing, likely combined with
str.startswith() (untested code):
url = 'http://thunder/
if url.startswith('http://'):
url = url[7:]
else
# Handle case without the prefix in whatever manner is correct for your
case. Possibly continue, possibly error out.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23516] requests: parse_url() mishandles special characters when the URL specifies authentication credentials

2015-02-24 Thread Martin Panter

Martin Panter added the comment:

Sounds like this might be in a third-party module, not in Python itself. But 
see also Issue 23328 and Issue 18140.

The RFC you referenced also says this, which suggests the authority cannot 
contain a literal question mark:

‘The authority component . . . is terminated by the next slash (/), question 
mark (?), or number sign (#) character, or by the end of the URI.’

Some more definitions from that RFC indicating a literal question mark is not 
allowed in “userinfo”:

userinfo = *( unreserved / pct-encoded / sub-delims / : )
unreserved = ALPHA / DIGIT / - / . / _ / ~
pct-encoded = % HEXDIG HEXDIG
sub-delims = ! / $ /  / ' / ( / ) / * / + / , / ; / =

--
nosy: +vadmium

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



[issue2292] Missing *-unpacking generalizations

2015-02-24 Thread Guido van Rossum

Guido van Rossum added the comment:

The patch no longer applies cleanly. I had to do hg up -r ac0d6c09457e to get 
a checkpoint to which it applies. (But I'm not sure at what point that landed 
me.)

--

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



[issue23516] requests: parse_url() mishandles special characters when the URL specifies authentication credentials

2015-02-24 Thread Demian Brecht

Changes by Demian Brecht demianbre...@gmail.com:


--
nosy: +demian.brecht

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



Re: Newbie question about text encoding

2015-02-24 Thread Steven D'Aprano
Laura Creighton wrote:

 Dave Angel
 are you another Native English speaker living in a world where ASCII
 is enough?

ASCII was never enough. Not even for Americans, who couldn't write things
like I bought a comic book for 10¢ yesterday, let alone interesting
things from maths and science.

I missed the whole 7-bit ASCII period, my first computer (Mac 128K) already
had an extended character set beyond ASCII. But even that never covered the
full range of characters I wanted to write, and then there was the horrible
mess that you got whenever you copied text files from a Mac to a DOS or
Windows PC or visa versa. Yes, even in 1984 we were transferring files and
running into encoding issues.



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


[issue23516] requests: parse_url() mishandles special characters when the URL specifies authentication credentials

2015-02-24 Thread Demian Brecht

Demian Brecht added the comment:

 Sounds like this might be in a third-party module

+1. urllib3.url_parse doesn't make use of the standard library.

 userinfo = *( unreserved / pct-encoded / sub-delims / : )

This leads me to believe that using something like this might work:

from urllib.parse import quote
userinfo = '{}:{}'.format(quote(user), quote(password))

That said, there's also another relevant block that should be of note in the 
RFC:

   Use of the format user:password in the userinfo field is
   deprecated.  Applications should not render as clear text any data
   after the first colon (:) character found within a userinfo
   subcomponent unless the data after the colon is the empty string
   (indicating no password).  Applications may choose to ignore or
   reject such data when it is received as part of a reference and
   should reject the storage of such data in unencrypted form.  The
   passing of authentication information in clear text has proven to be
   a security risk in almost every case where it has been used.

In any event, this issue should be closed as it's not related to the standard 
library.

--

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



Re: Newbie question about text encoding

2015-02-24 Thread Steven D'Aprano
Laura Creighton wrote:

 The idea that the whole world loves utf-8 is nonsense.

I don't think anyone says the whole world loves UTF-8. I think people say
that the whole world *ought to* love UTF-8, and that legacy encodings from
the Windows code-page days ought to die.


 Most of europe has been using latin1, latin2 etc. before 
 unicode was invented and will, as far as I know, continue to use it.

And this is why people in Greece cannot transfer text files to people in
France without the content changing (ISO-8859-7 vs ISO-8859-1). And why
Russians cannot even swap text files with other Russians (a plethora of
encodings).

:-(



-- 
Steven

-- 
https://mail.python.org/mailman/listinfo/python-list


strip bug?

2015-02-24 Thread baykiwi
 'http://xthunder'.strip('http://')
'xthunder'
 'http://thunder'.strip('http://')
'under'


I could understand backslash but forward slash?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue10954] csv.reader/writer to raise exception if mode is binary or newline is not ''

2015-02-24 Thread Martin Panter

Martin Panter added the comment:

I suspect it may not be practical to check the newline translation mode of a 
TextIOWrapper or StringIO stream, and I don’t think newline translation is even 
required in general for text stream classes. Beware that the “newlines” 
attribute isn’t going to help; see Issue 8895.

--
nosy: +vadmium

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



Re: Bug in timsort!?

2015-02-24 Thread Chris Kaynor
On Tue, Feb 24, 2015 at 4:07 PM, Chris Angelico ros...@gmail.com wrote:

 On Wed, Feb 25, 2015 at 10:50 AM, Skip Montanaro
 skip.montan...@gmail.com wrote:
  Even if/when we get to the point where machines can hold an array of
  2**49 elements, I suspect people won't be using straight Python to
  wrangle them.

 Looking just at CPython, what is the absolute minimum storage space
 for a massive list like that? My guess is that a 64-bit CPython might
 get as good as eight bytes per element; playing around with smaller
 figures (up to circa a million elements) shows it ranging from 8 to 9
 bytes per element, bottoming out at just a smidge over 8, presumably
 at the moments when there's no slack space (there's a fixed overhead,
 which gets diminishingly significant). So an array of 2**49 elements
 would take 2**52 bytes (4 petabytes) of storage - addressable, to be
 sure, but an awful lot to be sorting.

 Would it be sufficient to stick a comment into the source saying This
 may have problems with lists in excess of 2**49 elements, and leave
 it until that's actually likely to happen?


I would agree that it will be quite a while as it stands before the bug
appears, so documenting it MAY be appropriate, as it is likely to be far
enough in the future that a number of unforeseen things may block the bug
from being an issue (TimSort may be replaced by something better, CPython
could die, etc).

That said, from what I understand, their proposed fix would be reasonably
easy to use, and have minimal cost, so it may be worthwhile to use just
because the issue is likely to be in use for quite a while before somebody
remembers the issue exists. Once somebody does hit it, it may take a while
to realize that TimSort is at fault, as it will only occur on some data
sets (my understanding is that the elements must be in certain
configurations with at-least the minimum number), so it will likely appear
as just a random crash occurring.

If it were fully up to me, I would do one of the following, in order of
preference:
1) Implement and test the fix provided on the blog. This requires the most
work due to licensing, reviewing, and testing.
2) Add a noisy warning/error to the code when sorting lists large enough to
potentially hit the error (probably 2**48 to leave some wiggle room). This
is much easier to do, but merely pushes the can down the road to be dealt
with later. It does still make it obvious what is going long when it
finally breaks.
3) Add a comment explaining the issue (likely linking back to the blog).
While by far the easiest solution, again, this merely pushes the can down
the road, and it may be very non-obvious what went wrong when it breaks,
despite the comment.

Chris
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Are threads bad? - was: Future of Pypy?

2015-02-24 Thread Ryan Stuart
On Tue Feb 24 2015 at 3:32:47 PM Paul Rubin no.email@nospam.invalid wrote:

 Ryan Stuart ryan.stuart...@gmail.com writes:
 Sure, the shared memory introduces the possibility of some bad errors,
 I'm just saying that I've found that by staying with a certain
 straightforward style, it doesn't seem difficult in practice to avoid
 those errors.


And all I'm saying is that it doesn't matter how careful you are, all it
takes is someone up the stack to not be as careful and you will be bitten.
And even if they are careful, it's still very easy to be bitten because
everything runs in shared memory.


 I don't understand what you mean about malloc.


My point is malloc, something further up (down?) the stack, is making
modifications to shared state when threads are involved. Modifying shared
state makes it infinitely more difficult to reason about the correctness of
your software.


 That article was interesting in some ways but confused in others.  One
 way it was interesting is it said various non-thread approaches (such as
 coroutines) had about the same problems as threads.  Some ways it
 was confused were:


We clearly got completely different things from the article. My
interpretation was that it was making *the exact opposite* point to what
you stated mainly because non-threading approaches don't share state. It
states that quite clearly. For example it is – literally – exponentially
more difficult to reason about a routine that may be executed from an
arbitrary number of threads concurrently.


   1) thinking Haskell threads were like processes with separate address
   spaces.  In fact they are in the same address space and programming
   with them isn't all that different from Python threads, though the
   synchronization primitives are a bit different.  There is also an STM
   library available that is ingenious though apparently somewhat slow.


I don't know Haskell, so I can't comment too much, except to say that by
default Haskell looks to use lightweight threads where only 1 thread can be
executing at a time [1] (sounds similar to the GIL to me). That doesn't
seem to be shared state multithreading, which is what the article is
referring to. But again, they will undoubtedly be someone sharing state
higher up the stack.


   2) it has a weird story about the brass cockroach, that basically
   signified that they didn't have a robust enough testing system to be
   able to reproduce the bug.  That is what they should have worked on.


The point was that it wasn't feasible to have a robust testing suite
because, you guessed it, shared state and concurrent threads producing n*n
complexity.


   3) It goes into various hazards of the balance transfer example not
   mentioning that STM (available in Haskell and Clojure) completely
   solves it.


This is probably correct. Is there any STM implementations out that that
don't significantly compromise performance?

Anyway, I got one thing out of this, which is that the multiprocessing
 module looks pretty nice and I should try it even when I don't need
 multicore parallelism, so thanks for that.


It's 1 real advantage is that it side-steps the GIL. So, if you need to
utilise multiple cores for CPU bound tasks, then it might well be the only
option.

Cheers


 In reality though, Python is still my most productive language for
 throwaway, non-concurrent scripting, but for more complicated concurrent
 programs, alternatives like Haskell, Erlang, and Go all have significant
 attractions.
 --
 https://mail.python.org/mailman/listinfo/python-list

-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Bug in timsort!?

2015-02-24 Thread Grant Edwards
On 2015-02-24, Roy Smith r...@panix.com wrote:

 http://envisage-project.eu/proving-android-java-and-python-sorting-algorithm-is-broken-and-how-to-fix-it/

I don't get it. 

3.2 Corrected Python merge_collapse function

merge_collapse(MergeState *ms)
{
struct s_slice *p = ms-pending;

assert(ms);
while (ms-n  1) {
Py_ssize_t n = ms-n - 2;
if ( n  0p[n-1].len = p[n].len + p[n+1].len
|| (n-1  0   p[n-2].len = p[n].len + p[n-1].len)) {
if (p[n-1].len  p[n+1].len)
--n;
if (merge_at(ms, n)  0)
return -1;
}
else if (p[n].len = p[n+1].len) {
 if (merge_at(ms, n)  0)
return -1;
}
else
break;
}
return 0;
}

Or does Python function mean something else in this context?




-- 
Grant Edwards   grant.b.edwardsYow! I request a weekend in
  at   Havana with Phil Silvers!
  gmail.com
-- 
https://mail.python.org/mailman/listinfo/python-list


  1   2   >