[issue13322] buffered read() and write() does not raise BlockingIOError

2016-10-16 Thread Petri Lehtinen

Changes by Petri Lehtinen :


--
nosy:  -petri.lehtinen

___
Python tracker 

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



[issue28447] socket.getpeername() failure on broken TCP/IP connection

2016-10-16 Thread Martin Panter

Martin Panter added the comment:

So is your “automatic closing” due to your program, or a bug in Python? You 
will have to give more information if you want anyone else to look at this. 
When I run the code you posted (with various modules imported) all I get is

NameError: name 'yellow_page' is not defined

--

___
Python tracker 

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



[issue28447] socket.getpeername() failure on broken TCP/IP connection

2016-10-16 Thread Georgey

Georgey added the comment:

Yes that is definitely a closed socket. But it is strange that in a single 
thread server without select module, the socket is never closed until I 
explicitly use close() method. 


except:
  print(sock)  #<- here it looks normal
  time.sleep(3)
  print(sock)  #<- here it still looks normal 
  sock.close()
  print(sock)  #<- finally the [closed] tag appears and all the details lost


So I guess the "Socket Automatically Closing" effect associate with "select" 
module? For when I run the single-thread server in the IDLE and called 
time.sleep(), it has been already treated as multi-thread.

--

___
Python tracker 

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



[issue21720] "TypeError: Item in ``from list'' not a string" message

2016-10-16 Thread Nick Coghlan

Nick Coghlan added the comment:

@Berker: the warning under "-bb" is a separate issue related to the handling of 
wildcard imports (_handle_fromlist searches for '*' and then pops it from a 
copy of the input list, replacing it with __all__ if that's defined)

@Ben: As a general principle, we don't give value information in type errors, 
since the error is structural rather than value based. The closest equivalent 
to us doing that that I'm aware of is the sequence index being given in 
str.join's TypeError:

>>> "".join(["a", "b", b"c"])
Traceback (most recent call last):
  File "", line 1, in 
TypeError: sequence item 2: expected str instance, bytes found

By contrast, when sorting, we don't give *any* indication as to where in the 
sequence the problem was found or the specific values involved:

>>> sorted(["a", "b", b"c"])
Traceback (most recent call last):
  File "", line 1, in 
TypeError: unorderable types: bytes() < str()

That doesn't make it a bad idea (as I think you're right that it would often 
make debugging easier), I'd just prefer to consider that as a separate question 
rather than introducing a one-off inconsistency with the general policy here 
(in particular, encountering TypeError is far more likely with str.join and 
sorted than it is with __import__, so it would be genuinely weird for the 
latter to have the most helpful error message).

--

___
Python tracker 

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



[issue28455] argparse: convert_arg_line_to_args does not actually expect self argument

2016-10-16 Thread Berker Peksag

Berker Peksag added the comment:

Thanks! I removed the import statement and simplified the last sentence a bit.

--
nosy: +berker.peksag
resolution:  -> fixed
stage:  -> resolved
status: open -> closed
versions: +Python 3.5, Python 3.6, Python 3.7 -Python 3.4

___
Python tracker 

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



[issue28455] argparse: convert_arg_line_to_args does not actually expect self argument

2016-10-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 4f8f7403881f by Berker Peksag in branch '3.5':
Issue #28455: Clarify example of overriding the convert_arg_line_to_args method
https://hg.python.org/cpython/rev/4f8f7403881f

New changeset 0b29adb5c804 by Berker Peksag in branch '3.6':
Issue #28455: Merge from 3.5
https://hg.python.org/cpython/rev/0b29adb5c804

New changeset a293e5db9083 by Berker Peksag in branch 'default':
Issue #28455: Merge from 3.6
https://hg.python.org/cpython/rev/a293e5db9083

--
nosy: +python-dev

___
Python tracker 

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



Re: Build desktop application using django

2016-10-16 Thread Mario R. Osorio
On Sunday, October 16, 2016 at 1:42:23 PM UTC-4, Ayush Saluja wrote:
> Hello I want to build a desktop application which retrieves data from server 
> and stores data on server. I have basic experience of python and I dont know 
> how to build that thing.

I agree with Martin's suspicion on you having no idea of what the F you are 
talking about. Nevertheless, I'm throwing in my 2 cents:

http://dabodev.com/
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28455] argparse: convert_arg_line_to_args does not actually expect self argument

2016-10-16 Thread Mariatta Wijaya

Mariatta Wijaya added the comment:

Hello,

I updated the documentation with an example of how to override ArgumentParser 
class. Hope this is a clearer than before.

Please review.

Thanks :)

--
keywords: +patch
nosy: +Mariatta
Added file: http://bugs.python.org/file45121/issue28455.patch

___
Python tracker 

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



[issue28452] Remove _asyncio._init_module function

2016-10-16 Thread INADA Naoki

Changes by INADA Naoki :


Added file: http://bugs.python.org/file45122/asyncio-speedup-refactoring2.patch

___
Python tracker 

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



[issue14991] Option for regex groupdict() to show only matching names

2016-10-16 Thread Matthew Barnett

Matthew Barnett added the comment:

I'd prefer an explicit suppression to changing a long-standing behaviour.

--

___
Python tracker 

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



Re: Term frequency using scikit-learn's CountVectorizer

2016-10-16 Thread MRAB

On 2016-10-17 02:04, Abdul Abdul wrote:

I have the following code snippet where I'm trying to list the term 
frequencies, where first_text and second_text are .tex documents:

from sklearn.feature_extraction.text import CountVectorizer
training_documents = (first_text, second_text)
vectorizer = CountVectorizer()
vectorizer.fit_transform(training_documents)
print "Vocabulary:", vectorizer.vocabulary
When I run the script, I get the following:

File "test.py", line 19, in 
vectorizer.fit_transform(training_documents)
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py", 
line 817, in fit_transform
self.fixed_vocabulary_)
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py", 
line 752, in _count_vocab
for feature in analyze(doc):
  File "/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py", 
line 238, in 
tokenize(preprocess(self.decode(doc))), stop_words)
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py", 
line 115, in decode
doc = doc.decode(self.encoding, self.decode_error)
  File 
"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py",
 line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa2 in position 200086: 
invalid start byte
How can I fix this issue?


I've had a quick look at the docs here:

http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html#sklearn.feature_extraction.text.CountVectorizer

and I think you need to tell it what encoding the text actually uses. By 
default CountVectorizer assumes the text uses UTF-8, but, clearly, your 
text uses a different encoding.


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


