Re: Python under PowerShell adds characters

2017-03-30 Thread Steve D'Aprano
On Thu, 30 Mar 2017 04:43 pm, Marko Rauhamaa wrote:

> Steven D'Aprano :
> 
>> On Thu, 30 Mar 2017 07:29:48 +0300, Marko Rauhamaa wrote:
>>> I'd expect not having to deal with Unicode decoding exceptions with
>>> arbitrary input.
>>
>> That's just silly. If you have *arbitrary* bytes, not all
>> byte-sequences are valid Unicode, so you have to expect decoding
>> exceptions, if you're processing text.
> 
> The input is not in my control, and bailing out may not be an option:


You have to deal with bad input *somehow*. You can't just say it will never
happen. If bailing out is not an option, then perhaps the solution is not
to read stdin as Unicode text, if there's a chance that it actually doesn't
contain Unicode text. Otherwise, you have to deal with any errors.

("Deal with" can include the case of not dealing with them at all, and just
letting your script raise an exception.)



>$ echo $'aa\n\xdd\naa' | grep aa
>aa
>aa
>$ echo $'\xdd' | python2 -c 'import sys; sys.stdin.read(1)'
>$ echo $'\xdd' | python3 -c 'import sys; sys.stdin.read(1)'
>Traceback (most recent call last):
>  File "", line 1, in 
>  File "/usr/lib64/python3.5/codecs.py", line 321, in decode
>(result, consumed) = self._buffer_decode(data, self.errors, final)
>UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdd in position 0:
> invalid continuation byte

As I said, what did you expect? You choose to read from stdin as Unicode
text, then fed it something that wasn't Unicode text. That's no different
from expecting to read a file name, then passing an ASCII NUL byte.
Something is going to break, somewhere, so you have to deal with it.

I'm not sure if there are better ways, but one way of dealing with this is
to bypass the text layer and read from the raw byte-oriented stream:

[steve@ando ~]$ echo $'\xdd' | python3 -c 'import sys;
print(sys.stdin.buffer.read(1))'
b'\xdd'


You have a choice. The default choice is aimed at the most-common use-case,
which is that input will be text, but its not the only choice.



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.

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


Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-30 Thread Pavol Lisy
On 3/29/17, Jan Gosmann  wrote:
> On 28 Mar 2017, at 14:21, INADA Naoki wrote:
>
>> On Wed, Mar 29, 2017 at 12:29 AM, Jan Gosmann 
>> wrote:
>>
>> I suppose smaller and faster benchmark is better to others looking for
>> it.
>> I already stopped the azure instance.
>> [...]
>> There are no maxrss difference in "smaller existing examples"?
>> [...]
>> I want to investigate RAM usage, without any swapping.
>
> Running further trials indicate that the problem actually is related to
> swapping. If I reduce the model size in the benchmark slightly so that
> everything fits into the main memory, the problem disappears. Only when
> the memory usage exceeds the 32GB that I have, Python 3.6 will acquire
> way more memory (from the swap) than Python 3.5.
>
> Jan
> --
> https://mail.python.org/mailman/listinfo/python-list

Could you add table comparing time benchmarks when memory is bigger?
(if your hypothesis is true and memory measurement tools are right
than time difference has to be huge)

Did you compare "pip list" results? There could be more differences in
your environments (not only python version). For example different
numpy versions or some missing packages could change game.

I tried to search "except.*ImportError" in your repository, but I am
not sure that it could change it significantly...

( 
https://github.com/ctn-archive/gosmann-frontiers2017/search?utf8=%E2%9C%93=ImportError=

This one seems suspitious - sparse matrix class could be game changer

from scipy.sparse import bsr_matrix
assert bsr_matrix
except (ValueError, ImportError):
return False

)


This one doesn't seems suspicious to me (but who knows?):

try:
import faulthandler
faulthandler.enable()
except:
pass

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


Re: pandas dataframe, find duplicates and add suffix

