[issue34613] asyncio.StreamReader initialization documentation incorrectly declare limit as None

2018-09-09 Thread Laurent Peuch


New submission from Laurent Peuch :

asyncio.StreamReader documentation incorrectly declare its initialization 
argument "limit" to be "None" by default 
https://docs.python.org/3/library/asyncio-stream.html#asyncio.StreamReader

In the source code it is set to _DEFAULT_LIMIT 
https://github.com/python/cpython/blob/0afada163c7ef25c3a9d46ed445481fb69f2ecaf/Lib/asyncio/streams.py#L353
 

_DEFAULT_LIMIT is set to "2 ** 16 # 64 KiB" 
https://github.com/python/cpython/blob/0afada163c7ef25c3a9d46ed445481fb69f2ecaf/Lib/asyncio/streams.py#L19

This information is especially needed when you get the exception 
"asyncio.streams.LimitOverrunError: Separator is not found, and chunk exceed 
the limit" and want to increase the limit, but you don't have the initial value 
and you have to look at the source code to get it.

PS: this is my first ticket, I don't know if I should have open one for such a 
minor detail in the documentation

--
assignee: docs@python
components: Documentation, asyncio
messages: 324873
nosy: asvetlov, docs@python, psycojoker, yselivanov
priority: normal
severity: normal
status: open
title: asyncio.StreamReader initialization documentation incorrectly declare 
limit as None
type: enhancement
versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue34613] asyncio.StreamReader initialization documentation incorrectly declare limit as None

2018-09-09 Thread Roundup Robot


Change by Roundup Robot :


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

___
Python tracker 

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



[issue34421] Cannot install package with unicode module names on Windows

2018-09-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I would prefer to use the backslashreplace error handler rather of the 
unicode-escape codec. Just as few lines above, but with ASCII encoding.

msg = msg.encode('ascii', 'backslashreplace').decode('ascii')

It is still not clear to me why the current code purposed to handle this 
problem doesn't work in this case. We need to find the cause and fix the 
existing solution.

--

___
Python tracker 

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