Term frequency using scikit-learn's CountVectorizer

2016-10-16 Thread Abdul Abdul
Hello,

I have the following code snippet where I'm trying to list the term
frequencies, where first_textand second_text are .tex documents:

from sklearn.feature_extraction.text import CountVectorizer
training_documents = (first_text, second_text)
vectorizer = CountVectorizer()
vectorizer.fit_transform(training_documents)print "Vocabulary:",
vectorizer.vocabulary

When I run the script, I get the following:

File "test.py", line 19, in 
vectorizer.fit_transform(training_documents)
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py",
line 817, in fit_transform
self.fixed_vocabulary_)
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py",
line 752, in _count_vocab
for feature in analyze(doc):
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py",
line 238, in 
tokenize(preprocess(self.decode(doc))), stop_words)
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py",
line 115, in decode
doc = doc.decode(self.encoding, self.decode_error)
  File 
"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py",
line 16, in decode
return codecs.utf_8_decode(input, errors, True)UnicodeDecodeError:
'utf8' codec can't decode byte 0xa2 in position 200086: invalid start
byte

How can I fix this issue?

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


Term frequency using scikit-learn's CountVectorizer

2016-10-16 Thread Abdul Abdul
I have the following code snippet where I'm trying to list the term 
frequencies, where first_text and second_text are .tex documents:

from sklearn.feature_extraction.text import CountVectorizer
training_documents = (first_text, second_text)  
vectorizer = CountVectorizer()
vectorizer.fit_transform(training_documents)
print "Vocabulary:", vectorizer.vocabulary 
When I run the script, I get the following:

File "test.py", line 19, in 
vectorizer.fit_transform(training_documents)
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py", 
line 817, in fit_transform
self.fixed_vocabulary_)
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py", 
line 752, in _count_vocab
for feature in analyze(doc):
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py", 
line 238, in 
tokenize(preprocess(self.decode(doc))), stop_words)
  File 
"/usr/local/lib/python2.7/site-packages/sklearn/feature_extraction/text.py", 
line 115, in decode
doc = doc.decode(self.encoding, self.decode_error)
  File 
"/usr/local/Cellar/python/2.7.11/Frameworks/Python.framework/Versions/2.7/lib/python2.7/encodings/utf_8.py",
 line 16, in decode
return codecs.utf_8_decode(input, errors, True)
UnicodeDecodeError: 'utf8' codec can't decode byte 0xa2 in position 200086: 
invalid start byte
How can I fix this issue?

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


[issue14991] Option for regex groupdict() to show only matching names

2016-10-16 Thread Ned Deily

Ned Deily added the comment:

How do others feel about Serhiy's proposal for eventually changing the 
semantics of groupdict() to mean only return matched groups?  If that seems 
reasonable, then there is the separate question of how to make the transition.  
Adding a somewhat unpredictable FutureWarning, i.e. one that depends on the 
input, seems somewhat risky and user-unfriendly at this late stage of the 
release cycle.  But I'm open to persuasion.

--

___
Python tracker 

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



[issue28457] Make public the current private known hash functions in the C-API

2016-10-16 Thread Raymond Hettinger

New submission from Raymond Hettinger:

The known-hash variants for dict getitem/setitem/delitem have proven useful to 
us for writing fast C code.  They may be useful to others as well.  There does 
not seem to be any other way of getting to this functionality.

--
components: Interpreter Core
messages: 278788
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Make public the current private known hash functions in the C-API
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



[issue28456] Test failures under macOS 10.12 Sierra

2016-10-16 Thread Ned Deily

Ned Deily added the comment:

This is a duplicate of Issue28087.

--

___
Python tracker 

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



[issue28456] Test failures under macOS 10.12 Sierra

2016-10-16 Thread Ned Deily

Changes by Ned Deily :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> macOS 12 poll syscall returns prematurely

___
Python tracker 

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



[issue21720] "TypeError: Item in ``from list'' not a string" message

2016-10-16 Thread Ben Finney

Ben Finney added the comment:

On 16-Oct-2016, Roundup Robot wrote:

> New changeset 7dd0910e8fbf by Berker Peksag in branch '2.7':
> Issue #21720: Improve exception message when the type of fromlist is unicode
> https://hg.python.org/cpython/rev/7dd0910e8fbf

This is an improvement, but it still should IMO show *which* item
caused the error.

Can it state “Item in from list must be str, not {type}: {item!r}”?
That would show the exact item so the reader has a better chance at
finding where it came from.

--

___
Python tracker 

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



[issue28293] Don't completely dump the regex cache when full

2016-10-16 Thread Raymond Hettinger

Changes by Raymond Hettinger :


--
assignee: rhettinger -> serhiy.storchaka

___
Python tracker 

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



[issue21720] "TypeError: Item in ``from list'' not a string" message

2016-10-16 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the reviews! I pushed the patch for 2.7.

Nick, what do you think about the case Serhiy mentioned in msg278515? Should we 
fix it or is issue21720_python3.diff good to go?

--

___
Python tracker 

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



py.test/tox InvocationError

2016-10-16 Thread D.M. Procida
When I run:

   py.test --cov=akestra_utilities --cov=akestra_image_plugin
--cov=chaining --cov=contacts_and_people --cov=housekeeping --cov=links
--cov=news_and_events --cov=vacancies_and_studentships --cov=video
--cov-report=term-missing example tests

it works quite happily.

When I run tox -e coveralls, which runs the same thing, it raises an
InvocationError.

You can see the same error at
.

Any suggestions on what is different in the two cases?

Thanks,

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


[issue28454] Spurious arguments to PyErr_Format in unicodeobject.c

