[issue22594] Add a link to the regex module in re documentation

2017-02-22 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


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



[issue27788] platform module's version number doesn't match its docstring

2017-02-22 Thread Mariatta Wijaya

Changes by Mariatta Wijaya :


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



Re: concurrent futures, async futures and await

2017-02-22 Thread Ian Kelly
On Wed, Feb 22, 2017 at 12:50 PM, Nagy László Zsolt
 wrote:
>
> I'm in a situation where I would like to refactor some code to use
> native coroutine functions (aync def) instead of "normal" coroutines
> that use yield. Most of the code is asnyc, but some of the operations
> are performed in different threads (using concurrent.futures.Executor).
>
> We have concurrent.futures.Future and asyncio.Future. The former one an
> be used to execute code in a different thread, the later one can be
> awaited. Since concurrent.futures.Future does not implement the
> __await__ method, it cannot be awaited in an ioloop. For example, if I
> want to read from a file in a different thread, then I can submit that
> as a task to a ThreadPoolExecutor, but it is not possible to await for
> it. It is still possible to read from the file in the same thread, but
> obviously I do not want to do that (because file read can block the
> loop, and I do not want that).
>
> In other words: this makes it impossible to refactor coroutine functions
> to native coroutine functions.
>
> In my concrete use case, coroutines are used in tornado's ioloop, and
> tornado handles both types of futures *if they are yielded*. But once I
> switch to async def, yield becomes await and the native await is
> incompatible with concurrent.futures.Future.
>
> Both the await keyword and concurrent.futures.Future are in the standard
> library. They should be compatible. Is there a reason why
> concurrent.futures does not implement __await__ ?

My guess: because asyncio wouldn't know what to do with a
concurrent.futures.Future.

The tornado docs say that "You can also use
tornado.gen.convert_yielded to convert anything that would work with
yield into a form that will work with await":
http://www.tornadoweb.org/en/stable/guide/coroutines.html#python-3-5-async-and-await
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: any one used moviepy please come in!!! I need help, thanks!

2017-02-22 Thread sntc99
On Thursday, January 26, 2017 at 8:12:24 AM UTC+5:30, Tony Chen wrote:
> On Wednesday, January 25, 2017 at 8:34:01 PM UTC+13, Chris Angelico wrote:
> > On Wed, Jan 25, 2017 at 6:22 PM, Tony Chen  
> > wrote:
> > > This error can be due to the fact that ImageMagick is not installed on 
> > > your computer, or (for Windows users) that you didn't specify the path to 
> > > the ImageMagick binary in file conf.py, or.that the path you specified is 
> > > incorrect
> > 
> > So... is ImageMagick installed?
> > 
> > ChrisA
> 
> Okay... Yes it's installed. This problem has been solved haha. Thank you for 
> replying.

Hi Tony,
same issue facing by me. kindly help me
please list the solution
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29616] input() after restarting causes bug

2017-02-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

The implementation of standard input/output in IDLE was significantly changed 
in recent years.

--

___
Python tracker 

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



[issue29553] Argparser does not display closing parentheses in nested mutex groups

2017-02-22 Thread paul j3

paul j3 added the comment:

I played around with the patch 117.  I was wrong in thinking this was another 
case of excess brackets being wrongly purged.  The fix works by adding ending ] 
that were missing the original.  And it does add a symmetry to the code.  

But it is easy to construct a set of Actions that creates further errors.  For 
the 'inserts' to work correctly the mutually exclusive Actions have to be 
defined together.  So all the actions of the nested group have to be defined 
after the non nest actions of the parent group.  An optional positional can 
also cause problems.

This whole _format_actions_usage method was not written with nested groups in 
mind.  While this patch fixes one or two cases, it isn't robust.

I also don't like the idea of enshrining group nesting in the test_argparse.py 
file.  That fact that it works as well as it does is an accident, a feature, 
not an intentional behavior.

I haven't tested PR120 yet.  Dropping the inner brackets gives a cleaner 
display.  The nested brackets of 117 are hard to read, even if they are 
correct.  

Note that in http://bugs.python.org/issue22047 I proposed blocking nested 
groups, by raising an error.

The reason why it is possible to add either kind of group to a 
_MutuallyExclusiveGroup is because it inherits the add methods from 
_ActionsContainer.  Normally those group add methods are used by ArgumentParser 
which also inherits from _ActionsContainer.

It is possible to add a MutuallyExclusiveGroup to an ArgumentGroup, and that is 
somewhat useful.  It doesn't change the usage, but does let you group that set 
of Actions in the help lines.  But this nesting is not fully developed, as 
hinted at by a commeent in the method that copies 'parents':

def _add_container_actions
# add container's mutually exclusive groups
# NOTE: if add_mutually_exclusive_group ever gains title= and
# description= then this code will need to be expanded as above

--

___
Python tracker 

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



[issue29629] rgb_to_hls in colorsys.py

2017-02-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

0.8334 * 360 is equivalent to 300.

--

___
Python tracker 

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



[issue29533] urllib2 works slowly with proxy on windows

2017-02-22 Thread Julia Dolgova

Changes by Julia Dolgova :


--
pull_requests: +212

___
Python tracker 

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



[issue29629] rgb_to_hls in colorsys.py

2017-02-22 Thread Madhavendra Sharma

Madhavendra Sharma added the comment:

Please check examples in en.wikipedia.org/wiki/HSL_and_HSV

I picked one of them
for R = .750, B=0.250, G=0.750 
corresponding HLS value are H= 300 = (5.0 * 60) , L =  .5, S=.5

but colorsys.rgb_to_hls(0.75 ,  0.25,  0.75) gives following output
(0.8334, 0.5, 0.5)
h*60 = 0.8334 * 60 is not equal to 300

correct out put should be (5.0, 0.5, 0.5) or if h is multiplied by 60 then 
(300, 0.5, 0.5)

Thank you.
Madhavendra Sharma

--

___
Python tracker 

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



[issue29616] input() after restarting causes bug

2017-02-22 Thread Terry J. Reedy

Terry J. Reedy added the comment:

Characters typed before Enter are never sent the the execution process, so 
there are not even interpreted as a string, let alone a command.

Do you see exactly the following when you start IDLE?

Python 3.6.0 (v3.6.0:41df79263a11, Dec 23 2016, 08:06:12) [MSC v.1900 64 bit 
(AMD64)] on win32

If so, there must either be something different about your system, or you are 
doing something other than what I understand you to have done.

The 5 1/2-year-old report in not completely clear to me.  The behavior reported 
could have been affected by subsequent patches.

The only restart glitch I have noticed is that previous output very 
occasionally show up after the >>> prompt.

In any case, I cannot (intentionally) fix what I cannot see.

--

___
Python tracker 

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



[issue27788] platform module's version number doesn't match its docstring

2017-02-22 Thread Matthias Bussonnier

Changes by Matthias Bussonnier :


--
pull_requests: +211

___
Python tracker 

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



[issue29622] ast module doesn't support optional fields of Parser/Python.asdl

2017-02-22 Thread INADA Naoki

INADA Naoki added the comment:

AST type doesn't have any information about optional fields.  And I don't know 
it's worth enough to add it.
When AST is instantiated by keyword arguments, there are no check about absence 
of some fields.
I suppose we can just loosen positional arguments too.

current:

