[issue32911] Doc strings no longer stored in body of AST

2018-04-12 Thread INADA Naoki

INADA Naoki  added the comment:

> in practice `ast.parse()` is often used with smaller fragments of source code 
> that don't directly correspond to a complete module, and this behaviour makes 
> no sense in such cases.
>
> The resulting bug in kdev-python took a while to track down (because I had no 
> immediate reason to suspect this change), and will be somewhat awkward to 
> workaround.

Would you elaborate it more, please?
Without concrete example, we cannot to decide how it's important problem.

> I would prefer that this be reverted; it's likely to break a variety of users 
> in strange ways.

I don't want to revert, see discussions in this issue and PR-5927.

And would you give us real world example of "variety of users"?
How many applications use ast.parse for such way?

--

___
Python tracker 

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



[issue33265] contextlib.ExitStack abuses __self__

2018-04-12 Thread Yury Selivanov

Yury Selivanov  added the comment:

Yep, I think this is a good fix!

--

___
Python tracker 

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



[issue32911] Doc strings no longer stored in body of AST

2018-04-12 Thread Francis Herne

Francis Herne  added the comment:

Note:

Because this also applies to module-level docstrings, a rather strange effect 
that, for example, `ast.parse("'foo'")` is now an empty module.

While the root node is always an instance of `ast.Module`, in practice 
`ast.parse()` is often used with smaller fragments of source code that don't 
directly correspond to a complete module, and this behaviour makes no sense in 
such cases.

The resulting bug in kdev-python took a while to track down (because I had no 
immediate reason to suspect this change), and will be somewhat awkward to 
workaround.

I would prefer that this be reverted; it's likely to break a variety of users 
in strange ways.

--
nosy: +flherne

___
Python tracker 

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



[issue33264] Remove to-be-deprecated urllib.request.urlretrieve function reference from HOWTO

2018-04-12 Thread Andrés Delfino

Andrés Delfino  added the comment:

My contributor form shows as received now :)

Don't know how to update the "CLA not signed" label on the PR.

--

___
Python tracker 

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



[issue33211] lineno and col_offset are wrong on function definitions with decorators

2018-04-12 Thread Ethan Smith

Change by Ethan Smith :


--
pull_requests: +6154

___
Python tracker 

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



[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Josh Rosenberg

Josh Rosenberg  added the comment:

Pretty sure this is a problem with classes in general; classes are 
self-referencing, and using multiplication to create new ctypes array types is 
creating new classes.

--
nosy: +josh.r

___
Python tracker 

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



[issue19993] Pool.imap doesn't work as advertised

2018-04-12 Thread Josh Rosenberg

Josh Rosenberg  added the comment:

Related: issue29842 "Make Executor.map work with infinite/large inputs 
correctly" for a similar problem in concurrent.futures (but worse, since it 
doesn't even allow you to begin consuming results until all inputs are 
dispatched).

A similar approach to my Executor.map patch could probably be used with 
imap/imap_unordered.

--
nosy: +josh.r

___
Python tracker 

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



[issue33217] x in enum.Flag member is True when x is not a Flag

2018-04-12 Thread Ethan Furman

Ethan Furman  added the comment:

DeprecationWarning is in 3.7, now need to raise TypeError in 3.8.

--
stage: patch review -> needs patch
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



[issue33219] x in IntFlag should test raise TypeError if x is not an IntFlag

2018-04-12 Thread Ethan Furman

Ethan Furman  added the comment:

This and issue33217 are similar enough I'm going to track it in issue33217.

--
resolution:  -> duplicate
stage: needs patch -> resolved
status: open -> closed
superseder:  -> x in enum.Flag member is True when x is not a Flag

___
Python tracker 

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



[issue33270] tags for anonymous code objects should be interned

2018-04-12 Thread Daniel Moisset

New submission from Daniel Moisset :

In compile.c, some strings are created to be used as name of anonymous code 
objects: "", "", "", "", "" and 
"".