2016-10-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset cbe313cd1b55 by Benjamin Peterson in branch '3.5':
remove extra PyErr_Format arguments (closes #28454)
https://hg.python.org/cpython/rev/cbe313cd1b55

New changeset 738579b25d02 by Benjamin Peterson in branch '3.6':
merge 3.5 (#28454)
https://hg.python.org/cpython/rev/738579b25d02

New changeset b37db216c8e0 by Benjamin Peterson in branch 'default':
merge 3.6 (#28454)
https://hg.python.org/cpython/rev/b37db216c8e0

--
nosy: +python-dev
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



[issue23532] add example of 'first match wins' to regex "|" documentation?

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Regular Expressions
type: behavior -> enhancement
versions: +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



[issue26656] Documentation for re.compile is a bit outdated

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett
type: behavior -> enhancement
versions: +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



[issue26436] Add the regex-dna benchmark

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett

___
Python tracker 

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



[issue28293] Don't completely dump the regex cache when full

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Regular Expressions
nosy: +ezio.melotti, mrabarnett

___
Python tracker 

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



[issue21720] "TypeError: Item in ``from list'' not a string" message

2016-10-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 7dd0910e8fbf by Berker Peksag in branch '2.7':
Issue #21720: Improve exception message when the type of fromlist is unicode
https://hg.python.org/cpython/rev/7dd0910e8fbf

--
nosy: +python-dev

___
Python tracker 

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



[issue28456] Test failures under macOS 10.12 Sierra

2016-10-16 Thread STINNER Victor

STINNER Victor added the comment:

Try to modify pyconfig.h to define HAVE_BROKEN_POLL. It should work around the 
bug.

configure.ac contains a test for HAVE_BROKEN_POLL. We need another test for 
poll() being broken differently.

Note: asyncio doesn't seem to be affect because it probably uses the more 
efficient kqueue by default on OS X.

--

___
Python tracker 

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



[issue28456] Test failures under macOS 10.12 Sierra

2016-10-16 Thread STINNER Victor

STINNER Victor added the comment:

See https://daniel.haxx.se/blog/2016/10/11/poll-on-mac-10-12-is-broken/

C function poll() seems to be broken on Sierra.

--
nosy: +haypo, lukasz.langa, ned.deily, ronaldoussoren

___
Python tracker 

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



[issue28456] Test failures under macOS 10.12 Sierra

2016-10-16 Thread Raymond Hettinger

New submission from Raymond Hettinger:

On a fresh checkout, I'm getting two test failures:

$ ./configure && make
$ ./python.exe -m test.regrtest -v test_asyncore
 [snip]
==
FAIL: test_handle_expt (test.test_asyncore.TestAPI_UseIPv4Poll)
--
Traceback (most recent call last):
  File "/Users/raymond/cleancpython/Lib/test/test_asyncore.py", line 674, in 
test_handle_expt
self.loop_waiting_for_flag(client)
  File "/Users/raymond/cleancpython/Lib/test/test_asyncore.py", line 514, in 
loop_waiting_for_flag
self.fail("flag not set")
AssertionError: flag not set

==
FAIL: test_handle_expt (test.test_asyncore.TestAPI_UseIPv6Poll)
--
Traceback (most recent call last):
  File "/Users/raymond/cleancpython/Lib/test/test_asyncore.py", line 674, in 
test_handle_expt
self.loop_waiting_for_flag(client)
  File "/Users/raymond/cleancpython/Lib/test/test_asyncore.py", line 514, in 
loop_waiting_for_flag
self.fail("flag not set")
AssertionError: flag not set

--
Ran 101 tests in 20.506s

FAILED (failures=2, skipped=6)
test test_asyncore failed
test_asyncore failed

1 test failed:
test_asyncore


$ ./python.exe -m test.regrtest -v test_eintr
  [snip]

==
FAIL: test_poll (__main__.SelectEINTRTest)
--
Traceback (most recent call last):
  File "/Users/raymond/cleancpython/Lib/test/eintrdata/eintr_tester.py", line 
446, in test_poll
self.assertGreaterEqual(dt, self.sleep_time)
AssertionError: 9.176997991744429e-06 not greater than or equal to 0.2

--
Ran 22 tests in 5.288s

FAILED (failures=1, skipped=5)
---

stderr:
---
Traceback (most recent call last):
  File "/Users/raymond/cleancpython/Lib/test/eintrdata/eintr_tester.py", line 
492, in 
test_main()
  File "/Users/raymond/cleancpython/Lib/test/eintrdata/eintr_tester.py", line 
488, in test_main
SelectEINTRTest)
  File "/Users/raymond/cleancpython/Lib/test/support/__init__.py", line 1849, 
in run_unittest
_run_suite(suite)
  File "/Users/raymond/cleancpython/Lib/test/support/__init__.py", line 1824, 
in _run_suite
raise TestFailed(err)
test.support.TestFailed: Traceback (most recent call last):
  File "/Users/raymond/cleancpython/Lib/test/eintrdata/eintr_tester.py", line 
446, in test_poll
self.assertGreaterEqual(dt, self.sleep_time)
AssertionError: 9.176997991744429e-06 not greater than or equal to 0.2
---

--
Ran 1 test in 5.424s

FAILED (failures=1)
test test_eintr failed
test_eintr failed

1 test failed:
test_eintr

Total duration: 5 sec
Tests result: FAILURE

--
components: Interpreter Core
messages: 278780
nosy: rhettinger
priority: normal
severity: normal
status: open
title: Test failures under macOS 10.12 Sierra
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



[issue28432] Fix doc of PyUnicode_EncodeLocale

2016-10-16 Thread Berker Peksag

Berker Peksag added the comment:

Thanks.

--
nosy: +berker.peksag
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

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



[issue28432] Fix doc of PyUnicode_EncodeLocale

2016-10-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset a4889719e3c2 by Berker Peksag in branch '3.5':
Issue #28432: Fix first parameter name in PyUnicode_EncodeLocale documentation
https://hg.python.org/cpython/rev/a4889719e3c2

New changeset 1fc08c283f8f by Berker Peksag in branch '3.6':
Issue #28432: Merge from 3.5
https://hg.python.org/cpython/rev/1fc08c283f8f

New changeset 767a78aacd29 by Berker Peksag in branch 'default':
Issue #28432: Merge from 3.6
https://hg.python.org/cpython/rev/767a78aacd29

--
nosy: +python-dev

___
Python tracker 

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



Re: Writing library documentation?

2016-10-16 Thread Irmen de Jong
On 16-10-2016 19:41, tshep...@rcsreg.com wrote:
> Is there a standard or best way to write documentation for
> a particular python library?  I'd mostly target HTML, I guess.
> 
> Thanks!
> 
> 
> Tobiah
> 

I guess most people use Sphinx for this task
http://www.sphinx-doc.org/

You can use various themes to customize your html output.

Irmen

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


[issue14991] Option for regex groupdict() to show only matching names

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Proposed patch makes groupdict() without argument emitting FutureWarning if the 
result includes unmatched groups. Maybe warning message and the documentation 
could be better.

Ned, I ask your permission for including this change in 3.6. Yes, it can break 
third-party code that ran with -Werror, but I think groupdict() is rarely used 
in comparison of other match object API. The workaround is simple -- just use 
groupdict(None). The earlier we add a warning, the earlier we can change the 
behavior of groupdict(). If we did it in 3.4 (the time Raymond opened this 
issue), we could get new behavior in 3.7.

--
keywords: +patch
nosy: +ned.deily
stage: needs patch -> patch review
Added file: 
http://bugs.python.org/file45120/re_groupdict_no_default_future_warning.patch

___
Python tracker 

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



Re: How make the judge with for loop?

2016-10-16 Thread alister
On Sat, 15 Oct 2016 22:23:29 -0700, 380162267qq wrote:

> c="abcdefghijk"
> len=len(c)
> n is a int sb=[[] for i in range(n)]
> 
> while (i < len) {
> for (int j = 0; j < n && i < len; j++)
> sb[j].append(c[i++]);
> for (int j = n-2; j >= 1 && i < len; j--) //
> sb[j].append(c[i++]);
> }
> 
> How to translate to python? I tried but my python code is really stupid

show your python code,
does it at least get the right results
if so you may get better feed back on how to imporve it

also as other has suggested try detailing the actual problem & working on 
that rather than trying to translate an existing solution 



-- 
Producers seem to be so prejudiced against actors who've had no training.
And there's no reason for it.  So what if I didn't attend the Royal 
Academy
for twelve years?  I'm still a professional trying to be the best actress
I can.  Why doesn't anyone send me the scripts that Faye Dunaway gets?
-- Farrah Fawcett-Majors
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Help me!, I would like to find split where the split sums are close to each other?

2016-10-16 Thread Michael Torrie
On 10/16/2016 05:25 AM, k.adema...@gmail.com wrote:
> Help me!, I would like to find split where the split sums are close
> to each other?
> 
> I have a list is
> 
> test = [10,20,30,40,50,60,70,80,90,100]
> 
> ​and I would like to find split where the split sums are close to
> each other by number of splits = 3 that ​all possible combinations
> and select the split where the sum differences are smallest.
> 
> Please example code or simple code Python.

Ahh, sounds like a homework problem, which we will not answer directly,
if at all.

If you had no computer at all, how would you do this by hand?  Can you
describe the process that would identify how to split the piles of
candies, money, or whatever other representation you might use?  So
forgetting about Python and the specifics of making a valid program, how
would you solve this problem?  What steps would you take? This is known
as an algorithm.  Once you have that figured out, then you can begin to
express the algorithm as a computer program.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Build desktop application using django

2016-10-16 Thread Michael Torrie
On 10/16/2016 11:38 AM, ayuchitsalu...@gmail.com wrote:
> Hello I want to build a desktop application which retrieves data from
> server and stores data on server. I have basic experience of python
> and I dont know how to build that thing.

Crystal balls are always risky things to turn to when trying to decipher
intentions from extremely vague questions. But my crystal ball says you
should read a few Django tutorials and try building a simple web-based
system with a database backend (even SQLite to start with).


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


[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Needed new tests for changed behavior. Test re.sub() with incorrect groups and 
the string that doesn't match the pattern (e.g. empty string).

Added other comments on Rietveld.

--

___
Python tracker 

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



[issue28455] argparse: convert_arg_line_to_args does not actually expect self argument

2016-10-16 Thread R. David Murray

R. David Murray added the comment:

The documentation assumes you know how python class methods work, but I agree 
that the wording is not entirely obvious even then and could be improved.  In 
particular it should make clear that the example shows how to define the 
function for subclassing or assignment to the class object.  If you assign it 
to the instance, as in your example, then indeed self does not get passed and 
you want a true single argument function.

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



Re: How to pick out the same titles.

2016-10-16 Thread duncan smith
On 16/10/16 16:16, Seymore4Head wrote:
> How to pick out the same titles.
> 
> I have a  long text file that has movie titles in it and I would like
> to find dupes.
> 
> The thing is that sometimes I have one called "The Killing Fields" and
> it also could be listed as "Killing Fields"  Sometimes the title will
> have the date a year off.
> 
> What I would like to do it output to another file that show those two
> as a match.
> 
> I don't know the best way to tackle this.  I would think you would
> have to pair the titles with the most consecutive letters in a row.
> 
> Anyone want this as a practice exercise?  I don't really use
> programming enough to remember how.
> 

Tokenize, generate (token) set similarity scores and cluster on
similarity score.


>>> import tokenization
>>> bigrams1 = tokenization.n_grams("The Killing Fields".lower(), 2,
pad=True)
>>> bigrams1
['_t', 'th', 'he', 'e ', ' k', 'ki', 'il', 'll', 'li', 'in', 'ng', 'g ',
' f', 'fi', 'ie', 'el', 'ld', 'ds', 's_']
>>> bigrams2 = tokenization.n_grams("Killing Fields".lower(), 2, pad=True)
>>> import pseudo
>>> pseudo.Jaccard(bigrams1, bigrams2)
0.7


You could probably just generate token sets, then iterate through all
title pairs and manually review those with similarity scores above a
suitable threshold. The code I used above is very simple (and pasted below).


def n_grams(s, n, pad=False):
# n >= 1
# returns a list of n-grams
# or an empty list if n > len(s)
if pad:
s = '_' * (n-1) + s + '_' * (n-1)
return [s[i:i+n] for i in range(len(s)-n+1)]

def Jaccard(tokens1, tokens2):
# returns exact Jaccard
# similarity measure for
# two token sets
tokens1 = set(tokens1)
tokens2 = set(tokens2)
return len(tokens1) / len(tokens1|tokens2)


Duncan


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


Writing library documentation?

2016-10-16 Thread tshepard
Is there a standard or best way to write documentation for
a particular python library?  I'd mostly target HTML, I guess.

Thanks!


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


Build desktop application using django

2016-10-16 Thread ayuchitsaluja8
Hello I want to build a desktop application which retrieves data from server 
and stores data on server. I have basic experience of python and I dont know 
how to build that thing.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27896] Allow passing sphinx options to Doc/Makefile

2016-10-16 Thread STINNER Victor

STINNER Victor added the comment:

I pushed your patch to the default branch (Python 3.7). Thanks Julien.

--
nosy: +haypo
resolution:  -> fixed
status: open -> closed
type:  -> enhancement
versions: +Python 3.7 -Python 3.6

___
Python tracker 

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



[issue28449] tarfile.open(mode = 'r:*', ignore_zeros = True) has 50% chance failed to open compressed tars?

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Proposed patch fixes the issue.

Existing test was passed by accident -- compressed tarfiles were too short for 
false detecting.

--
keywords: +patch
nosy: +serhiy.storchaka
stage:  -> patch review
Added file: http://bugs.python.org/file45119/tarfile_ignore_zeros_auto.patch

___
Python tracker 

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



[issue27896] Allow passing sphinx options to Doc/Makefile

2016-10-16 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3884a7e3df1c by Victor Stinner in branch 'default':
Issue #27896: Allow passing sphinx options to Doc/Makefile
https://hg.python.org/cpython/rev/3884a7e3df1c

--
nosy: +python-dev

___
Python tracker 

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



[issue28439] Remove redundant checks in PyUnicode_EncodeLocale and PyUnicode_DecodeLocaleAndSize

2016-10-16 Thread Xiang Zhang

Changes by Xiang Zhang :


--
title: Remove redundant checks in PyUnicode_EncodeLocale -> Remove redundant 
checks in PyUnicode_EncodeLocale and PyUnicode_DecodeLocaleAndSize
Added file: http://bugs.python.org/file45118/issue28349.patch

___
Python tracker 

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



[issue28439] Remove redundant checks in PyUnicode_EncodeLocale

2016-10-16 Thread Xiang Zhang

Changes by Xiang Zhang :


Removed file: http://bugs.python.org/file45089/PyUnicode_EncodeLocale.patch

___
Python tracker 

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



Re: How to pick out the same titles.

2016-10-16 Thread Alain Ketterlin
Seymore4Head  writes:

[...]
> I have a  long text file that has movie titles in it and I would like
> to find dupes.
>
> The thing is that sometimes I have one called "The Killing Fields" and
> it also could be listed as "Killing Fields"  Sometimes the title will
> have the date a year off.
>
> What I would like to do it output to another file that show those two
> as a match.

Try the difflib module (read the doc, its default behavior may be
surprising).

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


Re: Help me!, I would like to find split where the split sums are close to each other?

2016-10-16 Thread breamoreboy
On Sunday, October 16, 2016 at 12:27:00 PM UTC+1, k.ade...@gmail.com wrote:
> Help me!, I would like to find split where the split sums are close to each 
> other?
> 
> I have a list is
> 
> test = [10,20,30,40,50,60,70,80,90,100]
> 
> ​and I would like to find split where the split sums are close to each other 
> by number of splits = 3 that ​all possible combinations and select the split 
> where the sum differences are smallest.
> 
> Please example code or simple code Python.
> 
> Thank you very much
> 
> K.ademarus

We do not write code for you.  I'd suggest you start here 
https://docs.python.org/3/library/itertools.html

Kindest regards.

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


[issue28455] argparse: convert_arg_line_to_args does not actually expect self argument

2016-10-16 Thread siccegge

New submission from siccegge:

Hi!

Both the 3.4 version and the current version of python documentation wrt the 
argparse module imply convert_arg_line_to_args replacements needs to accept two 
arguments while it acutally only works with one. (Not completely sure about 
details but documentation really could be clearer!)

https://docs.python.org/3.4/library/argparse.html#argparse.ArgumentParser.convert_arg_line_to_args

Example from documentation

def convert_arg_line_to_args(self, arg_line):
return arg_line.split()

If codeparser = argparse.ArgumentParser actually does

def convert_arg_line_to_args(self, arg_line):
return arg_line.split()
parser = argparse.ArgumentParser()
parser.convert_arg_line_to_args = convert_arg_line_to_args

The code fails

  File "/usr/lib/python3.5/argparse.py", line 1735, in parse_args
args, argv = self.parse_known_args(args, namespace)
  File "/usr/lib/python3.5/argparse.py", line 1767, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
  File "/usr/lib/python3.5/argparse.py", line 1779, in _parse_known_args
arg_strings = self._read_args_from_files(arg_strings)
  File "/usr/lib/python3.5/argparse.py", line 2037, in _read_args_from_files
for arg in self.convert_arg_line_to_args(arg_line):
  TypeError: convert_arg_line_to_args() missing 1 required positional argument: 
'arg_line'

--
assignee: docs@python
components: Documentation
messages: 278771
nosy: docs@python, siccegge
priority: normal
severity: normal
status: open
title: argparse: convert_arg_line_to_args does not actually expect self argument
type: behavior
versions: Python 3.4

___
Python tracker 

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



[issue27659] Check for the existence of crypt()

2016-10-16 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Android does not have crypt, but the crypt module is cross-built nevertheless 
after this warning has been issued:
warning: implicit declaration of function 'crypt' is invalid in C99 
[-Wimplicit-function-declaration]
And at runtime, importing the crypt module fails with:
ImportError: dlopen failed: cannot locate symbol "crypt" referenced by 
"_crypt.cpython-37m-i686-linux-android.so"

gcc and clang do not enforce the C99 rules and emit just a warning for implicit 
function declarations instead of the error that would be conforming to C99. 
This can be changed with the flag '-Werror=implicit-function-declaration' and 
the compilation of the crypt extension module rightly fails in that case.

I think this issue should be fixed by adding this flag to the Makefile.
Maybe in another issue.

--
nosy: +benjamin.peterson, haypo, martin.panter

___
Python tracker 

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



[issue28115] Use argparse for the zipfile module

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Proposed patch makes zipfile using argparse and adds tests for zipfile CLI. 
Originally it is based on tarfile code and tests (but reworked, especially 
tests). Basically the interface is not changed, but added support of long 
options, and exit code in case of calling without options is changed from 1 to 
2 (the same as wrong option is specified). The format of help and usage info is 
changed of course.

Tests are passed with old releases of Python (except supporting long options). 
They will be backported.

--
Added file: http://bugs.python.org/file45117/zipfile_argparse.patch

___
Python tracker 

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



How to pick out the same titles.

2016-10-16 Thread Seymore4Head
How to pick out the same titles.

I have a  long text file that has movie titles in it and I would like
to find dupes.

The thing is that sometimes I have one called "The Killing Fields" and
it also could be listed as "Killing Fields"  Sometimes the title will
have the date a year off.

What I would like to do it output to another file that show those two
as a match.

I don't know the best way to tackle this.  I would think you would
have to pair the titles with the most consecutive letters in a row.

Anyone want this as a practice exercise?  I don't really use
programming enough to remember how.
-- 
https://mail.python.org/mailman/listinfo/python-list


Announcement: Code generation from state diagrams

2016-10-16 Thread peter . o . mueller
>From (UML) state diagrams to Python code made easy.

State machines are without any doubt a very good way to model behavior. The new 
code generator from Sinelabore translates hierarchical state machines 
efficiently into different languages now including Python.

The generator accepts diagrams from many common UML tools. It automatically 
performs robustness tests  and allows interactive simulation of the model. The 
generated code is maintainable and readable. No special runtime libraries are 
required. 

More information and a demo version is available on www.sinelabore.com

Best regards,
Peter Mueller
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue28451] pydoc.safeimport() raises ErrorDuringImport() if __builtin__.__import__ is monkey patched

2016-10-16 Thread R. David Murray

R. David Murray added the comment:

Can you provide a test case that shows when this condition might occur?  We'd 
want a test in any case if we accept the patch.

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



Re: pyserial: wait for execute

2016-10-16 Thread Grant Edwards
On 2016-10-16, Michael Okuntsov  wrote:

> is there a way, other than time.sleep(), to be sure that the command
> sent through a serial port has been fully executed?

If the remote device doesn't send a response telling you it's done
executing the command, then there is no way to know when that has
happened.

-- 
Grant


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


[issue22949] fnmatch.translate doesn't add ^ at the beginning

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
keywords: +patch
Added file: http://bugs.python.org/file45116/doc_fnmatch_translate.patch

___
Python tracker 

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



[issue28449] tarfile.open(mode = 'r:*', ignore_zeros = True) has 50% chance failed to open compressed tars?

2016-10-16 Thread Roland Bogosi

Roland Bogosi added the comment:

For anyone finding this bug through Google before it is fixed, a workaround 
could be to monkeypatch the OPEN_METH dict with an OrderedDict:

tarfile.TarFile.OPEN_METH = OrderedDict()
tarfile.TarFile.OPEN_METH['gz']  = 'gzopen'
tarfile.TarFile.OPEN_METH['bz2'] = 'bz2open'
tarfile.TarFile.OPEN_METH['xz']  = 'xzopen'
tarfile.TarFile.OPEN_METH['tar'] = 'taropen'

--
nosy: +RoliSoft

___
Python tracker 

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



Help me!, I would like to find split where the split sums are close to each other?

2016-10-16 Thread k . ademarus
Help me!, I would like to find split where the split sums are close to each 
other?

I have a list is

test = [10,20,30,40,50,60,70,80,90,100]

​and I would like to find split where the split sums are close to each other by 
number of splits = 3 that ​all possible combinations and select the split where 
the sum differences are smallest.

Please example code or simple code Python.

Thank you very much

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


[issue28453] SSLObject.selected_alpn_protocol() not documented

2016-10-16 Thread Alex Grönholm

Alex Grönholm added the comment:

HTTP/2 (h2) is kind of a biggie :)