[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-09 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +8576

___
Python tracker 

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



[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-09 Thread STINNER Victor


STINNER Victor  added the comment:

> I think we need to handle only two cases: short and fully qualified names. 
> __qualname__ without __module__ doesn't make sense, and the value of tp_name 
> depends on implementation details (is it Python class or builtin class, heap 
> class or dynamic class?). Maybe use %t and %T?

Ok, I wrote PR 9122 to add %t format and modify %T format:

* %t <=> type(obj).__name__
* %T <=> f"{type(obj).__module__}.{type(obj).__qualname__}"


> But we may want to support formatting the name of the type itself and the 
> name of the object's type. This give us 4 variants.

Again, I'm not sure about these ones. _PyType_Name() can be used for %t-like 
directly on a type. Later we can expose _PyType_FullName() (function that I 
added in my latest PR) as a private function for %T-like directly on a type.


> For old string formatting we can introduce new % codes (with possible 
> modifiers). But in modern string formatting "T" can have meaning for some 
> types (e.g. for datetime). We can implement __format__ for the type type 
> itself (though it can cause confusion if cls.__format__() is different from 
> cls.__format__(instance)), but for formatting the name of  the object's type 
> (as in your original proposition) we need to add a new  conversion flag like 
> "!r".

I'm not sure that I understood directly.

Do you want to add a third formatter in PyUnicode_FromFormat() which would use 
Py_TYPE(obj)->tp_name? I dislike Py_TYPE(obj)->tp_name, since my intent is to 
conform to the PEP 399: tp_name is not accessible at the Python level, only 
type(obj).__name__ and type(obj).__qualname__.

Or do you want to add a new formatter to type.__format__() to expose %T at the 
Python level, f"{type(obj).__module__}.{type(obj).__qualname__}"?

Currently, type(obj).__name__ is the most popular way to format a string. Would 
it break the backward compatibility to modify *existing* error messages?

--

___
Python tracker 

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



[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

> Ok, I wrote PR 9122 to add %t format and modify %T format:

Nice!

I agree that it is easy to use _PyType_Name() directly. But using 
_PyType_FullName() instead of tp_name can be cumbersome because it returns a 
new object and needs error handling.

> Or do you want to add a new formatter to type.__format__() to expose %T at 
> the Python level, f"{type(obj).__module__}.{type(obj).__qualname__}"?

Yes, I think we need a convenient way of formatting fully qualified name that 
omits the module name for types in the builtins module. It is equivalent to 
Py_TYPE(obj)->tp_name for extension types which is the most popular way to 
format a type name in error messages for now.

There are several open issues for inconsistency in error messages for Python 
and C implementations, because the former use type(obj).__name__ or 
obj.__class__.__name__, and the latter use Py_TYPE(obj)->tp_name. I hope 
finally we will fix this.

--

___
Python tracker 

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



[issue34595] PyUnicode_FromFormat(): add %T format for an object type name

2018-09-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

> in error messages

And in reprs. It is common to format a repr as "{typename}(...)" or 
"<{typename}(...)>". The difference is whether the typename is a short or fully 
qualified name.

--

___
Python tracker 

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



[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'

2018-09-09 Thread hongweipeng


Change by hongweipeng :


--
pull_requests: +8577
stage: test needed -> patch review

___
Python tracker 

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



[issue34421] Cannot install package with unicode module names on Windows

2018-09-09 Thread Jeremy Kloth


Jeremy Kloth  added the comment:

The existing re-code solution is being triggered, as the `errors` in this case 
is 'surrogateescape' with an encoding of 'cp1252'.

Here, pip is using subprocess.Popen() to have Python run setup.py.  During 
execution, a filename, 'taqdir\\\u0634\u0645\u0627\u0631.py', which has 
characters not encodable in cp1252.

I think that here, Python is not configuring its stdin/stdout/stderr streams 
correctly when run as a subprocess connected to pipes.  Or, at least, 
subprocess.Popen() isn't passing the right (or enough) information to Python to 
get itself configured.

There should ultimately be a way to have Python (in a subprocess, on Windows) 
pass through Unicode untouched to its calling process.  I suppose it would mean 
setting the PYTHONIOENCODING envvar when using subprocess.

After all that, it seems that:
1) pip needs to be changed to support calling Python subprocesses to enable 
lossless unicode transmission,
2) change the `errors` check in distutils.log to include 'surrogateescape'? 
(the heart of this issue)

--
nosy: +jkloth

___
Python tracker 

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



[issue34604] Possible mojibake in pwd.getpwnam and grp.getgrnam

2018-09-09 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 1bcd891c200b8122493ddad5a203331e1a3bfcb5 by Victor Stinner 
(William Grzybowski) in branch '3.6':
[3.6] bpo-34604: Fix possible mojibake in pwd.getpwnam() and grp.getgrnam() 
(GH-9098) (GH-9105)
https://github.com/python/cpython/commit/1bcd891c200b8122493ddad5a203331e1a3bfcb5


--

___
Python tracker 

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



[issue34604] Possible mojibake in pwd.getpwnam and grp.getgrnam

2018-09-09 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 7a633ed79cfba2cfc0f80410ddcaeecadc2030e9 by Victor Stinner 
(William Grzybowski) in branch '3.7':
[3.7] bpo-34604: Fix possible mojibake in pwd.getpwnam() and grp.getgrnam() 
(GH-9098) (GH-9104)
https://github.com/python/cpython/commit/7a633ed79cfba2cfc0f80410ddcaeecadc2030e9


--

___
Python tracker 

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



[issue20104] expose posix_spawn(p)

2018-09-09 Thread STINNER Victor


STINNER Victor  added the comment:

> Thank you for your contribution Pablo. This issue have appeared much more
complex and less obvious than it looked initially.

Yeah, thanks Pablo for your tenacy! This function is interesting in term of
performance and correctness ("atomic" function, signal safe?).

--

___
Python tracker 

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



[issue34604] Possible mojibake in pwd.getpwnam and grp.getgrnam

2018-09-09 Thread STINNER Victor


STINNER Victor  added the comment:

The bug has been fixed. For %R, does someone want to propose a change for 
master? William?

--

___
Python tracker 

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



[issue20104] expose posix_spawn(p)

2018-09-09 Thread STINNER Victor


STINNER Victor  added the comment:

I close the issue, it's now done.

If someone wants to experiment in posix_spawn() in subprocess, please open a 
new 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



[issue34597] Python needs to check existence of functions at runtime for targeting older macOS platforms

2018-09-09 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

Binaries currently work on the system you compiled on and any later release of 
macOS.  That's the only "promise" there currently is.

Anything better requires work, and hence someone willing to do that work. 

I'd love to be able to build on the latest macOS and deploy to older versions, 
but that's functionality I don't need myself at the moment which means this 
does not have priority for me. 

BTW. I haven't checked yet how invasive supporting weak linking for these 
symbols will be. That depends on where the symbols are used.

--

___
Python tracker 

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



[issue17535] IDLE: Add an option to show line numbers along the left side of the editor window, and have it enabled by default.

2018-09-09 Thread Mike Thompson


Mike Thompson  added the comment:

I am a teacher, and this feature would really help me teach Python to my 
students. Especially when I am teaching the course remotely.

--
nosy: +mthompsonwhs

___
Python tracker 

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



[issue34608] gc.get_referrers behavior change 3.6 to 3.7

2018-09-09 Thread INADA Naoki


INADA Naoki  added the comment:

Benjamin is right.
This is very implementation detail.  We shouldn't rely on such edge case.

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



[issue32502] uuid1() fails if only 64-bit interface addresses are available

2018-09-09 Thread Chih-Hsuan Yen


Change by Chih-Hsuan Yen :


--
pull_requests: +8578

___
Python tracker 

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



[issue32502] uuid1() fails if only 64-bit interface addresses are available

2018-09-09 Thread Chih-Hsuan Yen


Chih-Hsuan Yen  added the comment:

I created the backport PR for 2.7 branch. Can anyone reopen this issue?

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



[issue34421] Cannot install package with unicode module names on Windows

2018-09-09 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +8579
stage: commit review -> patch review

___
Python tracker 

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



[issue34421] Cannot install package with unicode module names on Windows

2018-09-09 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 9126 makes distutils.log using "backslashreplace" instead of 
"unicode-escape" and simplifies the code (it is more efficient now, although 
the performance of logging is not critical).

"unicode-escape" escapes all non-ASCII characters, even encodable. It also 
escapes control characters like \t, \b, \r or \x1a (which starts control 
sequences for ANSI compatible terminals), this can be not desirable.

--
stage: patch review -> commit review

___
Python tracker 

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



[issue34569] test__xxsubinterpreters.ShareableTypeTests._assert_values fails on AIX - 32-bit mode

2018-09-09 Thread Michael Felt


Change by Michael Felt :


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

___
Python tracker 

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



[issue34421] Cannot install package with unicode module names on Windows

2018-09-09 Thread Julien Malard


Julien Malard  added the comment:

Hello,

Thanks for the insights and better fixes. Regarding (1), do you have any 
pointers on how or where to fix pip? I have an inprogress pull request there 
(https://github.com/pypa/pip/pull/5712) to fix a related unicode error during 
installation and could perhaps combine both solutions.

Thanks!

-Julien

--

___
Python tracker 

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



[issue34614] Builtin `abs(Path)` returns `Path.absolute()`.

2018-09-09 Thread Brandt Bucher


New submission from Brandt Bucher :

This complements the current Path behavior that overrides division operators 
for path joining, in that it makes manually-constructed paths easier to form 
and arguably more readable.

Before:

p = Path("some", "relative", "path")
q = p.absolute() / "some" / "further" / "path"

After:

p = Path("some", "relative", "path")
q = abs(p) / "some" / "further" / "path"

--
components: Library (Lib)
messages: 324890
nosy: brandtbucher
priority: normal
severity: normal
status: open
title: Builtin `abs(Path)` returns `Path.absolute()`.
type: enhancement
versions: Python 3.8

___
Python tracker 

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



[issue34614] Builtin `abs(Path)` returns `Path.absolute()`.

2018-09-09 Thread Brandt Bucher


Change by Brandt Bucher :


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

___
Python tracker 

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



[issue34486] "RuntimeError: release unlocked lock" when starting a thread

2018-09-09 Thread hongweipeng


hongweipeng  added the comment:

It seems to me the problem is related to nested `finally` or `with`, which 
can't handle signals well.

class Event:
...
def wait(self, timeout=None):
self._cond.__enter__()
signaled = self._flag
if not signaled:
signaled = self._cond.wait(timeout)
self._cond.__exit__()
return signaled


Reducing one layer of nesting can solve this issue,but it can't pass `test` 
module.

--
nosy: +hongweipeng

___
Python tracker 

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



[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'

2018-09-09 Thread paul j3


paul j3  added the comment:

It's been sometime since I looked at this issue.  

The main sticking point is passing unittests, and ensuring that there are no 
backward compatibility issues.

But, since FileType is a standalone class, anyone could put a corrected version 
in their own workspace without modifying their stock version.  The 'type' 
parameter is designed for this kind of flexibility - it accepts any callable, 
whether a function, or a class with a __call__ method.

--

___
Python tracker 

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



[issue34614] Builtin `abs(Path)` returns `Path.absolute()`.

2018-09-09 Thread Raymond Hettinger


Change by Raymond Hettinger :


--
assignee:  -> pitrou
nosy: +pitrou

___
Python tracker 

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



[issue34614] Builtin `abs(Path)` should return `Path.absolute()`.

2018-09-09 Thread Antoine Pitrou


Change by Antoine Pitrou :


--
title: Builtin `abs(Path)` returns `Path.absolute()`. -> Builtin `abs(Path)` 
should return `Path.absolute()`.

___
Python tracker 

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



[issue34486] "RuntimeError: release unlocked lock" when starting a thread

2018-09-09 Thread Xiang Zhang


Xiang Zhang  added the comment:

It's not right to replace with statement by manually calling __enter__ and 
__exit__. If there is any exception after __enter__ and before __exit__, 
__exit__ method will be skipped. That's not what we want.

--

___
Python tracker 

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



[issue34614] Builtin `abs(Path)` should return `Path.absolute()`.

2018-09-09 Thread Antoine Pitrou


Antoine Pitrou  added the comment:

Hmm, thanks for taking the time of proposing this and submitting a PR, but no.  
The documentation for `abs()` states:
"""
Return the absolute value of a number. The argument may be an integer or a 
floating point number. If the argument is a complex number, its magnitude is 
returned.
"""

This is all about numbers. Not about filesystem paths or any other kind of 
object. It's true that Path overrides the "division" operator, but that's an 
exception meant to make it easy to write a very common operation on paths (path 
joining), and because some people felt it looked pleasantly like the standard 
Unix path separator (it wasn't the initial choice, by the way).  No such 
argument applies in favour of abs(Path).

Moreover, Path.resolve() is strongly recommended over Path.absolute(), which 
currently isn't even exposed in the docs (though it seems that doesn't prevent 
people from actually using it ;-)).

--

___
Python tracker 

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



[issue34614] Builtin `abs(Path)` should return `Path.absolute()`.

2018-09-09 Thread Antoine Pitrou


Change by Antoine Pitrou :


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



[issue34614] Builtin `abs(Path)` should return `Path.absolute()`.

2018-09-09 Thread Brandt Bucher


Brandt Bucher  added the comment:

That all makes sense. Thanks for the quick response!

--

___
Python tracker 

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



[issue12733] Request for grapheme support in Python re lib

2018-09-09 Thread Matej Cepl


Change by Matej Cepl :


--
nosy: +mcepl

___
Python tracker 

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



[issue34486] "RuntimeError: release unlocked lock" when starting a thread

2018-09-09 Thread Vladimir Matveev


Vladimir Matveev  added the comment:

To bring in analogy: C# has lock statement that allow to run a block of code 
holding a mutual-exclusion lock on some object. 
```
lock(o) 
{  
}
```
is compiled as 
```
object _lock = o;
bool _lockTaken = false;
try
{
   System.Threading.Monitor.Enter(_lock, out _lockTaken);
   ...
}
finally 
{
   if (_lockTaken) 
   {
  System.Threading.Monitor.Exit(_lock);
   }
}
```
In C# System.ThreadAbortException can be raised in arbitrary point in code and 
yet lock statement needs to to enforce the invariant "if lock is taken it will 
be released". In order to do so:
- lock acquisition is performed inside the try block, as a side effect it sets 
the value of '_lockTaken' passed as out parameter - these two actions are 
performed atomically and cannot be interrupted by the asynchronous exception
- lock is released in finally block only if lock was previously taken. Also 
finally blocks in .NET has a property that they cannot be interrupted by 
asynchronous exceptions so call to Monitor.Exit is guaranteed to be run if 
control flow has entered matching try block.

I feel that something similar can be used to solve this issue as well. 
Discussions for issue29988 has already mentioned adding special semantic to 
__enter__/__exit__ methods or marking bytecode ranges as atomic to make sure 
that they are not interrupted. While the former case is specific to with 
statements, the latter one can probably be generalized to support finally 
blocks as well.

--

___
Python tracker 

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



[issue30717] Add unicode grapheme cluster break algorithm

2018-09-09 Thread Matej Cepl


Change by Matej Cepl :


--
nosy: +mcepl

___
Python tracker 

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



[issue34615] subprocess.call wrong exit code

2018-09-09 Thread Kay Hayen


New submission from Kay Hayen :

Hello there,

I am probably confusing myself. I am using this kind of code in Nuitka to 
emulate "os.execl" on Windows, and so far it never let me down:

r = subprocess.call(
args,
shell = False
)

print (r, args)

sys.exit(r)

When i execute my tests with Nuitka and Python 3.6 and everything before, this 
gives:

1 ['test_call.exe']
1 ['C:\\Python36_32\\python.exe', '-S', '..\\..\\nuitka\\__main__.py', '--run', 
'test/test_call.py']

And with python 3.7 it gives:

0 ['test_call.exe']
0 ['C:\\Python37_32\\python.exe', '-S', '..\\..\\nuitka\\__main__.py', '--run', 
'test/test_call.py']

So I am in Nuitka re-executing itself without the site module, and then 
immediately the created binary. For 3.7 it doesn't give me an error. I manually 
confirmed that "test_call.exe" indeed gives error code 1 as well, in both bash 
and cmd.exe, but it is not seen in the return value. Checking existing issues, 
I didn't find any hint at all, how this can be. I added "shell = False" to make 
it clear that no "cmd.exe" should be used, for which there had been issues.

I also confirmed, by adding a exit(27), that if I simulate that "test_call.exe" 
gave 27, rather then 0, then that one is detected by the exec, so what could be 
going on here. But I am also sure I don't confuse binaries or so, plus it's 
working as expected in other Python versions than 3.7.0 here.

This happens with 64 bits too, I am only citing 32 bits. And it is happening 
with just about every compiled unit test that gives an error exit, where 
otherwise e.g. tests that check for error exits to be the case work nicely.

Thanks for any help or direction you can give me there. I am at loss.

Yours,
Kay

--
components: Windows
messages: 324897
nosy: kayhayen, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: subprocess.call wrong exit code
type: behavior
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



[issue17781] optimize compilation options

2018-09-09 Thread Zachary Ware


Zachary Ware  added the comment:

After 2.5 years without response, I think the answer is probably "no" :)

--
resolution:  -> fixed
stage:  -> resolved
status: pending -> closed

___
Python tracker 

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



[issue34615] subprocess.call wrong exit code

2018-09-09 Thread Kay Hayen


Kay Hayen  added the comment:

I think that the whole reason I was doing this, is because with "os.execl" on 
Windows, the exit code was always lost, but of course it is very important and 
"subprocess.call" promises to return it. 

I just tried if 3.7 has any better exit code handling right there for 
"os.execl", but apparently it's not the case.

--

___
Python tracker 

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



[issue34616] implement "Async exec"

2018-09-09 Thread Matthias Bussonnier


New submission from Matthias Bussonnier :

Hi, 

This is an issue, prompted by twitter 
(https://twitter.com/Mbussonn/status/1038866329971961859) and by the imminent 
release of IPython 7.0 that provides an async REPL to discuss the introducion 
of something I'll call "Async exec", the exact form can vary, but I believe the 
name si relatively self explanatory. 

The short description would be to allow something akin to `exec` but for 
asynchronous code. Typically for one to be able to write an async-repl in the 
generic sens that is not say not obviously liked to asyncio.

For example IPython 7.0 (current master branch) allow the following:

```

In [1]: import asyncio, trio, curio

In [2]: await asyncio.sleep(0)

In [3]: %autoawait trio

In [4]: await trio.sleep(0)

In [5]: %autoawait curio

In [6]: await curio.sleep(0)
Out[6]: 30980.70591396
```


Sleep is here and example, but you can play with aoihttp, asks, and other 
library and it "just works". Alternatively when using IPython via Jupyter, you 
can also schedule background tasks that will execute in the currently running 
loop. 

To reach this, we had to work around a large number of roadblock, and there is 
a number of missing pieces (or things especially prevented) in core Python we 
had to work around. To see how we did that see 
https://github.com/ipython/ipython/pull/11265

The core being if we have a block of async code like `await sleep(0)`, we need 
an asynchronous way to exec it without blocking, hence the proposal for 
async-exec.

During the development and test of the above feature of IPython here are some 
of the challenges we got with top-level async code. 

1) top-level async is invalid syntax. 

It make sens for a module for this to be invalid syntax, but not in a repl.
Since Python 3.7 we can (at least) compile it to AST, but not to bytecode.

2) It would also be extremely convenient to have a util function to tell you 
whether what you just compiled need to be ran async or not, from Source Code, 
ast tree, code object. It's surprisingly not trivial to get it always right.

So far in IPython we have to carry-over and recompute whether to actually run 
the compiled byte code in classical `exec` or our pseudo async-exec. You may 
think that `await exec()` always cover the case, but when you are already 
running under asyncio, you may want to tell user "no you can't run async code", 
and use the normal `exec` path.


3) Have  distinction in this `async exec`/`compile` between "I am compiling a 
module", currently `exec` mode for both exec and compile, and a "I'm compiling 
a _multiline_ interactive statement".

