[issue27149] Implement socket.sendmsg() for Windows

2016-05-28 Thread Марк Коренберг

New submission from Марк Коренберг:

Please add, but do not emulate, since atomicity of that IO must be kept, as 
said in man-page.

--
components: Library (Lib), Windows
messages: 266586
nosy: mmarkk, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Implement socket.sendmsg() for Windows
type: enhancement
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



[issue27117] turtledemo does not work with IDLE's new dark theme.

2016-05-28 Thread Terry J. Reedy

Changes by Terry J. Reedy :


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



[issue27117] turtledemo does not work with IDLE's new dark theme.

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c95864a37ee2 by Terry Jan Reedy in branch 'default':
Issue #27117: Make colorizer htest and turtledemo work with dark theme.
https://hg.python.org/cpython/rev/c95864a37ee2

New changeset f383eaf207ca by Terry Jan Reedy in branch '3.5':
Issue #27117: Make ColorDelegator htest and turtledemo work with dark theme.
https://hg.python.org/cpython/rev/f383eaf207ca

--
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: Coding systems are political (was Exended ASCII and code pages)

2016-05-28 Thread Steven D'Aprano
On Sat, 28 May 2016 02:46 pm, Rustom Mody wrote:

[...]
> In idealized, simplified models like Turing models where
> 3 is 111
> 7 is 111
> 100, 8364 etc I wont try to write but you get the idea!
> its quite clear that bigger numbers cost more than smaller ones

I'm not sure that a tally (base-1, unary) is a good model for memory usage
in any computing system available today. And I thought that the Turing
model was based on binary: the machine could both mark a cell and erase the
mark, which corresponds to a bit.



> With current hardware it would seem to be a flat characteristic for
> everything < 2³² (or even 2⁶⁴)
> 
> But thats only an optical illusion because after that the characteristic
> will rise jaggedly, slowly but monotonically, typically log-linearly
> [which AIUI is jmf's principal error]

Can you be more specific at what you are trying to say? You seem to think
that you're saying something profound here, but I don't know what it is.



> Which also means that if the Chinese were to have more say in the design
> of Unicode/ UTF-8 they would likely not waste swathes of prime real-estate
> for almost never used control characters just in the name of ASCII
> compliance

There is this meme going around that Unicode is a Western imperialistic
conspiracy against Asians. For example, there was a blog post a year or so
ago by somebody bitterly complaining that he could draw a pile of poo in
Unicode but not write his own name, blaming Westerners for this horrible
state of affairs.

But like most outrage on the Internet, his complaint was nonsense. He *can*
write his name -- he just has to use a combining character to add an
accent(?) to a base character. (Or possibly a better analogy is that of a
ligature.) His complaint came down to the fact that because his name
included a character which was unusual even in his own language (Bengali),
he had to use two Unicode code points rather than one to represent it. This
is, of course, the second worst[1] kind of discrimination.

https://news.ycombinator.com/item?id=9219162

Likewise the hoo-har over CJK unification. Some people believe that this is
the evil Western imperialists forcing their ignorant views on the Chinese,
Japanese and Koreans, but the reality is that the Unicode Consortium merely
follows the decisions made by the Ideographic Rapporteur Group (IRG),
originally the CJK-JRG group. That is a multinational group set up by the
Chinese and Japanese, now including other East Asians (both Koreas,
Singapore, Vietnam) to decide on a common set of Han characters.

Anyway, I digress.

Given that there are tens of thousands of Han characters (with unification),
more than will fit in 16 bits, the 64 control characters in Unicode is not
going to make any practical difference. In some hypothetical world where
Han speakers got to claim code points U+-001F and U+0080-009F for
ideographs, pushing the control characters out into the astral planes, all
they would gain is *sixty four* code points. They would still need multiple
thousands of astral characters.

Besides, some level of ASCII compatibility is useful even for Han speakers.
Their own native-designed standard encodings like Big5 and Shift-JIS (which
predate Unicode) keep byte-compatibility with the 32 ASCII control
characters. (I'm not sure about the 32 "C1" control characters.) Since the
Chinese and Japanese national standards pre-dating Unicode choose to keep
compatibility with the ASCII control characters, I don't think that there
is any good reason to think they would have made a different decision when
it came to Unicode had they had more of a say than they already did.

Which was, and still is, considerable. Both China and Japan are very
influential in the Unicode Consortium, driving the addition of many new Han
characters and emoji. The idea that a bunch of Western corporations and
academics are pushing them around is laughable.




[1] The worst being that my US English keyboard doesn't have a proper curly
apostrophe, forcing me to use a straight ' mark in my name like some sort
of animal.

-- 
Steven

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


[issue27117] turtledemo does not work with IDLE's new dark theme.

2016-05-28 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I was wrong about turtledemo's text pane.  Turtledemo only uses textview for 
help.  The text frame contains a plain Text widget.  I moved the text 
color-config code from editor to a function in colorizer, where it is also 
needed for the colorizer test.

--
assignee:  -> terry.reedy

___
Python tracker 

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



[issue27148] Make VENV_DIR relative to Script directory

2016-05-28 Thread Jon Nabozny

New submission from Jon Nabozny:

I would like to see some enhancement where the activate.bat and activate 
scripts allow the script to determine where the python executable resides.

When the executable cannot be found (because the path doesn't exist for some 
reason), the system will ultimately find the installed version of python. This 
can cause side effects that may be non-obvious to users.

Example:
User creates a virtual environment:
python -m venv C:\Location\To\Project venv

 User manually changes location of project:
xcopy /E C:\Location\To\Project C:\New\Project\Location

 User runs activate.bat:
(venv) C:\New\Project\Location

 At this point, the user will get the modified prompt, but will 
 actually be using his/her globally installed python. Therefore,
 running anything like pip will taint their install. Further, if
 they had set up the environment previously, it can cause errors
 because modules won't be found (because it's pointing at the
 wrong Lib\site-packages folder).

Code:
activate.bat
;Replace set "VIRTUAL_ENV=__VENV_DIR__"
set "VIRTUAL_ENV=%~dp0..\"

activate
FILE=$(readlink -f "$0")
FILE_DIR=$(dirname "$FILE")
# Replace VIRTUAL_ENV="__VENV_DIR__"
VIRTUAL_ENV="$FILE_DIR/../"

Somewhat related, I've also found that's it's incredibly convenient to also 
include activate and deactivate files at the root of the venv:

 python -m venv C:\project venv

 # Now, C:\project looks like this:
 .\venv
 .\activate.bat
 .\deactivate.bat

 # activate and deactivate are very simple:
 ;activate.bat
 @ECHO OFF

 pushd env\Scripts
 call activate
 popd

 ;deactivate.bat
 @ECHO OFF

 pushd env\Scripts
 call deactivate
 popd

--
components: Demos and Tools
messages: 266583
nosy: widmo
priority: normal
severity: normal
status: open
title: Make VENV_DIR relative to Script directory
type: enhancement
versions: Python 3.2, Python 3.3, Python 3.4, 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



[issue27124] binascii.a2b_hex raises binascii.Error and ValueError, not TypeError

2016-05-28 Thread Martin Panter

Changes by Martin Panter :


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



Re: Package setup best practice style question

2016-05-28 Thread Steven D'Aprano
On Sun, 29 May 2016 03:00 am, Steven D'Aprano wrote:

> On Sun, 29 May 2016 02:15 am, Gerald Britton wrote:
> 
>> suppose I have a simple python project setup like this:
[...]

To which I responded:

> If this is a single project, why do you set it up like this? Is there a
> reason why you don't just have:
[...]


I'm sorry, on re-reading my post I realise that it might come across as a
bit confrontational. Sorry Gerald, it wasn't intended that way. I was just
intending to point out that we aren't forced to use a package structure at
all, unless it brings actual advantages to the project.



-- 
Steven

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


[issue27124] binascii.a2b_hex raises binascii.Error and ValueError, not TypeError

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset ef89ecb6debc by Martin Panter in branch '3.5':
Issue #27124: Fix documentation of exception raised by a2b_hex()
https://hg.python.org/cpython/rev/ef89ecb6debc

New changeset 85e6da63d73f by Martin Panter in branch 'default':
Issue #27124: Merge binascii doc from 3.5
https://hg.python.org/cpython/rev/85e6da63d73f

--
nosy: +python-dev

___
Python tracker 

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



[issue27105] cgi.__all__ is incomplete

2016-05-28 Thread Martin Panter

Martin Panter added the comment:

For this particular case, there is only one existing test class called 
CgiTests, without any special setup or handling. It seems too arbitrary to have 
a second class called MiscTestCase, so I would prefer the new test be added to 
CgiTests.

--

___
Python tracker 

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



[issue27109] plistlib.__all__ list is incomplete

2016-05-28 Thread Martin Panter

Martin Panter added the comment:

I think this patch is okay

--
nosy: +martin.panter

___
Python tracker 

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



[issue27112] tokenize.__all__ list is incomplete

2016-05-28 Thread Martin Panter

Martin Panter added the comment:

Changing the names to tokenize. does solve the problem of the tokenize 
module versus the tokenize() fuction, so I can accept this way since you prefer 
it.

So I think that just leaves what to do with the actual test case. I don’t think 
it matters too much, but I would lean toward ensuring the test fails if someone 
adds a new implementation detail without an underscore prefix. It is also good 
to be explicit that the ISTERMINAL() etc functions are special cases.

On the other hand, neither the original patch nor Jacek’s proposal for 
“expected = token.__all__ + ...” would pick up the fact that the tok_name 
dictionary is another special case copied from the “token” module. (See also 
Issue 25324.)

--

___
Python tracker 

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



[issue9363] data_files are not installed relative to sys.prefix

2016-05-28 Thread Berker Peksag

Berker Peksag added the comment:

Issue 25592 is a duplicate of this and but it has a patch that almost ready to 
commit so I'm closing this one.

--
nosy: +berker.peksag
resolution:  -> duplicate
stage: test needed -> resolved
status: open -> closed
superseder:  -> distutils docs: data_files always uses sys.prefix

___
Python tracker 

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



[issue25592] distutils docs: data_files always uses sys.prefix

2016-05-28 Thread Berker Peksag

Changes by Berker Peksag :


--
components: +Distutils
nosy: +berker.peksag, dstufft, eric.araujo
stage:  -> patch review
type:  -> behavior
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



Re: Python-list Digest, Vol 152, Issue 43

2016-05-28 Thread Noah Fleiszig
Thank you and ok

-- 
Sent from Gmail Mobile
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How can I debug silent failure - print no output

2016-05-28 Thread cs

On 28May2016 03:32, Sayth Renshaw  wrote:

On Saturday, 28 May 2016 19:44:53 UTC+10, Sayth Renshaw  wrote:

On Saturday, 28 May 2016 18:02:06 UTC+10, Sayth Renshaw  wrote:
> So how do i get argparse to read the file arguments correctly?
>
> Looking at the namespace it all gets pushed into path and extension remains 
empty.
>
> [sayth@localhost pyXML]$ python3 racemeeting.py data/ *.xml
> Namespace(extension='', path=['data/', '*.xml'])
> This is the section I am running
>
> parser = argparse.ArgumentParser()
> parser.add_argument("path", nargs="+")
> parser.add_argument('-e', '--extension', default='',
> help='File extension to filter by.')
>
> args = parser.parse_args()
> name_pattern = "*" + args.extension
> print(args)

Ah if only i used argparse properly

python racemeeting.py data/ -e *.xml


There are a couple of things here.

First is that a normal UNIX command puts all the options first, so you should 
be desiging your command line to run like this:


 python racemeeting.py -e *.xml data

or perhaps:

 python racemeeting.py -d data -e *.xml

It is traditional to stop parsing options such as -e when you reach the first 
non-option, because that lets one put whatever is necessary safely _after_ the 
options without fear that one of the arguments will resemble an option. For 
example, suppoing you have a file with the name "-e" and said:


 somecommand -f foo dir *

intending to use all the local filenames after "dir". In your current scheme 
(accepting options after "dir") a "-e" appearing later would be misinterpreted.


The second is to be aware that the shell expands globs _before_ invoking the 
command. This is extremely useful because it means that (a) commands usually 
don't need to do their own glob expansion and (b) all commands end up using the 
same glob syntax because it is common to the shell, not a command-specific 
special syntax. Which makes everything easier to use.


The upshot of that is that you should _either_ be quoting "*.xml" on your 
command line to prevent expansion, _or_ you should not be bothering with he 
asterisk, instead passing the argument ".xml" or even just "xml".


As an experiment, make two dummy XML files in your current directory (where 
your script is):


 >>dummy1.xml
 >>dummy2.xml

and run your script passing *.xml as you currently do, and see what your print 
statements say. This should make the effect obvious.


Cheers,
Cameron Simpson 
--
https://mail.python.org/mailman/listinfo/python-list


[issue26526] In parsermodule.c, replace over 2KLOC of hand-crafted validation code, with a DFA

2016-05-28 Thread Fred L. Drake, Jr.

Fred L. Drake, Jr. added the comment:

I've read through this, but haven't applied the patch & run tests (that's what 
buildbots are for).

No objections.

--

___
Python tracker 

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



[issue27122] Hang with contextlib.ExitStack and subprocess.Popen (regression)

2016-05-28 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
assignee:  -> gregory.p.smith

___
Python tracker 

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



[issue26372] Popen.communicate not ignoring BrokenPipeError

2016-05-28 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
assignee:  -> gregory.p.smith

___
Python tracker 

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



[issue7951] Should str.format allow negative indexes when used for __getitem__ access?

2016-05-28 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue21084] IDLE can't deal with characters above the range (U+0000-U+FFFF)