--

___
Python tracker 

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



[issue28453] SSLObject.selected_alpn_protocol() not documented

2016-10-16 Thread Cory Benfield

Cory Benfield added the comment:

Yeah, probably! There aren't many protocols with defined ALPN identifiers, but 
we should still probably explain how this works. Do you want me to write them?

--

___
Python tracker 

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



[issue28290] BETA report: Python-3.6 build messages to stderr: AIX and "not GCC"

2016-10-16 Thread Christian Heimes

Christian Heimes added the comment:

I'm cautious about messing with crypto code. The problem should be fixed 
upstream. Please talk the blake2 issue to https://github.com/BLAKE2/BLAKE2.

--

___
Python tracker 

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



[issue28453] SSLObject.selected_alpn_protocol() not documented

2016-10-16 Thread Christian Heimes

Christian Heimes added the comment:

Cory, does it make sense to document some examples?

--
assignee: christian.heimes -> 
components: +Documentation
nosy: +Lukasa
type:  -> enhancement

___
Python tracker 

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



[issue27627] clang fails to build ctypes on Android armv7

2016-10-16 Thread Xavier de Gaye

Xavier de Gaye added the comment:

As this problem occurs with the bundled libffi, closing this issue as won't fix 
for the same reasons as those listed in msg278759.