4) Not be coupled to a specific async library.

Allow new AIO library like trio/curio/... to use this.

Note that despite both using IPython, the above cover 2 use cases. 
- Terminal IPython were the loop is started/stopped between each user input. 
- Notebook kernel/Jupyter IPython where the loop is already running and 
task/user code can be process in background w/o pausing the loop. 

AFAICT, this would also be of potential use for other REPL (Xonsh, Bpython).

I'm happy to give more details, but I think that's a enough of a broad 
overview, as we should be releasing this in IPython in a few days/week, we will 
likely have further feedback from a wider range of users that can inform the 
design.

--
components: Interpreter Core
messages: 324900
nosy: mbussonn
priority: normal
severity: normal
status: open
title: implement "Async exec"
type: enhancement
versions: Python 3.8

___
Python tracker 

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



[issue34616] implement "Async exec"

2018-09-09 Thread Matthias Bussonnier


Change by Matthias Bussonnier :


--
nosy: +minrk, willingc, yselivanov

___
Python tracker 

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



[issue34617] socket.recvfrom(): docs should warn about packet truncation when bufsize is insufficient

2018-09-09 Thread Anees Ahmed


New submission from Anees Ahmed :

When one is receiving UDP packets (socket.SOCK_DGRAM) using:

socket.recvfrom(bufsize, flags)