if (PyTuple_GET_SIZE(args) > 0) {
if (numfields != PyTuple_GET_SIZE(args)) {
PyErr_Format(PyExc_TypeError, "%.400s constructor takes %s"
 "%zd positional argument%s",
 Py_TYPE(self)->tp_name,
 numfields == 0 ? "" : "either 0 or ",
 numfields, numfields == 1 ? "" : "s");

will be:

if (PyTuple_GET_SIZE(args) > 0) {
if (numfields > PyTuple_GET_SIZE(args)) {
PyErr_Format(PyExc_TypeError, "%.400s constructor takes at most "
 "%zd positional argument%s",
 Py_TYPE(self)->tp_name,
 numfields, numfields == 1 ? "" : "s");

--

___
Python tracker 

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



[issue29533] urllib2 works slowly with proxy on windows

2017-02-22 Thread Julia Dolgova

Julia Dolgova added the comment:

I added variable smart_proxy_bypass into request module. If it's False then 
checking IP and FQDN of the host is skipped in proxy_bypass_registry function. 

I set the default value to False, because I think it's better when the 
behaviour of urllib corresponds to IE rather than previous versions of urllib. 
This will affect only NT-systems.

--
Added file: http://bugs.python.org/file46661/request.patch

___
Python tracker 

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



[issue29629] rgb_to_hls in colorsys.py

2017-02-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

All coordinates in RGB and HSV spaces are floating point numbers between 0.0 
and 1.0. In Wikipedia article h is a degree value between 0° and 360°.

Could you provide an example of rgb_to_hls() returning invalid result?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29627] configparser.ConfigParser.read() has undocumented/unexpected behaviour when given a bytestring path.

2017-02-22 Thread Berker Peksag

Changes by Berker Peksag :


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue29628] struct objects can no longer be pickled

2017-02-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

As a workaround you can make Struct pickleable:

from struct import Struct
import copy, copyreg
def pickle_struct(s):
return Struct, (s.format,)

copyreg.pickle(Struct, pickle_struct)

s1 = Struct('

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



[issue29629] rgb_to_hls in colorsys.py

2017-02-22 Thread Madhavendra Sharma

Changes by Madhavendra Sharma :


--
title: rgb_to_hls to colorsys.py -> rgb_to_hls in colorsys.py

___
Python tracker 

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



[issue29629] rgb_to_hls to colorsys.py

2017-02-22 Thread Madhavendra Sharma

New submission from Madhavendra Sharma:

Calculations in rgb_to_hls at line number 67 in python version 2.7.3 for "h" 
the hue component are not correct according reference mentioned in the same 
source file "en.wikipedia.org/wiki/HSV_color_space".


code snippet:

if r == maxc:
#h = (bc-gc) #current code
h = (bc-gc)%6 # suggestion
elif g == maxc:
h = 2.0+rc-bc
else:
#h = 4.0+gc-rc #current code
h = 4.0+rc-gc # suggestion

#h = (h/6.0) % 1.0 not required 

# h = 60 *h # component should be multiplied by 60 but it depends on user

--
messages: 288410
nosy: madhavendra.sharma
priority: normal
severity: normal
status: open
title: rgb_to_hls to colorsys.py
type: behavior
versions: Python 2.7, Python 3.5

___
Python tracker 

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



[issue29355] sqlite3: remove sqlite3_stmt_readonly()

2017-02-22 Thread Berker Peksag

Berker Peksag added the comment:

> - if (!sqlite3_stmt_readonly(self->statement->st)) {
> + if (self->statement->is_dml) {

Ah, yes now I understand what do you mean! :) I agree and this is already in my 
local branch to fix issue 28518.

--

___
Python tracker 

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



[issue29549] Improve docstring for str.index

2017-02-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I mean that this work is useless since it will be lost when convert str.index 
to Argument Clinic. Well, even when don't use Argument Clinic, but make 
str.index() be supported by inspect.signature(), the docstring should be 
significantly rewritten.

I think there are many other easy documentation issues for practicing.

And all proposed PRs change only the docstring of str.index. They don't touch 
docstrings of str.rindex, bytes.index, bytes.rindex, bytearray.index and 
bytearray.rindex. I can't approve such changes.

--

___
Python tracker 

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



[issue29628] struct objects can no longer be pickled

2017-02-22 Thread mesheb82

mesheb82 added the comment:

Thank you.

On Wed, Feb 22, 2017 at 9:22 PM, Serhiy Storchaka 
wrote:

>
> Serhiy Storchaka added the comment:
>
> > When I run the following code on Windows/Linux for < Python 3.6, I have
> no problems.
>
> You have a problem. Did you try to use the copied object? It is a broken
> Struct object.
>
> >>> copied = copy.deepcopy(this_fails)
> >>> copied.format
> >>> copied.size
> -1
> >>> copied.pack(42)
> Traceback (most recent call last):
>   File "", line 1, in 
> struct.error: pack expected -1 items for packing (got 1)
> >>> copied.unpack(b'abcd')
> Traceback (most recent call last):
>   File "", line 1, in 
> struct.error: unpack requires a bytes object of length -1
>
> Copying Struct object never worked. Now it raises an error rather than
> silently creating a broken object.
>
> --
> nosy: +serhiy.storchaka
> resolution:  -> not a bug
> stage:  -> resolved
> status: open -> closed
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue29628] struct objects can no longer be pickled

2017-02-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

> When I run the following code on Windows/Linux for < Python 3.6, I have no 
> problems.

You have a problem. Did you try to use the copied object? It is a broken Struct 
object.

>>> copied = copy.deepcopy(this_fails)
>>> copied.format
>>> copied.size
-1
>>> copied.pack(42)
Traceback (most recent call last):
  File "", line 1, in 
struct.error: pack expected -1 items for packing (got 1)
>>> copied.unpack(b'abcd')
Traceback (most recent call last):
  File "", line 1, in 
struct.error: unpack requires a bytes object of length -1

Copying Struct object never worked. Now it raises an error rather than silently 
creating a broken object.

--
nosy: +serhiy.storchaka
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



[issue29549] Improve docstring for str.index

2017-02-22 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Please everyone.  Ease up.  This is a very simple patch.  Copy what is done in 
str.find to str.index.  It doesn't need infinite discussion and debate.  I 
assigned this to Lisa to give her practice.  It wasn't intended to have five 
developers jump in and shove it back and forth.  Let's let simple things be 
simple and not waste the time of new contributors.

--

___
Python tracker 

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



First Live Online Python Syntax Checker

2017-02-22 Thread 17chiue
Hi everyone! :)

I just wanted to share with everyone a lightweight online tool I created called 
PythonBuddy (https://github.com/ethanchewy/PythonBuddy) which actively lints 
Python online.

I made this so that MOOCs like edX or codecademy could easily embed and use 
this on their courses. Also, PythonBuddy could help alleviate the frustrations 
with setting up a programming environment.

Just thought it might be helpful for those who want to program in Python online 
with a helpful live syntax checker.

Please leave a  if you found this project to be helpful!
I'm currently trying to convert this project to an XBlock so that online 
courses (like 6.00.1x) can embed a live python syntax checker for quizzes and 
assignments online.
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29549] Improve docstring for str.index

2017-02-22 Thread Xiang Zhang

Xiang Zhang added the comment:

Lisa, could you make a PR? It could let more developers see your patch.

--
nosy: +xiang.zhang
stage: needs patch -> patch review

___
Python tracker 

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



RE: Python application launcher (for Python code)

2017-02-22 Thread Deborah Swanson
Dennis Lee Bieber wrote, on February 22, 2017 6:48 PM
> 
> On Wed, 22 Feb 2017 10:50:18 -0800, "Deborah Swanson" 
>  declaimed the following:
> 
> 
> >first, and be able to use a running C version to check my Python 
> >version against. I couldn't afford Visual Studio, especially since 
> >there was
> 
>   Must have been quite some time ago, since VS Express 
> versions have been available since 2005.
> 
>   Granted, Express has limitations... But if porting C 
> code, you would likely not have been affected -- it's 
> unlikely your code used MFC...
> -- 
>   Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/

Didn't even look. Visual Studio has always been pricey, and it never
occurred to me that they might have a free or cheap version now.

This was last summer, and I ended up just writing the Python by looking
at the C, and attempting to verify against a data set I knew the correct
answers for. But it wasn't looking exactly right and I dropped the
project.

I'll remember VS Express if I revisit this, so thanks!

Deborah

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


[issue29626] Issue with spacing in argparse module while using help

2017-02-22 Thread paul j3

paul j3 added the comment:

We need to see the parser setup as well.  I've never seen a bug like this 
before.  The `usage` line suggests that you are using subparsers.

It might be better if you asked this on StackOverFlow with a repeatable code 
example.  That's a better place to get debugging help of your own code.  Come 
back here if others think this is a problem with `argparse` itself rather than 
your own setup.

--
nosy: +paul.j3

___
Python tracker 

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



[issue29549] Improve docstring for str.index

2017-02-22 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Serhiy, I'm not sure what you're referring to by "Just make docstrings in the 
style of of Argument Clinic descriptions".   For the time being, I would like 
the docstring to match that of str.find().  The point of the patch is to 
decouple the two.  

AC issues and migrations can wait.  At this point, AC adoption has been more 
disruptive that helpful in a number of cases.

--

___
Python tracker 

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



[issue29628] struct objects can no longer be pickled

2017-02-22 Thread mesheb82

New submission from mesheb82:

When I run the following code on Windows/Linux for < Python 3.6, I have no 
problems.  When I run in Python 3.6.0, I get the subsequent traceback.

I checked the release notes and only saw the following struct module note 
related to half-floats: Issue #11734

from struct import Struct
import copy
this_fails = Struct('

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



[issue29463] Add `docstring` field to AST nodes

2017-02-22 Thread INADA Naoki

INADA Naoki added the comment:

s/ #29522 / #29622 /

--

___
Python tracker 

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



[issue29463] Add `docstring` field to AST nodes

2017-02-22 Thread INADA Naoki

INADA Naoki added the comment:

OK, let's continue on #29522, and close this issue.

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



[issue29569] threading.Timer class: Continue periodical execution till action returns True

2017-02-22 Thread Raymond Hettinger

Raymond Hettinger added the comment:

Ideally, proposed API expansions should be based on a demonstrated user need. 
This API is over decade old and I don't recall a single user request for this 
functionality.  A quick scan of StackOverflow didn't turn-up any questions or 
answers on the subject.

I don't see anything intrinsically wrong with the idea, but in the absence of 
demonstrated need, it is likely to become unused cruft with it attendant burden 
on maintenance and cognitive load.

--
nosy: +rhettinger

___
Python tracker 

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



[issue29355] sqlite3: remove sqlite3_stmt_readonly()

2017-02-22 Thread Ma Lin

Ma Lin added the comment:

The "old way" is not using sqlite3_stmt_readonly().

Before 3.6.0, we only count rowcount for INSERT, UPDATE, DELETE, REPLACE:
https://hg.python.org/cpython/file/3.5/Modules/_sqlite/cursor.c#l689

These four statements can be representd by is_dml in PR 245:
https://github.com/python/cpython/pull/245/commits/cbeabf4044e9e1563d228e359b0e7952f369b42a#diff-5a6abb9997d51e693f3b24986659c857R88

So only change this line is ok, then restore the behavior before 3.6.0 exactly:

- if (!sqlite3_stmt_readonly(self->statement->st)) {
+ if (self->statement->is_dml) {
self->rowcount += (long)sqlite3_changes(self->connection->db);
} else {
self->rowcount= -1L;
}

Why it's better?
sqlite3_changes() only works for INSERT, UPDATE, DELETE. see:
https://sqlite.org/c3ref/changes.html
So using sqlite3_stmt_readonly() to determine statements is not necessary at 
all.

In addition, we can add a comment for code safe in statement.c.
+/* is_dml is used in two sites:
+1, determine statements for implicit BEGIN.
+2, determine statements for counting rowcount */
self->is_dml = (PyOS_strnicmp(p, "insert ", 7) == 0)
|| (PyOS_strnicmp(p, "update ", 7) == 0)
|| (PyOS_strnicmp(p, "delete ", 7) == 0)
|| (PyOS_strnicmp(p, "replace ", 8) == 0);

--

___
Python tracker 

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



[issue29594] implementation of __or__ in enum.auto

2017-02-22 Thread Ethan Furman

Ethan Furman added the comment:

I also think using leading underscores is a better way to signal that a 
particular value is "weird".

--

___
Python tracker 

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



[issue29594] implementation of __or__ in enum.auto

2017-02-22 Thread Ethan Furman

Ethan Furman added the comment:

@Julian: Giving flag combinations their own name can be useful.  For example, 
instead of seeing Color.GREEN|RED one can see Color.YELLOW .

@Marc: I'm not convinced this is a needed change as it doesn't seem to be a 
common method, nor one that cannot be easily implemented independently (perhaps 
as a recipe in the docs).

Are you aware of other enumerations that take this approach?

--

___
Python tracker 

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



Re: CSV

2017-02-22 Thread Nathan Ernst
One other thing besides the issues noted with filename - newline is set to
a space. It should be set to an empty string.

See: https://docs.python.org/3/library/csv.html#id3

Regards,
Nate

On Wed, Feb 22, 2017 at 3:52 PM,  wrote:

> On Wednesday, February 22, 2017 at 5:55:47 PM UTC, Braxton Alfred wrote:
> > Why does this not run?  It is right out of the CSV file in the Standard
> Lib.
> >
> > Python ver 3.4.4, 64 bit.
> >
> > import csv
> > """ READ EXCEL FILE """
> > filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv'
> > with open (filename, newline = ' ') as bp:
> > dialect = csv.excel
> > reader = csv.reader(bp)
> > for row in reader:
> > print (row)
> >
> > Marc
>
> Of course it will run, assuming that there are no syntax errors.
>
> Besides that using raw strings or forward slashes will probably help.
>
> Of course we don't actually know as you haven't shown us the actual error
> that you get, and our crystal balls broke down long ago owing to over use.
>
> You might like to read http://www.catb.org/~esr/faqs/smart-questions.html
> and then http://sscce.org/ or even http://stackoverflow.com/help/mcve and
> then ask again.
>
> Kindest regards.
>
> Mark Lawrence.
> --
> https://mail.python.org/mailman/listinfo/python-list
>
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29627] configparser.ConfigParser.read() has undocumented/unexpected behaviour when given a bytestring path.

2017-02-22 Thread David Ellis

New submission from David Ellis:

Related:
https://github.com/python/cpython/pull/242
https://bugs.python.org/issue29623

In the discussion over my PR for bpo-29623 it became clear that bytestring 
paths were also unsupported and it was suggested that that should be a separate 
issue (currently the PR adds checks for both types).

There is some possible odd behaviour as when given a bytestring path the method 
attempts to open the integer file descriptors for each character in the 
bytestring. This will most likely fail silently but if it does find an actual 
file descriptor it will attempt to read and then close the file.

Example from the discussion on the PR:

>>> import os
>>> import configparser
>>> k = os.open('/home/david/develop/cpython/Lib/test/cfgparser.1', os.O_RDONLY)
>>> k
3
>>> c = configparser.ConfigParser()
>>> c.read(b'\x03') 
[3]
>>> list(c)
['DEFAULT', 'Foo Bar']
>>> os.close(k)  # File has already been closed
OSError: [Errno 9] Bad file descriptor

Currently bytestrings do work correctly when provided as part of a list.

--
components: Library (Lib)
messages: 288394
nosy: David Ellis
priority: normal
severity: normal
status: open
title: configparser.ConfigParser.read() has undocumented/unexpected behaviour 
when given a bytestring path.
type: behavior
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



[issue29614] Additional implementation alternative to DictReader

2017-02-22 Thread Raymond Hettinger

Raymond Hettinger added the comment:

I concur with Serhiy, David, and Inada

Marking this as closed.

--
nosy: +rhettinger
resolution:  -> rejected
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



[issue29616] input() after restarting causes bug

2017-02-22 Thread Juan

Juan added the comment:

I am using Windows 10 64-bit.

>> sometimes whatever you pressed in step 3 disappears,
>
> When Shell is restarted by whatever means, any pending input, whether in 
> response to '>>>' or user input(), is cancelled and
> *should* disappear and not be left to look as if it were processed.  It  
> consistently does for me.
It doesn't for me.

> > doesn't respond to commands
> 
> When a user-coded input() is active, anything typed *should* be treated as 
> text and not interpreted as a command.
Even before enters?

At the comments of 
http://inventwithpython.com/blog/2011/11/29/the-things-i-hate-about-idle-that-i-wish-someone-would-fix/
 I found someone having the same problem as me, MrValdez ()

This is a relevant part of his comment:
> ANNOYANCE: input() doesn't play well when re-running a script when the script 
> is already running.
> 
> Here's a use case. A student types this program in IDLE:
>
> --
>
> x = input("Typ a word:")
> print (x)
>
> --
>
> They run the code. In the shell window, the student would notice the 
> mispelling. Without exiting the shell window,
> they would go edit the code and then press F5.
>
> The shell would still be running the previous code instead of restarting.
>
> In some of my exercises, the students would sometimes think their code are 
> broken when in reality, they already 
> got the solution. They were just running the older instance.
>
> This becomes common enough that I ask my students to exit the shell window 
> before running their scripts.

--

___
Python tracker 

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



[issue25008] Deprecate smtpd (based on deprecated asyncore/asynchat)

2017-02-22 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

aiosmtpd is coming along nicely:

http://aiosmtpd.readthedocs.io/en/latest/

We'll soon have a 1.0 release.  Still, I don't think it's worth pulling this 
into the stdlib.  But we could silently deprecate it and point to aiosmtpd in 
the docs.

--
assignee:  -> barry
components: +Documentation -Library (Lib)
title: Deprecate smtpd (based on deprecated asyncore/asynchat): write a new 
smtp server with asyncio -> Deprecate smtpd (based on deprecated 
asyncore/asynchat)
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



[issue15657] Error in Python 3 docs for PyMethodDef

2017-02-22 Thread Barry A. Warsaw

Barry A. Warsaw added the comment:

I think this bug has been fixed.

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



[issue29626] Issue with spacing in argparse module while using help

2017-02-22 Thread Falguniben Jhaveri

New submission from Falguniben Jhaveri:

When I use argparse the optional arguments with character "-p" and "-s" has 
improper spacing while using help/usage command.

Sample out put from argparse module:

usage: cli node list [-h] [-p] [-o]

Lists nodes in your current project.

optional arguments:
  -h, --help show this help message and exit
  // extra space after p
  -p , --projectid  
  -o, --org (For administrators only) Lists all the nodes in

--
components: Library (Lib)
messages: 288389
nosy: falu2010
priority: normal
severity: normal
status: open
title: Issue with spacing in argparse module while using help
versions: Python 2.7

___
Python tracker 

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



[issue29355] sqlite3: remove sqlite3_stmt_readonly()

2017-02-22 Thread Berker Peksag

Berker Peksag added the comment:

Thanks for the report, Ma.

> We can use the old way in here, the old way is even better IMO.

What do you mean by the old way? The use of switch statement?

--
dependencies: +execute("begin immediate") throwing OperationalError

___
Python tracker 

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



[issue29616] input() after restarting causes bug

2017-02-22 Thread Terry J. Reedy

Terry J. Reedy added the comment:

What OS are you using?

> 6. Bug.

This does not tell me what you think the bug is.

> sometimes whatever you pressed in step 3 disappears,

When Shell is restarted by whatever means, any pending input, whether in 
response to '>>>' or user input(), is cancelled and *should* disappear and not 
be left to look as if it were processed.  It consistently does for me.

> doesn't respond to commands

When a user-coded input() is active, anything typed *should* be treated as text 
and not interpreted as a command.

--

___
Python tracker 

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



[issue29098] document minimum sqlite version

2017-02-22 Thread Berker Peksag

Changes by Berker Peksag :


--
dependencies: +sqlite3: remove sqlite3_stmt_readonly()
type:  -> enhancement
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



[issue28518] execute("begin immediate") throwing OperationalError

2017-02-22 Thread Berker Peksag

Changes by Berker Peksag :


--
pull_requests: +210

___
Python tracker 

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



[issue29625] colorsys.rgb_to_hsv always returns saturation as 0 (python2.7 only)

2017-02-22 Thread Will Pittman

Will Pittman added the comment:

oh, thank you very much and sorry for my negligence!

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



[issue20438] inspect: Deprecate getfullargspec?

2017-02-22 Thread Berker Peksag

Changes by Berker Peksag :


--
pull_requests: +207

___
Python tracker 

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



[issue20438] inspect: Deprecate getfullargspec?

2017-02-22 Thread Berker Peksag

Changes by Berker Peksag :


--
pull_requests: +209

___
Python tracker 

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



[issue28814] Deprecation notice on inspect.getargvalues() is incorrect

2017-02-22 Thread Berker Peksag

Changes by Berker Peksag :


--
pull_requests: +208

___
Python tracker 

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



[issue28814] Deprecation notice on inspect.getargvalues() is incorrect

2017-02-22 Thread Berker Peksag

Changes by Berker Peksag :


--
pull_requests: +206

___
Python tracker 

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



Re: CSV

2017-02-22 Thread breamoreboy
On Wednesday, February 22, 2017 at 5:55:47 PM UTC, Braxton Alfred wrote:
> Why does this not run?  It is right out of the CSV file in the Standard Lib. 
> 
> Python ver 3.4.4, 64 bit.
> 
> import csv
> """ READ EXCEL FILE """
> filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv'
> with open (filename, newline = ' ') as bp:
> dialect = csv.excel
> reader = csv.reader(bp)
> for row in reader:
> print (row)
> 
> Marc

Of course it will run, assuming that there are no syntax errors.

Besides that using raw strings or forward slashes will probably help.

Of course we don't actually know as you haven't shown us the actual error that 
you get, and our crystal balls broke down long ago owing to over use.

You might like to read http://www.catb.org/~esr/faqs/smart-questions.html and 
then http://sscce.org/ or even http://stackoverflow.com/help/mcve and then ask 
again.

Kindest regards.

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


[issue29623] configparser.ConfigParser.read() does not accept Pathlib path as a single argument.

2017-02-22 Thread Berker Peksag

Changes by Berker Peksag :


--
stage:  -> patch review

___
Python tracker 

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



[issue29623] configparser.ConfigParser.read() does not accept Pathlib path as a single argument.

2017-02-22 Thread David Ellis

Changes by David Ellis :


--
pull_requests: +205

___
Python tracker 

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



Re: How to store properties

2017-02-22 Thread MRAB

On 2017-02-22 21:08, Gilmeh Serda wrote:

On Wed, 08 Feb 2017 09:31:09 -0800, Rob Gaddi wrote:


JSON's cute, but the format doesn't support inline comments.


{
"your_key": "whatever",
"COMMENT": "blah",
"meh": [
"yup",
"yep",
"yip"
],
"COMMENT": "mooh"
}

Works fine for me. As long as you don't have any use for your "COMMENT"
key elsewhere, it will continue to work.

That's a dictionary, so if you read it in and then write it out again, 
the order might change, and one of the comments will be lost.


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


[issue22549] bug in accessing bytes, inconsistent with normal strings and python 2.7

2017-02-22 Thread Marco Buttu

Changes by Marco Buttu :


--
pull_requests: +203

___
Python tracker 

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



[issue22273] abort when passing certain structs by value using ctypes

2017-02-22 Thread Eryk Sun

Eryk Sun added the comment:

Notes on fix-22273-02.diff:

In the second pass over _fields_, you can (should) use dict->length and 
dict->proto for array types instead of the _length_ and _type_ attributes. 

When reassigning stgdict->ffi_type_pointer.elements, if 
use_broken_old_ctypes_semantics is false, then you also have to allocate space 
for and copy the elements from the base class if any (i.e. if basedict && 
basedict->length > 0).

Regarding structs with bitfields and unions, we could add an stgdict flag to 
prevent passing them as arguments in the Unix X86_64 ABI -- e.g.   add a flag 
named TYPEFLAG_NONARGTYPE (0x400). ConvParam (callproc.c) and 
converters_from_argtypes (_ctypes.c) would raise an ArgumentError or TypeError 
in this case. Subclasses of structs and unions would inherit this flag value in 
StructUnionType_new.

The first pass in PyCStructUnionType_update_stgdict can set arrays_seen and 
bitfields_seen. Also, per the above suggestion, isArgType can be added. 
Moreover, since we don't have to worry about bitfields if we forbid passing 
structs with bitfields in this ABI, then MAX_ELEMENTS can be reduced to 8. For 
example:

#ifdef X86_64
#define MAX_ELEMENTS 8
isArgType = (!(stgdict->flags & TYPEFLAG_NONARGTYPE) &&
 isStruct && !bitfields_seen);
if (!isArgType) {
stgdict->flags |= TYPEFLAG_NONARGTYPE;
} else if (size <= 16 && arrays_seen) {
ffi_type *actual_types[MAX_ELEMENTS + 1];
int actual_type_index = 0;

/* second pass over _fields_ */

}

This is speculative based on how we address passing unions and structs with 
bitfields in the 64-bit Unix ABI. Raising a descriptive exception is at least 
an improvement over abruptly aborting the process.

--

___
Python tracker 

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



[issue22594] Add a link to the regex module in re documentation

2017-02-22 Thread Marco Buttu

Changes by Marco Buttu :


--
pull_requests: +204

___
Python tracker 

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



[issue29622] ast module doesn't support optional fields of Parser/Python.asdl

2017-02-22 Thread Thomas Kluyver

Changes by Thomas Kluyver :


--
nosy: +takluyver

___
Python tracker 

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



[issue29176] /tmp does not exist on Android and is used by curses.window.putwin()

2017-02-22 Thread Christian Heimes

Christian Heimes added the comment:

I think we can live with the fact some tmpfile() might write an error message 
if the system is broken. If user's tmp is not writeable, the user has more 
serious issues than a write to stdout inside curses module.

--

___
Python tracker 

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



[issue27200] make doctest in CPython has failures

2017-02-22 Thread Marco Buttu

Changes by Marco Buttu :


--
pull_requests: +202

___
Python tracker 

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



[issue28686] py.exe ignored PATH when using python3 shebang

2017-02-22 Thread Vinay Sajip

Changes by Vinay Sajip :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue29625] colorsys.rgb_to_hsv always returns saturation as 0 (python2.7 only)

2017-02-22 Thread Mark Dickinson

Mark Dickinson added the comment:

The arguments to rgb_to_hsv are supposed to be floating-point numbers in the 
range 0.0 to 1.0. That's documented here: 
https://docs.python.org/2/library/colorsys.html

> Coordinates in all of these color spaces are floating point values. In the 
> YIQ space, the Y coordinate is between 0 and 1, but the I and Q coordinates 
> can be positive or negative. In all other spaces, the coordinates are all 
> between 0 and 1.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue29623] configparser.ConfigParser.read() does not accept Pathlib path as a single argument.

2017-02-22 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



[issue29553] Argparser does not display closing parentheses in nested mutex groups

2017-02-22 Thread paul j3

paul j3 added the comment:

http://bugs.python.org/issue22047 "argparse improperly prints mutually 
exclusive options when they are in a group"

is similar.

-

There are two issues:

- the nesting of mutually exclusive groups

- the formatting of the usage in such cases.

Both have come up in one way or other in other bug reports.

Yes, it is possible to add a group to an existing group.  But from a testing 
standpoint the effect is the same as if you put all actions into one super 
group. 

More often people try to nest ArgumentGroups in MutuallyExclusiveGroups 
thinking that would give some sort of 'any' or 'and' logic within the 'xor' 
logic.  I have explored that in 

http://bugs.python.org/issue11588.  

Defining nestable groups is relatively easy.  Writing good usage is much harder.
 
The usage formatter is brittle.  It creates a big string, strips out 'excess' 
characters (the problem here), and then splits and reassembles the string 
(leading to assertion errors if the metavars contain funny characters).

In 

http://bugs.python.org/issue11874  

I submitted a patch that substantially rewrites the usage formatter.  The idea 
was to keep the action strings separate until the last moment.  While I haven't 
tested it with the current problem, I did use it in my nested-groups coding.

While I'm not opposed to patching the usage formatting in bits and pieces, we 
should do so while fully aware of the big picture.  Little patches tend to make 
brittle code even more brittle.

--

___
Python tracker 

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



Re: CSV

2017-02-22 Thread Jussi Piitulainen
Braxton Alfred writes:

> Why does this not run?  It is right out of the CSV file in the Standard Lib.
>
>
>  
>
> Python ver 3.4.4, 64 bit.
>
>  
>
>  
>
>  
>
> import csv
> """ READ EXCEL FILE """
> filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv'

'\b' is backspace. A couple of months ago I actually met a filename with
a backspace in it. I renamed the file. Or maybe I removed it, I forget.

But don't you get a SyntaxError from '\user'?

[snip]
-- 
https://mail.python.org/mailman/listinfo/python-list


concurrent futures, async futures and await

2017-02-22 Thread Nagy László Zsolt

I'm in a situation where I would like to refactor some code to use
native coroutine functions (aync def) instead of "normal" coroutines
that use yield. Most of the code is asnyc, but some of the operations
are performed in different threads (using concurrent.futures.Executor).

We have concurrent.futures.Future and asyncio.Future. The former one an
be used to execute code in a different thread, the later one can be
awaited. Since concurrent.futures.Future does not implement the
__await__ method, it cannot be awaited in an ioloop. For example, if I
want to read from a file in a different thread, then I can submit that
as a task to a ThreadPoolExecutor, but it is not possible to await for
it. It is still possible to read from the file in the same thread, but
obviously I do not want to do that (because file read can block the
loop, and I do not want that).

In other words: this makes it impossible to refactor coroutine functions
to native coroutine functions.

In my concrete use case, coroutines are used in tornado's ioloop, and
tornado handles both types of futures *if they are yielded*. But once I
switch to async def, yield becomes await and the native await is
incompatible with concurrent.futures.Future.

Both the await keyword and concurrent.futures.Future are in the standard
library. They should be compatible. Is there a reason why
concurrent.futures does not implement __await__ ? 


Thanks,

  Laszlo



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


[issue29625] colorsys.rgb_to_hsv always returns saturation as 0 (python2.7 only)

2017-02-22 Thread Will Pittman

Changes by Will Pittman :


--
title: colorsys.rgb_to_hsv  always returns saturation as 0 (python2.7.13 only) 
-> colorsys.rgb_to_hsv  always returns saturation as 0 (python2.7 only)

___
Python tracker 

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



[issue28129] assertion failures in ctypes

2017-02-22 Thread Vinay Sajip

Changes by Vinay Sajip :


--
nosy: +vinay.sajip

___
Python tracker 

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



[issue29625] colorsys.rgb_to_hsv always returns saturation as 0 (python2.7.13 only)

2017-02-22 Thread Will Pittman

Will Pittman added the comment:

The bug appears to be caused by the difference in division
symbols between python3 vs python2.

The issue appears to be resolved if you add the following line to the
`/usr/lib/python2.7.13/colorsys.py` module (or if all arguments are converted 
to floats).

from __future__ import division

I noticed that this bug persists all the back to at least python2.7.10

--

___
Python tracker 

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



[issue29625] colorsys.rgb_to_hsv always returns saturation as 0 (python2.7.13 only)

2017-02-22 Thread Will Pittman

New submission from Will Pittman:

colorsys.rgb_to_hsv appears to be broken on python2.7.13 (on archlinux).
Saturation is always reported as 0.

ex:

import colorsys
rgb_to_hsv( 127, 116, 18 )
>>> (0.1, 0, 127)

--
messages: 288380
nosy: Will Pittman
priority: normal
severity: normal
status: open
title: colorsys.rgb_to_hsv  always returns saturation as 0 (python2.7.13 only)
type: behavior
versions: Python 2.7

___
Python tracker 

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



[issue29624] Python 3.5.3 x86 web installer cannot install launcher

2017-02-22 Thread Steve Dower

New submission from Steve Dower:

For some reason, the install bootstrapper for 3.5.3 x86 embedded the wrong hash 
value for launcher.msi. As a result, it will fail to download the file and 
install will be aborted.

The workaround is to deselect the launcher from being installed, and use the 
64-bit installer to install the launcher. Or alternatively, install Python 3.6 
to get the later version of the installer, which will then automatically skip 
it for the 3.5 installer.

Python 3.6 is unaffected, so this may just have been a build glitch, but it 
needs investigation and testing so it doesn't happen again. (Adding a /layout 
test after uploading is an easy way to test this.)