--
resolution:  -> wont fix
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



[issue26072] pdb fails to access variables closed over

2016-10-16 Thread Chun-Yu Tseng

Chun-Yu Tseng added the comment:

Surrender.

After digging into the implementation of how CPython handles closures, I am 
sure that it is impossible to solve this problem now correctly. What I can do 
is create a patch to let Pdb print enough information when the problem occurs. 
It would look like:

(Pdb) ll
  3  def f():
  4  x = 1
  5  ->import pdb; pdb.set_trace()
(Pdb) (lambda: x)()

Pdb can not use the local variable 'x' to create a closure in
your evaluation. Instead, it tries to use 'x' in globals().
This behavior is due to the limitation of dynamic
interpretation within a debugger session.

Hint: type 'help interact' to check 'interact' command.

*** NameError: name 'x' is not defined

I believe it would be helpful and less annoyed for those who encounters this 
problem. Call for maintainers review, please.


PS.
1. Ruby does not have this problem. Whether it exists depends on how a 
programming language to implement closures. However, I think that what CPython 
do (by `PyCellObject`) is smart and efficient.

2. I tried to solve the problem by copying local variables to globals() (just 
like what `interact` command do), but it results in **more** problems. The most 
typical one is that if I eval `globals()` in such an affected environment, I 
will always get the wrong result.