2017-03-30 Thread Pavol Lisy
On 3/28/17, zljubi...@gmail.com  wrote:
> In dataframe
>
> import pandas as pd
>
> data = {'model': ['first', 'first', 'second', 'second', 'second', 'third',
> 'third'],
> 'dtime': ['2017-01-01_112233', '2017-01-01_112234',
> '2017-01-01_112234', '2017-01-01_112234', '2017-01-01_112234',
> '2017-01-01_112235', '2017-01-01_112235'],
> }
> df = pd.DataFrame(data, index = ['a.jpg', 'b.jpg', 'c.jpg', 'd.jpg',
> 'e.jpg', 'f.jpg', 'g.jpg'], columns=['model', 'dtime'])
>
> print(df.head(10))
>
> model  dtime
> a.jpg   first  2017-01-01_112233
> b.jpg   first  2017-01-01_112234
> c.jpg  second  2017-01-01_112234
> d.jpg  second  2017-01-01_112234
> e.jpg  second  2017-01-01_112234
> f.jpg   third  2017-01-01_112235
> g.jpg   third  2017-01-01_112235
>
> within model, there are duplicate dtime values.
> For example, rows d and e are duplicates of the c row.
> Row g is duplicate of the f row.
>
> For each duplicate (within model) I would like to add suffix (starting from
> 1) to the dtime value. Something like this:
>
> model  dtime
> a.jpg   first  2017-01-01_112233
> b.jpg   first  2017-01-01_112234
> c.jpg  second  2017-01-01_112234
> d.jpg  second  2017-01-01_112234-1
> e.jpg  second  2017-01-01_112234-2
> f.jpg   third  2017-01-01_112235
> g.jpg   third  2017-01-01_112235-1
>
> How to do that?
> --
> https://mail.python.org/mailman/listinfo/python-list
>

I am not expert, just played a little...

This one could work:

gb = df.groupby([df.model, df.dtime])
df.dtime = df.dtime + gb.cumcount().apply(lambda a:str(-a) if a else '')

this one is probably more readable:
df.dtime = df.dtime + [str(-a) if a else '' for a in gb.cumcount()]

I don't know which one is better in memory consumption and/or speed.

This small dataframe gave me:

%timeit -r 5 df.dtime + gb.cumcount().apply(lambda a:str(-a) if a else '')
1000 loops, best of 5: 387 µs per loop

%timeit -r 5 df.dtime + [str(-a) if a else '' for a in gb.cumcount()]
1000 loops, best of 5: 324 µs per loop

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


[issue29947] In SocketServer, why not passing a factory instance for the RequestHandlerClass instead of the class itself?

2017-03-30 Thread Dominic Mayers

New submission from Dominic Mayers:

I am just curious to know if someone considered the idea of passing a factory 
instance that returns RequestHandlerClass instances instead of directly passing 
the class? It may affect existing handlers that read non local variables, but 
there should be a way to make the factory optional. The purpose is only 
aesthetic and a better organization of the code. I find it awkward to have to 
subclass the server every time that we have an handler that needs special 
objects, a database connection, a socket connection to another party, etc. The 
server class should have a single purpose: accept a request and pass it to an 
handler. We should only need to subclass a server when we need to do that in a 
different way : TCP vs UDP, Unix Vs INET, etc. The usage is simpler and more 
natural. Instead of subclassing the server, we create a factory for the handler.

--
components: Library (Lib)
messages: 290840
nosy: dominic108
priority: normal
severity: normal
status: open
title: In SocketServer, why not passing a factory instance for the 
RequestHandlerClass  instead of the class itself?
type: enhancement
versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue29944] Argumentless super() calls do not work in classes constructed with type()

2017-03-30 Thread Xiang Zhang

Changes by Xiang Zhang :


--
nosy: +ncoghlan, xiang.zhang

___
Python tracker 

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



[issue29945] decode string:u"\ufffd" UnicodeEncodeError

2017-03-30 Thread Eryk Sun

