[issue37868] `is_dataclass` returns `True` if `getattr` always succeeds.

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15056
pull_request: https://github.com/python/cpython/pull/15339

___
Python tracker 

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



[issue37868] `is_dataclass` returns `True` if `getattr` always succeeds.

2019-08-19 Thread Eric V. Smith


Eric V. Smith  added the comment:


New changeset b0f4dab8735f692bcfedcf0fa9a25e238a554bab by Eric V. Smith in 
branch 'master':
bpo-37868: Improve is_dataclass for instances. (GH-15325)
https://github.com/python/cpython/commit/b0f4dab8735f692bcfedcf0fa9a25e238a554bab


--

___
Python tracker 

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



[issue37868] `is_dataclass` returns `True` if `getattr` always succeeds.

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15057
pull_request: https://github.com/python/cpython/pull/15340

___
Python tracker 

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



[issue37890] Modernize several tests in test_importlib

2019-08-19 Thread Kyle Stanley


Change by Kyle Stanley :


--
stage:  -> needs patch
type:  -> enhancement

___
Python tracker 

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



[issue37835] typing.get_type_hints wrong namespace for forward-declaration of inner class

2019-08-19 Thread Netzeband


Netzeband  added the comment:

I tried my idea with the small example code above. However it does not work 
like expected: 
(see zipped example project, attached to this comment)

At the moment where the function decorator is applied to the method of the 
inner class, the local namespace ("locals()") does not contain any inner class. 
Even not another inner class, define before the corresponding class.

So the only way to get it working is to add the __locals__ attribute manually 
after defining the class, which is even more ugly than my suggested workaround 
with the function decorator :-(

Any further ideas about this?

--
Added file: 
https://bugs.python.org/file48552/get_type_hints_for_inner_classes.zip

___
Python tracker 

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



[issue37754] Persistence of Shared Memory Segment after process exits

2019-08-19 Thread Vinay Sharma


Vinay Sharma  added the comment:

Hi Davin,
Thanks for replying!

As you said I went through the issue, and now understand why segments should 
not be automatically created if they don't exist.

But, after reading that thread I got to know that shared memory is supposed to 
exist even if the process exits, and it can only be freed by unlink, which I 
also believe is an important functionality required by many use cases as you 
mentioned.

But, this is not the behaviour currently.
As soon as the process exists, all the shared memory created is unlinked.

Also, the documentation currently mentions: "shared memory blocks may outlive 
the original process that created them", which is not the case at all.

Currently, the resource_tracker, unlinks the shared memory, by calling unlink 
as specified here:
```
if os.name == 'posix':
import _multiprocessing
import _posixshmem

_CLEANUP_FUNCS.update({
'semaphore': _multiprocessing.sem_unlink,
'shared_memory': _posixshmem.shm_unlink,
})
```

So, is this an expected behaviour, if yes documentation should be updated, and 
if not the code base should be.

I will be happy to submit a patch in both the cases.

PS: I personally believe from my experience that shared memory segments should 
outlive the process, unless specified otherwise. Also, a argument persist=True, 
can be added which can ensure that the shared_memory segment outlives the 
process, and can be used by processes which are spawned later.

--

___
Python tracker 

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



[issue37835] typing.get_type_hints wrong namespace for forward-declaration of inner class

2019-08-19 Thread Netzeband


Netzeband  added the comment:

Thanks for your response. I was also thinking much about it and was not able to 
find a nice idea how to get this working. 

The problem is, that we loose the local-namespace information as soon as we 
leave the context of the function, where the class was defined in. This 
information is not stored in the function object of the method, we want to get 
the type hints from. The only open question, I have in this context is: 

Why can python resolve the reference to class A (also a inner class, but no 
forward declaration)? Is there any chance to use the same mechanism also for 
forward declared references?

Beside from this question, I will give you my thoughts, how I think this issue 
could be addressed:

 - What we need is the local namespace information from the function, where the 
inner class was defined in. This is not stored from python in the function 
object of this class (but __global__ is stored). 
 - Maybe any upcoming python version could store this information in __local__ 
? So maybe we could clone this ticket to the python core in order to address 
this?

 - As long as python is not storing this information, a workaround could be 
used: We could define a function decorator, which adds the attribute __local__ 
to a function object. I think about this syntax:

class InnerClass():
@store_namespace(locals())
def method() -> 'InnerClass':
...

- The get_type_hints function is then checking for the __local__ attribute and 
if it exits it is passed to the function, which resolves the forward 
declaration.

This workaround is not beautiful, since it requires manual work for those 
methods (adding the function decorator to those methods). Furthermore - without 
knowing the internals of the get_type_hints function - this workaround is not 
straight forward and easy to understand. So it needs to be carefully documented 
and even then I expect confusing questions on StackOverflow or other 
communities. 

However, it is a quite rare case that someone really needs to use inner 
classes. Normally one could simply put the class in the global namespace. But 
when this happens and there is really a need for it, than this workaround would 
make it possible. Furthermore, checking a __local__ attribute of the function 
object would be a nice preparation for a feature request to the python core, 
which should store the reference to the local namespace for every function 
object, without using any decorators.

What do you think?

--

___
Python tracker 

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



[issue37754] Persistence of Shared Memory Segment after process exits

2019-08-19 Thread Vinay Sharma


Change by Vinay Sharma :


--
title: alter size of segment using multiprocessing.shared_memory -> Persistence 
of Shared Memory Segment after process exits

___
Python tracker 

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



[issue37890] Modernize several tests in test_importlib

2019-08-19 Thread Kyle Stanley


Change by Kyle Stanley :


--
nosy: +eric.snow, ncoghlan

___
Python tracker 

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



[issue37890] Modernize several tests in test_importlib

2019-08-19 Thread Kyle Stanley


Kyle Stanley  added the comment:

I'm not entirely certain as to which parts should be modernized, and which ones 
can remain the same. A large part of my uncertainty is that there are no header 
comments for "test_pkg_import.py" to explain the test coverage, so I don't know 
if there are additional tests beyond the existing ones that should be added.

The first steps I can think of: 

1) Use ``importlib.import_module()`` instead of the built-in ``__import__()``