3. I also tried to patch and evaluate again what user inputs when catching a 
closure-related `NameError`. Obviously, it is not a good idea due to side 
effects of evaluation.

4. The last possible solution I think of is import `ast` and do some hacking 
... it's overkill, and it also brings up other side effects.

--
keywords: +patch
Added file: http://bugs.python.org/file45115/default.patch

___
Python tracker 

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



[issue26942] android: test_ctypes crashes on armv7 and aarch64

2016-10-16 Thread Xavier de Gaye

Changes by Xavier de Gaye :


--
status: open -> closed

___
Python tracker 

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



[issue26942] android: test_ctypes crashes on armv7 and aarch64

2016-10-16 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Thanks Chi Hsuan Yen for your contributions with this issue.

--

___
Python tracker 

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



[issue26942] android: test_ctypes crashes on armv7 and aarch64

2016-10-16 Thread Xavier de Gaye

Xavier de Gaye added the comment:

At least for non-Darwin POSIX builds:
* Building _ctypes with the bundled copy of libffi is deprecated in 3.6 and the 
default is to use a system copy of libffi, issue 27976.
* The bundled libffi is removed in 3.7, issue 27979.

As this crash happens with the bundled libffi, closing this issue as won't fix.

--
resolution:  -> wont fix
stage: patch review -> resolved