the UDP packet payload is truncated if it was too big to fit into the buffer 
(decided by `bufsize` here).


This is documented in Linux Docs:

All receive operations return only one packet.  When the packet is
smaller than the passed buffer, only that much data is returned; when
it is bigger, the packet is truncated and the MSG_TRUNC flag is set.
MSG_WAITALL is not supported.

Source: http://man7.org/linux/man-pages/man7/udp.7.html


This is also documented in Windows Docs:

For message-oriented sockets, data is extracted from the first enqueued 
message, up to the size of the buffer specified. If the datagram or message is 
larger than the buffer specified, the buffer is filled with the first part of 
the datagram, and recvfrom generates the error WSAEMSGSIZE. For unreliable 
protocols (for example, UDP) the excess data is lost. For UDP if the packet 
received contains no data (empty), the return value from the recvfrom function 
function is zero.

Source: 
https://docs.microsoft.com/en-us/windows/desktop/api/winsock2/nf-winsock2-recvfrom


** PYTHON DOCS DO NOT WARN ABOUT THIS AT ALL !!! **

The relevant portion of Python Docs is here: 
https://docs.python.org/3.7/library/socket.html#socket.socket.recvfrom


I, not knowing this simple fact when I started socket programming today, wasted 
half an hour finding out what was wrong. This is a very important piece of 
information that MUST be present in the Python Docs, even though it is present 
at Linux Docs and Windows Docs.