--
assignee: steve.dower
components: Windows
messages: 288379
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: critical
severity: normal
stage: test needed
status: open
title: Python 3.5.3 x86 web installer cannot install launcher
type: crash
versions: Python 3.5

___
Python tracker 

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



RE: Python application launcher (for Python code)

2017-02-22 Thread Deborah Swanson
Grant Edwards wrote, on February 22, 2017 7:52 AM
> 
> On 2017-02-21, Chris Warrick  wrote:
> 
> > Git Bash, or basically msys, is pretty reasonable. But if you are on

> > Windows 10, you might like the built-in Windows Subsystem for Linux 
> > (aka Bash on Ubuntu on Windows) more - it's real Linux that runs 
> > alongside Windows, but less crazy than Cygwin.
> 
> Cygwin is indeed crazy.
> 
> I've been in awe of it for 15 years.
> 
> Even  sshd works (if you're carefuly and a little lucky).
> 
> It's a medium-sized miracle that Cygwin works as well as it 
> does.  For a few years, I distributed and supported a custom 
> snapshot of base Cygwin plus a software development kit for a 
> specific hardware product.  It was not fun.  Cygwin is a bit 
> brittle and presents many mysterious failure modes. But, had 
> I not seen it myself, I never would have believed Cygwin 
> would work in a useful way.
> 
> In then end, we gave up on supporting Cygwin for our Windows 
> customers.  It's actually easier to install Ubuntu in a VM 
> and have them use that.  The last customer I had who was 
> trying to install Cyginw and use it for development spent 
> weeks and never got everything to work with Cygwin.  About 
> two hours after I finally convinced him to try Linux on a VM, 
> I got an e-mail saying his Linux VM as installed, the 
> devleopment tools were installed on that, and he was happily 
> building his applications.
> 
> -- 
> Grant Edwards   grant.b.edwardsYow! I 
> know how to do
>   at   SPECIAL EFFECTS!!
>   gmail.com

I tried Cygwin once. I had a fairly complex library of C functions I
wanted to rewrite portions of in Python, and I wanted to run the C code
first, and be able to use a running C version to check my Python version
against. I couldn't afford Visual Studio, especially since there was
only this one project to use it for, and Cygwin seemed like a reasonable
alternative. Cygwin has an avid fan club of followers for using Cygwin
to write and execute C code, and as an IDE, I think. But I couldn't get
it to run right, and I usually get along pretty well with software. Not
an experience I'm eager to repeat.

Deborah

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


Re: If statement with or operator

2017-02-22 Thread Rhodri James

On 22/02/17 17:38, Peter Pearson wrote:

On Wed, 22 Feb 2017 22:33:31 +0530, Ganesh Pal wrote:
[snip]

I  need suggestion on the if statement in the below code  , all that I was
trying to do was to add a check  i.e if any one of the functions return
True then  break the loop.

 end_time = time.time() + 300
umount_completed = False
while time.time() < end_time:
if attempt_umount() is True or df_output_lines() is True:
   logging.info("umount completed sucessfully")
   umount_completed = True
   break
time.sleep(15)
assert umount_completed, "ERROR: The umount failed Exiting"


The if statement is healthy and reasonable.


Quite to the contrary, the if statement should be discouraged with great 
vigour unless the OP is certain that the functions return only the 
object True for success, and not just values that are true in a boolean 
context.


  if attempt_umount() or df_output_lines():

is far more likely to do what you expect.


--
Rhodri James *-* Kynesim Ltd
--
https://mail.python.org/mailman/listinfo/python-list


[issue29623] configparser.ConfigParser.read() does not accept Pathlib path as a single argument.

2017-02-22 Thread David Ellis

New submission from David Ellis:

Trying to use configparser.ConfigParser.read on a pathlib object results in a 
TypeError. If supplied in a list it works as expected.

Repro:
>>> import pathlib, configparser
>>> configparser.ConfigParser().read(pathlib.Path('some.ini'))

TypeError: 'PosixPath' object is not iterable

The issue appears to be line 690 which checks for str before attempting to 
iterate and doesn't check for os.PathLike (or bytes?).

This was actually mentioned as an example where pathlib did not work here: 
https://bugs.python.org/issue22570

--
components: Library (Lib)
messages: 288378
nosy: David Ellis
priority: normal
severity: normal
status: open
title: configparser.ConfigParser.read() does not accept Pathlib path as a 
single argument.
type: behavior
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



Re: python decorator

2017-02-22 Thread Irmen de Jong
On 22-2-2017 8:39, Argentinian Black ops lll wrote:
> Thanks for the quick response...! you saved me a lot of time, thank you!
> 

I don't know if you want/have to use your own custom caching decorator, but are 
you
aware of the lru_cache decorator that's part of the standard library?

https://docs.python.org/3/library/functools.html#functools.lru_cache


Irmen

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


Re: CSV

2017-02-22 Thread Irmen de Jong
On 22-2-2017 18:26, Braxton Alfred wrote:
> Why does this not run?  It is right out of the CSV file in the Standard Lib.

What does "not run" mean.
We can't help if you are not telling us the exact error message you're getting 
(if any)


> filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv'

That being said, there's at least a problem with this line because you're not 
escaping
the backslashes. So the resulting filename string is not what you intended it 
to be (try
printing it to see what I mean).

Several solutions possible:
- switch to using forward slashes /  this works on windows too.
- use a raw string literal  r'.'
- or escape the backslashes \\


Irmen

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


Re: CSV

2017-02-22 Thread Chris Angelico
On Thu, Feb 23, 2017 at 4:26 AM, Braxton Alfred  wrote:
> filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv'

Use forward slashes instead.

Also, if something isn't working, post the actual output - probably an
exception. Don't assume that we can read your mind, even when we can.

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


CSV

2017-02-22 Thread Braxton Alfred
Why does this not run?  It is right out of the CSV file in the Standard Lib.


 

Python ver 3.4.4, 64 bit.

 

 

 

import csv
""" READ EXCEL FILE """
filename = 'c:\users\user\my documents\Braxton\Excel\personal\bp.csv'
with open (filename, newline = ' ') as bp:
dialect = csv.excel
reader = csv.reader(bp)
for row in reader:
print (row)

 

 

Marc

 

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


[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-22 Thread slytomcat

slytomcat added the comment:

I've closed pull request on GitHub.

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



[issue29603] More informative Queue class: new method that returns number of unfinished tasks

2017-02-22 Thread slytomcat

slytomcat added the comment:

I can't fully agree with this:
>Queue objects are primarily about managing a queue of inputs.  
>Monitoring and managing consumers is another (mostly orthogonal) realm.

Monitoring of consumers is already added via task_done() and join() methods. At 
least this two methods allows to understand that all consumers are in idle 
state.
The unfinished() - is just functional extension to this existing functionality.

>For other users, the new method is problematic because it is distracting
>and prone to misuse (potentially out-of-date upon return and potentially 
>meaningless if task_done isn't being used).  I believe the new method 
>will cause more problems than it fixes.

This sounds reasonable because I also understand that this method is not usable 
in all cases as in most cases task_done is not used.

Probably my idea for method unfinished is really not so good...

Actually I've manage to find unpublished Queue.unfinished_tasks variable just 
in several minutes when I tried to find solution for threaded PoolExecutor. 
Hope that any curious developer can find it too.

I don't mind if you close this CR. 

Thanks for pleasant discussion.

--

___
Python tracker 

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



Re: python decorator

2017-02-22 Thread Ian Kelly
On Wed, Feb 22, 2017 at 8:16 AM, Pavol Lisy  wrote:
> Maybe this technique could be reusable (and maybe part of functools?)
>
> With this decorator:
>
> def wrap_args(decorator):
> def decor_out(*args, **kwargs):
> def decor_in(func):
> return decorator(func, *args, **kwargs)
> return decor_in
> return decor_out
>
> Alfredo needs to change only (*) next 2 lines:
>
> def fun_cache(function):
> memo = {}
>
> to:
>
> @wrap_args
> def fun_cache(function, cache):
> memo = cache
>
> (*) - Steve's improvements (for example using functools.wraps) are
> good to consider as well! :)
> (but maybe catching TypeError could more problems hide than solve)

When all the arguments are optional it's generally desirable that @foo
and @foo() be equivalent. See:

https://blogs.it.ox.ac.uk/inapickle/2012/01/05/python-decorators-with-optional-arguments/

I would augment that example by making the optional arguments
keyword-only to prevent accidentally passing one as the function to be
decorated. Hopefully this feature would also be part of any general
reusable solution.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: If statement with or operator

2017-02-22 Thread Peter Pearson
On Wed, 22 Feb 2017 22:33:31 +0530, Ganesh Pal wrote:
[snip]
> I  need suggestion on the if statement in the below code  , all that I was
> trying to do was to add a check  i.e if any one of the functions return
> True then  break the loop.
>
>  end_time = time.time() + 300
> umount_completed = False
> while time.time() < end_time:
> if attempt_umount() is True or df_output_lines() is True:
>logging.info("umount completed sucessfully")
>umount_completed = True
>break
> time.sleep(15)
> assert umount_completed, "ERROR: The umount failed Exiting"

The if statement is healthy and reasonable.  If you have a guarantee
that attempt_umount and df_output_lines return only True or False,
then this would be equivalent:

if  attempt_umount() or df_output_lines():

However, at the bottom, checking for completion with "assert" is (as
I understand it) weak because assertions may be ignored in optimized
situations.  I'd raise RuntimeError.

Also, an consider this alternative loop structure:

while not (attempt_umount() or df_output_lines()):
if end_time < time.time():
raise RuntimeError("The umount failed.  Exiting.")
time.sleep(15)
logging.info("umount completed successfully")

-- 
To email me, substitute nowhere->runbox, invalid->com.
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: If statement with or operator

2017-02-22 Thread alister
On Wed, 22 Feb 2017 22:33:31 +0530, Ganesh Pal wrote:

> Hello Friends,
> 
> I  need suggestion on the if statement in the below code  , all that I
> was trying to do was to add a check  i.e if any one of the functions
> return True then  break the loop.
> 
> 
>  end_time = time.time() + 300
> umount_completed = False while time.time() < end_time:
> if attempt_umount() is True or df_output_lines() is True:
>logging.info("umount completed sucessfully")
>umount_completed = True break
> time.sleep(15)
> assert umount_completed, "ERROR: The umount failed Exiting"
> 
> Can this be optimized better  , please suggest.  I am on Linux and
> Python 2.7
> 
> 
> Regards.
> Ganesh

a simple
 if attempt_umount() or df_output_lines():

would suffice
(Q argument on whether the unnecessary is True makes the code more 
readable or not)

there may also be better ways to perform your unmount but without knowing 
the details of the code it is difficult to say 



-- 
"Nuclear war would really set back cable."
- Ted Turner
-- 
https://mail.python.org/mailman/listinfo/python-list


If statement with or operator

2017-02-22 Thread Ganesh Pal
Hello Friends,

I  need suggestion on the if statement in the below code  , all that I was
trying to do was to add a check  i.e if any one of the functions return
True then  break the loop.


 end_time = time.time() + 300
umount_completed = False
while time.time() < end_time:
if attempt_umount() is True or df_output_lines() is True:
   logging.info("umount completed sucessfully")
   umount_completed = True
   break
time.sleep(15)
assert umount_completed, "ERROR: The umount failed Exiting"

Can this be optimized better  , please suggest.  I am on Linux and Python
2.7


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


[issue29463] Add `docstring` field to AST nodes

2017-02-22 Thread Matthias Bussonnier

Matthias Bussonnier added the comment:

thank you for your work on the AST, I know many developers are looking forward 
to improvement and stabilisation with the hope of having it stable (and 
documented) in the stdlib at some point. 

The recent change in PR 46 now change (at least) the constructor of 
`ast.Module` to take a second mandatory parameter (the docstring). 

I know the ast is autogenerated and "use at your own risk". But IPython for 
example, use `mod = ast.Module([nodes])`, with the second mandatory parameter 
added to Module that make it incompatible with current Python 3.7. 
Well it's long until it's released, and we can patch things, but I'm sure we 
are not the only one in this case, and we'd like older version of IPython to 
still be compatible with Python 3.7, so if  `Module()`'s second parameter (the 
docstring) could be optional, that would be great. 

I would be happy if it raise a deprecation warning that it will be required in 
the future.

I'm of course speaking about `Module` because that's the first error I 
encountered, but I'm guessing it applies to other changed AST nodes. 

Thanks.

--
nosy: +mbussonn

___
Python tracker 

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



[issue29622] ast module doesn't support optional fields of Parser/Python.asdl

2017-02-22 Thread Matthias Bussonnier

Matthias Bussonnier added the comment:

Duplicating my comment of 29463 who was in a race condition with this issue:


thank you for your work on the AST, I know many developers are looking forward 
to improvement and stabilisation with the hope of having it stable (and 
documented) in the stdlib at some point. 

The recent change in PR 46 now change (at least) the constructor of 
`ast.Module` to take a second mandatory parameter (the docstring). 

I know the ast is autogenerated and "use at your own risk". But IPython for 
example, use `mod = ast.Module([nodes])`, with the second mandatory parameter 
added to Module that make it incompatible with current Python 3.7. 
Well it's long until it's released, and we can patch things, but I'm sure we 
are not the only one in this case, and we'd like older version of IPython to 
still be compatible with Python 3.7, so if  `Module()`'s second parameter (the 
docstring) could be optional, that would be great. 