___
Python tracker 

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



[issue28454] Spurious arguments to PyErr_Format in unicodeobject.c

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

LGTM.

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

___
Python tracker 

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



[issue28454] Spurious arguments to PyErr_Format in unicodeobject.c

2016-10-16 Thread Xiang Zhang

New submission from Xiang Zhang:

In unicodeobject.c, there are some spurious arguments to PyErr_Format as the 
patch shows.

--
components: Interpreter Core
files: spurious_argument.patch
keywords: patch
messages: 278757
nosy: ncoghlan, xiang.zhang
priority: normal
severity: normal
stage: patch review
status: open
title: Spurious arguments to PyErr_Format in unicodeobject.c
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7
Added file: http://bugs.python.org/file45114/spurious_argument.patch

___
Python tracker 

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



Re: How make the judge with for loop?

2016-10-16 Thread Peter Otten
38016226...@gmail.com wrote:

> c="abcdefghijk"
> len=len(c)
> n is a int
> sb=[[] for i in range(n)]
> 
> while (i < len) {
> for (int j = 0; j < n && i < len; j++)
> sb[j].append(c[i++]);
> for (int j = n-2; j >= 1 && i < len; j--) //
> sb[j].append(c[i++]);
> }
> 
> How to translate to python? I tried but my python code is really stupid

It would still be good to provide it or a least a complete runnable C 
source. A description of the problem in plain English would be helpful, too.

What follows are mechanical translations of what I think your original C 
code does.

(1) You can use a while loop to replace C's for

# example: first for loop
j = ;
while j < n and i < length:
sb[j].append(chars[i])
i += 1
j += 1

which should be straight-forward, or 

(2) you can run a for loop until an exception is raised:

chars = "abcdefghijk"
...
chars = iter(chars)
try:
while True:
for sublist in sb[:n]:
sublist.append(next(chars))
for sublist in sb[n-2: 0: -1]:
sublist.append(next(chars))
except StopIteration:
pass # we ran out of characters

(3) If you concatenate the two list slices into one, and with a little help 
from the itertools (while True... becomes itertools.cycle()) you get:

up = sb[:n]
down = sb[n-2: 0: -1]

for sublist, c in zip(cycle(up + down), chars):
sublist.append(c)

(All untested code, you should check especially the slice indices)

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


[issue14991] Option for regex groupdict() to show only matching names

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Maybe start emitting FutureWarning when groupdict() is called without an 
argument? groupdict(None) returns the same result but without a warning. After 
1 or 2 releases the behavior can be changed: groupdict() will return only 
matched groups.

--
nosy: +serhiy.storchaka
versions: +Python 3.7 -Python 3.4

___
Python tracker 

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



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-16 Thread SilentGhost

SilentGhost added the comment:

Here is the updated patch with fixes to the test suite.

--
versions: +Python 3.7
Added file: http://bugs.python.org/file45113/25953_2.diff

___
Python tracker 

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



[issue16007] Improved Error message for failing re expressions

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Since 3.5 (issue22578) the re.error exception has attributes that contain a 
pattern and the position of the error. Error message contains the position of 
the error. A pattern is not included in the error message for purpose: it can 
be too long. Usually the pattern is clear from the context, and you always can 
check the pattern attribute.

--
resolution:  -> out of date
stage: needs patch -> resolved
status: open -> closed
superseder:  -> Add additional attributes to re.error

___
Python tracker 

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



[issue23692] Undocumented feature prevents re module from finding certain matches

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
nosy: +serhiy.storchaka
stage:  -> needs patch
versions: +Python 2.7, Python 3.5, Python 3.6, Python 3.7 -Python 3.4

___
Python tracker 

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



[issue22949] fnmatch.translate doesn't add ^ at the beginning

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Since issue22493 fnmatch.translate() uses scoped modifiers: r'(?s:%s)\Z' % res.

Here is a patch that updates the documentation for fnmatch.translate().

--
stage: needs patch -> patch review
versions: +Python 3.6, Python 3.7 -Python 3.4

___
Python tracker 

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



[issue25953] re fails to identify invalid numeric group references in replacement strings

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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

___
Python tracker 

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



Re: How make the judge with for loop?

2016-10-16 Thread Steven D'Aprano
On Sunday 16 October 2016 16:23, 38016226...@gmail.com wrote:

> c="abcdefghijk"
> len=len(c)
> n is a int
> sb=[[] for i in range(n)]
> 
> while (i < len) {
> for (int j = 0; j < n && i < len; j++)
> sb[j].append(c[i++]);
> for (int j = n-2; j >= 1 && i < len; j--) //
> sb[j].append(c[i++]);
> }
> 
> How to translate to python? I tried but my python code is really stupid

I don't know. What language is your code written in, and what does it do?

I can guess what some of it probably does, because it looks like Python code, 
but the for-loops are complicated and weird. What do they do?

It might help if you show the expected results.




-- 
Steven
git gets easier once you get the basic idea that branches are homeomorphic 
endofunctors mapping submanifolds of a Hilbert space.

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


[issue25550] RecursionError in re with '(' * 500

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Closed as not a bug. Unlike to issue401612 this is not an infinite recursion. 
Raising RecursionError depends on the context (it is more likely in deeply 
nested call) and there is a common workaround -- just increase maximum 
recursion depth using sys.setrecursionlimit(). There is nothing specific to 
regular expressions.

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



[issue28444] Missing extensions modules when cross compiling python 3.5.2 for arm on Linux

2016-10-16 Thread Xavier de Gaye

Xavier de Gaye added the comment:

Thanks for the reports. The next step is having the patch reviewed by one of 
the Python build machinery experts.
Nosying Martin, Zachary and Matthias.

--
nosy: +doko, martin.panter, zach.ware

___
Python tracker 

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



[issue28450] Misleading/inaccurate documentation about unknown escape sequences in regular expressions

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
components: +Regular Expressions
nosy: +ezio.melotti

___
Python tracker 

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



[issue24896] It is undocumented that re.UNICODE affects re.IGNORECASE

2016-10-16 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


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



[issue27471] sre_constants.error: bad escape \d

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

All behaves as purposed. But the documentation is not accurate, and even 
misleading. It should be enhanced (issue28450).

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