2) Use ``with self.assertRaises(, ): ...`` instead of

```
try: __import__(self.module_name)
except SyntaxError: pass
else: raise RuntimeError('Failed to induce SyntaxError') # self.fail()?

...
```

3) Replace ``self.assertEqual(getattr(module, var), 1)`` with 
``self.assertEqual(getattr(module, var, None), 1)`` so that AttributeErrors are 
not raised when unexpected behaviors occur

4) Provide useful error messages for failed assertions

I'll begin working on those, probably with a separate PR for each of them for 
ease of review. Let me know if there's anything else I should do, or if any of 
the above steps are unneeded. If I think of anything else I'll update the issue 
accordingly.

--

___
Python tracker 

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



[issue37890] Modernize several tests in test_importlib

2019-08-19 Thread Kyle Stanley


New submission from Kyle Stanley :

Last month, several tests were moved into test_importlib 
(https://bugs.python.org/issue19696): "test_pkg_import.py", 
"test_threaded_import.py", and  "threaded_import_hangers.py".

Those tests were created quite a while ago though and do not currently utilize 
importlib directly. They should be updated accordingly.

Brett Cannon:
> BTW, if you want to open a new issue and modernize the tests to use importlib 
> directly that would be great!

I'm interested in helping with this issue, but I may require some assistance as 
I'm not overly familiar with the internals of importlib. I'll probably start 
with "test_pkg_import.py". 

Anyone else can feel free to work on the other two in the meantime, but they 
should be worked on together as "threaded_import_hangers.py" is a dependency 
for "test_threaded_import.py".

--
components: Tests
messages: 349984
nosy: aeros167, brett.cannon
priority: normal
severity: normal
status: open
title: Modernize several tests in test_importlib
versions: Python 3.9

___
Python tracker 

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



[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread Greg Price


Greg Price  added the comment:

Thanks Victor for the reviews and merges!

(Unmarking 2.7, because https://docs.python.org/2/library/stdtypes.html seems 
to not have 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



[issue37866] PyModule_GetState Segmentation fault when called Py_Initialize

2019-08-19 Thread Hua Liu


Change by Hua Liu :


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



[issue37883] threading.Lock.locked is not documented

2019-08-19 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
keywords: +newcomer friendly

___
Python tracker 

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



[issue37887] some leak in the compiler_assert function

2019-08-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Hi hai shi,

As you can see in other pars of the code base objects returned from 
PyUnicode_InternFromString that have static storage class do not need to be 
deallocated in case there is a failure, so this is not considered a leak as 
there will be only one owned object across all calls. The Python object is 
reused every time the function is call (so in successive calls the object can 
be reused and therefore assertion_error!= NULL).

--
nosy: +pablogsal

___
Python tracker 

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



[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Steve Dower


Steve Dower  added the comment:

> So the order of the GetFileInformationByHandleEx and GetFileType blocks 
> actually needs to be flipped.

I've done that now.

And thanks for confirming. That was my suspicion, but I wasn't sure if you knew 
something here that I didn't (v. likely!).

--

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d11c2c607768fa549b1aed7899edc061b2ebf19f by Victor Stinner in 
branch 'master':
Revert "bpo-37788: Fix a reference leak if a thread is not joined (GH-15228)" 
(GH-15338)
https://github.com/python/cpython/commit/d11c2c607768fa549b1aed7899edc061b2ebf19f


--

___
Python tracker 

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



[issue37878] Sub-Interpreters : Document PyThreadState_DeleteCurrent()

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

Is it safe to call PyThreadState_DeleteCurrent()?

--
keywords:  -easy

___
Python tracker 

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



[issue37889] Fatal Python error: Py_EndInterpreter: not the last thread

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

It's a regression caused by bpo-37788. I created PR 15338 to revert my change.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> fix for bpo-36402 (threading._shutdown() race condition) causes 
reference leak

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

> https://github.com/python/cpython/commit/d3dcc92778807ae8f7ebe85178f36a29711cd478

This change introduced a regression :-(
https://github.com/python/cpython/pull/15228#issuecomment-522792133

I created PR 15338 to revert it

--

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15055
pull_request: https://github.com/python/cpython/pull/15338

___
Python tracker 

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



[issue37889] Fatal Python error: Py_EndInterpreter: not the last thread

2019-08-19 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
title: "Fatal Python error: Py_EndInterpreter: not the last thread" that's bad 
-> Fatal Python error: Py_EndInterpreter: not the last thread

___
Python tracker 

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



[issue37889] "Fatal Python error: Py_EndInterpreter: not the last thread" that's bad

2019-08-19 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

See also https://bugs.python.org/issue37788

--

___
Python tracker 

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



[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Eryk Sun


Eryk Sun  added the comment:

> Any particular reason you did GetFileAttributesW(path) in the 
> non-FILE_TYPE_DISK case when we have the hFile around?

The point of getting the file attributes is to identify the root directory of 
the namedpipe and mailslot file systems. For example, os.listdir('//./pipe') 
works because we append "\\*.*" to the path.

GetFileInformationByHandle[Ex] forbids a pipe handle, for reasons that may no 
longer be relevant in Windows 10 (?). I remembered the restriction in the above 
case, but it seems I forgot about it when querying the tag. So the order of the 
GetFileInformationByHandleEx and GetFileType blocks actually needs to be 
flipped. That would be a net improvement anyway since there's no point in 
querying a reparse tag from a device that's not a file system (namedpipe and 
mailslot are 'file systems', but only at the most basic level).

I can't imagine there being a problem with querying FileBasicInfo to get the 
file attributes. I just checked that it works fine with "//./pipe/" and 
"//./mailslot/" -- at least in Windows 10. Anyway, GetFileAttributesW uses a 
query-only open that doesn't create a real file object or even require an IRP 
usually, so it's not adding much cost compared to querying FileBasicInfo using 
the handle.

--

___
Python tracker 

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



[issue37889] "Fatal Python error: Py_EndInterpreter: not the last thread" that's bad

2019-08-19 Thread Pablo Galindo Salgado


New submission from Pablo Galindo Salgado :

The x86-64 High Sierra 3.x buildbot and AMD64 FreeBSD CURRENT Shared 3.x are 
failing with:

Fatal Python error: Py_EndInterpreter: not the last thread

https://buildbot.python.org/all/#/builders/145/builds/2233
https://buildbot.python.org/all/#/builders/168/builds/1295

Fatal Python error: Py_EndInterpreter: not the last thread
Current thread 0x7fff8e587380 (most recent call first):
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/support/__init__.py",
 line 2911 in run_in_subinterp
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/test_threading.py",
 line 1006 in test_threads_join_2
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", 
line 611 in _callTestMethod
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", 
line 654 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/case.py", 
line 714 in __call__
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 122 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 84 in __call__
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 122 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 84 in __call__
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 122 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/suite.py", 
line 84 in __call__
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/unittest/runner.py",
 line 176 in run
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/support/__init__.py",
 line 1996 in _run_suite
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/support/__init__.py",
 line 2092 in run_unittest
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 209 in _test_module
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 234 in _runtest_inner2
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 270 in _runtest_inner
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 153 in _runtest
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/runtest.py",
 line 193 in runtest
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/main.py",
 line 310 in rerun_failed_tests
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/main.py",
 line 678 in _main
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/main.py",
 line 628 in main
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/libregrtest/main.py",
 line 695 in main
  File 
"/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/test/__main__.py", 
line 2 in 
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/runpy.py", 
line 85 in _run_code
  File "/Users/buildbot/buildarea/3.x.billenstein-sierra/build/Lib/runpy.py", 
line 192 in _run_module_as_main
make: *** [buildbottest] Abort trap: 6
program finished with exit code 2
elapsedTime=1799.062811
test_threads_join_2 (test.test_threading.SubinterpThreadingTests) ... 

https://buildbot.python.org/all/#/builders/145/builds/2233

--
messages: 349974
nosy: pablogsal, vstinner
priority: normal
severity: normal
status: open
title: "Fatal Python error: Py_EndInterpreter: not the last thread" that's bad
versions: Python 3.9

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset d3dcc92778807ae8f7ebe85178f36a29711cd478 by Victor Stinner in 
branch 'master':
bpo-37788: Fix a reference leak if a thread is not joined (GH-15228)
https://github.com/python/cpython/commit/d3dcc92778807ae8f7ebe85178f36a29711cd478


--

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15054
pull_request: https://github.com/python/cpython/pull/15337

___
Python tracker 

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



[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15053
pull_request: https://github.com/python/cpython/pull/15336

___
Python tracker 

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



[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Steve Dower


Steve Dower  added the comment:

Thanks for the code snippet, that helped me a lot (and since you went to the 
trouble of fixing other bugs, I guess I'll have to merge it into my PR now).

Any particular reason you did GetFileAttributesW(path) in the 
non-FILE_TYPE_DISK case when we have the hFile around?

I'm trying to get one more opinion from a colleague on setting S_IFLNK for all 
name surrogate reparse points vs. only symlinks by default (the 
Python/fileutils.c change, and implicitly the fixes to Lib/shutil.py). I might 
try and get some broader opinions as well on whether "is_dir() is true, do you 
suspect it could be a junction" vs "is_link() is true, do you suspect it could 
be a junction", since that is what it really comes down to. (We need to make 
changes to shutil to match Explorer anyway - rmtree should not recurse, and 
copytree should.)

However, the minimal change is to leave S_IFLNK only for symlinks, so unless I 
get a strong case for treating all name surrogates as links, I'll revert to 
that.

--

___
Python tracker 

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



[issue23882] unittest discovery doesn't detect namespace packages when given no parameters

2019-08-19 Thread Roger Gammans


Change by Roger Gammans :


--
nosy: +rgammans

___
Python tracker 

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



[issue35617] unittest discover does not work with implicit namespaces

2019-08-19 Thread Roger Gammans


Change by Roger Gammans :


--
nosy: +rgammans

___
Python tracker 

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



[issue36723] Unittest Discovery for namespace subpackages dot notation fails

2019-08-19 Thread Roger Gammans

Roger Gammans  added the comment:

I think this is a duplicate of one (or both) of 35617, or 23882 .

Both of those have unmerged proposed fixes.

--
nosy: +rgammans

___
Python tracker 

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



[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Eryk Sun


Eryk Sun  added the comment:

Here are two additional differences between mount points and symlinks:

(1) A mount point in a remote path is always evaluated on the server and 
restricted to devices that are local to the server. So if we handle a mount 
point as if it's a POSIX symlink that works with readlink(), then what are we 
to do with the server's drive "Z:"? Genuine symlinks are evaluated on the 
client, so readlink() always makes sense. (Though if we resolve a symlink 
manually, then we're bypassing the system's R2L symlink policy.)

(2) A mount point has its own security that's checked in addition to the 
security on the target directory when it's reparsed. In contrast, security set 
on a symlink is not checked when the link is reparsed, which is why icacls.exe 
implicitly resolves a symlink when setting and viewing security unless the /L 
option is used.

>  - if it's a directory junction, call os.stat instead and return that > (???)

I wanted lstat in Windows to traverse mount points by default (but I gave up on 
this), as it does in Unix, because a mount point behaves like a hard name 
grafting in a path. This is important for relative symlinks that use ".." 
components to traverse above their parent directory. The result is different 
from a directory symlink that targets the same path.

A counter-argument (in favor of winlinks) is that a mount point is still 
ultimately a name-surrogate reparse point, so, unlike a hard link, its 
existence doesn't prevent the directory from being deleted. It's left in place 
as a dangling link if the target is deleted or the device is removed from the 
system. Trying to follow it fails with ERROR_PATH_NOT_FOUND or 
ERROR_FILE_NOT_FOUND. 

Also, handling a mount point as a directory by default would require an 
additional parameter because in some cases we need to be able to open a 
junction instead of traversing it, such as to implement shutil.rmtree to behave 
like CMD's `rmdir /s`. 

Another place identifying a mount point is required, unfortunately, is in 
realpath(). Ideally we would be able to handle mount points as just 
directories. The problem is that NT allows a mount point to target a symlink, 
something that's not allowed in Unix. Traversing the mount point is effectively 
the same as traversing the symlink. So we have to read the mount-point target, 
and if it's a symlink, we have to read and evaluate it. (Consequently it seems 
that getting the real path for a remote path is an intractable problem when 
mount points are involved. We can only get the final path.)

---

Even without the addition of a new parameter, we may still want to limit the 
definition of 'link' in Windows lstat to name-surrogate reparse points, i.e. 
winlinks. Reparse points that aren't name surrogates don't behave like links. 
They behave like the file itself, and reparsing may automatically replace the 
reparse point with the real file. Some of them are even directories that have 
the directory bit (28) set in the tag value, which means they're allowed to 
contain other files. (Without the directory tag bit, setting a reparse point on 
a non-empty directory should fail.)

The counter-argument to changing lstat to only open winlinks is that changing 
the meaning of 'link' in lstat is too disruptive to existing software that may 
depend on the old behavior, i.e. opening any reparse point. I think the use 
cases for opening non-links are rare enough that it's not beyond the pale to 
change this behavior in 3.8 or 3.9.

> Right, but is that because they deliberately want the junction 
> to be treated like a file? Or because they want it to be treated 
> like the directory is really right there?

For copytree it makes sense to traverse a mount point as a directory. We can't 
reliably copy a mount point. In Unix, even when a volume mount or bind mount 
can be detected, there's no standard way to clone it to a new mount point, and 
even if there were, that would require super-user access. In Windows, we could 
wrap CreateDirectorExW, which can copy a mount point, but it requires 
administrator access to copy a volume mount point (i.e. 
"?\\Volume{...}\\"), for which it calls SetVolumeMountPointW in order to 
update the mount-point manager in the kernel. 

We also have a limited ability to create mount points via 
_winapi.CreateJunction, but it's buggy in corner cases and incomplete. It 
suffices for the reason it was added -- testing the ability to delete a 
junction via os.remove(). 

> os.rmdir() already does special things to behave like a junction 
> rather than the real directory, 

This is similar in spirit to Unix, except Unix refuses to delete a mount point. 
For example, if we have a Unix bind mount to a non-empty directory, rmdir() 
fails with EBUSY. On the other hand, rmdir() on the real directory fails with 
ENOTEMPTY. If Unix handled the mount point as if it's just the mounted 
directory, I'd expect the error to be the same. 

It's not particularly special in 

[issue37834] readlink on Windows cannot read app exec links

2019-08-19 Thread Eryk Sun


Eryk Sun  added the comment:

Here's the requested overview for the case where name-surrogate reparse points 
are handled as winlinks (Windows links), but S_IFLNK is reserved for 
IO_REPARSE_TAG_SYMLINK. I took the time this afternoon to write it up in C, 
which hopefully is clearer than my prose.  It handles all CreateFileW failures 
inline, but uses a recursive call to traverse a non-link. No reparse tag values 
are hard coded in win32_xstat_impl.

I extended it to support devices that aren't file systems, such as "con", disk 
volumes, and raw disks. This enhancement was requested on another issue, but it 
may as well get updated in this issue if win32_xstat_impl is getting 
overhauled. Some of these devices are already supported by fstat(). The latter 
can be extended similarly to support volume devices and raw disk devices.

I opted to fail the call in the unhandled-tag case if it opens a link that 
should be traversed. Either it's an unhandled link, which is an unacceptable 
condition (i.e. it should be a sink, not a link), or it's a link or sequence of 
links to an unhandled reparse point. Returning the link reparse-point data is 
not what the caller wants from a successful stat().

---

static int
win32_xstat_impl(const wchar_t *path, struct _Py_stat_struct *result,
 BOOL traverse)
{
HANDLE hFile;
BY_HANDLE_FILE_INFORMATION fileInfo;
FILE_ATTRIBUTE_TAG_INFO tagInfo = { 0 };
DWORD fileType, error;
BOOL isUnhandledTag = FALSE;
int retval = 0;

DWORD access = FILE_READ_ATTRIBUTES;
DWORD flags = FILE_FLAG_BACKUP_SEMANTICS; /* Allow opening directories. */
if (!traverse) {
flags |= FILE_FLAG_OPEN_REPARSE_POINT;
}

hFile = CreateFileW(path, access, 0, NULL, OPEN_EXISTING, flags, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
/* Either the path doesn't exist, or the caller lacks access. */
error = GetLastError();
switch (error) {
case ERROR_ACCESS_DENIED: /* Cannot sync or read attributes. */
case ERROR_SHARING_VIOLATION: /* It's a paging file. */
/* Try reading the parent directory. */
if (!attributes_from_dir(path, , )) {
/* Cannot read the parent directory. */
SetLastError(error);
return -1;
}
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) {
if (traverse ||
!IsReparseTagNameSurrogate(tagInfo.ReparseTag)) {
/* The stat call has to traverse but cannot, so fail. */
SetLastError(error);
return -1;
}
}
break;

case ERROR_INVALID_PARAMETER:
/* \\.\con requires read or write access. */
hFile = CreateFileW(path, access | GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, NULL,
OPEN_EXISTING, flags, NULL);
if (hFile == INVALID_HANDLE_VALUE) {
SetLastError(error);
return -1;
}
break;

case ERROR_CANT_ACCESS_FILE:
/* bpo37834: open unhandled reparse points if traverse fails. */
if (traverse) {
traverse = FALSE;
isUnhandledTag = TRUE;
hFile = CreateFileW(path, access, 0, NULL, OPEN_EXISTING,
flags | FILE_FLAG_OPEN_REPARSE_POINT, NULL);
}
if (hFile == INVALID_HANDLE_VALUE) {
SetLastError(error);
return -1;
}
break;

default:
return -1;
}
}

if (hFile != INVALID_HANDLE_VALUE) {

/* Query the reparse tag, and traverse a non-link. */
if (!traverse) {
if (!GetFileInformationByHandleEx(hFile, FileAttributeTagInfo,
, sizeof(tagInfo))) {
/* Allow devices that do no support FileAttributeTagInfo. */
error = GetLastError() ;
if (error == ERROR_INVALID_PARAMETER ||
error == ERROR_INVALID_FUNCTION ||
error == ERROR_NOT_SUPPORTED) {
tagInfo.FileAttributes = FILE_ATTRIBUTE_NORMAL;
tagInfo.ReparseTag = 0;
} else {
retval = -1;
goto cleanup;
}
} else if (tagInfo.FileAttributes &
 FILE_ATTRIBUTE_REPARSE_POINT) {
if (IsReparseTagNameSurrogate(tagInfo.ReparseTag)) {
if (isUnhandledTag) {
/* Traversing previously failed for either this link
   or its target. */
SetLastError(ERROR_CANT_ACCESS_FILE);
retval = -1;
goto cleanup;
}
/* Traverse a 

[issue34155] email.utils.parseaddr mistakenly parse an email

2019-08-19 Thread Abhilash Raj


Abhilash Raj  added the comment:

2.7 needs a separate PR since the code is very different and my familiarity 
with 2.7 version of email package is very limited. 

I am going to work on a separate patch later this week for 2.7.

--

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

AFAICT, no end-user has ever requested this ever.   Despite your insistence, we 
really don't have to clutter the math module with this.

We sometimes do have two or three repetitions of logic in the standard library; 
however, our needs tend to be much different from end-users. Also, we tend to 
benefit from the loose coupling and not turning every little detail into a 
published cross-module API.

Now that we've propagated the as_integer_ratio() into bool, int, float,  
Decimal, and Fraction, I propose we stop there.  This micro-problem to too 
small to warrant adding yet more machinery and API creep.

--

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

This issue if for optimization only. It does not expand the math module API.

Adding public math.as_integer_ratio() has other benefits (it allows to simplify 
the user code), but it is a different issue (see issue37822).

--

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> ISTM that small and probably unimportant opimizations shouldn't spill-over 
> into API feature creep.

The way I see it, the optimization is besides the point here. Regardless of 
performance, the added function is a useful feature to have to avoid forcing 
people to reinvent the wheel.  For example, would you want the exact same code 
duplicated for fractions.Fraction() and for statictics.mean()?

See also #37836 in case you didn't know about that issue.

--

___
Python tracker 

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



[issue37888] Sub-interpreters : Confusing docs about state after calling Py_NewInterpreter()

2019-08-19 Thread Joannah Nanjekye


New submission from Joannah Nanjekye :

In the documentation for Py_NewInterpreter(): It is said that :

The return value points to the first thread state created in the new 
sub-interpreter.  This thread state is made in the current thread state.

I think changing :

This thread state is made in the current thread state.

To:

This thread state is made the current thread state.

Sounds good. Since a call such as:

substate = Py_NewInterpreter()

makes *substate* the current state. no?

The *in* takes me in a different direction of thought.

--
messages: 349964
nosy: nanjekyejoannah
priority: normal
severity: normal
status: open
title: Sub-interpreters : Confusing docs about state after calling 
Py_NewInterpreter()

___
Python tracker 

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



[issue37875] gzip module any difference for compressing png file in version 2.X and 3.X

2019-08-19 Thread Zachary Ware


Change by Zachary Ware :


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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Mark, I don't think the math module API should be expanded for 
as_integer_ratio().  ISTM that small and probably unimportant opimizations 
shouldn't spill-over into API feature creep.  What do you think?

--
assignee:  -> mark.dickinson

___
Python tracker 

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



[issue37764] email.Message.as_string infinite loop

2019-08-19 Thread Ashwin Ramaswami


Ashwin Ramaswami  added the comment:

Thanks, I've fixed the first case as you suggested.

I found an example of the 2nd case -- '=?utf-8?q?=somevalue?=' -- which causes 
the method to hang. I've added a fix, though I'm not sure if it treats the 
string properly -- it parses it as '=?utf-8?q?=somevalue?=' and doesn't raise 
any defects. Is that the behavior we would want?

--

___
Python tracker 

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



[issue37886] PyStructSequence_UnnamedField not exported

2019-08-19 Thread Jeff Robbins


Jeff Robbins  added the comment:

Editing one line in structseq.h seems to fix the issue.

I changed this

extern char* PyStructSequence_UnnamedField;

to

PyAPI_DATA(char*) PyStructSequence_UnnamedField;

rebuilt, and now my C extension can use PyStructSequence_UnnamedField.

--
Added file: https://bugs.python.org/file48551/structseq.h

___
Python tracker 

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



[issue37878] Sub-Interpreters : Document PyThreadState_DeleteCurrent()

2019-08-19 Thread Joannah Nanjekye


Joannah Nanjekye  added the comment:

>From what I know the GIL is released by calling PyEval_ReleaseThread() or 
>PyEval_SaveThread(). 

I see we can use PyThreadState_Delete() to clean up-specifically destroy thread 
state but does not release the GIL and requires a thread state. On the other 
hand, PyThreadState_DeleteCurrent() allows to both clean up the current thread 
state - no thread state is required as well release the GIL which is 
convenient. I would not fight so much to keep it public given we have 
PyEval_ReleaseThread() or PyEval_SaveThread().

--

___
Python tracker 

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



[issue37887] some leak in the compiler_assert function

2019-08-19 Thread hai shi


New submission from hai shi :

Some reference leak in compiler_assert function, due to not using  
Py_DECREF(assertion_error) before return. And having a question about code 
order in compiler_assert function.

--
components: Interpreter Core
files: compiler_assert.patch
keywords: patch
messages: 349959
nosy: pitrou, shihai1991, vstinner
priority: normal
severity: normal
status: open
title: some leak in the compiler_assert function
type: resource usage
versions: Python 3.9
Added file: https://bugs.python.org/file48550/compiler_assert.patch

___
Python tracker 

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



[issue37835] typing.get_type_hints wrong namespace for forward-declaration of inner class

2019-08-19 Thread Ivan Levkivskyi


Ivan Levkivskyi  added the comment:

Thanks for reporting!

I spent some time thinking about this and I can't find any reasonable way of 
doing this, sorry. Anyway, let's keep this open, maybe someone will come up 
with a proposal.

--

___
Python tracker 

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



[issue34155] email.utils.parseaddr mistakenly parse an email

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

> Created a backport PR for 3.5.

Thanks. I reviewed it (LGTM).

What about Python 2.7, it's also vulnerable, no?

--

___
Python tracker 

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



[issue37886] PyStructSequence_UnnamedField not exported

2019-08-19 Thread Jeff Robbins


New submission from Jeff Robbins :

Python 3.8.0b3 has the fixed 
https://docs.python.org/3/c-api/tuple.html#c.PyStructSequence_NewType, but one 
of the documented features of PyStructSequence is the special 
https://docs.python.org/3/c-api/tuple.html#c.PyStructSequence_UnnamedField 
which is meant to be used for unnamed (and presumably also "hidden") fields.

However, this variable is not "exported" (via __declspec(dllexport) or the 
relevant Python C macro) and so my C extension cannot "import" it and use it.

My guess is that this passed testing because the only tests using it are 
internal modules linked into python38.dll, which are happy with the `extern` in 
the header:

Include\structseq.h:extern char* PyStructSequence_UnnamedField;

--
components: Windows
messages: 349956
nosy: je...@livedata.com, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: PyStructSequence_UnnamedField not exported
type: compile error
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



[issue37866] PyModule_GetState Segmentation fault when called Py_Initialize

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

Python 3.5 no longer accept bug fixes. Are you able to reproduce the bug with 
Python 3.8, or Python 3.7?

> the crash file came out when i tried to call Py_Initialize in a C file.

Can you provide this file?

What is your OS and OS version? How did you install Python?

--

___
Python tracker 

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



[issue37878] Sub-Interpreters : Document PyThreadState_DeleteCurrent()

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

I'm not sure why PyThreadState_DeleteCurrent() is exposed. Why would anyone use 
it?

It is used internally by the _thread module when the thread function completes.

I suggest to make the function internal instead of documenting it.

Eric, Joannah: what do you think?

--

___
Python tracker 

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



[issue37565] test_faulthandler: test_register_chain() crash with SIGSEGV (signal 11) on Skylake chipset

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

Bennet Fauber:
> It would appear that jshelly was correct and this is resolved by fixing the 
> problem isolated in issue 21131, which was closed and a patch was committed.

Great! I close this issue as a duplicate of bpo-21131.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> test_faulthandler.test_register_chain fails on 64bit ppc/arm 
with kernel >= 3.10

___
Python tracker 

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



[issue18835] Add PyMem_AlignedAlloc()

2019-08-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15052
pull_request: https://github.com/python/cpython/pull/15333

___
Python tracker 

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



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-19 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +15051
pull_request: https://github.com/python/cpython/pull/15333

___
Python tracker 

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



[issue37869] Compilation warning on GCC version 7.4.0-1ubuntu1~18.04.1

2019-08-19 Thread STINNER Victor


Change by STINNER Victor :


--
stage:  -> resolved
status: open -> closed
superseder:  -> Possible uninitialized variable in Objects/obmalloc.c

___
Python tracker 

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



[issue37732] Possible uninitialized variable in Objects/obmalloc.c

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

bpo-37869 has been marked as a duplicate of this issue.

--
nosy: +vstinner

___
Python tracker 

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



[issue37869] Compilation warning on GCC version 7.4.0-1ubuntu1~18.04.1

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

Duplicate of bpo-37732.

--

___
Python tracker 

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



[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

str.isspace() documentation has been fixed, thanks Greg Price for the fix! I 
close the 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



[issue21131] test_faulthandler.test_register_chain fails on 64bit ppc/arm with kernel >= 3.10

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:

> Its interesting to read the comment on the IA64 definition for SIGSTKSZ:

Python doesn't support IA64 architecture.

Note: I'm not sure that this architecture is going to survive in the long 
term... More and more systems stopped to support it.


> Well, one argument for the dynamic approach is that existing python
binaries can adjust without needing to be respun for new CPUs.

PR 13649 gets the default thread stack size, it doesn't get SIGSTKSZ. I expect 
a thread stack size to be way larger than SIGSTKSZ.

For on my Fedora 30 (Linux kernel 5.1.19-300.fc30.x86_64, 
glibc-2.29-15.fc30.x86_64) on x86-64, SIGSTKSZ is just 8 KiB (8192 bytes) 
whereas pthread_attr_getstacksize() returns 8 MiB (8388608 bytes).

As I already wrote, using 8 MiB instead of 8 KiB looks like a waste of memory: 
faulthandler is only useful for stack overflow, which is a very unlikely bug.

--

___
Python tracker 

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



[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread miss-islington


miss-islington  added the comment:


New changeset 0fcdd8d6d67f57733203fc79e6a07a89b924a390 by Miss Islington (bot) 
in branch '3.7':
bpo-36502: Correct documentation of str.isspace() (GH-15019) (GH-15296)
https://github.com/python/cpython/commit/0fcdd8d6d67f57733203fc79e6a07a89b924a390


--
nosy: +miss-islington

___
Python tracker 

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



[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread miss-islington


Change by miss-islington :


--
pull_requests: +15050
pull_request: https://github.com/python/cpython/pull/15332

___
Python tracker 

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



[issue36502] str.isspace() for U+00A0 and U+202F differs from document

2019-08-19 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 8c1c426a631ba02357112657193f82c58d3e08b4 by Victor Stinner (Greg 
Price) in branch '3.8':
bpo-36502: Correct documentation of str.isspace() (GH-15019) (GH-15296)
https://github.com/python/cpython/commit/8c1c426a631ba02357112657193f82c58d3e08b4


--

___
Python tracker 

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



[issue37819] as_integer_ratio() missing from fractions.Fraction()

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> Sorry, but I do not understand why adding Fraction.as_integer_ratio() 
> prevents adding math.as_integer_ratio().

I also support a public function for that. It seems that we're planning this 
"as_integer_ratio" thing to become public API, so why not have a function as 
Serhiy proposes?

I consider the situation with as_integer_ratio() very analogous to __index__ 
where we have operator.index(), so I would actually suggest 
operator.as_integer_ratio() but that's bikeshedding territory.

--
nosy: +jdemeyer

___
Python tracker 

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



[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> I afraid this can slow down the Fraction constructor.

No, it doesn't! It even speeds up the constructor in some cases:

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
1' 'Fraction(x)'
BEFORE: Mean +- std dev: 826 ns +- 20 ns
AFTER:  Mean +- std dev: 814 ns +- 17 ns

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
1' 'Fraction(x, x)'
BEFORE: Mean +- std dev: 1.44 us +- 0.03 us
AFTER:  Mean +- std dev: 1.46 us +- 0.02 us

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
Fraction(1)' 'Fraction(x)'
BEFORE: Mean +- std dev: 1.64 us +- 0.03 us
AFTER:  Mean +- std dev: 1.30 us +- 0.04 us

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
Fraction(1)' 'Fraction(x, x)'
BEFORE: Mean +- std dev: 3.03 us +- 0.05 us
AFTER:  Mean +- std dev: 2.34 us +- 0.06 us

./python -m perf timeit --duplicate 200 -s 'from fractions import Fraction; x = 
1.0' 'Fraction(x)'
BEFORE: Mean +- std dev: 1.82 us +- 0.02 us
AFTER:  Mean +- std dev: 1.29 us +- 0.04 us

--

___
Python tracker 

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



[issue37885] venv: Don't produce unbound variable warning on deactivate

2019-08-19 Thread Daniel Abrahamsson


Change by Daniel Abrahamsson :


--
keywords: +patch
pull_requests: +15048
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15330

___
Python tracker 

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



[issue37885] venv: Don't produce unbound variable warning on deactivate

2019-08-19 Thread Daniel Abrahamsson


New submission from Daniel Abrahamsson :

Running deactivate from a bash shell configured to treat undefined variables as 
errors (`set -u`) produces a warning:

``` 
$ python3 -m venv test
$ source test/bin/activate
(test) $ deactivate
-bash: $1: unbound variable
```

--
components: Library (Lib)
messages: 349944
nosy: danabr
priority: normal
severity: normal
status: open
title: venv: Don't produce unbound variable warning on deactivate
type: enhancement

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> There is a 14% regression in creating a Fraction from an integer

Isn't that the main use case? I suggest to keep the special case for 'int' as 
fast path to avoid this regression.

--
nosy: +jdemeyer

___
Python tracker 

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



[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-19 Thread Jeroen Demeyer


Jeroen Demeyer  added the comment:

> See issue37884 which uses a C accelerator.

Note that that doesn't replace this issue, because I need to support 
as_integer_ratio both in the *numerator* and *denominator*.

--

___
Python tracker 

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



[issue37664] Update bundled pip and setuptools

2019-08-19 Thread Pradyun Gedam


Pradyun Gedam  added the comment:

There wasn't a new setuptools release when I updated these the last time,
IIRC.

Anyway, I'll cut a new release for pip, file a new b.p.o. issue and get to
updating both of these sometime this week.

On Mon, 19 Aug 2019 at 11:20 AM, Inada Naoki  wrote:

>
> Inada Naoki  added the comment:
>
> When updating pip next time, please update setuptools too.
> https://setuptools.readthedocs.io/en/latest/history.html#v41-1-0
>
> > #1788: Changed compatibility fallback logic for html.unescape to avoid
> accessing HTMLParser.unescape when not necessary. HTMLParser.unescape is
> deprecated and will be removed in Python 3.9.
>
> This is blocking #37328.
>
> --
> nosy: +inada.naoki
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue37836] Support .as_integer_ratio() in fractions.Fraction

2019-08-19 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See issue37884 which uses a C accelerator.

--

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
pull_requests: +15047
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/15329

___
Python tracker 

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



[issue37884] Optimize Fraction() and statistics.mean()

2019-08-19 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

The proposed PR optimizes the Fraction constructor and statistics.mean() (and 
several other statistics functions) by using a private helper implemented in C 
which abstracts converting a number to an integer ratio.

$ ./python -m timeit -s "from fractions import Fraction as F" "F(123)"
50 loops, best of 5: 655 nsec per loop
50 loops, best of 5: 749 nsec per loop

$ ./python -m timeit -s "from fractions import Fraction as F" "F(1.23)"
20 loops, best of 5: 1.29 usec per loop
20 loops, best of 5: 1.03 usec per loop

$ ./python -m timeit -s "from fractions import Fraction as F; f = F(22, 7)" 
"F(f)"
20 loops, best of 5: 1.17 usec per loop
50 loops, best of 5: 899 nsec per loop

$ ./python -m timeit -s "from fractions import Fraction as F; from decimal 
import Decimal as D; d = D('1.23')" "F(d)"
20 loops, best of 5: 1.64 usec per loop
20 loops, best of 5: 1.29 usec per loop


$ ./python -m timeit -s "from statistics import mean; a = [1]*1000" "mean(a)"
500 loops, best of 5: 456 usec per loop
1000 loops, best of 5: 321 usec per loop

$ ./python -m timeit -s "from statistics import mean; a = [1.23]*1000" "mean(a)"
500 loops, best of 5: 645 usec per loop
500 loops, best of 5: 659 usec per loop

$ ./python -m timeit -s "from statistics import mean; from fractions import 
Fraction as F; a = [F(22, 7)]*1000" "mean(a)"
500 loops, best of 5: 637 usec per loop
500 loops, best of 5: 490 usec per loop

$ ./python -m timeit -s "from statistics import mean; from decimal import 
Decimal as D; a = [D('1.23')]*1000" "mean(a)"
500 loops, best of 5: 946 usec per loop
500 loops, best of 5: 915 usec per loop

There is a 14% regression in creating a Fraction from an integer, but for 
non-integer numbers it gains 25% speed up. The effect on statistics.mean() 
varies from insignificant to +40%.

--
components: Library (Lib)
messages: 349939
nosy: mark.dickinson, rhettinger, serhiy.storchaka, steven.daprano
priority: normal
severity: normal
status: open
title: Optimize Fraction() and statistics.mean()
type: performance
versions: Python 3.9

___
Python tracker 

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



[issue37873] unittest: execute tests in parallel

2019-08-19 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +ezio.melotti, michael.foord

___
Python tracker 

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



[issue37873] unittest: execute tests in parallel

2019-08-19 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

test.regrtest has a  -j option. Perhaps some of the Python coding for that 
could be used for unitest also.

--
nosy: +terry.reedy

___
Python tracker 

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