I would be happy if it raise a deprecation warning that it will be required in 
the future.

I'm of course speaking about `Module` because that's the first error I 
encountered, but I'm guessing it applies to other changed AST nodes. 

Thanks.
---

--
nosy: +mbussonn

___
Python tracker 

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



[issue29463] Add `docstring` field to AST nodes

2017-02-22 Thread STINNER Victor

STINNER Victor added the comment:

This issue broke the ast API. Copy of the following comment on the PR:
https://github.com/python/cpython/pull/46#issuecomment-281721296
---
Carreau: Thanks for this ! Improvement to the AST are welcome !

Would it have been possible to make the docstring optional ? (It's already 
breaking things, like IPython).

Should I comment on upstream bpo ?
---

I created the issue #29622 to fix this.

--

___
Python tracker 

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



[issue29622] ast module doesn't support optional fields of Parser/Python.asdl

2017-02-22 Thread STINNER Victor

New submission from STINNER Victor:

The _ast.AST constructor requires a tuple with the same number of items than 
the fields list.

Example with Raise:

ASDL: Raise(expr? exc, expr? cause)

>>> import _ast
>>> _ast.Raise()
<_ast.Raise object at 0x7fc2ca7dee90>
>>> _ast.Raise(1)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: Raise constructor takes either 0 or 2 positional arguments
>>> _ast.Raise(1, 2)
<_ast.Raise object at 0x7fc2ca7def60>