[issue28450] Misleading/inaccurate documentation about unknown escape sequences in regular expressions

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you for your report Lele. Agreed, the documentation looks misleading.

Do you want to provide more clear wording?

--
nosy: +Rosuav, mrabarnett, nedbat, serhiy.storchaka
stage:  -> needs patch
title: Misleading/inaccurate documentation about unknown escape sequences -> 
Misleading/inaccurate documentation about unknown escape sequences in regular 
expressions
type:  -> enhancement
versions: +Python 3.5, Python 3.7

___
Python tracker 

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



[issue28437] Documentation for handling of non-type metaclass hints is unclear

2016-10-16 Thread Nick Coghlan

Nick Coghlan added the comment:

The "used directly as the metaclass" is a reference to 
https://docs.python.org/3/reference/datamodel.html#creating-the-class-object 
further down, and specifically the "metaclass(name, bases, namespace, **kwds)" 
call. It's not saying Python has a way to bypass that instantiation process.

As a result, your code is consistently getting to that step just fine, but 
*that call* is throwing an exception.

Hence my comment earlier that there's a case to be made that we should be 
better indicating where we were in the type creation process when the metaclass 
resolution failed.

--

___
Python tracker 

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



[issue28437] Documentation for handling of non-type metaclass hints is unclear

2016-10-16 Thread Nick Coghlan

Nick Coghlan added the comment:

Oops, couple of typos:

"... only triggers metaclass resolution at that point ..."

"... if either the metaclass being instantiated is a subclass of all the 
metaclasses of all of the bases ..."

But the only way to bypass the "most derived metaclass" rule is for the the 
metaclass hint to be a callable that creates something that *isn't* a subclass 
of type. If you look at the tracebacks you're getting, you should see that the 
failure *isn't* in the class statement or the outer dynamic type, it's in 
"metaclass_callable", where the *inner* dynamic type creation is failing.

--

___
Python tracker 

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



[issue28437] Documentation for handling of non-type metaclass hints is unclear

2016-10-16 Thread Neil Girdhar

Neil Girdhar added the comment:

Okay, I understand what you're saying, but I it says in the documentation that 
"if an explicit metaclass is given and it is not an instance of type(), then it 
is used directly as the metaclass".  My recent updated "metaclass_callable" is 
not an instance of type.  Why should it raise an exception?

--

___
Python tracker 

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



[issue28437] Documentation for handling of non-type metaclass hints is unclear

2016-10-16 Thread Nick Coghlan

Nick Coghlan added the comment:

Because they're checking for different things:

- types.prepare_class is only checking "How do I call __prepare__?". It only 
triggers type resolution at that point if the metaclass hint is an instance of 
type, otherwise it skips that process entirely and queries the metaclass hint 
directly.

- type.__new__ is checking "Can I actually create a new instance of this 
metaclass with these bases?". It can only do that if either the metaclass being 
instantiated is a subclass of all the bases of the type being defined, or else 
such a metaclass exists amongst the bases.

To be clear, your example isn't failing due to the way MyDerived is defined - 
it's failing because OtherMetaclass is itself an instance of type, and you're 
declaring it (directly or indirectly) as the metaclass of MyDerived, while 
inheriting from MyClass, which is an instance of MyMetaclass.

--

___
Python tracker 

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



[issue28437] Documentation for handling of non-type metaclass hints is unclear

2016-10-16 Thread Neil Girdhar

Neil Girdhar added the comment:

Thanks for taking the time to explain, but it's still not working for me:

from types import new_class


class MyMetaclass(type):
pass

class OtherMetaclass(type):
pass

def metaclass_callable(name, bases, namespace):
return new_class(name, bases, dict(metaclass=OtherMetaclass))

class MyClass(metaclass=MyMetaclass):
pass

try:
class MyDerived(MyClass, metaclass=metaclass_callable):
pass
except:
print("Gotcha!")


try:
MyDerived = new_class("MyDerived", (MyClass,), 
dict(metaclass=metaclass_callable))
except:
print("Gotcha again!")

So my questions are:

1. Why shouldn't Lib/types:new_class behave in exactly the same way as 
declaring a class using "class…" notation?

2. What's the point of checking if the metaclass is an instance of type?  It 
seems to me that in Python 2, non-type metaclasses did not have to be the "most 
derived class" (that's what the documentation seems to suggest with the second 
rule).  However, we no longer accept that in CPython 3 — neither in the 
Lib/types, nor in a regular declaration.  In fact, the exception is:

"metaclass conflict: "
"the metaclass of a derived class "
"must be a (non-strict) subclass "
"of the metaclasses of all its bases");

So why not just check that unconditionally in Lib/types.py?

--

___
Python tracker 

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



[issue28437] Documentation for handling of non-type metaclass hints is unclear

2016-10-16 Thread Nick Coghlan

Nick Coghlan added the comment:

Why should it trip the PEP 3115 namespace preparation exception? We only check 
for __prepare__ (and hence need to do an early most-derived metaclass 
resolution) on instances of "type", not on arbitrary callables used as a 
metaclass hint

The checks are different in the two places because the rules are different in 
the two places. (One case that *can* be made is that we should be throwing 
different exceptions or chaining them to show which metaclass resolution 
failed, rather than re-using the same message in both places).

This means that when you define a non-type metaclass hint, you're bypassing 
*all* of the PEP 3115 machinery, including the early metaclass resolution.

However, if your metaclass hint still creates a type instance, you're not 
bypassing tp_new.

If you're asking "Where is the bug in the presented example code?", it's here, 
in the definition of your metaclass hint:

def metaclass_callable(name, bases, namespace):
return OtherMetaclass(name, bases, namespace)

Instantiating instances of "type" directly in Python 3 bypasses the PEP 3115 
machinery - that's the entire reason that types.new_class was added. So if you 
want that metaclass hint to be PEP 3115 compliant, you need to explicitly write 
it that way:

def metaclass_callable(name, bases, namespace):
return types.new_class(name, bases, dict(metaclass=OtherMetaclass)

--
resolution: not a bug -> 
stage: resolved -> 
status: closed -> open
title: Class definition is not consistent with types.new_class -> Documentation 
for handling of non-type metaclass hints is unclear

___
Python tracker 

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



[issue15988] Inconsistency in overflow error messages of integer argument

2016-10-16 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Thank you Oren. I'll make a detailed review in next few days.

--
stage: needs patch -> patch review
versions: +Python 3.7 -Python 3.6

___
Python tracker 

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