PROPOSED FIX


Include the warning about packet truncation in the docs.

NOTE: I have only pointed out socket.recvfrom(), but there are other related 
functions too, e.g. socket.recvfrom_into(), which require the same warning in 
their docs.

--
assignee: docs@python
components: Documentation
messages: 324901
nosy: Anees Ahmed, docs@python
priority: normal
severity: normal
status: open
title: socket.recvfrom(): docs should warn about packet truncation when bufsize 
is insufficient
type: enhancement
versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue27869] test failures under Bash on Windows / WSL

2018-09-09 Thread Paul Waldorf


Paul Waldorf  added the comment:

Thought my experience could be helpful.  My env is varies from @brett.cannon in 
that I'm running Debian 9 (Stretch) on my WSL, which makes me think that these 
failures have more to do with WSL than any difference in distros? 

Configured with

./configure --with-pydebug

Tests ran with 

./python -m test -j0 -x test_signal -x test_ssl -v

Both test_signal and test_ssl would hang indefinitely.

364 tests OK.

27 tests failed:
test_asyncio test_asyncore test_concurrent_futures test_epoll
test_fcntl test_ftplib test_httplib test_httpservers test_import
test_io test_mmap test_multiprocessing_fork
test_multiprocessing_forkserver test_multiprocessing_main_handling
test_multiprocessing_spawn test_os test_posix test_regrtest
test_selectors test_socket test_source_encoding test_subprocess
test_sys test_sysconfig test_syslog test_time test_unicode_file