Eryk Sun added the comment:

> windows version run success!

Trying to decode a non-ASCII unicode string should raise an exception on any 
platform:

Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40)
[MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> a=u"\ufffd"
>>> a.decode("utf=8")
Traceback (most recent call last):
  File "", line 1, in 
  File "C:\Program Files\Python27\lib\encodings\utf_8.py",
  line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd'
in position 0: ordinal not in range(128)

Unless you've modified the default encoding to something other than ASCII. For 
example:

Python 2.7.13 (v2.7.13:a06454b1afa1, Dec 17 2016, 20:53:40)
[MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys, inspect, sitecustomize
>>> print inspect.getsource(sitecustomize)
import sys
sys.setdefaultencoding('utf-8')

>>> sys.getdefaultencoding()
'utf-8'
>>> a=u"\ufffd"
>>> a.decode("utf=8")
u'\ufffd'

--
nosy: +eryksun
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue29935] list and tuple index methods should accept None parameters

2017-03-30 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Sorry, modifying these mature APIs is a really bad idea.  They are worked well 
as-is of over a decade.  Seeing people use None for these arguments makes the 
code less readable. 

Python has a number of APIs where the number of arguments controls the 
behavior.  For example, type() with one argument does something very different 
that type() with three arguments.  Likewise, iter() behaves differently with 
two arguments than three.  The pattern used by index() shows-up in a number of 
places where we have optional start and end arguments.  These APIs are a long 
standing Python norm, both for the core and for third-party modules.  Type 
checking will have to adapt to norms rather than having all of Python change 
for the convenience of typing.

Serhiy, please go ahead with the doc fix.

If the OP really wants to insist on changing old and stable APIs through out 
the language in a way that I consider harmful to readability, we can battle it 
out in a PEP and on mailing lists.

--

___
Python tracker 

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



[issue29943] PySlice_GetIndicesEx change broke ABI in 3.5 and 3.6 branches

2017-03-30 Thread Charalampos Stratakis

Changes by Charalampos Stratakis :


--
nosy: +cstratak

___
Python tracker 

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



[issue29946] compiler warning "sqrtpi defined but not used"

2017-03-30 Thread Louie Lu

Louie Lu added the comment:

I can reproduce on ArchLinux 4.10.1-1, GCC 6.3.1:

/home/louielu/Python/cpython/Modules/mathmodule.c:74:21: warning: ‘sqrtpi’ 
defined but not used [-Wunused-const-variable=]
 static const double sqrtpi = 1.772453850905516027298167483341145182798;



Is used by `m_erfc_contfrac` and `m_erf_series`, and inside the block of "#if 
!defined(HAVE_ERF) || !defined(HAVE_ERFC)", maybe sqrtpi should do the same 
condition?

--
nosy: +louielu

___
Python tracker 

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



Re: Program uses twice as much memory in Python 3.6 than in Python 3.5

2017-03-30 Thread INADA Naoki
>
> Running further trials indicate that the problem actually is related to
> swapping. If I reduce the model size in the benchmark slightly so that
> everything fits into the main memory, the problem disappears. Only when the
> memory usage exceeds the 32GB that I have, Python 3.6 will acquire way more
> memory (from the swap) than Python 3.5.
>
> Jan
> --

It's very hard to believe...
I think there are some factor other than swap cause the problem.
Or, can't it reproducible in 64GB RAM machine?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29946] compiler warning "sqrtpi defined but not used"

2017-03-30 Thread Xiang Zhang

New submission from Xiang Zhang:

Ubuntu 16.10, GCC 6.2.0

/home/angwer/repos/cpython/Modules/mathmodule.c:74:21: warning: ‘sqrtpi’ 
defined but not used [-Wunused-const-variable=]
 static const double sqrtpi = 1.772453850905516027298167483341145182798;

--
components: Build
messages: 290836
nosy: xiang.zhang
priority: normal
severity: normal
status: open
title: compiler warning "sqrtpi defined but not used"
versions: Python 3.7

___
Python tracker 

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



[issue29945] decode string:u"\ufffd" UnicodeEncodeError

2017-03-30 Thread STINNER Victor

STINNER Victor added the comment:

Decoding Unicode doesn't make any sense. You should take a look at 
http://unicodebook.readthedocs.io/ to understand what you are doing :-)

(On Python 3, Unicode strings, the str type, has no mode .decode() type.)

I suggest to close the issue has NOT A BUG.

--

___
Python tracker 

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



[issue29945] decode string:u"\ufffd" UnicodeEncodeError

2017-03-30 Thread webber

Changes by webber :


Added file: http://bugs.python.org/file46767/windows.jpg

___
Python tracker 

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



[issue29945] decode string:u"\ufffd" UnicodeEncodeError

2017-03-30 Thread webber

New submission from webber:

I use  python on linux, version is 2.7.13:

[root@localhost bin]# ./python2.7
Python 2.7.13 (default, Mar 30 2017, 00:54:08) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> a=u"\ufffd"
>>> a.decode("utf=8")
Traceback (most recent call last):
  File "", line 1, in 
  File "/opt/python2.7.13/lib/python2.7/encodings/utf_8.py", line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeEncodeError: 'ascii' codec can't encode character u'\ufffd' in position 
0: ordinal not in range(128)

but,windows version run success!

--
components: Unicode
messages: 290834
nosy: ezio.melotti, foxscheduler, haypo
priority: normal
severity: normal
status: open
title: decode string:u"\ufffd" UnicodeEncodeError
versions: Python 2.7

___
Python tracker 

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



[issue29533] urllib2 works slowly with proxy on windows

2017-03-30 Thread Paul Moore

Paul Moore added the comment:

The behaviour you're describing for IE sounds like a bug to me. If you specify 
a host that should bypass the proxy, then that's what should happen - it 
shouldn't matter if you specify the host by IP address or by name.

I'm -1 on Python trying to match IE bugs.

--

___
Python tracker 

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



[issue29887] test_normalization doesn't work

2017-03-30 Thread STINNER Victor

STINNER Victor added the comment:

Benjamin: "We should change the tests to fail if they get a 404."

Good idea. Currently, the test is explicitly skipped on this case. Since "-u 
urlfetch" option must be explicitly passed on the command line, it makes sense 
to fail on that case.

I proposed https://github.com/python/cpython/pull/905 change for that. Not sure 
if it's worth to backport such change to older Python versions?

--

___
Python tracker 

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



[issue29887] test_normalization doesn't work

2017-03-30 Thread STINNER Victor

Changes by STINNER Victor :


--
pull_requests: +805

___
Python tracker 

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



[issue29942] Stack overflow in itertools.chain.from_iterable.

2017-03-30 Thread Mark Dickinson

Mark Dickinson added the comment:

> I would have guessed that the C compiler would have automatically removed the 
> tail recursion

I think it probably does, unless optimisation is turned off: I'm unable to 
reproduce except in debug builds of Python.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue29913] ipadress compare_networks does not work according to documentation

