[issue23556] Scope for raise without argument is different in Python 2 and 3

2015-12-23 Thread John Mark Vandenberg

John Mark Vandenberg added the comment:

In pyflakes we've looked at some of the strange scenarios where a raise without 
argument is 'legal'.  A patch to report errors for some of these was rejected 
because they are legal. See https://github.com/pyflakes/pyflakes/pull/57  The 
worst example of 'legal' is an exception in one module can be re-raised by 
another module.

--
nosy: +jayvdb

___
Python tracker 

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



[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

2015-12-23 Thread Steve Dower

Steve Dower added the comment:

Did we want a deprecation warning too? I don't see it in the patch.

Otherwise, LGTM.

--

___
Python tracker 

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



[issue25381] Doc: Use of old description of raise in Python3

2015-12-23 Thread John Mark Vandenberg

Changes by John Mark Vandenberg :


--
nosy: +jayvdb

___
Python tracker 

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



[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

2015-12-23 Thread Eryk Sun

Eryk Sun added the comment:

Considering there's no plan to implement bytes paths for scandir on Windows, 
then the following line in the os docs needs to be modified: "All functions 
accepting path or file names accept both bytes and string objects, and result 
in an object of the same type, if a path or file name is returned." It should 
be changed to acknowledge that some functions on Windows do not support bytes 
paths, and that existing support is deprecated and may be removed in a future 
release.

Also, the docs for listdir should warn that using bytes returns invalid results 
on Windows when filenames contain characters that aren't mapped in the system 
locale codepage.

--

___
Python tracker 

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



[issue25410] Clean up and fix OrderedDict

2015-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

And even simpler example: list(od.keys()) is [1, 3] in 3.4 and [0, 1, 2, 3, 4] 
in 3.5.

--

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread Stefan Krah

Changes by Stefan Krah :


--
nosy: +steven.daprano

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread Stefan Krah

Stefan Krah added the comment:

I guess there's some version mixup here:  From Python 3.3 on
the integrated C version of decimal does not store the digits
as a string and does not have the private _int method.

--
nosy: +skrah

___
Python tracker 

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



[issue25932] Windows installer ships an outdated and insecure curl.exe

2015-12-23 Thread Ismail Donmez

New submission from Ismail Donmez:

Installed Python 3.5.1 windows x64 version and ended up having

C:\Users\ismail\AppData\Local\Programs\Python\Python35\curl.exe

which is outdated:

C:\Users\ismail>C:\Users\ismail\AppData\Local\Programs\Python\Python35\curl.exe 
-V
curl 7.37.0 (Windows) libcurl/7.37.0 OpenSSL/1.0.2d zlib/1.2.8
Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp smtp 
smtps telnet tftp
Features: NTLM SSL libz

That is released in May 2014!

Also its insecure:

C:\Users\ismail>C:\Users\ismail\AppData\Local\Programs\Python\Python35\curl.exe 
- "https://www.g
oogle.com"
* Rebuilt URL to: https://www.google.com/
* timeout on name lookup is not supported
* Hostname was NOT found in DNS cache
*   Trying 173.194.32.177...
* Connected to www.google.com (173.194.32.177) port 443 (#0)
* libcurl is now using a weak random seed!
[...]

I would be happy if you don't ship curl at all, or at least use a secure, 
up-to-date version from https://bintray.com/vszakats/generic/curl/view

--
components: Windows
messages: 256918
nosy: donmez, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Windows installer ships an outdated and insecure curl.exe
versions: Python 3.5

___
Python tracker 

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



[issue25864] collections.abc.Mapping should include a __reversed__ that raises TypeError

2015-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I agree that by default calling reversed() on mapping should raise a TypeError. 
But for now issubclass(collections.abc.Mapping, typing.Reversible) returns 
False. If add default __reversed__ implementation this test will return True. 
We have to find other way to make Mapping true non-reversible in all meanings.

Perhaps there is a bug in typing.Reversible. It doesn't accept all types 
supported by reversed().

>>> class Counter(int):
...   def __getitem__(s, i): return i
...   def __len__(s): return s
... 
>>> list(reversed(Counter(10)))
[9, 8, 7, 6, 5, 4, 3, 2, 1, 0]
>>> issubclass(Counter, typing.Reversible)
False

And accepts types that don't work with reversed().

>>> class L(list):
...__reversed__ = None
... 
>>> reversed(L())
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'NoneType' object is not callable
>>> issubclass(L, typing.Reversible)
True

--
nosy: +gvanrossum, serhiy.storchaka

___
Python tracker 

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



[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-12-23 Thread Thomas Petazzoni

Thomas Petazzoni added the comment:

I can confirm that I'm affected by the same issue. Booting a simple Linux 
system on a Qemu ARM platform, the python startup hangs during 25 seconds due 
to the call to getrandom(). I am not doing anything with Python, just starting 
the Python interpreter:

# strace -t -o strace.log python
random: nonblocking pool is initialized
Python 3.5.0 (default, Dec 23 2015, 15:11:18) 
[GCC 5.1.1 20150608] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>  
# grep -A 2 getrandom strace.log 
14:43:50 
getrandom("\245\362a=\305\32Z\263\364\352j\223\0017\302q\361M\336+\2722>[", 24, 
0) = 24
14:44:35 ioctl(0, TCGETS, {B38400 opost isig icanon echo ...}) = 0
14:44:35 mmap2(NULL, 262144, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, 
-1, 0) = 0x76baf000

As you can see, 25 seconds blocked due to the getrandom() system call. Makes 
the Python interpreter not really usable anymore. I would understand if Python 
would do when I need to generate cryptographically secure random numbers. But 
at this point, I am just starting the interpreter, nothing else.

This is a regression from Python 3.4.3.

--
nosy: +thomas-petazzoni

___
Python tracker 

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



[issue25157] Installing Python 3.5.0 32bit on Windows 8.1 64bit system gives Error 0x80240017

2015-12-23 Thread Joakim Karlsson

Joakim Karlsson added the comment:

I got this working on a Windows 8.1 box with the following mess. Hopefully 
someone more capable than me can piece together a viable fix from this.

I downloaded and executed the Visual C++ Redistributable for VS 2015 here: 
https://www.microsoft.com/en-us/download/details.aspx?id=48145

I then watched that installation fail with the same error as in the python 
installer.

>From the steps described here: http://stackoverflow.com/a/31536998

1. Copy the file "C:\ProgramData\Package 
Cache\FC6260C33678BB17FB8B88536C476B4015B7C5E9\packages\Patch\x64\Windows8.1-KB2999226-x64.msu"
 to c:\temp\

(Note: the guid in the path above is not the same as in the stack overflow 
answer. It seems it may vary)

2. From an elevated (important!) command prompt:

>cd c:\temp
>mkdir extracted
>wusa.exe Windows8.1-KB2999226-x64.msu /extract:extracted

(Make sure files are extracted to the new dir)

>dism.exe /Online /Add-Package 
>/PackagePath:extracted\Windows8.1-KB2999226-x64.cab

3. Run vc_redist.x64.exe again, and choose repair

4. Now, I could finally install Python (3.5.1)

--
nosy: +Joakim.Karlsson

___
Python tracker 

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



[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

2015-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

There is open issue16700 for the documentation.

--

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

May be implement the as_integer_ratio() method and/or numerator and denominator 
attributes in the Decimal class?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue24726] OrderedDict has strange behaviour when dict.__setitem__ is used.

2015-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch that fixes an infinite loop reported in msg254071. May be this 
is not the best solution. It makes the behavior of Python and C implementation 
differ (the former just iterates a linked list, the latter raises an error). 
But to reproduce Python implementation behavior we need to add refcounters to 
linked list nodes.

--
stage: commit review -> patch review
Added file: http://bugs.python.org/file41398/odict_delitem_iter_hung.patch

___
Python tracker 

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



[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-12-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
assignee:  -> rhettinger

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread Stefan Krah

Changes by Stefan Krah :


--
versions:  -Python 3.5

___
Python tracker 

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



[issue12484] The Py_InitModule functions no longer exist, but remain in the docs

2015-12-23 Thread Anish Shah

Anish Shah added the comment:

Can anyone review the patch?

--

___
Python tracker 

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



[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-12-23 Thread Thomas Petazzoni

Thomas Petazzoni added the comment:

Obviously I did my math wrong: it waits 45 seconds in getrandom(), not 25 
seconds. See my strace log.

--

___
Python tracker 

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



[issue25932] Windows installer ships an outdated and insecure curl.exe

2015-12-23 Thread Zachary Ware

Zachary Ware added the comment:

I have no idea how you got a curl.exe there, but it didn't come from our 
installer.  Where did you get your 3.5.1 installer from?

--
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



[issue25410] Clean up and fix OrderedDict

2015-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Following code prints X([(1, 1), (3, 3)]) on 3.4 and X([(0, 0), (1, 1), (2, 2), 
(3, 3), (4, 4)]) on 3.5+.

from collections import OrderedDict
class X(OrderedDict):
def __iter__(self):
for k in OrderedDict.__iter__(self):
if k % 2:
yield k

od = X((i, i) for i in range(5))
print(od.copy())

--

___
Python tracker 

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



[issue25920] PyOS_AfterFork should reset socketmodule's lock

2015-12-23 Thread Ronald Oussoren

Ronald Oussoren added the comment:

#25924 is related to this, I filed this after reading the blog post. The lock 
might not be necessary on OSX, and possibly on the other systems as well.


Yury: resetting the lock in the child should be safe because after the fork the 
child only has a single thread that is returning from fork(2). The thread that 
acquired the lock does not exist in the child process.

--
nosy: +ronaldoussoren

___
Python tracker 

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



[issue25157] Installing Python 3.5.0 32bit on Windows 8.1 64bit system gives Error 0x80240017

2015-12-23 Thread Joakim Karlsson

Joakim Karlsson added the comment:

My previous fix works for me when I install for current user only. When I 
attempt to install for all users, I get an error stating that 
"api-ms-win-crt-runtime-I1-1-0.dll" is missing during the "Precompililng 
standard library" phase.

--

___
Python tracker 

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



[issue25157] Installing Python 3.5.0 32bit on Windows 8.1 64bit system gives Error 0x80240017

2015-12-23 Thread Joakim Karlsson

Joakim Karlsson added the comment:

...and I seem not to have a working installation even when installing for a 
single user. The installation completes without complaining, but running python 
ends up in an error message telling me that "api-ms-win-crt-heap-l1-1-0.dll" is 
missing.

--

___
Python tracker 

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



[issue25932] Windows installer ships an outdated and insecure curl.exe

2015-12-23 Thread Ismail Donmez

Ismail Donmez added the comment:

Indeed, I am sorry! It was pycurl.

--

___
Python tracker 

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



[issue19475] Add timespec optional flag to datetime isoformat() to choose the precision

2015-12-23 Thread Skip Montanaro

Changes by Skip Montanaro :


--
nosy:  -skip.montanaro

___
Python tracker 

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



[issue25933] Unhandled exception (TypeError) with ftplib in function retrbinary/retrlines causes inoperable behavior without crashing

2015-12-23 Thread Sam Adams

New submission from Sam Adams:

Hello,

I believe that I found a bug in ftplib.py in version 3.3.6.

Whenever a user opens a file for writing in nonbinary mode and then proceeds to 
call the retrbinary function, or opens the file in binary mode and proceeds to 
call the retrlines fuction, then attempts to write to the file using the 
callback function, an unhandled TypeError exception is raised that does not 
cause the program to crash, but rather cause the last message from the server 
to not be "read" by the readline() function, thus causing cascading errors 
until the function readline() is called on its own or the connection with the 
server is reset.

Code to replicate:
from ftplib import FTP
ftp = FTP('your.server.here')
ftp.login()
fileTest = open('filename','w') < not binary
ftp.retrbinary('retr randomfilehere',fileTest.write)

Unhandled exception raised: 

File "/usr/local/lib/python3.3/ftplib.py", line 434, in retrbinary
callback(data)
TypeError: must be str, not bytes

Likewise, if 

ftp.retrlines('retr randomfilehere', fileTest.write) 

is called when fileTest is opened for writing with binary option the following 
error is raised:

File "/usr/local/lib/python3.3/ftplib.py", line 464, in retrlines
callback(line)
TypeError: 'str' does not support the buffer interface

Calling ftp.getline() clears the error and resumes normal operation


Possible Solution:

add exception handling in lines 434/464 for TypeError

--
components: Library (Lib)
messages: 256927
nosy: Sam Adams
priority: normal
severity: normal
status: open
title: Unhandled exception (TypeError) with ftplib in function 
retrbinary/retrlines causes inoperable behavior without crashing
versions: Python 3.3

___
Python tracker 

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



[issue25933] Unhandled exception (TypeError) with ftplib in function retrbinary/retrlines causes inoperable behavior without crashing

2015-12-23 Thread Sam Adams

Sam Adams added the comment:

I don't have access to 3.5 where I am now. I can try later on, but it appears 
after a quick glance that the code for this function between 3.3 and 3.5 is the 
same for calling the callback function.

--

___
Python tracker 

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



[issue25933] Unhandled exception (TypeError) with ftplib in function retrbinary/retrlines causes inoperable behavior without crashing

2015-12-23 Thread SilentGhost

SilentGhost added the comment:

With the default branch I get regular TypeError exception, without any extras. 
To me it seems that its responsibility of the caller to provide the correct 
callback for the type of data being retrieved. So, I'm not exactly sure that 
this is a bug at all.

--
nosy: +SilentGhost
versions: +Python 3.5, Python 3.6 -Python 3.3

___
Python tracker 

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



[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-12-23 Thread STINNER Victor

STINNER Victor added the comment:

getrandom() is used to initialize the randomized hash function. Set
PYTHONHASHSEED env var to not use getrandom() at startup. But the hash
function will not randomized anymore :-/

--

___
Python tracker 

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



[issue1753718] base64 "legacy" functions violate RFC 3548

2015-12-23 Thread R. David Murray

R. David Murray added the comment:

Thanks everyone.

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



[issue20782] base64 module docs do not use the terms 'bytes' and 'string' consistently.

2015-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 105bf5dd93b8 by R David Murray in branch '3.5':
#1753718: clarify RFC compliance and bytes/string argument types.
https://hg.python.org/cpython/rev/105bf5dd93b8

--
nosy: +python-dev

___
Python tracker 

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



[issue1753718] base64 "legacy" functions violate RFC 3548

2015-12-23 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 105bf5dd93b8 by R David Murray in branch '3.5':
#1753718: clarify RFC compliance and bytes/string argument types.
https://hg.python.org/cpython/rev/105bf5dd93b8

New changeset 92760d2edc9e by R David Murray in branch 'default':
Merge: #1753718: clarify RFC compliance and bytes/string argument types.
https://hg.python.org/cpython/rev/92760d2edc9e

--
nosy: +python-dev

___
Python tracker 

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



[issue25933] Unhandled exception (TypeError) with ftplib in function retrbinary/retrlines causes inoperable behavior without crashing

2015-12-23 Thread Sam Adams

Sam Adams added the comment:

Silent: The issue that i see is how the error is handled. I can trap the 
TypeError easily, however, if I keep the socket open, the behavior of ftplib 
will not be as intended. For example:

fileTest = open('filename1', 'wb')

ftp.retrlines('RETR README.html', fileTest.write)

This will give a TypeError, as intended

However, what happens next is, I believe, not intended --

If i send a command after this trapped error, say, ftp.sendcmd('NOOP')

The result will not be 
200 NOOP command successful

but, instead,

226 Transfer Complete

As the previous status was not read from the file created by the socket, so if 
i want to try and do anything for the user after, the message received, and 
subsequently parsed by the getresp function, will not be the message that is 
expected.

For a noop command this is ok, but for a transfer command, it will set the mode 
to either A or I and return a 200 status when a different status was expected. 
This will raise an error. 

The only way to fix this is to either run the internal function getline() or 
reset the connection, thus clearing all messages from the file.

I have attached a file that has a fix, Im not sure if this is helpful or not.

I modified the retrbinary function on lines:
440,449-450,454-455

I also modified the retrlines function on lines:
470,490-491,496-497

--
Added file: http://bugs.python.org/file41400/ftplib.py

___
Python tracker 

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



[issue20782] base64 module docs do not use the terms 'bytes' and 'string' consistently.

2015-12-23 Thread R. David Murray

R. David Murray added the comment:

Everything here should be covered by the fix committed for #1753718.  If I 
missed anything let me know :)

--
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



[issue25936] Improve FastChildWatcher with WNOWAIT?

2015-12-23 Thread WGH

New submission from WGH:

The problem with FastChildWatcher lies in the fact that it can accidentally 
reap processes that it doesn't watch.

However, os module includes waitid function (since Python 3.3), and it has 
WNOWAIT flags, which means "return status, let process remain waitable (=don't 
reap)".

What do you think, can this feature fix the problem with FastChildWatcher?

--
components: asyncio
messages: 256946
nosy: WGH, gvanrossum, haypo, yselivanov
priority: normal
severity: normal
status: open
title: Improve FastChildWatcher with WNOWAIT?

___
Python tracker 

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



[issue25937] DIfference between utf8 and utf-8 when i define python source code encoding.

2015-12-23 Thread 王杰

New submission from 王杰:

I use CentOS 7.0 and change LANG=gbk.

I has a file "gbk-utf-8.py" and it's encoding is GBK.

# -*- coding:utf-8 -*-
import chardet
if __name__ == '__main__':
s = '中文'
print s, chardet.detect(s) 

I execute it and everything is ok. However it raise "SyntaxError" (as I 
expected) after I change "encoding:utf-8" to "encoding:utf8".

  File "gbk-utf8.py", line 2
SyntaxError: 'utf8' codec can't decode byte 0xd6 in position 0: invalid 
continuation byte

Is this ok? Or where I wrong?

--
messages: 256952
nosy: 王杰
priority: normal
severity: normal
status: open
title: DIfference between utf8 and utf-8 when i define python source code 
encoding.

___
Python tracker 

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



[issue25933] Unhandled exception (TypeError) with ftplib in function retrbinary/retrlines causes inoperable behavior without crashing

2015-12-23 Thread Sam Adams

Changes by Sam Adams :


--
type:  -> behavior

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread John Walker

John Walker added the comment:

> I guess there's some version mixup here:  From Python 3.3 on
> the integrated C version of decimal does not store the digits
> as a string and does not have the private _int method.

Stefan, _int is a slot in Lib/_pydecimal.py. It should be defined on python 3.5 
and tip, unsure about other versions.

Python 3.5.1 (default, Dec  7 2015, 12:58:09) 
[GCC 5.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from decimal import Decimal
>>> Decimal("100.00")
Decimal('100.00')
>>> Decimal("100.00")._int
'1'

--
versions: +Python 3.5

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread Stefan Krah

Stefan Krah added the comment:

On Wed, Dec 23, 2015 at 09:01:22PM +, John Walker wrote:
> Stefan, _int is a slot in Lib/_pydecimal.py. It should be defined on python 
> 3.5 and tip, unsure about other versions.
> 
> Python 3.5.1 (default, Dec  7 2015, 12:58:09) 
> [GCC 5.2.0] on linux
> Type "help", "copyright", "credits" or "license" for more information.
> >>> from decimal import Decimal
> >>> Decimal("100.00")
> Decimal('100.00')
> >>> Decimal("100.00")._int
> '1'

That should only happen if the C version did not build for some reason:

Python 3.6.0a0 (default:323c10701e5d, Dec 14 2015, 14:28:41) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from decimal import Decimal
>>> Decimal("100.00")._int
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'decimal.Decimal' object has no attribute '_int'
>>>

--

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread John Walker

John Walker added the comment:

> No, the regular build uses the libmpdec that is shipped with
> Python.  The external libmpdec.so only comes into play if you
> compile --with-system-libmpdec.

Oh, OK. I see whats happening. My distro deletes the shipped version and 
compiles --with-system-libmpdec. We're on the same page now, thanks.

https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/python

--

___
Python tracker 

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



[issue12484] The Py_InitModule functions no longer exist, but remain in the docs

2015-12-23 Thread Berker Peksag

Berker Peksag added the comment:

The patch looks good to me.

_PyImport_FixupExtension does not exist in Python 3, but it's still documented 
in Doc/c-api/import.rst. We need to remove it, too.

(Or we could document _PyImport_FixupExtensionObject since there are already 
documented internal functions in that file.)

--
nosy: +berker.peksag, brett.cannon
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



[issue25928] Add Decimal.as_integer_ratio()

2015-12-23 Thread Stefan Krah

Stefan Krah added the comment:

Let's re-target this issue:

Implementing as_integer_ratio() sounds reasonable, but let's hope
people won't try to convert Decimal('1E+99').


Mark, was there perhaps a reason not to add the method?

--
assignee:  -> skrah
nosy: +mark.dickinson
title: Improve performance of statistics._decimal_to_ratio and 
fractions.from_decimal -> Add Decimal.as_integer_ratio()

___
Python tracker 

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



[issue24999] ICC compiler: ICC treats denormal floating point numbers as 0.0

2015-12-23 Thread Stefan Krah

Stefan Krah added the comment:

The current issue description should have been fixed by #25827.
Is the segfault in test_re still happening?

--

___
Python tracker 

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



[issue25934] ICC compiler: ICC treats denormal floating point numbers as 0.0

2015-12-23 Thread Stefan Krah

New submission from Stefan Krah:

Zachary in #24999:

"If that's the case, would anyone (in particular, Steve, Tim or Tim) mind if we 
just made the default (for MSVC as well as ICC) /fp:strict?  It would be much 
easier to just change the global default than to try to either make it settable 
or to change it just when ICC is used."

--
messages: 256943
nosy: haypo, mark.dickinson, paul.moore, pitrou, python-dev, r.david.murray, 
serhiy.storchaka, skrah, steve.dower, tim.golden, tim.peters, zach.ware
priority: normal
severity: normal
status: open
title: ICC compiler: ICC treats denormal floating point numbers as 0.0

___
Python tracker 

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



[issue25935] OrderedDict prevents garbage collection if a circulary referenced class is used as key

2015-12-23 Thread Simon Charette

New submission from Simon Charette:

I attached a file with a reproduction test case that passes on Python 2.7 and 
3.4 but fails on 3.5.0 and 3.5.1

This might be solved by the improvement planed in #25410.

--
components: Extension Modules
files: test.py
messages: 256945
nosy: charettes
priority: normal
severity: normal
status: open
title: OrderedDict prevents garbage collection if a circulary referenced class 
is used as key
type: behavior
versions: Python 3.5
Added file: http://bugs.python.org/file41399/test.py

___
Python tracker 

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



[issue25157] Installing Python 3.5.0 32bit on Windows 8.1 64bit system gives Error 0x80240017

2015-12-23 Thread Steve Dower

Steve Dower added the comment:

Joakim, your operating system is corrupted somehow. I'd suggest getting in 
touch with Microsoft support, as you should be able to install that update. (Or 
maybe you've done something to block Windows Update?)

--

___
Python tracker 

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



[issue24999] Segfault in test_re.test_sre_character_class_literals() when Python is compiled by ICC

2015-12-23 Thread Stefan Krah

Changes by Stefan Krah :


--
title: ICC compiler: ICC treats denormal floating point numbers as 0.0 -> 
Segfault in test_re.test_sre_character_class_literals() when Python is compiled 
by ICC

___
Python tracker 

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



[issue25933] Unhandled exception (TypeError) with ftplib in function retrbinary/retrlines causes inoperable behavior without crashing

2015-12-23 Thread R. David Murray

R. David Murray added the comment:

Can you test this against 3.5?  I guessing it hasn't been fixed, but we did do 
some bytes/string fixes since 3.3, so it might have been.

--
nosy: +r.david.murray

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread Stefan Krah

Stefan Krah added the comment:

No, the regular build uses the libmpdec that is shipped with
Python.  The external libmpdec.so only comes into play if you
compile --with-system-libmpdec.

--

___
Python tracker 

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



[issue24999] Segfault in test_re.test_sre_character_class_literals() when Python is compiled by ICC

2015-12-23 Thread Zachary Ware

Zachary Ware added the comment:

Unfortunately, #25827 has no effect on Windows, which is where this issue 
occurs.  There are still several segfaults on Windows, including test_re.

--

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread John Walker

John Walker added the comment:

> That should only happen if the C version did not build for some reason:

Ahh, gotcha. I assume one instance where this happens is when the machine 
doesn't have libmpdec.so

--

___
Python tracker 

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



[issue25928] Improve performance of statistics._decimal_to_ratio and fractions.from_decimal

2015-12-23 Thread Steven D'Aprano

Steven D'Aprano added the comment:

On Wed, Dec 23, 2015 at 03:18:28PM +, Serhiy Storchaka wrote:
> May be implement the as_integer_ratio() method and/or numerator and 
> denominator attributes in the Decimal class?

That would also be good as it will decrease the API differences between 
floats and Decimals and make it easier to duck-type one for the other.

--

___
Python tracker 

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



[issue24999] Segfault in test_re.test_sre_character_class_literals() when Python is compiled by ICC

2015-12-23 Thread Stefan Krah

Stefan Krah added the comment:

I see, thanks.  I've opened #25934 to keep the issues separate.

--

___
Python tracker 

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



[issue1753718] base64 "legacy" functions violate RFC 3548

2015-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

While we are here, may be update docstrings too?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue25938] if sentence doesn't work with input()

2015-12-23 Thread Benjamin Peterson

Benjamin Peterson added the comment:

In Python 2, input() is basically equivalent to eval(raw_input()). In Python 3, 
input() is the same as raw_input() in Python 2. This explains the difference.

--
nosy: +benjamin.peterson
resolution:  -> not a bug
status: open -> closed

___
Python tracker 

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



[issue25938] if sentence doesn't work with input()

2015-12-23 Thread Kozo Oeda

New submission from Kozo Oeda:

if sentence doesn't work well with input() in Python 3(I confirmed 3.4.3 and 
3.5.1 on OS X 10.10.5). I also confirmed Python 2.7.11 works well. I think the 
code which I wrote in the lower section explains what happened enough. 

I couldn't get the proper component so I selected Interpreter Core temporally.
Thanks 

#Code Start=
#Python 3.4.3 and 3.5.1 on OS X 10.10.5

def test(a):
if a == 0:
print("0")
else:
print("not 0")

a = input()
print(a)
test(a)

# Input 
# 0 
#
# Output
# 0
# 0
# not 0

# Input
# 1
#
# Output
# 1
# 1
# not 0
#Code End=

--
components: Interpreter Core
messages: 256954
nosy: kozmof
priority: normal
severity: normal
status: open
title: if sentence doesn't work with input()
versions: Python 3.5

___
Python tracker 

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



[issue20440] Use the Py_SETREF macro

2015-12-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
title: Use Py_REPLACE/Py_XREPLACE macros -> Use the Py_SETREF macro

___
Python tracker 

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



[issue25934] ICC compiler: ICC treats denormal floating point numbers as 0.0

2015-12-23 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Build, Windows
type:  -> crash
versions: +Python 3.5, Python 3.6

___
Python tracker 

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



[issue15068] fileinput requires two EOF when reading stdin

2015-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> It's more a question of whether the entire change is appropriate for 2.7.

What is your answer? To me there is a bug and we can fix it.

--

___
Python tracker 

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



[issue25919] htp.client PUT method ignores error responses sent immediatly after headers

2015-12-23 Thread SilentGhost

SilentGhost added the comment:

All the tests pass now, not sure why your patch doesn't get associated rietveld 
link, it applies cleanly using hg patch --no-commit

--

___
Python tracker 

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



[issue25860] os.fwalk() silently skips remaining directories when error occurs

2015-12-23 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



[issue25911] Regression: os.walk now using os.scandir() breaks bytes filenames on windows

2015-12-23 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch that restores the ability of os.walk() to work with bytes 
filenames on Windows.

--
keywords: +patch
stage: test needed -> patch review
Added file: http://bugs.python.org/file41397/walks_bytes.patch

___
Python tracker 

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