20 tests skipped:
test_curses test_devpoll test_gdb test_kqueue test_msilib
test_ossaudiodev test_smtpnet test_socketserver test_startfile
test_timeout test_tix test_tk test_ttk_guionly test_urllib2net
test_urllibnet test_winconsoleio test_winreg test_winsound
test_xmlrpc_net test_zipfile64

--
nosy: +paul.waldorf

___
Python tracker 

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



[issue34596] [unittest] raise error if @skip is used with an argument that looks like a test method

2018-09-09 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

For what its worth, I'm +1 with Serhiy that we raise an exception 
on a non-string argument, including the case where the caller forgets to 
provide a reason at all.

I don't think that @skip with no reason was ever intended to work (it 
certainly wasn't documented as working) and as this only effects tests, 
not production code, I don't think we ought to be constrained by "bug 
compatibility" concerns. Fixing broken tests is easier than fixing 
broken production code.

--

___
Python tracker 

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



[issue34618] Encoding error running in subprocess with captured output

2018-09-09 Thread Jeremy Kloth

New submission from Jeremy Kloth :

When running Python via subprocess with captured output an encoding error 
occurs attempting to output a Unicode filename.  The same does not happen when 
just using spawnl().

Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit 
(AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import os, sys, subprocess
>>> sys.stdout.encoding, sys.stdout.errors
('utf-8', 'surrogateescape')
>>> args = ['-u', '-c', "print('taqdir\\\u0634\u0645\u0627\u0631.py')"]
>>> os.spawnl(os.P_WAIT, sys.executable, '"%s"' % sys.executable, *args)
taqdir\شمار.py
0
>>> subprocess.run([sys.executable, *args], stdout=subprocess.PIPE, 
>>> stderr=subprocess.STDOUT)
CompletedProcess(args=['C:\\Program Files (x86)\\Microsoft Visual 
Studio\\Shared\\Python36_64\\python.exe', '-u', '-c', 
"print('taqdir\\شمار.py')"], returncode=1, stdout=b'Traceback (most recent call 
last):\r\n  File "", line 1, in \r\n  File "C:\\Program Files 
(x86)\\Microsoft Visual 
Studio\\Shared\\Python36_64\\lib\\encodings\\cp1252.py", line 19, in encode\r\n 
   return 
codecs.charmap_encode(input,self.errors,encoding_table)[0]\r\nUnicodeEncodeError:
 \'charmap\' codec can\'t encode characters in position 7-10: character maps to 
\r\n')

--
components: Interpreter Core, Library (Lib), Unicode, Windows
messages: 324904
nosy: ezio.melotti, jkloth, paul.moore, steve.dower, tim.golden, vstinner, 
zach.ware
priority: normal
severity: normal
status: open
title: Encoding error running in subprocess with captured output
versions: Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue34618] Encoding error running in subprocess with captured output

2018-09-09 Thread Jeremy Kloth


Jeremy Kloth  added the comment:

Related to issue34421

--

___
Python tracker 

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



[issue34619] Typo in docs.python.jp

2018-09-09 Thread kuri8ive

New submission from kuri8ive <1yen@gmail.com>:

Typo in https://docs.python.jp/3/tutorial/index.html
"Python Web サイト(htts://www.python.org)"
should be
"Python Web サイト(https://www.python.org) "

--
assignee: docs@python
components: Documentation
messages: 324906
nosy: docs@python, kuri8ive
priority: normal
severity: normal
status: open
title: Typo in docs.python.jp
type: enhancement

___
Python tracker 

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



[issue34421] Cannot install package with unicode module names on Windows

2018-09-09 Thread Jeremy Kloth


Jeremy Kloth  added the comment:

For pip, in call_subprocess() (given here in rough pseudo-code)

is_python = (cmd[0] == sys.executable)
kwds = {}
if is_python:
env['PYTHONIOENCODING'] = 'utf8'
kwds['encoding'] = 'utf8'
proc = Popen(..., **kwds)
.
.
.
if stdout is not None:
while True:
line = proc.stdout.readline()
# When running Python, the output is already Unicode
if not is_python:
line = console_to_str(line)
if not line:
break


Hopefully, there is enough context to figure out the exact placement.

--

___
Python tracker 

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



[issue21109] tarfile: Traversal attack vulnerability

2018-09-09 Thread shashank


shashank  added the comment:

A. Regrading Jakub's tests, I suppose the changes needed are to 
for every name in tar
i) find reasonable occurrence of symlink's name and replace it with smylink's 
linkname
ii) convert it to normal path and then check for relative / absolute paths