2016-05-28 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue16182] readline: Wrong tab completion scope indices in Unicode terminals

2016-05-28 Thread Mark Lawrence

Changes by Mark Lawrence :


--
nosy:  -BreamoreBoy

___
Python tracker 

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



[issue25731] Assigning and deleting __new__ attr on the class does not allow to create instances of this class

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 3ff84a3eeb6b by Benjamin Peterson in branch '2.7':
Backed out changeset e7062dd9085e (#25731)
https://hg.python.org/cpython/rev/3ff84a3eeb6b

--

___
Python tracker 

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



[issue27146] posixmodule.c needs stdio.h

2016-05-28 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
assignee:  -> gregory.p.smith
nosy: +gregory.p.smith
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue25731] Assigning and deleting __new__ attr on the class does not allow to create instances of this class

2016-05-28 Thread Benjamin Peterson

Benjamin Peterson added the comment:

I'll have to think about how to fix this while maintaining compatiblity with 
obscure cases like above.

--

___
Python tracker 

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



[issue27146] posixmodule.c needs stdio.h

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset c8e113bf56ae by Gregory P. Smith in branch '3.5':
Fix issue27146 - add stdio.h include to posixmodule.c for ctermid().
https://hg.python.org/cpython/rev/c8e113bf56ae

New changeset 74fcfc29187e by Gregory P. Smith in branch 'default':
Fix issue27146 - add stdio.h include to posixmodule.c for ctermid().
https://hg.python.org/cpython/rev/74fcfc29187e

--
nosy: +python-dev

___
Python tracker 

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



[issue9327] doctest DocFileCase setUp/tearDown asymmetry

2016-05-28 Thread Berker Peksag

Changes by Berker Peksag :


--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> doctest.DocTestCase fails when run repeatedly

___
Python tracker 

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



[issue24225] Idlelib: changing file names

2016-05-28 Thread Terry J. Reedy

Terry J. Reedy added the comment:

I have a new idea for public interfaces: keep most of idlelib private and add a 
new 'interface' module containing public interfaces.  It could be backported to 
3.5 and even 2.7.

This was prompted by working with turtledemo.  It currently imports textview, 
percolator, and colorizer to create a colorized code viewer.  At the moment, 
changing the names in the three imports worked, but that could change if any of 
the files are refactored.  (And what about people who have trouble hooking the 
three components together correctly?)

Instead, lets create, say, class ColorCodeview (or maybe a function) in 
interface and have turtledemo do one import, say 'from idlelib.interface import 
ColorCodeview'.  The internal code code would be slilghtly different in each of 
2.7, 3.5, and 3.6 (and maybe different again sometime after the initial 
commit).  But the import and basic use should be the same.

The only thing I might put in the main idlelib doc would be something like 'See 
the interface module for currently supported external uses of idlelib 
components."

--

___
Python tracker 

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



[issue24225] Idlelib: changing file names

2016-05-28 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Revision should definitely be tested on Mac by running IDLE from a console to 
check for any Mac-specific warnings and check that the menu looks 'right', 
which is to say, same as with 3.5.

Still to do: news entries, What's New section, README.txt revision with new 
names.

--
stage: test needed -> needs patch

___
Python tracker 

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



[issue24225] Idlelib: changing file names

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 6ecd4db71b88 by Terry Jan Reedy in branch 'default':
Issue #24225: Rename many idlelib/*.py and idlelib/idle_test/test_*.py files.
https://hg.python.org/cpython/rev/6ecd4db71b88