2017-03-30 Thread Xiang Zhang

Changes by Xiang Zhang :


--
resolution:  -> fixed
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

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



[issue29913] ipadress compare_networks does not work according to documentation

2017-03-30 Thread Xiang Zhang

Xiang Zhang added the comment:


New changeset 16f852345bcdec1bbb15e5363fad6b33bf960912 by Xiang Zhang 
(s-sanjay) in branch 'master':
bpo-29913: deprecate compare_networks() in documentation (GH-865)
https://github.com/python/cpython/commit/16f852345bcdec1bbb15e5363fad6b33bf960912


--

___
Python tracker 

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



[issue29942] Stack overflow in itertools.chain.from_iterable.

2017-03-30 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This looks fine.  Feel free to apply and to backport this to earlier versions.

I would have guessed that the C compiler would have automatically removed the 
tail recursion, but your experience would indicate otherwise.

--
assignee:  -> twouters

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset c90ff1b78cb79bc3762184e03fa81f11984aaa45 by Serhiy Storchaka in 
branch '3.5':
bpo-27863: Fixed multiple crashes in ElementTree. (#765) (#904)
https://github.com/python/cpython/commit/c90ff1b78cb79bc3762184e03fa81f11984aaa45


--

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2017-03-30 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +804

___
Python tracker 

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



[issue29918] Missed "const" modifiers in C API documentation

2017-03-30 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue29918] Missed "const" modifiers in C API documentation

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 84b8e92e463bd6a5174bd3e5a6543580f6319c57 by Serhiy Storchaka in 
branch 'master':
bpo-29918: Add missed "const" modifiers in C API documentation. (#846)
https://github.com/python/cpython/commit/84b8e92e463bd6a5174bd3e5a6543580f6319c57


--

___
Python tracker 

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



[issue29816] Get rid of C limitation for shift count in right shift

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your review Mark.

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2017-03-30 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
pull_requests: +803

___
Python tracker 

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



[issue29816] Get rid of C limitation for shift count in right shift

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 918403cfc3304d27e80fb792357f40bb3ba69c4e by Serhiy Storchaka in 
branch 'master':
bpo-29816: Shift operation now has less opportunity to raise OverflowError. 
(#680)
https://github.com/python/cpython/commit/918403cfc3304d27e80fb792357f40bb3ba69c4e


--

___
Python tracker 

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



[issue27863] multiple issues in _elementtree module

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 576def096ec7b64814e038f03290031f172886c3 by Serhiy Storchaka in 
branch 'master':
bpo-27863: Fixed multiple crashes in ElementTree. (#765)
https://github.com/python/cpython/commit/576def096ec7b64814e038f03290031f172886c3


--

___
Python tracker 

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



[issue29944] Argumentless super() calls do not work in classes constructed with type()

2017-03-30 Thread assume_away

New submission from assume_away:

The simplest example:

def mydec(cls):
return type(cls.__name__, cls.__bases__, dict(cls.__dict__))

@mydec
class MyList(list):

def extend(self, item):
super(MyList, self).extend(item)

def insert(self, index, object):
super().insert(index, object)

>>> lst = MyList()
>>> lst.extend([2,3])
>>> lst.insert(0, 1)
TypeError: super(type, obj): obj must be an instance or subtype of type
>>> lst
[2, 3]

If this is intended behavior, at least the error message could be fixed.

--
messages: 290823
nosy: assume_away
priority: normal
severity: normal
status: open
title: Argumentless super() calls do not work in classes constructed with type()
type: behavior
versions: Python 3.6

___
Python tracker 

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



[issue29939] Compiler warning in _ctypes_test.c

2017-03-30 Thread Benjamin Peterson

Changes by Benjamin Peterson :


--
pull_requests: +802

___
Python tracker 

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



[issue29935] list and tuple index methods should accept None parameters

2017-03-30 Thread Jelle Zijlstra

Jelle Zijlstra added the comment:

I agree with George that supporting None here is the better option.

This problem also applies to collections.deque. tuple, list, and deque all have 
very similar index implementations, and it would be nice to merge their 
argument parsing boilerplate.

--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue25996] Add support of file descriptor in os.scandir()

2017-03-30 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue24821] The optimization of string search can cause pessimization

2017-03-30 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue29878] Add global instances of int 0 and 1