The cause field is optional in the ASDL, but required in the _ast module.

A tradeoff would be to add the minimum and maximum number of fields to _ast.AST.

This issue should prevent API breakage caused by the new docstring attribute 
added by issue #29463.

--
messages: 288372
nosy: haypo, inada.naoki
priority: normal
severity: normal
status: open
title: ast module doesn't support optional fields of Parser/Python.asdl
type: enhancement
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



[issue29621] telnetlib.Telnet.write gives confusing error message when a string is passed in

2017-02-22 Thread John Hagen

New submission from John Hagen:

I was recently helping someone learn Python 3 from Python 2 and they were 
confused by error resulting from the following easy-to-make mistake:

import telnetlib

tn = telnetlib.Telnet('localhost')
tn.write('hello')

Traceback (most recent call last):
  File "/Users/user/PycharmProjects/python-test/main.py", line 4, in 
tn.write('hello')
  File 
"/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/telnetlib.py", 
line 287, in write
if IAC in buffer:
TypeError: 'in ' requires string as left operand, not bytes

What is confusing is that the solution is to pass in `bytes`, not a `str`, but 
the place where this manifests is in an `in` operator with the first argument 
as a `bytes` (telnetlib.IAC).

Perhaps a simple isinstance(buffer, bytes) could be used to throw a `TypeError` 
or something a bit more helpful.