New changeset 0c3fdb161901 by Terry Jan Reedy in branch 'default':
Issue #24225: Within idlelib files, update idlelib module names.
https://hg.python.org/cpython/rev/0c3fdb161901

--
nosy: +python-dev

___
Python tracker 

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



[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-28 Thread Emanuel Barry

Emanuel Barry added the comment:

Serhiy, it seems as though _functools is always required for functools to work 
- heck, tests start to fail all over the place if it isn't available, because 
functools.reduce doesn't exist.

Subclassing _functools.partial is already tested for, so I wouldn't qualify it 
as an implementation detail myself. Moreover, I feel that we should try to 
(somewhat) keep both implementations identical - or close enough.

It seems that _pickle checks for _functools.partial, and that trying to pickle 
the pure Python version triggers the error in msg266530.

This probably doesn't matter for most (if not all) of cases where CPython is 
concerned. But I care about the ability for alternate implementations to work 
the same way.

Compromise: rename the current partial function to partial_func and keep it 
around ;-)

--

___
Python tracker 

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



[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-05-28 Thread Gregory P. Smith

Changes by Gregory P. Smith :


--
resolution:  -> fixed
status: open -> closed

___
Python tracker 

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



[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 184dfef08a93 by Gregory P. Smith in branch '2.7':
issue26083: Avoid duplicate error message string from a subprocess exec 
failure.Avoid a duplicate error message string from a subprocess exec failure.
https://hg.python.org/cpython/rev/184dfef08a93

--

___
Python tracker 

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



RE: re.search - Pattern matching review ( Apologies re sending)

2016-05-28 Thread Albert-Jan Roskam
> Date: Sat, 28 May 2016 23:48:16 +0530
> Subject: re.search - Pattern matching review ( Apologies re sending)
> From: ganesh1...@gmail.com
> To: python-list@python.org
> 
> Dear Python friends,
> 
> I am  on Python 2.7 and Linux . I am trying to extract the address
> "1,5,147456:8192" from the below stdout using re.search
> 
> (Pdb) stdout
> 'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
> 1,5,147456:8192) --\nlinux-host-machine-1: magic
> 0xdeaff2fe mark_cookie 0x300a\n'
> (Pdb) type(stdout)
> 
> 
> Here is the code I have come up with, this looks buggy please review
> the same and suggest any better ways  to code.
> 
> Could we use splitlines() or re.complie() etc , my intention is to
> match 1,5,147456:8192 and return the same.
> 
> 
> #Sample code
> 
> import re
> import subprocess_run
> 
> def get_block():
> try:
> cmd = "get_block_info -l"
> # stdout is the output retrieved by subprocess.Popen()
> stdout, stderr, exitcode = subprocess_run(cmd)
> search_pat = 'Block Address.* \(block (\d+),(\d+),(\d+):(\d+)'
> matched = re.search(search_pat, stdout)
> block = (int(matched.group(1)),
>int(matched.group(2)),
>int(matched.group(3)),
>int(matched.group(4)),
>   )
Perhaps:map(int,  re.search(search_pat, stdout).groups())
Or re.findall
> except IOError, e:
> logging.warning('Error reading lines from "%s" (%s).'
> % (cmd, e))
> 
> if block is None:
>logging.error("block not found")
>return False
> logging.info("block not found")
> return block
> 
> Regards,
> 
> Ganesh
> -- 
> https://mail.python.org/mailman/listinfo/python-list
  
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue3982] support .format for bytes

2016-05-28 Thread Gregory P. Smith

Gregory P. Smith added the comment:

This came up in the language summit today when discussing twisted.  .format() 
is still not supported on bytes though % is in 3.5.

realistically it sounded like twisted needs to support python 3.4 for many 
years so they can't rely on bytes having a .format() method that also works on 
2.7 anyways... but assuming .format() is only useful for text may still have 
been an oversight.  (i'll have to go re-read pep 460 and 461 and discussion 
before commenting further)

--

___
Python tracker 

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



[issue27132] New assert method that checks an error message for a list of strings

2016-05-28 Thread R. David Murray

R. David Murray added the comment:

The complexity of those solutions argues in favor of adding a method, I'd say.

Personally I'd write multiple asserts rather than regex permutations.

--

___
Python tracker 

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



re.search - Pattern matching review ( Apologies re sending)

2016-05-28 Thread Ganesh Pal
Dear Python friends,

I am  on Python 2.7 and Linux . I am trying to extract the address
"1,5,147456:8192" from the below stdout using re.search

(Pdb) stdout
'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
1,5,147456:8192) --\nlinux-host-machine-1: magic
0xdeaff2fe mark_cookie 0x300a\n'
(Pdb) type(stdout)


Here is the code I have come up with, this looks buggy please review
the same and suggest any better ways  to code.

Could we use splitlines() or re.complie() etc , my intention is to
match 1,5,147456:8192 and return the same.


#Sample code

import re
import subprocess_run

def get_block():
try:
cmd = "get_block_info -l"
# stdout is the output retrieved by subprocess.Popen()
stdout, stderr, exitcode = subprocess_run(cmd)
search_pat = 'Block Address.* \(block (\d+),(\d+),(\d+):(\d+)'
matched = re.search(search_pat, stdout)
block = (int(matched.group(1)),
   int(matched.group(2)),
   int(matched.group(3)),
   int(matched.group(4)),
  )
except IOError, e:
logging.warning('Error reading lines from "%s" (%s).'
% (cmd, e))

if block is None:
   logging.error("block not found")
   return False
logging.info("block not found")
return block

Regards,

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


re.search - Pattern matching review

2016-05-28 Thread Ganesh Pal
Dear Python friends,

I am  on Python 2.7 and Linux . I am trying to extract the address
"1,5,147456:8192" from the below stdout using re.search

(Pdb) stdout
'linux-host-machine-1: Block Address for 1,5,27320320:8192 (block
1,5,147456:8192) --\nlinux-host-machine-1: magic
0xdeaff2fe mark_cookie 0x300a\n'
(Pdb) type(stdout)


Here is the code I have come up with, this looks buggy please review
the same and suggest any better ways  to code the same

the same may be splitlines() , re.complie() etc , my intention is to
just match 1,5,147456:8192 and return the same.


#Sample code

import re
import subprocess_run

def get_block():
try:
cmd = "get_block_info -l"
# stdout is the output retrieved by subprocess.Popen()
stdout, stderr, exitcode = subprocess_run(cmd)
search_pat = 'Block Address.* \(block (\d+),(\d+),(\d+):(\d+)'
matched = re.search(search_pat, stdout)
block = (int(matched.group(1)),
   int(matched.group(2)),
   int(matched.group(3)),
   int(matched.group(4)),
  )
except IOError, e:
logging.warning('Error reading lines from "%s" (%s).'
% (cmd, e))

if block is None:
   logging.error("block not found")
   return False
logging.info("block not found")
return block

Regards,

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


[issue27147] importlib docs do not mention PEP 420

2016-05-28 Thread Eric Snow

Changes by Eric Snow :


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

___
Python tracker 

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



[issue27147] importlib docs do not mention PEP 420

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 6f50c04e4a1e by Eric Snow in branch '3.5':
Issue #27147: Mention PEP 420 in the importlib docs.
https://hg.python.org/cpython/rev/6f50c04e4a1e

New changeset 0177af33ce76 by Eric Snow in branch 'default':
Issue #27147: Mention PEP 420 in the importlib docs.
https://hg.python.org/cpython/rev/0177af33ce76

--
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: Coding systems are political (was Exended ASCII and code pages)

2016-05-28 Thread Random832
On Sat, May 28, 2016, at 00:46, Rustom Mody wrote:
> Which also means that if the Chinese were to have more say in the
> design of Unicode/ UTF-8 they would likely not waste swathes of prime
> real-estate for almost never used control characters just in the name
> of ASCII compliance

There are only 128 code points in the single-byte range of UTF-8. Only
32 of which are used for, almost-never-used or otherwise, control
characters. What do you imagine they would have put there instead?

At least Unicode doesn't do as badly as the first-draft ISO-UCS, which
didn't allow a C0/C1 control value in *any* position in UCS-2 or UCS-4,
therefore UCS-2 would encode only 192*192=36,864 codepoints as two bytes
(and 64 control characters as one byte), as opposed to UTF-16's 63,488
(including all control characters) two-byte characters.