Only the first two of those are interned (created with 
PyUnicode_InternFromString ), the rest are created with "PyUnicode_FromString". 
Even if they use a static variable to avoid creating multiple instances, not 
interning results in multiple copies when code objects are marshaled into pyc 
files and reloaded (one copy per module).

Always using PyUnicode_InternFromString should be more consistent, and slightly 
more efficient

--
components: Interpreter Core
messages: 315232
nosy: Daniel Moisset
priority: normal
severity: normal
status: open
title: tags for anonymous code objects should be interned

___
Python tracker 

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



[issue19173] Expose Queue maxsize parameter to multiprocessing.Pool class

2018-04-12 Thread Ned Deily

Change by Ned Deily :


--
nosy: +davin, pitrou

___
Python tracker 

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



[issue19993] Pool.imap doesn't work as advertised

2018-04-12 Thread Ned Deily

Change by Ned Deily :


--
nosy: +davin, pitrou

___
Python tracker 

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



[issue19993] Pool.imap doesn't work as advertised

2018-04-12 Thread Alex Garel

Alex Garel  added the comment:

Hello, I think this is a really important feature, it hits me hard those days. 

It would also solve https://bugs.python.org/issue19173 in a nice way.

--
nosy: +alex-garel

___
Python tracker 

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



[issue33266] 2to3 doesn't parse all valid string literals

2018-04-12 Thread Ned Deily

Change by Ned Deily :


--
nosy: +benjamin.peterson

___
Python tracker 

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



[issue32696] Fix pickling exceptions with multiple arguments

2018-04-12 Thread Jason R. Coombs

Jason R. Coombs  added the comment:

Kirill, see https://bugs.python.org/issue1692335#msg310951 in the related issue 
for one possible way to work around the issue on Python 3.

--

___
Python tracker 

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



[issue14573] json iterencode can not handle general iterators

2018-04-12 Thread Ned Deily

Ned Deily  added the comment:

If there is still interest in this, perhaps @Zectbumo could rebase the patch as 
a PR against the master branch of the current python/cpython repo now that 
we've moved to git and GitHub (https://devguide.python.org/pullrequest/).  
There's no guarantee that it will ultimately be accepted but it will make it 
much easier to review.

--
nosy: +ned.deily
versions: +Python 3.8 -Python 3.5

___
Python tracker 

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



[issue33065] IDLE debugger: problem importing user created module

2018-04-12 Thread Brett Cannon

Brett Cannon  added the comment:

Without knowing the exact Python version it's hard to tell as line 59 changed 
between Python 3.5 and where Python 3.6 is now (FYI, the line as it currently 
sits in Python 3.6 is 
https://github.com/python/cpython/blob/e98e3385f2acfc6d98f70f8e66c96b752d003b8f/Lib/importlib/_bootstrap.py#L59).
 But the double-reporting of the same line is a bit odd.

The best I can think of is that IDLE is requesting the __repr__() of `self` 
while still executing `__init__()` but before `self.name` is set, triggering an 
AttributeError (although those lines don't exactly line up with that). 
Otherwise looking at the code for _ModuleLock suggests this really shouldn't 
happen as `self.name` is set in `__init__()` and there's no use of `del` or 
`delattr()` that would cause this.

--

___
Python tracker 

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



[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Ned Deily

Change by Ned Deily :


--
nosy: +amaury.forgeotdarc, belopolsky, meador.inge

___
Python tracker 

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



[issue33269] InteractiveConsole behaves differently when used on terminal and used within script

2018-04-12 Thread Kadir Haldenbilen

Kadir Haldenbilen  added the comment:

Attached is a non working example
I could not attach a second file, which works OK within script I will attach 
separately

--
Added file: https://bugs.python.org/file47533/iitests.py

___
Python tracker 

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



[issue33269] InteractiveConsole behaves differently when used on terminal and used within script

2018-04-12 Thread Kadir Haldenbilen

Kadir Haldenbilen  added the comment:

This script works OK. Compare with iitests.py uploaded before

--
Added file: https://bugs.python.org/file47534/iiteswok.py

___
Python tracker 

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



[issue32696] Fix pickling exceptions with multiple arguments

2018-04-12 Thread Kirill Matsaberydze

Kirill Matsaberydze  added the comment:

Hi, I encounter similar behavior in python 3.6.5 with following code:

import pickle
class CustomException(Exception):
def __init__(self, arg1, arg2):
msg = "Custom message {} {}".format(arg1, arg2)
super().__init__(msg)


obj_dump = pickle.dumps(CustomException("arg1", "arg2"))
obj = pickle.loads(obj_dump)

Traceback (most recent call last):
  File "", line 1, in 
TypeError: __init__() missing 1 required positional argument: 'arg2'

So it looks like it not only python 2.7 problem

--
nosy: +Kirill Matsaberydze

___
Python tracker 

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



[issue33269] InteractiveConsole behaves differently when used on terminal and used within script

2018-04-12 Thread Kadir Haldenbilen

New submission from Kadir Haldenbilen :

on terminal push and runcode accepts indentation where required (like for loop 
etc), within script gives error message

on terminal import works properly and objects can be found  as normal, within 
script you may need to add module name upfront

simple example
import code
ii = code.InteractiveConsole()
ii.push("for ii in range(3):")
ii.push("print('i', i)")

you will get normal expected output on terminal, but indentation error within 
script

ii.push("from time import sleep")
ii.push("sleep(1)")
will sleep 1 sec on terminal, but will give name error

--
messages: 315224
nosy: Kadir Haldenbilen
priority: normal
severity: normal
status: open
title: InteractiveConsole behaves differently when used on terminal and used 
within script
type: behavior
versions: Python 3.6

___
Python tracker 

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



[issue33266] 2to3 doesn't parse all valid string literals

2018-04-12 Thread Eric V. Smith

Eric V. Smith  added the comment:

Is 2to3 supposed to be able to parse non-python2 files? I don't recall.

--
nosy: +eric.smith

___
Python tracker 

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



[issue14573] json iterencode can not handle general iterators

2018-04-12 Thread Jan Vlcinsky

Jan Vlcinsky  added the comment:

I found proposed change very handy (came here researching why it is not 
behaving that way).

Taking into account:
- Python shines in handling lists, using generators and iterators
- Largest group of python developers develop web apps, and there it is typical 
pattern to iterate across many records and return them as long list of 
dictionaries

I think proposed feature could become very popular.

--
nosy: +vlcinsky

___
Python tracker 

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



[issue33265] contextlib.ExitStack abuses __self__

2018-04-12 Thread Nick Coghlan

Nick Coghlan  added the comment:

Yury, could you double check the async exit stack change in the PR? I think 
it's fine since the bound method just passes back the underlying coroutine and 
the tests all still pass, but a second opinion would be good :)

--
nosy: +yselivanov

___
Python tracker 

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



[issue33268] iteration over attrs in metaclass' __new__ affects class' __name__

2018-04-12 Thread tkhyn

tkhyn  added the comment:

oops,  indeed. Sometimes the obvious things are not so obvious ..
Sorry for the noise!

--

___
Python tracker 

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



[issue33268] iteration over attrs in metaclass' __new__ affects class' __name__

2018-04-12 Thread Eric V. Smith

Eric V. Smith  added the comment:

In the loop, you're reassigning the value of name, then using it in the super 
call. If you change the name of the loop variable, your code works.

--
nosy: +eric.smith
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type:  -> behavior

___
Python tracker 

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



[issue33268] iteration over attrs in metaclass' __new__ affects class' __name__

2018-04-12 Thread tkhyn

New submission from tkhyn :

The following script, run with python 3.6.5, highlights an issue with the 
class' __name__ attribute being set incorrectly just because of a loop in the 
metaclass' __new__ method:

class MC(type):
def __new__(mcs, name, bases, attrs):
for name, attr in attrs.items():
pass
return super(MC, mcs).__new__(mcs, name, bases, attrs)

class C(metaclass=MC):
a = None

print(C.__name__)


Expected output: "C"
Actual output: "a"

Comment the for loop and you get the expected output!

On Python 2.7.13, the amended code exposes the same bug:

class MC(type):
def __new__(mcs, name, bases, attrs):
for name, attr in attrs.items():
pass
return super(MC, mcs).__new__(mcs, name, bases, attrs)

class C(object):
__metaclass__ = MC
a = None

print C.__name__

output is "__metaclass__" and should be "C"

--
components: Interpreter Core
messages: 315218
nosy: tkhyn
priority: normal
severity: normal
status: open
title: iteration over attrs in metaclass' __new__ affects class' __name__
versions: Python 2.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



[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Eric Wieser

Eric Wieser  added the comment:

Apologies, I missed the important part of that snippet:
```
In [3]: gc.collect(); x = make_array_ctype((1,)); del x; gc.collect()
Out[3]: 7
```

--

___
Python tracker 

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



[issue33267] ctypes array types create reference cycles

2018-04-12 Thread Eric Wieser

New submission from Eric Wieser :

Discovered in https://github.com/numpy/numpy/pull/10882/files#r180813166

A reproduction:
```
In [1]: import ctypes

In [2]: def make_array_ctype(shape):
   ...: import ctypes
   ...: ct = ctypes.c_uint8
   ...: for i in shape:
   ...: ct = i * ct
   ...: return ct
   ...:

# all on one line to keep ipython out of this
In [3]: gc.collect(); x = make_array_ctype((1,)); del x; gc.collect()
```

Using the proposed function in https://github.com/numpy/numpy/pull/10891, we 
get a few more details:
```
In [4]: from numpy.testing import assert_no_gc_cycles

In [5]: assert_no_gc_cycles(make_array_ctype, (1,))
AssertionError: Reference cycles were found when calling make_array_ctype: 7 
objects were collected, of which 6 are shown below:
  tuple object with id=282226536:
(,)
  PyCArrayType object with id=286500408:

  getset_descriptor object with id=2822252062256:

  getset_descriptor object with id=2822252062184:

  tuple object with id=2822243712440:
(,
 ,
 ,
 )
  StgDict object with id=286211928:
{'__dict__': ,
 '__doc__': None,
 '__module__': '__main__',
 '__weakref__': ,
 '_length_': 1,
 '_type_': }
```

I suppose this isn't really a bug, but it's not clear to me why a cycle needs 
to be created here.

--
components: ctypes
messages: 315216
nosy: Eric.Wieser
priority: normal
severity: normal
status: open
title: ctypes array types create reference cycles
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



[issue33266] 2to3 doesn't parse all valid string literals

2018-04-12 Thread Roundup Robot

Change by Roundup Robot :


--
keywords: +patch
pull_requests: +6152
stage:  -> patch review

___
Python tracker 

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



[issue33266] 2to3 doesn't parse all valid string literals

2018-04-12 Thread Zsolt Dollenstein

New submission from Zsolt Dollenstein :

For example `rf"blah"` is not tokenized properly.

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 315215
nosy: Zsolt Dollenstein
priority: normal
severity: normal
status: open
title: 2to3 doesn't parse all valid string literals
type: behavior

___
Python tracker 

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



[issue29456] bugs in unicodedata.normalize: u1176, u11a7 and u11c3

2018-04-12 Thread Wonsup Yoon

Wonsup Yoon  added the comment:

Hello!

--

___
Python tracker 

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



[issue33265] contextlib.ExitStack abuses __self__

2018-04-12 Thread Eric V. Smith

Change by Eric V. Smith :


--
nosy: +ncoghlan

___
Python tracker 

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