B. Jakub, are your tests exhaustive or there maybe some corner cases missing? I 
think we don't have tests for hardlinks, yet. Also I think, we will need tests 
for CHRTYPE, FIFOTYPE and BLKTYPE of tar's typeflag[0]


[0] http://www.gnu.org/software/tar/manual/html_node/Standard.html

--
nosy: +shanxS

___
Python tracker 

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



[issue34600] python3 regression ElementTree.iterparse() unable to capture comments

2018-09-09 Thread Martin Hosken


Martin Hosken  added the comment:

Sorry. This test is rather long because it is 3 tests:

from __future__ import print_function
import sys
import xml.etree.ElementTree as et
import xml.etree.cElementTree as cet
from io import StringIO

teststr = u"""


Hello  World

"""
testf = StringIO(teststr)

if len(sys.argv) >= 2 and 'a' in sys.argv[1]:
testf.seek(0)
for event, elem in et.iterparse(testf, events=["end", "comment"]):
if event == 'end':
print(elem.tag + ": " + str(elem.text))
elif event == 'comment':
print("comment: " + elem.text)

if len(sys.argv) < 2 or 'b' in sys.argv[1]:
testf.seek(0)
def doComment(data):
parser.parser.StartElementHandler("!--", ('text', data))
parser.parser.EndElementHandler("!--")
parser = et.XMLParser()
parser.parser.CommentHandler = doComment
for event, elem in et.iterparse(testf, parser=parser):
if hasattr(elem, 'text'):
print(elem.tag + ": " + str(elem.text))
else:
print(elem.tag + ": " + elem.get('text', ""))

if len(sys.argv) < 2 or 'c' in sys.argv[1] or 'd' in sys.argv[1]:
testf.seek(0)
useet = et if len(sys.argv) < 2 or 'c' in sys.argv[1] else cet
class CommentingTb(useet.TreeBuilder):
def __init__(self):
self.parser = None
def comment(self, data):
self.parser.parser.StartElementHandler("!--", ('text', data))
self.parser.parser.EndElementHandler("!--")
tb = CommentingTb()
parser = useet.XMLParser(target=tb)
tb.parser = parser
kw = {'parser': parser} if len(sys.argv) < 2 or 'c' in sys.argv[1] else {}
for event, elem in useet.iterparse(testf, **kw):
if hasattr(elem, 'text'):
print(elem.tag + ": " + str(elem.text))
else:
print(elem.tag + ": " + elem.get('text', ""))

Test 'a' is how I would like to write the solution to my problem. Not sure why 
'comment' isn't supported by iterparse directly, but hey.

Test 'b' is how I solved in it python2

Test 'c' is how I would have to solve it in python3 if it worked

Test 'd' is the same as 'c' but uses cElementTree rather than ElementTree.

Results:

Success output for a test is:
```
!--: None
child: 
Hello 
root: 

```

Python2:
aFails (obviously)
bSucceeds
cSucceeds
dFails: can't inherit from cElementTree.TreeBuilder

Python3:
aFails (obviously)
bFails: XMLParser has no attribute 'parser'
cFails: event handling only supported for ElementTree.TreeBuilder targets
dFails: Gives output but no initial comment component (line 1)

The key failure here is Python3 'c'. This is what stops any hope of comment 
handling using the et.XMLParser. The only way I could get around it was to use 
my own copy from the source code.

--

___
Python tracker 

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



[issue34600] python3 regression ElementTree.iterparse() unable to capture comments

2018-09-09 Thread Martin Hosken


Martin Hosken  added the comment:

Blast. Bugs. Sorry. Missing superclass init call in CommentingTb. I enclose the 
whole thing again to save editing. Also fixes comment output to give text.

from __future__ import print_function
import sys
import xml.etree.ElementTree as et
import xml.etree.cElementTree as cet
from io import StringIO

teststr = u"""


Hello  World

"""
testf = StringIO(teststr)

if len(sys.argv) >= 2 and 'a' in sys.argv[1]:
testf.seek(0)
for event, elem in et.iterparse(testf, events=["end", "comment"]):
if event == 'end':
print(elem.tag + ": " + str(elem.text))
elif event == 'comment':
print("comment: " + elem.text)

if len(sys.argv) < 2 or 'b' in sys.argv[1]:
testf.seek(0)
def doComment(data):
parser.parser.StartElementHandler("!--", ('text', data))
parser.parser.EndElementHandler("!--")
parser = et.XMLParser()
parser.parser.CommentHandler = doComment
for event, elem in et.iterparse(testf, parser=parser):
if elem.tag == "!--":
print(elem.tag + ": " + elem.get('text', ""))
else:
print(elem.tag + ": " + str(elem.text))

if len(sys.argv) < 2 or 'c' in sys.argv[1] or 'd' in sys.argv[1]:
testf.seek(0)
useet = et if len(sys.argv) < 2 or 'c' in sys.argv[1] else cet
class CommentingTb(useet.TreeBuilder):
def __init__(self):
useet.TreeBuilder.__init__(self)
self.parser = None
def comment(self, data):
self.parser.parser.StartElementHandler("!--", ('text', data))
self.parser.parser.EndElementHandler("!--")
tb = CommentingTb()
parser = useet.XMLParser(target=tb)
tb.parser = parser
kw = {'parser': parser} if len(sys.argv) < 2 or 'c' in sys.argv[1] else {}
for event, elem in useet.iterparse(testf, **kw):
if elem.tag == "!--":
print(elem.tag + ": " + elem.get('text', ""))
else:
print(elem.tag + ": " + str(elem.text))