It also doesn't help that for some reason Googling "python telnet" only seems 
to bring up the Python 2 docs link, rather than Python 3 or both.

--
components: Library (Lib)
messages: 288371
nosy: John Hagen
priority: normal
severity: normal
status: open
title: telnetlib.Telnet.write gives confusing error message when a string is 
passed in
type: enhancement
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



[issue29620] unittest.TestCase.assertWarns raises RuntimeEror if sys.modules changes size

2017-02-22 Thread kernc

New submission from kernc:

If any of the objects in sys.modules is a module-like object that performs some 
additional imports in its __getattribute__ (as appropriate) handler, the 
following simple unit test test case:

import unittest
import warnings

... # Ensure one of the imported modules is a module-like object as above

class Case(unittest.TestCase):
def test_assertWarns(self):
with self.assertWarns(UserWarning):
warnings.warn('Some warning')

fails with:

==
ERROR: test_assertWarns (example.Case)
--
Traceback (most recent call last):
  File "/tmp/example.py", line 9, in test_assertWarns
with self.assertWarns(UserWarning):
  File "/usr/lib/python3.4/unittest/case.py", line 205, in __enter__
for v in sys.modules.values():
RuntimeError: dictionary changed size during iteration
--

The problem is in the iteration over sys.modules in 
unittest.case._AssertWarnsContext.__enter__() and accessing every module's 
__warningregistry__ attribute. On this access, the module-like objects may 
perform arbitrary actions including importing of further modules which extends 
sys.modules.