For completeness, I'll note that conventional East Asian character
coding systems do have a higher information density compared to UTF-8,
but at a cost of not being self-synchronizing. And their single-byte
characters are in fact ASCII and C0/C1 controls, with only Japanese
Shift-
JIS encodings additionally having Katakana as single-byte characters.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27147] importlib docs do not mention PEP 420

2016-05-28 Thread Eric Snow

New submission from Eric Snow:

PEP 420 should be mentioned in the introduction section of the importlib docs.  
I'll push a change to fix this in a minute.

--
assignee: eric.snow
components: Documentation
messages: 266565
nosy: brett.cannon, eric.snow
priority: normal
severity: normal
stage: needs patch
status: open
title: importlib docs do not mention PEP 420
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



[issue27132] New assert method that checks an error message for a list of strings

2016-05-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The simple way is just write all possible variants 
('ENABLE.*NOAUTH|NOAUTH.*ENABLE').

The general way is to use itertools.permutations():

pattern = '|'.join(map('.*'.join, permutations(map(re.escape, strings

See also similar problem in issue19681. The first my patch used permutations(). 
But there was committed the patch with manually written variants.

--

___
Python tracker 

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



[issue27073] redundant checks in long_add and long_sub

2016-05-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I don't think this assert is needed. Nothing bad happens if the asserted 
condition is false. On other side, additional assert can slow down debug build 
(that is already slower than release build).

--

___
Python tracker 

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



[issue27073] redundant checks in long_add and long_sub

2016-05-28 Thread Oren Milman

Oren Milman added the comment:

And after quadruple checking myself, I found a foolish mistake - in that flow, 
x_add received at least one multiple-digit int (not necessarily two :().

I fixed that mistake in the comment. The updated diff file is attached.

--
Added file: http://bugs.python.org/file43045/issue27073.diff

___
Python tracker 

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



[issue27146] posixmodule.c needs stdio.h

2016-05-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


--
stage:  -> needs patch

___
Python tracker 

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



Re: Package setup best practice style question

2016-05-28 Thread Steven D'Aprano
On Sun, 29 May 2016 02:15 am, Gerald Britton wrote:

> suppose I have a simple python project setup like this:
> 
> Project diectory
>  prog.py
>  pkg directory
>   __init__.py
>   mod1.py
>class A:

If this is a single project, why do you set it up like this? Is there a
reason why you don't just have:

prog.py  # contains class A

or even:

prog.py
mod1.py  # contains class A


Or if the project is so big it needs to be a package, make it executable:

prog/
__init__.py
mod1.py
__main__.py


This layout is now executable using:

python -m prog

which automatically calls __main__.py.


But if you don't have a good reason for using a package, don't use a
package. Use the simplest project layout that solves your problem.

But for the rest of my comments, I'm going to assume that you DO have a good
reason.



> In order to have class A (unqualified) available from prog.py, there are a
> few options that I know about.  I'm currently considering two of them and
> would like some feedback on best practices.
> 
> 1. in pkg.__init__.py add:
> 
>from pkg.mod1 import A

This kinda-sorta defeats the purpose, or at least one purpose, of using a
package. Which is fine, so long as you understand that's what you are
doing.

Generally speaking, one of the purposes of using a package layout is to
allow unused sub-modules to be left unloaded unless needed. So pkg.mod1
doesn't get loaded unless you need it, in which case you explicitly call 

import pkg.mod1

or 

from pkg.mod1 import A

as you prefer. By putting that import in the pkg __init__ file, you're
making it automatically occur as soon as pkg is imported. Is that what you
intend? If so, then it is fine, and feel free to do it.

But in that case, why not just move class A into pkg/__init__.py?


> in prog.py add:
> 
>from pkg import A

*shrug* This entirely depends on the purpose and use of pkg. When you give
generic, meaningless names, I can only respond with wishy-washy, sit-on-
the-fence generic advice.

If the appropriate API is for callers to say:

from pkg import A

then this is the right way to design your package. But if the right API is:

from pkg.mod1 import A

then don't do it this way, instead do it as follows.


> 2. leave __init__.py empty
> in prog.py add:
> 
>  from pkg.mod1 import A
> 
> 
> Is there a preference or best practice that would indicate to prefer
> method
> 1 or method 2?  Are there methods 3, 4, 5, ... that I should consider that
> are even better?

One purpose of using a package is to have alternative implementations. For
instance I have a package which has to support Python 2.4 where the "with"
statement is not available, so I design it like this:

package/
__init__.py
module.py
module24.py

Since the user doesn't choose which implementation to use, I have this in
the init file:


try:
from module import thing
except SyntaxError:
from module24 import thing


and then the caller uses:

from package import thing

and is none the wiser.

On the other hand, if the user was supposed to choose, then I would have
then call:

from package.redblack import Tree
from package.avl import Tree
from package.scapegoat import Tree

and let the user choose which implementation they wanted.


-- 
Steven

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


[issue27146] posixmodule.c needs stdio.h

2016-05-28 Thread Phil Thompson

New submission from Phil Thompson:

posixmodule.c needs to #include  to get the declaration of ctermid(). 
On most platforms this happens as a side effect of including other .h files but 
does not on Android.

--
components: Library (Lib)
messages: 266561
nosy: philthompson10
priority: normal
severity: normal
status: open
title: posixmodule.c needs stdio.h
type: compile error
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



[issue27073] redundant checks in long_add and long_sub

2016-05-28 Thread Oren Milman

Oren Milman added the comment:

After giving it some more thought (while working on another, somewhat related 
issue - http://bugs.python.org/issue27145), I realized that that assert in 
long_add could further verify that the int x_add returned is a multiple-digit 
int (as x_add had received two multiple-digit ints to begin with).

The important thing about this updated assert is that it verifies that x_add 
didn't return a reference to an element in small_ints (as small ints must be 
single-digit ints), so negating it in-place is safe.

I have updated the assert and added an appropriate comment. The updated diff 
file is attached.

--
Added file: http://bugs.python.org/file43044/issue27073.diff

___
Python tracker 

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



[issue27132] New assert method that checks an error message for a list of strings

2016-05-28 Thread R. David Murray

R. David Murray added the comment:

Serhiy, how do you spell "match if and only if all of the following substrings 
exist in the target string, in any position" in a regex?  If we aren't going to 
add the method, we should add an example of how to do this to the 
assertMsgRegex docs.

--

___
Python tracker 

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



[issue27143] python 3.5 conflict with Mailman, ebtables and firewalld

2016-05-28 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

This is definitely not the right place to discuss this.  Please use the Mailman 
3 users mailing list or the Mailman Developers mailing list.

https://lists.mailman3.org/archives/list/mailman-us...@mailman3.org/
https://mail.python.org/mailman/listinfo/mailman-developers

--
status: open -> closed

___
Python tracker 

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



Package setup best practice style question

2016-05-28 Thread Gerald Britton
suppose I have a simple python project setup like this:

Project diectory
 prog.py
 pkg directory
  __init__.py
  mod1.py
   class A:

In order to have class A (unqualified) available from prog.py, there are a
few options that I know about.  I'm currently considering two of them and
would like some feedback on best practices.

1. in pkg.__init__.py add:

   from pkg.mod1 import A

in prog.py add:

   from pkg import A

2. leave __init__.py empty
in prog.py add:

 from pkg.mod1 import A


Is there a preference or best practice that would indicate to prefer method
1 or method 2?  Are there methods 3, 4, 5, ... that I should consider that
are even better?
-- 
Gerald Britton, MCSE-DP, MVP
LinkedIn Profile: http://ca.linkedin.com/in/geraldbritton
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27145] long_add and long_sub might return a new int where _ints[x] could be returned

2016-05-28 Thread Oren Milman

Changes by Oren Milman :


Added file: http://bugs.python.org/file43043/patchedCPythonTestOutput.txt

___
Python tracker 

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



[issue27145] long_add and long_sub might return a new int where _ints[x] could be returned

2016-05-28 Thread Oren Milman

Changes by Oren Milman :


Added file: http://bugs.python.org/file43042/CPythonTestOutput.txt

___
Python tracker 

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



[issue27145] long_add and long_sub might return a new int where _ints[x] could be returned

2016-05-28 Thread Oren Milman

New submission from Oren Milman:

 the current state 
>>> if is32BitCPython:
...   PyLong_SHIFT = 15
... elif is64BitCPython:
...   PyLong_SHIFT = 30
...
>>> # case A #
>>> a = 2 ** PyLong_SHIFT - 1
>>> b = 2 ** PyLong_SHIFT - 2
>>> a - b
1
>>> a - b is 1
True
>>> a + (-b) is 1
True
>>>
>>> # case B #
>>> a = 2 ** PyLong_SHIFT
>>> b = 2 ** PyLong_SHIFT - 1
>>> a - b
1
>>> a - b is 1
False
>>> a + (-b) is 1
False
>>>
>>> # case C #
>>> a = 2 ** PyLong_SHIFT + 1
>>> b = 2 ** PyLong_SHIFT
>>> a - b
1
>>> a - b is 1
False
>>> a + (-b) is 1
False
>>>

This behavior is caused by the implementation of long_add and long_sub:
Both long_add and long_sub check whether both a and b are single-digit 
ints, and then do (respectively):
return PyLong_FromLong(MEDIUM_VALUE(a) + MEDIUM_VALUE(b));
or
return PyLong_FromLong(MEDIUM_VALUE(a) - MEDIUM_VALUE(b));
Otherwise, long_add and long_sub call x_add or x_sub to do a calculation on 
the absolute values of a and b.
At last, long_add and long_sub negate the result of the calculation, if 
needed, and return the final result. 

Where both a and b are single-digit ints (e.g. case A), the result of the 
calculation is passed to PyLong_FromLong, which uses CHECK_SMALL_INT, and so a 
reference to an element of small_ints is returned where appropriate.
Where a and/or b are not single-digit ints (e.g. cases B and C), x_add or x_sub 
is called. Both x_add and x_sub don't check whether the result is a small int 
(except for a case in x_sub where the result is zero), and so long_add and 
long_sub might return a new int, even where an element of small_ints could be 
reused.

Due to the way CPython uses them, the issue is relevant to x_sub and not to 
x_add, as the calculation the former performs might result in a small int, 
while that of the latter would always result in a multiple-digit int.
(Except for being called by long_add and long_sub, x_add might be called by 
k_mul, but in that case also the calculation would certainly result in a 
multiple-digit int.)


 Note 
I am not sure whether this is actually an issue that we want to fix.
It seems to me that my proposed changes introduce a slight performance gain (in 
terms of memory, and probably also speed), and a more consistent behavior of 
CPython.
The performance gain would probably be much more relevant if and when greater 
default values are chosen for NSMALLNEGINTS and NSMALLPOSINTS.

Anyway, I guess documenting the issue here, along with a proposal for a fix, is 
better than nothing.
(As far as I know, since the unification of int and long in revision 40626, 
this issue never came up.)


 the proposed changes 
All of the proposed changes are in Objects/longobject.c:
1. in x_sub:
To make sure x_sub returns a small int where appropriate, I simply wrapped 
the return value of x_sub with the function maybe_small_long.

2. in long_sub:
The previous patch alone would create a nasty bug.
In case both a and b are negative, long_sub calls x_sub, and then negates 
the result in-place by doing 'Py_SIZE(z) = -(Py_SIZE(z));'.
If x_sub returned a reference to a statically allocated small int (which is 
not zero), long_sub would actually change that statically allocated small int.

To prevent that, I replaced that in-place negating with a call to 
_PyLong_Negate.

3. in _PyLong_Negate:
The previous patches, along with http://bugs.python.org/issue27073 (another 
issue I have opened recently), would cause long_sub to call _PyLong_Negate for 
a zero int, in case a and b are the same multiple-digit negative int. 
Moreover, in the default CPython branch, in case long_mul receives a 
multiple-digit negative int and zero, long_mul would call _PyLong_Negate for a 
zero int.

To prevent doing 'PyLong_FromLong(-MEDIUM_VALUE(x))' where x is a zero int, 
I have added a check before that (along with a little addition to the function 
comment), so that _PyLong_Negate would do nothing if x is a zero int. 
It should be noted that MEDIUM_VALUE also checks whether x is a zero int 
(for its own reasons), so thanks to the wisdom of nowadays compilers, the check 
I propose to add shouldn't introduce a performance penalty.
(Actually, when comparing the assembly of _PyLong_Negate (for win32) of the 
default CPython branch and the patched one, the latter looks simpler.)

With regard to similar changes made in the past, _PyLong_Negate wasn't 
changed since it replaced the macro NEGATE in revision 84698.

4. in x_sub:
The previous patches made it safe for x_sub to return a reference to a 
statically allocated small int, and thus made it possible to implement the 
following optimization.
In case a and b have the same number of digits, x_sub finds the most 
significant digit where a and b differ. Then, if there is no such digit, it 
means a and b are equal, and so x_sub does 'return 

Re: Coding systems are political (was Exended ASCII and code pages)

2016-05-28 Thread Ned Batchelder
On Saturday, May 28, 2016 at 11:16:39 AM UTC-4, wxjm...@gmail.com wrote:
> Le samedi 28 mai 2016 06:47:11 UTC+2, Rustom Mody a écrit :
> 
> > ...
> > [which AIUI is jmf's principal error]
> > 
> > ...
> 
> I'm very confident. It's only a question of time until
> the rest of the world dive into this mathematical
> absurdity.
> 
> With your math knowledge, it should not be too
> difficult to show it with a sheet of paper
> and a pencil. Hint: forget "bytes" and think
> "sets" and operators.

Let's please not re-open this debate.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27129] Wordcode, part 2

2016-05-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


Added file: http://bugs.python.org/file43040/word-jump-offsets.patch

___
Python tracker 

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



[issue27129] Wordcode, part 2

2016-05-28 Thread Serhiy Storchaka

Changes by Serhiy Storchaka :


Removed file: http://bugs.python.org/file43039/word-jump-offsets.patch

___
Python tracker 

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



[issue27101] Compilation of python (modules) for foreign target platform problem.

2016-05-28 Thread Ned Deily

Changes by Ned Deily :


--
nosy: +doko

___
Python tracker 

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



[issue27129] Wordcode, part 2

2016-05-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Here is a patch that implements only the first change -- makes jump offsets be 
in 16-bit units, not bytes. This is minimal change, it doesn't include 
refactoring.

--
Added file: http://bugs.python.org/file43039/word-jump-offsets.patch

___
Python tracker 

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



Re: Anonymous hyperlinks in restructuredtext

2016-05-28 Thread Ned Batchelder
On Saturday, May 28, 2016 at 8:58:41 AM UTC-4, Sergio Spina wrote:
> Il giorno sabato 28 maggio 2016 14:37:21 UTC+2, Ned Batchelder ha scritto:
> > On Saturday, May 28, 2016 at 8:28:35 AM UTC-4, Sergio Spina wrote:
> > > From the "restructuredtext markup specification":
> > > 
> > > >Anonymous hyperlink targets consist of an explicit markup
> > > >start (".. "), two underscores, a colon, whitespace, and a
> > > >link block; there is no reference name:
> > > >
> > > >.. __: anonymous-hyperlink-target-link-block
> > > >
> > > >An alternate syntax for anonymous hyperlinks consists of two
> > > >underscores, a space, and a link block:
> > > >
> > > >__ anonymous-hyperlink-target-link-block
> > > 
> > > Ok. I got the file "test.rst"
> > > 
> > > ...
> > > 
> > > Now I put a reference to link1_ and another to link2_
> > 
> > The docs say, "there is no reference name", so you cannot put a reference
> > to them.  You can use an anonymous syntax:
> > 
> > Jump to `my blog`__.
> > 
> > __ http://myblog.com
> > 
> > or you can use a named syntax:
> > 
> > Jump to `my blog`_.
> > 
> > .. _my blog: http://myblog.com
> > 
> > The ReST syntax can be arcane...
> > 
> > --Ned.
> 
> I need INTERNAL hyperlink targets, not external...

Can explain more about what kind of internal targets you need? Are these
sections with titles already?  Why are you interested in anonymous rather
than named links?

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


[issue27139] Increased test coverage for statistics.median_grouped

2016-05-28 Thread Julio C Cardoza

New submission from Julio C Cardoza:

I had signed the contributor agreement.!

--

___
Python tracker 

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



[issue27136] sock_connect fails for bluetooth (and probably others)

2016-05-28 Thread Guido van Rossum

Guido van Rossum added the comment:

> Why validate at all?

Because (at least for the IP 4/6 protocols) when you give a host name
Python's socket code will do a synchronous DNS lookup which would hold
up the entire event loop until it's done. This would be a major
problem in some cases, so we want to disallow it completely.

--

___
Python tracker 

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



[issue27121] imghdr does not support jpg files with Lavc bytes

2016-05-28 Thread SilentGhost

Changes by SilentGhost :


--
components: +Library (Lib)
nosy: +r.david.murray
stage:  -> test needed
type:  -> behavior
versions:  -Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5

___
Python tracker 

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



[issue27139] Increased test coverage for statistics.median_grouped

2016-05-28 Thread SilentGhost

Changes by SilentGhost :


--
nosy: +steven.daprano
stage:  -> patch review
type:  -> behavior

___
Python tracker 

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



[issue27144] concurrent.futures.as_completed() memory inefficiency

2016-05-28 Thread SilentGhost

Changes by SilentGhost :


--
stage:  -> patch review
versions:  -Python 3.2, Python 3.3, Python 3.4

___
Python tracker 

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



Re: Anonymous hyperlinks in restructuredtext

2016-05-28 Thread Lele Gaifax
Sergio Spina  writes:

> I need INTERNAL hyperlink targets, not external...

The difference is in how you use the two kinds of references: a named
hyperlink is referenced with the name followed by a single underscore, while
an anonymous one needs *two* underscores. So you have for example::

  Sample document
  ===
  
  See reST_ markup reference or `this section`__ below

  .. _rest:  
http://docutils.sourceforge.net/docs/ref/rst/restructuredtext.html#hyperlink-targets
  __ `Explain how it works`_

  Explain how it works
  

  This is an example...

Hope this helps,
ciao, lele.
-- 
nickname: Lele Gaifax | Quando vivrò di quello che ho pensato ieri
real: Emanuele Gaifas | comincerò ad aver paura di chi mi copia.
l...@metapensiero.it  | -- Fortunato Depero, 1929.

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


[issue27136] sock_connect fails for bluetooth (and probably others)

2016-05-28 Thread pyptr2

pyptr2 added the comment:

Thanks for looking into this. Some comments:

1.
yuri, I haven't tried the github repo. Is that where the development happens? 
The description suggests it is outdated since the adoption, but there are some 
commits that aren't in hg...?
Anyhow, the relevant code looks identical to me.

2.
guido, yes validation would be domain specific.
But, just to understand: why validate at all?
If I give create_connection() or sock_connect() an unresolved address, then I 
would expect some "yield from resolve(domain, name)" to happen, which would be 
getaddrinfo() for IP-domain. If that would hang the event loop on some 
platform, do it in an executor. This is exactly what create_server() already 
does, by the way.

3.
AF_UNPSEC seems to mean (AF_INET or AF_INET6) to a lot of people these days, 
possibly because getaddrinfo() accepts these three AFs. I am not 100% sure, but 
that is why I think it is reasonable that _ipaddr_info() handles AF_UNSPEC in 
the way it does.

4.
For my use case, anything that stops check_resolve() from raising when given a 
resolved non-IP address would be enough for now.

--

___
Python tracker 

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



[issue26526] In parsermodule.c, replace over 2KLOC of hand-crafted validation code, with a DFA

2016-05-28 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +berker.peksag

___
Python tracker 

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



[issue27144] concurrent.futures.as_completed() memory inefficiency

2016-05-28 Thread Grzegorz Grzywacz

Changes by Grzegorz Grzywacz :


--
keywords: +patch
Added file: http://bugs.python.org/file43038/issue27144.patch

___
Python tracker 

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



[issue27144] concurrent.futures.as_completed() memory inefficiency

2016-05-28 Thread Grzegorz Grzywacz

New submission from Grzegorz Grzywacz:

as_complite generator keeps reference of all passed futures until 
StopIteration. It may lead to serious memory inefficiency.

Solution is to remove reference from lists and yield future ad-hoc.

I have submitted patch and reproduce sample.

I can create backport for older versions if needed.

--
components: Library (Lib)
files: reproduce.py
messages: 266552
nosy: bquinlan, grzgrzgrz3
priority: normal
severity: normal
status: open
title: concurrent.futures.as_completed() memory inefficiency
type: resource usage
versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6
Added file: http://bugs.python.org/file43037/reproduce.py

___
Python tracker 

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



[issue27143] python 3.5 conflict with Mailman, ebtables and firewalld

2016-05-28 Thread Rubén Rivero Capriles

Rubén Rivero Capriles added the comment:

Hi. I decided to reinstall CentOs 7 and already installed Python 3.4 at 
http://www.codeghar.com/blog/install-latest-python-on-centos-7.html

I am downloading the tarball for mailman 3.0.3. I will greatly appreciate if 
you quickly let me know how to install it. I do not wish to use mailman bundler.

--

___
Python tracker 

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



Re: Anonymous hyperlinks in restructuredtext

2016-05-28 Thread Sergio Spina
Il giorno sabato 28 maggio 2016 14:37:21 UTC+2, Ned Batchelder ha scritto:
> On Saturday, May 28, 2016 at 8:28:35 AM UTC-4, Sergio Spina wrote:
> > From the "restructuredtext markup specification":
> > 
> > >Anonymous hyperlink targets consist of an explicit markup
> > >start (".. "), two underscores, a colon, whitespace, and a
> > >link block; there is no reference name:
> > >
> > >.. __: anonymous-hyperlink-target-link-block
> > >
> > >An alternate syntax for anonymous hyperlinks consists of two
> > >underscores, a space, and a link block:
> > >
> > >__ anonymous-hyperlink-target-link-block
> > 
> > Ok. I got the file "test.rst"
> > 
> > ...
> > 
> > Now I put a reference to link1_ and another to link2_
> 
> The docs say, "there is no reference name", so you cannot put a reference
> to them.  You can use an anonymous syntax:
> 
> Jump to `my blog`__.
> 
> __ http://myblog.com
> 
> or you can use a named syntax:
> 
> Jump to `my blog`_.
> 
> .. _my blog: http://myblog.com
> 
> The ReST syntax can be arcane...
> 
> --Ned.

I need INTERNAL hyperlink targets, not external...
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Anonymous hyperlinks in restructuredtext

2016-05-28 Thread Ned Batchelder
On Saturday, May 28, 2016 at 8:28:35 AM UTC-4, Sergio Spina wrote:
> From the "restructuredtext markup specification":
> 
> >Anonymous hyperlink targets consist of an explicit markup
> >start (".. "), two underscores, a colon, whitespace, and a
> >link block; there is no reference name:
> >
> >.. __: anonymous-hyperlink-target-link-block
> >
> >An alternate syntax for anonymous hyperlinks consists of two
> >underscores, a space, and a link block:
> >
> >__ anonymous-hyperlink-target-link-block
> 
> Ok. I got the file "test.rst"
> 
> ...
> 
> Now I put a reference to link1_ and another to link2_

The docs say, "there is no reference name", so you cannot put a reference
to them.  You can use an anonymous syntax:

Jump to `my blog`__.

__ http://myblog.com

or you can use a named syntax:

Jump to `my blog`_.

.. _my blog: http://myblog.com

The ReST syntax can be arcane...

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


Re: why for loop print only once after add if statement

2016-05-28 Thread meInvent bbird
when read my code again, i discover this error i fixed before

but forget to do for another branch of if statement

now fixed

On Saturday, May 28, 2016 at 6:19:23 PM UTC+8, meInvent bbird wrote:
> for item, i in enumerate(aa)
>   print item
> 
> this writing, it can print all values
> 
> for item, i in enumerate(aa)
>   if item == findit:
> print item
> 
> this only print the first value, means it only print once then not print 
> again,
> 
> where is wrong?

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


Re: why for loop print only once after add if statement

2016-05-28 Thread meInvent bbird
thanks, i discover that i misunderstand i and item,

they should be swapped

On Saturday, May 28, 2016 at 6:19:23 PM UTC+8, meInvent bbird wrote:
> for item, i in enumerate(aa)
>   print item
> 
> this writing, it can print all values
> 
> for item, i in enumerate(aa)
>   if item == findit:
> print item
> 
> this only print the first value, means it only print once then not print 
> again,
> 
> where is wrong?

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


how to write code generator for Isabelle by using pygments?

2016-05-28 Thread meInvent bbird
how to write code generator for Isabelle by using pygments?

i am thinking to write a machine learning code to generate code 
by learning example from Isabelle code

however, after google, not much information about this.
-- 
https://mail.python.org/mailman/listinfo/python-list


Anonymous hyperlinks in restructuredtext

2016-05-28 Thread Sergio Spina
>From the "restructuredtext markup specification":

>Anonymous hyperlink targets consist of an explicit markup
>start (".. "), two underscores, a colon, whitespace, and a
>link block; there is no reference name:
>
>.. __: anonymous-hyperlink-target-link-block
>
>An alternate syntax for anonymous hyperlinks consists of two
>underscores, a space, and a link block:
>
>__ anonymous-hyperlink-target-link-block

Ok. I got the file "test.rst"

==file test.rst==

Nunc ante nulla, porttitor vitae massa eu, mollis tristique
urna. Duis bibendum arcu est, elementum.

.. __: link1

Curabitur sed ultrices ex. Integer.

.. __: link2

Quisque ornare mollis risus eu fringilla. Sed eros mauris,
auctor.

Now I put a reference to link1_ and another to link2_

==end of file=

Let's try to pass it to docutils:

$ rst2latex test.rst > tests.tex
  test.rst:11: (ERROR/3) Anonymous hyperlink mismatch: 0 references
but 2 targets.
  See "backrefs" attribute for IDs.
  test.rst:10: (ERROR/3) Unknown target name: "link1".
  test.rst:10: (ERROR/3) Unknown target name: "link2".

Ok, I retry with the alternate syntax:

==file test.rst==

Nunc ante nulla, porttitor vitae massa eu, mollis tristique
urna. Duis bibendum arcu est, elementum.

__ link1

Curabitur sed ultrices ex. Integer.

__ link2

Quisque ornare mollis risus eu fringilla. Sed eros mauris,
auctor.

Now I put a reference to link1_ and another to link2_

==end of file=

Same error

$ rst2latex test.rst > test.tex
  test.rst:14: (ERROR/3) Anonymous hyperlink mismatch: 0 references
but 2 targets.
  See "backrefs" attribute for IDs.
  test.rst:13: (ERROR/3) Unknown target name: "link1".
  test.rst:13: (ERROR/3) Unknown target name: "link2".

Now, where is the error? How can I correctly set an internal
anonymous kyperlink?
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue27141] Fix collections.UserList shallow copy

2016-05-28 Thread Bar Harel

Bar Harel added the comment:

Added UserDict and UserList tests.
Keep in mind I am currently skipping UserDict's tests until we will implement 
the correct mechanism.
We do not need the same tests or functionality for UserString as UserString is 
immutable.

--
Added file: http://bugs.python.org/file43036/UserObj_tests.patch

___
Python tracker 

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



Re: why for loop print only once after add if statement

2016-05-28 Thread Steven D'Aprano
On Sat, 28 May 2016 08:19 pm, jobmatt...@gmail.com wrote:

> for item, i in enumerate(aa)
>   print item

Wrong way around. It should be:

for i, item in enumerate(aa):
print item

For example:

py> for i, item in enumerate(aa):
... print i, item
...
0 c
1 h
2 e
3 e
4 s
5 e


> this writing, it can print all values
> 
> for item, i in enumerate(aa)
>   if item == findit:
> print item
> 
> this only print the first value, means it only print once then not print
> again,

No, it doesn't not print the first value, it prints any value that equals
findit, whatever that is. If nothing equals findit, nothing will be
printed. Only items which equal findit will be printed.


py> findit = 'z'
py> for i, item in enumerate(aa):
... if item == findit:
... print i, item
...
py> findit = 'e'
py> for i, item in enumerate(aa):
... if item == findit:
... print i, item
...
2 e
3 e
5 e


-- 
Steven

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


Re: why for loop print only once after add if statement

2016-05-28 Thread Peter Otten
jobmatt...@gmail.com wrote:

> for item, i in enumerate(aa)
>   print item
> 
> this writing, it can print all values
> 
> for item, i in enumerate(aa)
>   if item == findit:
> print item
> 
> this only print the first value, means it only print once then not print
> again,

Assuming

aa = ["foo", "bar", "baz"]

and

findit = "bar"

the print statement will only be executed when findit == item.

First iteration of your for loop:

item = "foo"
if "foo" == "bar": # False
   print "foo" # not executed, nothing printed

Second iteration:

item = "bar"
if "bar" == "bar": # True
print "bar"# prints bar

Third iteration:

item = "baz"
if "baz" == "bar": # False
print "baz"# not executed, nothing printed

> where is wrong?

This depends on what you want to achieve. Can you tell us?

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


[issue27138] FileFinder.find_spec() docstring needs to be corrected.

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 8a49da84fc1d by Serhiy Storchaka in branch '3.5':
Issue #27138: Regenerate Python/importlib_external.h.
https://hg.python.org/cpython/rev/8a49da84fc1d

New changeset fb965ee44d5e by Serhiy Storchaka in branch 'default':
Issue #27138: Regenerate Python/importlib_external.h.
https://hg.python.org/cpython/rev/fb965ee44d5e

--

___
Python tracker 

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



[issue27141] Fix collections.UserList shallow copy

2016-05-28 Thread Bar Harel

Bar Harel added the comment:

I thought about UserDict, but adding this simple patch to UserDict will result 
in infinite recursion (due to how copy is implemented in there). We will have 
to change the implementation of UserDict's copy method.

--

___
Python tracker 

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



[issue25926] Clarify that the itertools pure python equivalents are only approximate.

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 35fa2ec1f237 by Serhiy Storchaka in branch 'default':
Merge heads (issue #25926).
https://hg.python.org/cpython/rev/35fa2ec1f237

--

___
Python tracker 

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



Re: why for loop print only once after add if statement

2016-05-28 Thread Sayth Renshaw
On Saturday, 28 May 2016 20:19:23 UTC+10, meInvent bbird  wrote:
> for item, i in enumerate(aa)
>   print item
> 
> this writing, it can print all values
> 
> for item, i in enumerate(aa)
>   if item == findit:
> print item
> 
> this only print the first value, means it only print once then not print 
> again,
> 
> where is wrong?

Enumerate is there to get rid of the i its not need enumerate is a generator.

list(enumerate(aa, start=1))

https://docs.python.org/3/library/functions.html#enumerate

In [1]: aa = range(10)

In [2]: list(enumerate(aa, start=1))
Out[2]: 
[(1, 0),
 (2, 1),
 (3, 2),
 (4, 3),
 (5, 4),
 (6, 5),
 (7, 6),
 (8, 7),
 (9, 8),
 (10, 9)]

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


Re: How can I debug silent failure - print no output

2016-05-28 Thread Sayth Renshaw
On Saturday, 28 May 2016 19:44:53 UTC+10, Sayth Renshaw  wrote:
> On Saturday, 28 May 2016 18:02:06 UTC+10, Sayth Renshaw  wrote:
> > So how do i get argparse to read the file arguments correctly?
> > 
> > Looking at the namespace it all gets pushed into path and extension remains 
> > empty.
> > 
> > [sayth@localhost pyXML]$ python3 racemeeting.py data/ *.xml
> > Namespace(extension='', path=['data/', '*.xml'])
> > 
> > This is the section I am running
> > 
> > parser = argparse.ArgumentParser()
> > parser.add_argument("path", nargs="+")
> > parser.add_argument('-e', '--extension', default='',
> > help='File extension to filter by.')
> > 
> > args = parser.parse_args()
> > name_pattern = "*" + args.extension
> > print(args)
> > 
> > Sayth
> 
> Ah if only i used argparse properly
> 
> python racemeeting.py data/ -e *.xml
> 
> Sayth

Which means I can rewrite it like this.

parser = argparse.ArgumentParser()
parser.add_argument("path", type=str, nargs="+")
parser.add_argument('-e', '--extension', default='',
help='File extension to filter by.')

args = parser.parse_args()
name_pattern = "*" + args.extension
my_dir = args.path[0]

for dir_path, subdir_list, file_list in os.walk(my_dir):
for name_pattern in file_list:
full_path = os.path.join(dir_path, name_pattern)

Cheers

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


why for loop print only once after add if statement

2016-05-28 Thread jobmattcon
for item, i in enumerate(aa)
  print item

this writing, it can print all values

for item, i in enumerate(aa)
  if item == findit:
print item

this only print the first value, means it only print once then not print again,

where is wrong?

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


Re: How can I debug silent failure - print no output

2016-05-28 Thread Sayth Renshaw
On Saturday, 28 May 2016 18:02:06 UTC+10, Sayth Renshaw  wrote:
> So how do i get argparse to read the file arguments correctly?
> 
> Looking at the namespace it all gets pushed into path and extension remains 
> empty.
> 
> [sayth@localhost pyXML]$ python3 racemeeting.py data/ *.xml
> Namespace(extension='', path=['data/', '*.xml'])
> 
> This is the section I am running
> 
> parser = argparse.ArgumentParser()
> parser.add_argument("path", nargs="+")
> parser.add_argument('-e', '--extension', default='',
> help='File extension to filter by.')
> 
> args = parser.parse_args()
> name_pattern = "*" + args.extension
> print(args)
> 
> Sayth

Ah if only i used argparse properly

python racemeeting.py data/ -e *.xml

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


Re: Exended ASCII and code pages [was Re: for / while else doesn't make sense]

2016-05-28 Thread Steven D'Aprano
On Sat, 28 May 2016 01:53 am, Rustom Mody wrote:

> On Friday, May 27, 2016 at 7:21:41 PM UTC+5:30, Random832 wrote:
>> On Fri, May 27, 2016, at 05:56, Steven D'Aprano wrote:
>> > On Fri, 27 May 2016 05:04 pm, Marko Rauhamaa wrote:
>> > 
>> > > They are all ASCII derivatives. Those that aren't don't exist.
>> > 
>> > *plonk*
>> 
>> That's a bit harsh, considering that this argument started ...
> 
> Is it now?
> For some reason I am reminded that when I was in junior school and we
> wanted to fight, we said "I am not talking to you!" made a certain gesture
> and smartly marched off.
> 
> I guess the gesture is culture-dependent and in these parts of the world
> it sounds like "*plonk*"

https://en.wikipedia.org/wiki/Plonk_%28Usenet%29



-- 
Steven

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


Re: How can I debug silent failure - print no output

2016-05-28 Thread Sayth Renshaw
So how do i get argparse to read the file arguments correctly?

Looking at the namespace it all gets pushed into path and extension remains 
empty.

[sayth@localhost pyXML]$ python3 racemeeting.py data/ *.xml
Namespace(extension='', path=['data/', '*.xml'])

This is the section I am running

parser = argparse.ArgumentParser()
parser.add_argument("path", nargs="+")
parser.add_argument('-e', '--extension', default='',
help='File extension to filter by.')

args = parser.parse_args()
name_pattern = "*" + args.extension
print(args)

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


[issue27141] Fix collections.UserList shallow copy

2016-05-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

What about UserDict?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

If the Python implementation is just a rough example, and the functools module 
always require the _functools module, exact behavior of the Python 
implementation is not very important, as well as its performance. If the 
functools module can be used without C implementation, Python implementation is 
just not completely compatible.

--

___
Python tracker 

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



[issue25926] Clarify that the itertools pure python equivalents are only approximate.

2016-05-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Nofar, thanks for the patch.

--
components: +Documentation -Interpreter Core
resolution:  -> fixed
status: open -> closed
title: problems with "times" keyword in itertools.repeat -> Clarify that the 
itertools pure python equivalents are only approximate.

___
Python tracker 

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



[issue25926] problems with "times" keyword in itertools.repeat

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset f66c30f66235 by Raymond Hettinger in branch '2.7':
Issue 25926:  Clarify that the pure python equivalents are only approximate.
https://hg.python.org/cpython/rev/f66c30f66235

--

___
Python tracker 

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



Re: IndexError for using pandas dataframe values

2016-05-28 Thread Peter Otten
Peter Otten wrote:

> Daiyue Weng wrote:
> 
>> Hi, I tried to use DataFrame.values to convert a list of columns in a
>> dataframe to a numpy ndarray/matrix,
>> 
>> matrix = df.values[:, list_of_cols]
>> 
>> but got an error,
>> 
>> IndexError: only integers, slices (:), ellipsis (...), numpy.newaxis
>> (None) and integer or boolean arrays are valid indices
>> 
>> so what's the problem with the list of columns I passed in?
>> 
>> many thanks
> 
> Your suggestively named list_of_cols is probably not a list. Have your
> script print its value and type before the failing operation:
> 
>   print(type(list_of_cols), list_of_cols)
>> matrix = df.values[:, list_of_cols]

Am Do Mai 26 2016, 09:21:59 schrieb Daiyue Weng:

[If you had sent this to the list I would have seen it earlier. 
Just in case you didn't solve the problem in the meantime:]

> it prints
> 
>  ['key1', 'key2']

So my initial assumption was wrong -- list_of_cols is a list. However, 
df.values is a numpy array and therefore expects integer indices:

>>> df = pd.DataFrame([[1,2,3],[4,5,6]], columns="key1 key2 key3".split())
>>> df
   key1  key2  key3
0 1 2 3
1 4 5 6

[2 rows x 3 columns]
>>> df.values
array([[1, 2, 3],
   [4, 5, 6]])
>>> df.values[["key1", "key2"]]
Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid literal for int() with base 10: 'key1'

(I get a different error message, probably because we use different versions 
of numpy)

To fix the problem you can either use integers

>>> df.values[:,[0, 1]]
array([[1, 2],
   [4, 5]])

or select the columns in pandas:

>>> df[["key1", "key2"]].values
array([[1, 2],
   [4, 5]])



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


[issue25926] problems with "times" keyword in itertools.repeat

2016-05-28 Thread Roundup Robot

Roundup Robot added the comment:

New changeset 613314c3f9ed by Raymond Hettinger in branch '3.5':
Issue 25926:  Clarify that the pure python equivalents are only approximate.
https://hg.python.org/cpython/rev/613314c3f9ed

New changeset e67e970de54a by Raymond Hettinger in branch 'default':
Issue 25926:  Clarify that the pure python equivalents are only approximate.
https://hg.python.org/cpython/rev/e67e970de54a

--
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: How can I debug silent failure - print no output

2016-05-28 Thread Sayth Renshaw
On Saturday, 28 May 2016 16:35:35 UTC+10, Sayth Renshaw  wrote:
> > >
> > >Ok after printing a few things i have found an error.
> > >
> > >def GetArgs():
> > >'''parse XML from command line'''
> > >parser = argparse.ArgumentParser()
> > >
> > >parser.add_argument("path", nargs="+")
> > >parser.add_argument('-e', '--extension', default='',
> > >help='File extension to filter by.')
> > >args = parser.parse_args()
> > >
> > >files = set()
> > >name_pattern = "*" + args.extension
> > >for path in args.path:
> > >files.update(glob.glob(os.path.join(path, name_pattern)))
> > >
> > >print(files)
> > >return files
> > >
> > >a = GetArgs()
> > >print(a)
> > >
> > >so printing the files or the call to the function returns set() not the 
> > >actual files.
> > 
> > Since you're constructing a set of filenames, this means it is probably 
> > returning the right kind of thing, but it is empty. That points to the glob 
> > not 
> > doing what you want or the for-loop not doing anything.
> > 
> > >[sayth@localhost pyXML]$ python3 racemeeting.py data/*.xml
> > >set()
> > >set()
> > >set()
> > 
> > So...  Add more prints!
> > 
> > Specificly, print(args) right after it is set, and put a print() _inside_ 
> > the 
> > loop before the call to files.update, probably printing "path", eg 
> > print("path 
> > =", path).
> > 
> > Then see what you learn.
> > 
> > Cheers,
> > Cameron Simpson 
> 
> Having done extra prints 
> 
> name_pattern = "*" + args.extension
> for path in args.path:
> print(args.path)
> print(path)
> files.update(glob.glob(os.path.join(path, name_pattern)))
> 
> it is getting the path and file however I think it is keeping the directory 
> so i am not getting files.
> 
> [sayth@localhost pyXML]$ python3 racemeeting.py data/*.xml
> ['data/20160528RAND0.xml']
> data/20160528RAND0.xml
> set()
> set()
> ['data/20160528RAND0.xml']
> data/20160528RAND0.xml
> 
> Sayth
Actually think I have found the cause and its really small but on way its 
called.
I was calling
python3 racemeeting.py data/*.xml
which gives the directory and file as the path 
['data/20160528RAND0.xml']

But with arguments separated by a space I actually receive what i thought I 
would get a path and extension such as

sayth@localhost pyXML]$ python3 racemeeting.py data/ *.xml
Namespace(extension='', path=['data/', '*.xml'])
Traceback (most recent call last):
  File "racemeeting.py", line 35, in 

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


[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-28 Thread Raymond Hettinger

Raymond Hettinger added the comment:

This kind of feature creep has a cost in tern complexity, maintenance, risk of 
bugs, loss of a clean example for others learn from, and in slower code.

--
assignee: rhettinger -> ncoghlan

___
Python tracker 

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



[issue26083] ValueError: insecure string pickle in subprocess.Popen on Python 2

2016-05-28 Thread Chi Hsuan Yen

Chi Hsuan Yen added the comment:

Great point!

--
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue27137] functools.partial: Inconsistency between Python and C implementations

2016-05-28 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

One problem with current Python implementation is that it doesn't support 
pickling. The ability of pickling functools.partial() is used in the pickle 
module for supporting __newobj_ex__ with pickle protocols 2 and 3 (issue24164) 
and for supporting pickling of operator.methodcaller() objects with keyword 
arguments (issue22955).

--
nosy: +serhiy.storchaka

___
Python tracker 

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



  1   2   >