--

___
Python tracker 

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



[issue34618] Encoding error running in subprocess with captured output

2018-09-09 Thread Eryk Sun


Eryk Sun  added the comment:

The interpreter uses the system ANSI codepage for non-console files. In your 
case this is codepage 1252. In my current setup I can't reproduce this issue 
since I'm using the new (beta) support in Windows 10 to configure the ANSI 
codepage as UTF-8 (65001).

You can force standard I/O to use UTF-8 by setting the environment variable 
PYTHONIOENCODING. Also, if you want the CompletedProcess stdout decoded as 
text, in 3.6+ you can pass the parameter `encoding='utf-8'`. For example:

environ = os.environ.copy()
environ['PYTHONIOENCODING'] = 'utf-8'
p = subprocess.run([sys.executable, *args], stdout=subprocess.PIPE, 
stderr=subprocess.STDOUT, env=environ, encoding='utf-8')
print(p.stdout)

--
nosy: +eryksun
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



[issue34475] functools.partial objects have no __qualname__ attribute

2018-09-09 Thread hongweipeng


hongweipeng  added the comment:

the functools.partial returns an instance not fun or cls.using 
`p.func.__qualname__` may be you want.

--
nosy: +hongweipeng

___
Python tracker 

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



[issue34475] functools.partial objects have no __qualname__ attribute

2018-09-09 Thread Chris Jerdonek


Chris Jerdonek  added the comment:

Using p.func would name the function passed to functools.partial() rather than 
the partial object itself.

--

___
Python tracker 

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



[issue34475] functools.partial objects have no __qualname__ attribute

2018-09-09 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue26093] __qualname__ different when calling generator object w/ functions.partial

2018-09-09 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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



[issue34475] functools.partial objects have no __qualname__ attribute

2018-09-09 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

It seems __repr__ call to partial object has qualname but I think it always 
returns "partial". Ref : 
https://github.com/python/cpython/blob/0afada163c7ef25c3a9d46ed445481fb69f2ecaf/Lib/functools.py#L276

>>> import functools
>>> int.__qualname__
'int'
>>> p = functools.partial(int)
>>> p.__qualname__
Traceback (most recent call last):
  File "", line 1, in 
AttributeError: 'functools.partial' object has no attribute '__qualname__'
>>> p
functools.partial()


Thanks

--

___
Python tracker 

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



[issue34616] implement "Async exec"

2018-09-09 Thread Nathaniel Smith


Nathaniel Smith  added the comment:

I think the first thing is to add async "modes" to compile: in particular 
"async-exec" and "async-single". These would be like the current "exec" and 
"single" modes respectively, except that they act like the code is inside an 
"async def", so "await" is allowed, and executing the resulting code object 
produces a coroutine object that has to be iterated to actually run the code.

I guess we might want "async-eval" too just for completeness, though I'm not 
currently aware of any use cases for that.

A utility to check whether an AST requires async mode should be fairly 
straightforward. So if you want to choose on the fly, you would do:

1. ast = compile(source, filename, "async-exec", ast.PyCF_ONLY_AST)
2. use a utility check whether 'ast' contains any top-level 'await'/'async 
with'/'async for'
3. if so, create bytecode with compile(ast, filename, "async-exec"). If not, 
create bytecode with compile(ast, filename, "exec").

Once you have a code object, I think it's too late: if you use "async-exec" 
mode to compile a code object that doesn't actually use 'await', then it should 
still return a coroutine object that needs iterating, etc., just like an 'async 
def' that has no 'await' in it. So if you want to do this check, the AST phase 
is the time to do it. Maybe ast.is_ast_async(ast_obj)?

> Have distinction in this `async exec`/`compile` between "I am compiling a 
> module", currently `exec` mode for both exec and compile, and a "I'm 
> compiling a _multiline_ interactive statement".


This seems like a separate problem from the async stuff... I'm curious to hear 
how what distinction you want to make between 'exec' and a new 'multi-single' 
(?) mode, but maybe that should be a new issue?

--
nosy: +njs

___
Python tracker 

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



[issue34619] Typo in docs.python.jp

2018-09-09 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks for the report. I think translations use Github issues 
(https://github.com/python/python-docs-ja/issues). 
https://www.python.org/dev/peps/pep-0545/#language-team tells me "Redirect 
issues posted on b.p.o to the correct GitHub issue tracker for the language." . 
I think filing an issue there will help. In case you want to raise a PR the 
relevant line is available at 
https://github.com/python/python-docs-ja/blob/29fb57f236ad2230d1aba88bef114633f47a19f9/tutorial/index.po#L44

Thanks

--
nosy: +xtreak

___
Python tracker 

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



[issue34600] python3 regression ElementTree.iterparse() unable to capture comments

2018-09-09 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +xtreak

___
Python tracker 

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