https://github.com/python/cpython/blob/16ea19fc6653ee4ec1be7cd0206073962119ac08/Lib/unittest/case.py#L226-L227

The simple proposed fix with no foreseen side-effects is to wrap 
sys.modules.values() call as a tuple().

--
components: Library (Lib)
messages: 288370
nosy: kernc
priority: normal
severity: normal
status: open
title: unittest.TestCase.assertWarns raises RuntimeEror if sys.modules changes 
size
type: behavior
versions: Python 3.4, Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue29614] Additional implementation alternative to DictReader

2017-02-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

Or use DictReader with an explicit fieldnames argument.

--

___
Python tracker 

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



Re: Python application launcher (for Python code)

2017-02-22 Thread Grant Edwards
On 2017-02-21, Chris Warrick  wrote:

> Git Bash, or basically msys, is pretty reasonable. But if you are on
> Windows 10, you might like the built-in Windows Subsystem for Linux
> (aka Bash on Ubuntu on Windows) more — it’s real Linux that runs
> alongside Windows, but less crazy than Cygwin.

Cygwin is indeed crazy.

I've been in awe of it for 15 years.

Even  sshd works (if you're carefuly and a little lucky).

It's a medium-sized miracle that Cygwin works as well as it does.  For
a few years, I distributed and supported a custom snapshot of base
Cygwin plus a software development kit for a specific hardware
product.  It was not fun.  Cygwin is a bit brittle and presents many
mysterious failure modes. But, had I not seen it myself, I never would
have believed Cygwin would work in a useful way.

In then end, we gave up on supporting Cygwin for our Windows
customers.  It's actually easier to install Ubuntu in a VM and have
them use that.  The last customer I had who was trying to install
Cyginw and use it for development spent weeks and never got everything
to work with Cygwin.  About two hours after I finally convinced him to
try Linux on a VM, I got an e-mail saying his Linux VM as installed,
the devleopment tools were installed on that, and he was happily
building his applications.

-- 
Grant Edwards   grant.b.edwardsYow! I know how to do
  at   SPECIAL EFFECTS!!
  gmail.com

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


[issue29614] Additional implementation alternative to DictReader

2017-02-22 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

I'm with Inada and David. This use case looks very specific. If you need to 
handle a CSV file with duplicated header, you can use the regular reader or 
implement your own specialised reader.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue29614] Additional implementation alternative to DictReader