2017-03-30 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue29852] Argument Clinic: add common converter to Py_ssize_t that accepts None

2017-03-30 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

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



[issue29852] Argument Clinic: add common converter to Py_ssize_t that accepts None

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 762bf40438a572a398e500c74e38f9894ea20a45 by Serhiy Storchaka in 
branch 'master':
bpo-29852: Argument Clinic Py_ssize_t converter now supports None (#716)
https://github.com/python/cpython/commit/762bf40438a572a398e500c74e38f9894ea20a45


--

___
Python tracker 

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



[issue25996] Add support of file descriptor in os.scandir()

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset ea720fe7e99d68924deab38de955fe97f87e2b29 by Serhiy Storchaka in 
branch 'master':
bpo-25996: Added support of file descriptors in os.scandir() on Unix. (#502)
https://github.com/python/cpython/commit/ea720fe7e99d68924deab38de955fe97f87e2b29


--

___
Python tracker 

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



[issue24821] The optimization of string search can cause pessimization

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset 0a58f72762353768c7d26412e627ff196aac6c4e by Serhiy Storchaka in 
branch 'master':
bpo-24821: Fixed the slowing down to 25 times in the searching of some (#505)
https://github.com/python/cpython/commit/0a58f72762353768c7d26412e627ff196aac6c4e


--

___
Python tracker 

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



[issue29878] Add global instances of int 0 and 1

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:


New changeset ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb by Serhiy Storchaka in 
branch 'master':
bpo-29878: Add global instances of int for 0 and 1. (#852)
https://github.com/python/cpython/commit/ba85d69a3e3610bdd05f0dd372cf4ebca178c7fb


--

___
Python tracker 

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



[issue22392] Clarify documentation of __getinitargs__

2017-03-30 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +alexandre.vassalotti

___
Python tracker 

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



[issue22392] Clarify documentation of __getinitargs__

2017-03-30 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See more detailed description in PEP 307.

--
nosy: +serhiy.storchaka
stage: needs patch -> patch review

___
Python tracker 

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



Re: Python under PowerShell adds characters

2017-03-30 Thread Chris Angelico
On Thu, Mar 30, 2017 at 4:57 PM, Marko Rauhamaa  wrote:
> What I'm saying is that every program must behave in a minimally
> controlled manner regardless of its inputs (which are not in its
> control). With UTF-8, it is dangerously easy to write programs that
> explode surprisingly. What's more, resyncing after such exceptions is
> not at all easy. I would venture to guess that few Python programs even
> try to do that.

If you expect to get a series of decimal integers, and you find a "Q"
in the middle, is it dangerously easy for your program blow up? How do
you resync after that? Do these questions even make sense? Not in my
opinion; you got invalid data, so you throw an exception and stop
reading data.

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



Re: Python under PowerShell adds characters

2017-03-30 Thread Marko Rauhamaa
Chris Angelico :

> On Thu, Mar 30, 2017 at 4:43 PM, Marko Rauhamaa  wrote:
>> The input is not in my control, and bailing out may not be an option:
>>
>>$ echo
>> aa\n\xdd\naa' | grep aa
>>aa
>>aa
>>$ echo \xdd' | python2 -c 'import sys; sys.stdin.read(1)'
>>$ echo \xdd' | python3 -c 'import sys; sys.stdin.read(1)'
>>Traceback (most recent call last):
>>  File "", line 1, in 
>>  File "/usr/lib64/python3.5/codecs.py", line 321, in decode
>>(result, consumed) = self._buffer_decode(data, self.errors, final)
>>UnicodeDecodeError: 'utf-8' codec can't decode byte 0xdd in position 0:
>> invalid continuation byte
>>
>> Note that "grep" is also locale-aware.
>
> So what exactly does byte value 0xDD mean in your stream?
>
> And if you say "it doesn't matter", then why are you assigning meaning
> to byte value 0x0A in your first example? Truly binary data doesn't
> give any meaning to 0x0A.

What I'm saying is that every program must behave in a minimally
controlled manner regardless of its inputs (which are not in its
control). With UTF-8, it is dangerously easy to write programs that
explode surprisingly. What's more, resyncing after such exceptions is
not at all easy. I would venture to guess that few Python programs even
try to do that.


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


[issue29887] test_normalization doesn't work

2017-03-30 Thread Benjamin Peterson

Benjamin Peterson added the comment:

We should change the tests to fail if they get a 404.

--

___
Python tracker 

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



<    1   2