2017-02-22 Thread R. David Murray

R. David Murray added the comment:

My opinion stated in that issue is still the same: I don't think this is a bug. 
 I don't think automatic handling of fieldnames when no other dictionary 
features are retained is worth the complication to the API.  So I'm still -1.  
We'll see what other people think.

--

___
Python tracker 

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



[issue29614] Additional implementation alternative to DictReader

2017-02-22 Thread foxfluff

foxfluff added the comment:

David:
You are correct that the goal is to handle CSVs with duplicate headers, and 
that the main intention is to have some of the behavior of DictReader without 
the destruction of data (such as the auto population of field names as you 
stated).

It is not the intention of this to change the behavior of DictReader, as stated 
in issue 17537. It is instead covering a problem that was discussed later in 
the thread and would offer an alternative solution with non destructive 
behavior to DictReader while maintaining backwards compatibility.

--

___
Python tracker 

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



[issue28911] Clarify the behaviour of assert_called_once_with

2017-02-22 Thread STINNER Victor

STINNER Victor added the comment:

Can you please try to write a pull request?
https://docs.python.org/devguide/pullrequest.html

--

___
Python tracker 

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



Re: python decorator

2017-02-22 Thread Pavol Lisy
On 2/22/17, Steve D'Aprano  wrote:
> On Wed, 22 Feb 2017 08:47 pm, Cecil Westerhof wrote:
>
>> On Wednesday 22 Feb 2017 08:49 CET, Argentinian Black ops lll wrote:
>>
>>> *** SOLVED ***
>>
>> It would be nice if you shared the solution.
>
> I believe Cameron's post contains the bones of a solution.
>
> Here's my untested solution.
>
>
> def func_cache(cache):
> # Create a decorator that uses cache.
> def decorate(function):
> @functools.wraps(function)
> def wrapper(*args):
> try:
> result = cache[args]
> except KeyError:
> result = function(*args)
> cache[args] = result
> except TypeError:
> result = function(*args)
> return result
> return wrapper
> return decorate
>
>
> @func_cache({}):
> def something(x):
> ...

Maybe this technique could be reusable (and maybe part of functools?)

With this decorator:

def wrap_args(decorator):
def decor_out(*args, **kwargs):
def decor_in(func):
return decorator(func, *args, **kwargs)
return decor_in
return decor_out

Alfredo needs to change only (*) next 2 lines:

def fun_cache(function):
memo = {}

to:

@wrap_args
def fun_cache(function, cache):
memo = cache

(*) - Steve's improvements (for example using functools.wraps) are
good to consider as well! :)
(but maybe catching TypeError could more problems hide than solve)
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue29546] A more helpful ImportError message

2017-02-22 Thread Barry A. Warsaw

Changes by Barry A. Warsaw :


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



[issue29614] Additional implementation alternative to DictReader

2017-02-22 Thread R. David Murray

R. David Murray added the comment:

Inada: I believe the goal is to be able to handle CSV files that have columns 
with duplicate names.  However, in that case one could just use the regular 
reader class.  The only advantage TableReader gives over the regular reader 
that I can see is that it automatically reads the header line and sets 
fieldnames.  I'm not sure that is enough motivation for introducing a whole new 
class.

It also doesn't address the issue the OP mentions, that columns are overwritten 
silently by DictReader.  However, that is a characteristic of dicts in Python 
in general, so I'm not sure I even see that as a bug.

Overall, I'm -1 on this proposal.

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



  1   2   >