[issue41458] Avoid overflow/underflow in math.prod()

2020-08-05 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Two edits:

- s.append(x) if side == s_side else t.append(y)
+ s.append(x) if side == s_side else t.append(x)


- return prod(s, start=total)
+for x in s:
+total *= x
+return total

--

___
Python tracker 

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



[issue39871] math.copysign raises SystemError with non-float x and custom y

2020-08-05 Thread Zackery Spytz


Change by Zackery Spytz :


--
pull_requests: +20893
pull_request: https://github.com/python/cpython/pull/21749

___
Python tracker 

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



[issue41458] Avoid overflow/underflow in math.prod()

2020-08-05 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Here's variant (minimally tested) that has a fast path for the common case (no 
overflow or underflow), that uses a list instead of a deque, that keeps memory 
use small (only storing pending values that can't be combined without 
triggering an overflow or underflow).



from math import fabs, prod, isfinite

def product(seq, start=1.0):
total = start
s = [] # values that would overflow the total
s_side = False # true if s_i increase the magnitude of the product
for x in seq:
old_total = total
total *= x
underflow = not total and old_total and not x
if isfinite(total) and not underflow:
continue   # fast-path for multiplies that doesn't 
overflow/underflow
total = old_total

side = fabs(x) > 1.0
if not s or side == s_side:
s.append(x)
s_side = side
continue

t = [x, total]
while s and t:  # opposite sides:  matter and antimatter
x = s.pop() * t.pop()
side = fabs(x) > 1.0
s.append(x) if side == s_side else t.append(y)
if t:
s = t
s_side = not s_side
total = s.pop()
return prod(s, start=total)

--

___
Python tracker 

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



[issue41411] Improve and consolidate f-strings docs

2020-08-05 Thread Ama Aje My Fren


Ama Aje My Fren  added the comment:

Hi,

>The online docs seem updated, so I'm not sure why it's not working. Maybe you 
>could try

So it seems that the .. index::[0] directive creates an index[1]. Both f-index 
and findex are available in it.
Search is a bit different. A searchindex[2] is generated once when the html is 
being created. This is then used, locally, when user does search. Still it is 
not very good. Multiple word queries[3] and hyphenated words don't appear to 
work[4] well (I also tested this locally, f-string does not get searchindexed 
while fstring does. Searching also gives the lexical analysis as one of the 
pages when searching for fstring.)


> What about doing the following:
> * keep having stdtypes.rst cover and explain all the built-in types and their 
> features;
> * move the "Format String Syntax", "Format Specification Mini-Language", 
> "Format examples" sections from string.rst to stdtypes.rst where they belong;
> * integrate f-strings in these sections, and add a new section explaining 
> f-string-specific quirks;
> * leave the printf-style string formatting in stdtypes.rst, after the format 
> sections
> * use string.rst to document the string module and its objects, hence leaving 
> string.Formatter and string.Template here, where they belong 
> (string.Formatter is self contained enough that doesn't need to be with the 
> other format sections);
> * leave the inputoutput.rst and lexical_analysis pages as they are;
> * update the introduction.rst page to mention f-string;

introduction.rst has a reference to "Formatted string literals" in the "See 
also:" box[5]. But I can still put an example here. Should we put both 
str.format() and f-strings, or make this exclusively for f-strings?

> * once all this is done, update all links to point to the appropriate 
> sections and cross-link all related sections;

Ok.

Please can we progress as follows: (Each as sequential and independent PR)

1) f-string added to stdtypes.rst. I have done this in PR 21552. We can 
complete that one and commit it as the first step. It provides both the 
f-string and the f-string-specific quacks.
2) Add the same wording of f-string to pydoc. I have been studying how to do 
this. At this moment help(fstring) and help(f-string) do not work.

PS C:\> py -3.9
Python 3.9.0b5 (tags/v3.9.0b5:8ad7d50, Jul 20 2020, 18:35:09) [MSC v.1924 64 
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> help(fstring)
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'fstring' is not defined
>>> help(f-string)
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'f' is not defined
>>>

3) Move "Format String Syntax", "Format Specification Mini-Language", "Format 
examples" sections from string.rst to stdtypes.rst and ensure references all 
work well.

4) Add additional f-string-quarks as we discuss into stdtypes.rst.


[0] 
https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html#index-generating-markup
[1] https://docs.python.org/dev/genindex-F.html
[2] https://docs.python.org/dev/searchindex.js
[3] https://github.com/sphinx-doc/sphinx/issues/1486
[4] https://github.com/sphinx-doc/sphinx/issues/1486#issuecomment-122115215
[5] https://docs.python.org/3.9/tutorial/introduction.html

--

___
Python tracker 

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



[issue41304] [CVE-2020-15801] python 38 embed ignore python38._pth file on windows

2020-08-05 Thread huangtaizhuo


huangtaizhuo  added the comment:

hi, since the affected system is not clearly stated on the NVD, I'd like to 
confirm with you that: 


Does the CVE-2020-15801 vulnerability affect only the Windows OS? 


thanks a lot!

--
nosy: +owen.huang

___
Python tracker 

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



[issue41456] loop.run_in_executor creat thread but not destory it after the task run over

2020-08-05 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

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



[issue41450] OSError is not documented in ssl library, but still can be thrown

2020-08-05 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

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



[issue41458] Avoid overflow/underflow in math.prod()

2020-08-05 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

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



[issue41465] io.TextIOWrapper.errors not writable

2020-08-05 Thread Jeffrey Kintscher


Jeffrey Kintscher  added the comment:

I looked at the implementation in Lib/_pyio.py.  The only way to change the 
error handler is by calling TextIOWrapper.reconfigure() and supply the new 
error handler as the "errors" parameter.  For example:

>>> import io
>>> s = io.TextIOWrapper(io.BytesIO())
>>> print(s.errors)
strict
>>> s.reconfigure(errors='replace')
>>> print(s.errors)
replace
>>>

--

___
Python tracker 

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



[issue41465] io.TextIOWrapper.errors not writable

2020-08-05 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

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



[issue41492] Fix signing description for Windows release builds

2020-08-05 Thread Steve Dower


New submission from Steve Dower :

At some point, Windows started displaying an authenticated certificate property 
as the display name in UAC prompts, rather than the file properties.

Currently our SigningDescription is set to the build identifier, which is not a 
nice display name. We should change it to be "Python 3.x.y" (which will involve 
updating the build YAML files to extract the version number).

--
assignee: steve.dower
components: Windows
messages: 374910
nosy: paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
stage: needs patch
status: open
title: Fix signing description for Windows release builds
type: behavior
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue41398] cgi module, parse_multipart fails

2020-08-05 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

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



[issue41470] smtplib.SMTP should reset internal 'helo' and 'ehlo' state within 'connect()'

2020-08-05 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

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



[issue41490] Update bundled pip to 20.2.1 and setuptools to 49.2.1

2020-08-05 Thread Steve Dower


Steve Dower  added the comment:

Test failure on Windows. I'll take a look tomorrow.

==
FAIL: test_with_pip (test.test_venv.EnsurePipTest)
--
Traceback (most recent call last):
  File "D:\a\cpython\cpython\lib\test\test_venv.py", line 476, in 
do_test_with_pip
self.run_with_capture(venv.create, self.env_dir,
  File "D:\a\cpython\cpython\lib\test\test_venv.py", line 76, in 
run_with_capture
func(*args, **kwargs)
subprocess.CalledProcessError: Command 
'['C:\\Users\\runneradmin\\AppData\\Local\\Temp\\tmp3cz40z50\\Scripts\\python.exe',
 '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit 
status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "D:\a\cpython\cpython\lib\test\test_venv.py", line 536, in test_with_pip
self.do_test_with_pip(False)
  File "D:\a\cpython\cpython\lib\test\test_venv.py", line 484, in 
do_test_with_pip
self.fail(msg.format(exc, details))
AssertionError: Command 
'['C:\\Users\\runneradmin\\AppData\\Local\\Temp\\tmp3cz40z50\\Scripts\\python.exe',
 '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit 
status 1.

**Subprocess Output**
Looking in links: c:\Users\RUNNER~1\AppData\Local\Temp\tmped5jdzqn

Processing 
c:\users\runneradmin\appdata\local\temp\tmped5jdzqn\setuptools-49.2.1-py3-none-any.whl

Processing 
c:\users\runneradmin\appdata\local\temp\tmped5jdzqn\pip-20.2.1-py2.py3-none-any.whl

Installing collected packages: setuptools, pip

Successfully installed pip-20.2.1 setuptools-49.2.1

Traceback (most recent call last):

  File "D:\a\cpython\cpython\lib\shutil.py", line 613, in _rmtree_unsafe

os.unlink(fullname)

PermissionError: [WinError 32] The process cannot access the file because it is 
being used by another process: 
'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmped5jdzqn\\pip-20.2.1-py2.py3-none-any.whl'



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "D:\a\cpython\cpython\lib\tempfile.py", line 802, in onerror

_os.unlink(path)

PermissionError: [WinError 32] The process cannot access the file because it is 
being used by another process: 
'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmped5jdzqn\\pip-20.2.1-py2.py3-none-any.whl'



During handling of the above exception, another exception occurred:



Traceback (most recent call last):

  File "D:\a\cpython\cpython\lib\runpy.py", line 197, in _run_module_as_main

return _run_code(code, main_globals, None,

  File "D:\a\cpython\cpython\lib\runpy.py", line 87, in _run_code

exec(code, run_globals)

  File "D:\a\cpython\cpython\lib\ensurepip\__main__.py", line 5, in 

sys.exit(ensurepip._main())

  File "D:\a\cpython\cpython\lib\ensurepip\__init__.py", line 213, in _main

return _bootstrap(

  File "D:\a\cpython\cpython\lib\ensurepip\__init__.py", line 132, in _bootstrap

return _run_pip(args + [p[0] for p in _PROJECTS], additional_paths)

  File "D:\a\cpython\cpython\lib\tempfile.py", line 827, in __exit__

self.cleanup()

  File "D:\a\cpython\cpython\lib\tempfile.py", line 831, in cleanup

self._rmtree(self.name)

  File "D:\a\cpython\cpython\lib\tempfile.py", line 813, in _rmtree

_shutil.rmtree(name, onerror=onerror)

  File "D:\a\cpython\cpython\lib\shutil.py", line 737, in rmtree

return _rmtree_unsafe(path, onerror)

  File "D:\a\cpython\cpython\lib\shutil.py", line 615, in _rmtree_unsafe

onerror(os.unlink, fullname, sys.exc_info())

  File "D:\a\cpython\cpython\lib\tempfile.py", line 805, in onerror

cls._rmtree(path)

  File "D:\a\cpython\cpython\lib\tempfile.py", line 813, in _rmtree

_shutil.rmtree(name, onerror=onerror)

  File "D:\a\cpython\cpython\lib\shutil.py", line 737, in rmtree

return _rmtree_unsafe(path, onerror)

  File "D:\a\cpython\cpython\lib\shutil.py", line 596, in _rmtree_unsafe

onerror(os.scandir, path, sys.exc_info())

  File "D:\a\cpython\cpython\lib\shutil.py", line 593, in _rmtree_unsafe

with os.scandir(path) as scandir_it:

NotADirectoryError: [WinError 267] The directory name is invalid: 
'C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\tmped5jdzqn\\pip-20.2.1-py2.py3-none-any.whl'



--

--

___
Python tracker 

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



[issue41477] test_genericalias fails if ctypes is missing

2020-08-05 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

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



[issue41489] HTMLParser : HTMLParser.error creating multiple errors.

2020-08-05 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

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



[issue41491] plistlib can't load macOS BigSur system LaunchAgent

2020-08-05 Thread Jeffrey Kintscher


Change by Jeffrey Kintscher :


--
nosy: +Jeffrey.Kintscher

___
Python tracker 

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



[issue41490] Update bundled pip to 20.2.1 and setuptools to 49.2.1

2020-08-05 Thread Steve Dower


Change by Steve Dower :


--
keywords: +patch
pull_requests: +20892
stage: needs patch -> patch review
pull_request: https://github.com/python/cpython/pull/21748

___
Python tracker 

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



[issue41491] plistlib can't load macOS BigSur system LaunchAgent

2020-08-05 Thread Wesley Whetstone


Change by Wesley Whetstone :


--
components: +macOS
nosy: +ned.deily, ronaldoussoren

___
Python tracker 

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



[issue41491] plistlib can't load macOS BigSur system LaunchAgent

2020-08-05 Thread Wesley Whetstone


New submission from Wesley Whetstone :

When attempting to load the new LaunchAgent at 
`/System/Library/LaunchAgents/com.apple.cvmsCompAgent3600_arm64.plist` plistlib 
Raises a ValueError of 

  File "/opt/salt/lib/python3.7/plistlib.py", line 272, in handle_end_element
handler()
  File "/opt/salt/lib/python3.7/plistlib.py", line 332, in end_integer
self.add_object(int(self.get_data()))
ValueError: invalid literal for int() with base 10: '0x010c'

on


0x010c


Technically this violates the spec at 
http://www.apple.com/DTDs/PropertyList-1.0.dtd. Figured it was worth reporting.

Full Plist is attached.

--
files: com.apple.cvmsCompAgent_arm64.plist
messages: 374908
nosy: jckwhet
priority: normal
severity: normal
status: open
title: plistlib can't load macOS BigSur system LaunchAgent
Added file: 
https://bugs.python.org/file49371/com.apple.cvmsCompAgent_arm64.plist

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread Eric V. Smith


Eric V. Smith  added the comment:

Thanks, Terry. That was my fault, trying to cherry pick manually. I'm not sure 
why the original backport failed, and once I did the manual cherry pick as 
suggested I got called away for real work. As you say, I should have tried 
deleting the tag and re-adding it before I pulled out the cherry pick tool.

Thank you for cleaning up after me.

--

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread miss-islington


miss-islington  added the comment:


New changeset b49b88a93a06b656d7f6a64d9d9e4828921d86eb by Miss Islington (bot) 
in branch '3.9':
bpo-41482: Fix error in ipaddress.IPv4Network docstring (GH-21736)
https://github.com/python/cpython/commit/b49b88a93a06b656d7f6a64d9d9e4828921d86eb


--

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

I was able to delete the spurious branch because it was not protected.

--

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Since this is a trivial typo fix, I approved the backport for auto-merge.

--

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread miss-islington


miss-islington  added the comment:


New changeset b5789a7419655f66692fab463320048bd2290e81 by Miss Islington (bot) 
in branch '3.8':
bpo-41482: Fix error in ipaddress.IPv4Network docstring (GH-21736)
https://github.com/python/cpython/commit/b5789a7419655f66692fab463320048bd2290e81


--

___
Python tracker 

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



[issue37293] concurrent.futures.InterpreterPoolExecutor

2020-08-05 Thread jakirkham


Change by jakirkham :


--
nosy: +jakirkham

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The issue resulting in the addition of a "backport-52f9842-3.9" branch to the 
main python/cpython repository.  I believe that this is a mistake and should be 
removed, but I don't know how.

When miss-islington fails to backport for reasons other than a merge conflict, 
the problem is likely transient  -- perhaps a timing issue or temporary 
resource unavailable issue that we have no control over.  The solution is to 
delete the backport label, close the label box, reopen the label box, add the 
label, and reclose.  I did this and the auto backport was generated.  (The 3.8 
backport is ready to approve and merge.)

--
nosy: +terry.reedy

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
type: enhancement -> behavior
versions:  -Python 3.5, Python 3.6, Python 3.7

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread miss-islington


Change by miss-islington :


--
pull_requests: +20891
pull_request: https://github.com/python/cpython/pull/21747

___
Python tracker 

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



[issue41490] Update bundled pip to 20.2.1 and setuptools to 49.2.1

2020-08-05 Thread Steve Dower


New submission from Steve Dower :

I'm doing the PR now, based on the latest versions available today:

https://pypi.org/project/pip/20.2.1/
https://pypi.org/project/setuptools/49.2.1/

If you're a maintainer and there's a reason to not update to to the latest, 
please let me know asap. All of our subsequent releases should be RC's, so I 
assume we won't take any changes bigger than targeted fixes before the next 
full releases.

--
assignee: steve.dower
components: Distutils
messages: 374901
nosy: Marcus.Smith, dstufft, eric.araujo, jaraco, lukasz.langa, ncoghlan, 
paul.moore, pradyunsg, steve.dower
priority: normal
severity: normal
stage: needs patch
status: open
title: Update bundled pip to 20.2.1 and setuptools to 49.2.1
versions: Python 3.10, Python 3.8, Python 3.9

___
Python tracker 

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



[issue41232] Python `functools.wraps` doesn't deal with defaults correctly

2020-08-05 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Thor, in the future, when you reply by email, snip off the messages you are 
replying to.  When you your message is added to the webpage below the earlier 
message, the copy become extraneous noise.  Quoting the hidden boilerplate on 
PRs is also useless.

For the purpose of this tracker, a bug is a discrepancy between the code and 
the docs.  Since I have hardly used wraps nor read it docs in detail, I have no 
particular opinion.

--

___
Python tracker 

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



[issue41489] HTMLParser : HTMLParser.error creating multiple errors.

2020-08-05 Thread AbcSxyZ

New submission from AbcSxyZ :

Coming from deprecated feature. Using python 3.7.3

Related and probably fixed with https://bugs.python.org/issue31844
Just in case.

I've got 2 different related problems, the first one creating the second.

Using linked file and this class :
```
from html.parser import HTMLParser

class LinkParser(HTMLParser):
""" DOM parser to retrieve href of all  elements """

def parse_links(self, html_content):
self.links = []
self.feed(html_content)
return self.links

def handle_starttag(self, tag, attrs):
if tag == "a":
attrs = {key.lower():value for key, *value in attrs}
urls = attrs.get("href", None)
if urls and urls[0]:
self.links.append(urls[0])

# def error(self, *args, **kwargs):
# pass

if __name__ == "__main__":
with open("error.txt") as File:
LinkParser().parse_links(File.read())

```

With error method commented, it creates :
```
  File "scanner/link.py", line 8, in parse_links


self.feed(html_content) 


  File "/usr/lib/python3.7/html/parser.py", line 111, in feed   


self.goahead(0)
  File "/usr/lib/python3.7/html/parser.py", line 179, in goahead
k = self.parse_html_declaration(i)
  File "/usr/lib/python3.7/html/parser.py", line 264, in parse_html_declaration
return self.parse_marked_section(i)
  File "/usr/lib/python3.7/_markupbase.py", line 159, in parse_marked_section
self.error('unknown status keyword %r in marked section' % rawdata[i+3:j])
  File "/usr/lib/python3.7/_markupbase.py", line 34, in error
"subclasses of ParserBase must override error()")
NotImplementedError: subclasses of ParserBase must override error()
```

If error method do not raise anything, using only pass, it creates :
```
  File "/home/simon/Documents/radio-parser/scanner/link.py", line 8, in 
parse_links
self.feed(html_content)
  File "/usr/lib/python3.7/html/parser.py", line 111, in feed
self.goahead(0)
  File "/usr/lib/python3.7/html/parser.py", line 179, in goahead
k = self.parse_html_declaration(i)
  File "/usr/lib/python3.7/html/parser.py", line 264, in parse_html_declaration
return self.parse_marked_section(i)
  File "/usr/lib/python3.7/_markupbase.py", line 160, in parse_marked_section
if not match:
UnboundLocalError: local variable 'match' referenced before assignment
```

We see here `match` variable is not created if `self.error` is called,
and because error do not raise exception, will create UnboundLocalError :

```
def parse_marked_section(self, i, report=1):
rawdata= self.rawdata
assert rawdata[i:i+3] == ' ending
match= _markedsectionclose.search(rawdata, i+3)
elif sectName in {"if", "else", "endif"}:
# look for MS Office ]> ending
match= _msmarkedsectionclose.search(rawdata, i+3)
else:
self.error('unknown status keyword %r in marked section' % 
rawdata[i+3:j])
if not match:
return -1
if report:
j = match.start(0)
self.unknown_decl(rawdata[i+3: j])
return match.end(0)

```

--
files: error.txt
messages: 374899
nosy: AbcSxyZ
priority: normal
severity: normal
status: open
title: HTMLParser : HTMLParser.error creating multiple errors.
type: crash
versions: Python 3.7
Added file: https://bugs.python.org/file49370/error.txt

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


[issue40726] ast.Call end_lineno is defined and returns None

2020-08-05 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


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



[issue41129] Python extension modules fail to build on Mac 10.15.1 (Catalina)

2020-08-05 Thread Andrew


Andrew  added the comment:

So I believe I've found the problem as to why we can't get the extension 
modules to build in our network area.

It seems to be a problem with setup.py's find_file() and is_macosx_sdk_path() 
functions when the extension modules are building. You can find these functions 
around line 182 of setup.py.

For some background, our network location /mathworks is usually mounted at 
root, but due to the restrictions on macOS Catalina, it mounts at 
/System/Volumes/Data and we then add a symlink to the root directory so 
"/mathworks -> /System/Volumes/Data/mathworks" as to not break old code and 
scripts. So the real problem is that we cannot find extension module files 
under /System/Volumes/Data.

This problem occurs because in setup.py, when we attempt to find an extension 
module file with find_file() wherein the file registers as being in the mac sdk 
path since the path starts with "/System". This is a problem because 
find_file() then prepends the file with the sdk path which isn't quite right 
and fails the existence check. For example a source file that actually exists 
at "/System/Volumes/Data/mathworks/hub/scratch/aflewell/Python-3.8.2/Modules/" 
find_file() calls os.path.exists() on 
"/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Volumes/Data/mathworks/hub/scratch/aflewell/Python-3.8.2/Modules/"
 which fails since the path does not exist at or after the "Volumes" part. This 
causes find_file to think the file does not exist at all, so the compiler ends 
up trying to compile the file without an absolute path or relative path to it, 
which fails.

This can be fixed by changing is_macosx_sdk_path() so it does not consider 
/System/Volumes/Data as part of the sdk path:

Change from:

def is_macosx_sdk_path(path):
"""
Returns True if 'path' can be located in an OSX SDK
"""
return ( (path.startswith('/usr/') and not path.startswith('/usr/local'))
or (path.startswith('/System/') )
or path.startswith('/Library/') )

to

def is_macosx_sdk_path(path):
"""
Returns True if 'path' can be located in an OSX SDK
"""
return ( (path.startswith('/usr/') and not path.startswith('/usr/local'))
or (path.startswith('/System/') and not 
path.startswith('/System/Volumes/Data'))
or path.startswith('/Library/') )

This change prevents the sdk path from being prepended to the expected path to 
the file.

I'm not sure if this is the right fix, so I'd like your opinion on it. I don'r 
know much about mac's developer sdk and how it works, but it doesn't seem like 
anything under /System/Volumes should be included in or locatable in the sdk. 
Anyways, it would be nice to have an official fix for this in the official 
python source.

Regarding reproduction, you may be able to reproduce by trying to build python 
under /Systems/Volumes/Data, if not, it may have to do with the mounting of our 
network filesystem. Thanks for your help.

--

___
Python tracker 

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



[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-05 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

On macOS CLOCK_UPTIME_RAW is the same as mach_absolute_time (according to the 
manpage).

--

___
Python tracker 

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



[issue41273] asyncio: proactor read transport: use recv_into instead of recv

2020-08-05 Thread David Bolen


David Bolen  added the comment:

It looks like there was an underlying asyncio.recv_into bug that was the likely 
root issue here.  It's recently been fixed in bpo-41467, and test_asyncio is 
passing on at least the Win10 buildbot.

--

___
Python tracker 

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



[issue41467] asyncio: recv_into() must not return b'' if the socket/pipe is closed

2020-08-05 Thread David Bolen


David Bolen  added the comment:

Just for the record, this fix also appears to have resolved the issue with the 
Win10 buildbot from bpo-41273, which was related to the same unraisable 
exceptions mentioned in bpo-38912.

--
nosy: +db3l

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread Eric V. Smith


Eric V. Smith  added the comment:


New changeset 52f98424a55e14f05dfa7483cc0faf634a61c9ff by Eric L. Frederich in 
branch 'master':
bpo-41482: Fix error in ipaddress.IPv4Network docstring (GH-21736)
https://github.com/python/cpython/commit/52f98424a55e14f05dfa7483cc0faf634a61c9ff


--
nosy: +eric.smith

___
Python tracker 

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



[issue41482] docstring errors in ipaddress.IPv4Network

2020-08-05 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +20890
pull_request: https://github.com/python/cpython/pull/21746

___
Python tracker 

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



[issue40726] ast.Call end_lineno is defined and returns None

2020-08-05 Thread miss-islington


miss-islington  added the comment:


New changeset b24c9d2b0656764bef48120d9511faf833bd7ead by Batuhan Taskaya in 
branch '3.8':
[3.8] bpo-40726: handle uninitalized end_lineno on ast.increment_lineno 
(GH-21745)
https://github.com/python/cpython/commit/b24c9d2b0656764bef48120d9511faf833bd7ead


--

___
Python tracker 

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



[issue40726] ast.Call end_lineno is defined and returns None

2020-08-05 Thread Batuhan Taskaya


Change by Batuhan Taskaya :


--
pull_requests: +20889
pull_request: https://github.com/python/cpython/pull/21745

___
Python tracker 

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



[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-05 Thread STINNER Victor


STINNER Victor  added the comment:

> There is a clock with similar behaviour as the Linux clock: CLOCK_UPTIME_RAW

On Linux, CLOCK_UPTIME_RAW is not adjusted by NTP and it should not be used for 
a clock using *seconds*. NTP ensures that a clock provides seconds and is not 
slower or faster.

On macOS, if you want a clock which is incremented while the system is asleep, 
CLOCK_MONOTONIC sounds like a better choice.

I don't know if time.perf_counter() and CLOCK_MONOTONIC have similar effective 
resolution on macOS. time.perf_counter() should have a better resolution, but 
can have a worse accurary, than time.monotonic().

--

___
Python tracker 

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



[issue41480] python won't save

2020-08-05 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

For anyone who finds this issue, it also affected 3.9.0b4/5.

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



[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-05 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

@Nathaniel: I hadn't noticed that CLOCK_MONOTONIC on macOS behaves different 
from that clock on Linux. Sigh.

That means there's little reason to switch to CLOCK_MONOTONIC on macOS, that 
would just result in different behaviour between Linux and macOS. 

There is a clock with similar behaviour as the Linux clock: CLOCK_UPTIME_RAW, 
but switching to that instead of mach_absolute_time would just complicate the 
code base because we still support macOS 10.9 where clock_gettime is not 
available.

BTW. I'm against using mach_continuous_time, if a change is needed it should be 
to clock_gettime as that's the more portable API.   And given the stated goal 
of time.perf_counter() a change is IMHO not necessary.

--

___
Python tracker 

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



[issue41488] Unusable type hint should not be silently ignored

2020-08-05 Thread Guido van Rossum


Guido van Rossum  added the comment:

No, that is up to the static type checker. With PEP 563 nearing completion in 
Python 3.10 we will in fact be ignoring all annotations silently.

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



[issue41303] perf_counter result does not count system sleep time in Mac OS

2020-08-05 Thread STINNER Victor


STINNER Victor  added the comment:

> (On which note: Please don't switch macOS to use 
> clock_gettime(CLOCK_MONOTONIC); that would be a breaking change for us!)

Right, I propose to add new clock(s) since people may rely on the current 
clock(s) specifications.

> At least Linux, macOS, FreeBSD, and Windows all have a way to access a 
> monotonic clock that stops ticking while the system is suspended.

Python also tries to support AIX, OpenBSD, Solaris, Android, etc.
https://pythondev.readthedocs.io/platforms.html#best-effort-and-unofficial-platforms

I'm not sure that all "supported" platforms provide such clock. It's ok if such 
clock is not available on all platforms. People can fallback on 
monotonic/perf_counter depending on their need. For example, previously, it was 
common to write something like:

try: from time import monotonic
except ImportError: from time import time as monotonic # Python 2 or clock not 
available

--

___
Python tracker 

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



[issue41488] Unusable type hint should not be silently ignored

2020-08-05 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +gvanrossum, levkivskyi

___
Python tracker 

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



[issue41475] __future__.annotations set to become default in Python 4.0?

2020-08-05 Thread YoSTEALTH


YoSTEALTH  added the comment:

@cool-RR since your patch focuses on ``3.7`` there might be a merge issue.

There might be other place where ``4.0`` is mentioned though. Its better to let 
core dev like Raymond make the call.

--

___
Python tracker 

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



[issue41475] __future__.annotations set to become default in Python 4.0?

2020-08-05 Thread Ram Rachum


Ram Rachum  added the comment:

Thanks for linking that, YoStealth. Unless I'm missing anything, it looks like 
there's agreement that the right answer is 3.10, and my PR fixes a spot which 
was omitted in the PR from the previous issues. Agreed?

--

___
Python tracker 

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



[issue41488] Unusable type hint should not be silently ignored

2020-08-05 Thread Andre Roberge


New submission from Andre Roberge :

The following code is currently consistent with the type hint syntax but 
contains a line that is completely ignored.

   >>> d = {}
   >>> d['a']: int
   >>> d
   {}
   >>> __annotations__
   {}
>>> '__annotations__' in dir(d)
   False

I believe that type hints that cannot be either attached to an object nor added 
to any other __annotations__ dict should either generate a SyntaxError or, at 
the very least, result in a warning.

--
messages: 374884
nosy: aroberge
priority: normal
severity: normal
status: open
title: Unusable type hint should not be silently ignored
type: behavior
versions: Python 3.6, Python 3.7, Python 3.8, Python 3.9

___
Python tracker 

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



[issue41475] __future__.annotations set to become default in Python 4.0?

2020-08-05 Thread YoSTEALTH


YoSTEALTH  added the comment:

@rhettinger https://bugs.python.org/issue41314

--
nosy: +YoSTEALTH

___
Python tracker 

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



[issue40989] [C API] Remove _Py_NewReference() and _Py_ForgetReference() from the public C API

2020-08-05 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 15edaecd97a3f8e82895046462342d8ddd8b9f1b by Victor Stinner in 
branch 'master':
bpo-40989: Fix compiler warning in winreg.c (GH-21722)
https://github.com/python/cpython/commit/15edaecd97a3f8e82895046462342d8ddd8b9f1b


--

___
Python tracker 

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



[issue41480] python won't save

2020-08-05 Thread LX Cubing


Change by LX Cubing :


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



[issue40726] ast.Call end_lineno is defined and returns None

2020-08-05 Thread miss-islington


miss-islington  added the comment:


New changeset a1320989f5350439e0677450f49b36f2c10583d2 by Miss Islington (bot) 
in branch '3.9':
bpo-40726: handle uninitalized end_lineno on ast.increment_lineno (GH-20312)
https://github.com/python/cpython/commit/a1320989f5350439e0677450f49b36f2c10583d2


--

___
Python tracker 

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



[issue41232] Python `functools.wraps` doesn't deal with defaults correctly

2020-08-05 Thread Thor Whalen


Thor Whalen  added the comment:

You are the guardians of the great python, so we can leave it at that if
you want. That said for posterity, I'll offer a defense.

The same "the tools does what it does, and if you need something else, use
another tool" argument could have been applied to vote against adding
`__annotations__` etc. back when it was lacking.
If there were clear use cases for having signature defaults be different
from actual defaults, I'd also agree with the argument.
If it were a complicated fix, I'd also agree with you.

But it's a simple fix that would help avoiding unintended misalignments.

I may be missing something, but the only positive reasons I see for keeping
it the way it is are: (1) backcompatibility safety, and (2) not having to
change the (in my opinion incorrect) tests.

If it is kept as such, I think a documentation warning would go a long way
in making users avoid the trap I myself fell into.

On Wed, Aug 5, 2020 at 8:51 AM Dominic Davis-Foster 
wrote:

>
> Dominic Davis-Foster  added the comment:
>
> To me your examples seem like a misuse of functools.wraps. IIUC its
> purpose is to make a wrapper that accepts solely *args and **kwargs appear
> to be the wrapped function; it doesn't seem to be intended to be used when
> the wrapper takes arguments of different types or that have different
> default values.
>
> I can't think of a situation where you'd use wraps with a decorator that
> doesn't take just *args and **kwargs. That's not to say there aren't
> occasions where you'd want to to that, just that wraps isn't the right tool.
>
> --
> nosy: +domdfcoding
>
> ___
> Python tracker 
> 
> ___
>

--

___
Python tracker 

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



[issue40726] ast.Call end_lineno is defined and returns None

2020-08-05 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +20888
pull_request: https://github.com/python/cpython/pull/21742

___
Python tracker 

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



[issue40726] ast.Call end_lineno is defined and returns None

2020-08-05 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 7.0 -> 8.0
pull_requests: +20887
pull_request: https://github.com/python/cpython/pull/21741

___
Python tracker 

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



[issue40726] ast.Call end_lineno is defined and returns None

2020-08-05 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset 8f4380d2f5839a321475104765221a7394a9d649 by Batuhan Taskaya in 
branch 'master':
bpo-40726: handle uninitalized end_lineno on ast.increment_lineno (GH-20312)
https://github.com/python/cpython/commit/8f4380d2f5839a321475104765221a7394a9d649


--

___
Python tracker 

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



[issue41232] Python `functools.wraps` doesn't deal with defaults correctly

2020-08-05 Thread Dominic Davis-Foster


Dominic Davis-Foster  added the comment:

To me your examples seem like a misuse of functools.wraps. IIUC its purpose is 
to make a wrapper that accepts solely *args and **kwargs appear to be the 
wrapped function; it doesn't seem to be intended to be used when the wrapper 
takes arguments of different types or that have different default values. 

I can't think of a situation where you'd use wraps with a decorator that 
doesn't take just *args and **kwargs. That's not to say there aren't occasions 
where you'd want to to that, just that wraps isn't the right tool.

--
nosy: +domdfcoding

___
Python tracker 

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



[issue17336] Complex number representation round-trip doesn't work with signed zero values

2020-08-05 Thread Eric Wieser


Eric Wieser  added the comment:

> BTW I don't want repr() of a complex number to use the complex(..., ...)

A compromise would be to only use this notation if signed zeros are involved.

---

Another option would be to use slightly unusual reprs for these complex 
numbers, which at least round-trip:

def check(s, v):
c = eval(s)
# use string equality, because it's the easiest way to compare signed 
zeros
cs = f"complex({c.real}, {c.imag})"
vs = f"complex({v.real}, {v.imag})"
assert vs == cs, f' expected {vs} got {cs}'

check("-(0+0j)", complex(-0.0, -0.0))
check("(-0.0-0j)", complex(-0.0, 0.0))  # non-intuitive
check("-(-0.0-0j)", complex(0.0, -0.0))  # non-intuitive

Which I suppose would extend to complex numbers containing just one signed zero

check("(-0.0-1j)", complex(-0.0, -1))
check("-(0.0-1j)", complex(-0.0, 1))
check("-(1+0j)", complex(-1, -0.0))
check("-(-1+0j)", complex(1, -0.0))

Only two of these reprs are misleading for users who don't understand what's 
going on, the rest will just strike users as odd.

--
nosy: +Eric Wieser

___
Python tracker 

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



[issue41487] Builtin bigint modulo operation can be made faster when the base is divisible by a large power of 2 (i.e: has many trailing 0 digits in binary)

2020-08-05 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy: +tim.peters

___
Python tracker 

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



[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Mark Dickinson


Mark Dickinson  added the comment:

[META] @Eric: No apology needed. I find the issue tracker search hard to use 
well, and in general we don't do a great job of tracking duplicates properly. 
I'm trying to be better about that.

--

___
Python tracker 

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



[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Eric Wieser


Eric Wieser  added the comment:

Apologies for not searching the issue tracker effectively until after filing 
this.

--

___
Python tracker 

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



[issue41487] Builtin bigint modulo operation can be made faster when the base is divisible by a large power of 2 (i.e: has many trailing 0 digits in binary)

2020-08-05 Thread Mark Dickinson


Mark Dickinson  added the comment:

I'd be opposed to changing Python's `int` implementation in this way: it adds 
complication to the codebase and potentially also slows down "normal" cases. If 
a user knows in advance (a) that they're using a divisor that's highly divisble 
by 2, and (b) that the division or modulo operation is performance critical, 
then they can take the appropriate steps to optimize their code.

--

___
Python tracker 

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



[issue40269] Inconsistent complex behavior with (-1j)

2020-08-05 Thread Mark Dickinson


Mark Dickinson  added the comment:

Updating resolution to "duplicate", in an effort to keep discussion in a single 
place.

--
resolution: not a bug -> duplicate
superseder:  -> Complex number representation round-trip doesn't work with 
signed zero values

___
Python tracker 

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



[issue41487] Builtin bigint modulo operation can be made faster when the base is divisible by a large power of 2 (i.e: has many trailing 0 digits in binary)

2020-08-05 Thread Karthikeyan Singaravelan


Change by Karthikeyan Singaravelan :


--
nosy: +lemburg, mark.dickinson, rhettinger, stutzbach

___
Python tracker 

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



[issue17336] Complex number representation round-trip doesn't work with signed zero values

2020-08-05 Thread Mark Dickinson


Mark Dickinson  added the comment:

Also related: #40269

--

___
Python tracker 

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



[issue17336] Complex number representation round-trip doesn't work with signed zero values

2020-08-05 Thread Mark Dickinson


Mark Dickinson  added the comment:

The issue of changing the complex repr came up again in #41485, which has been 
closed as a duplicate of this issue.

See also https://bugs.python.org/issue23229#msg233963, where Guido says:

> BTW I don't want repr() of a complex number to use the complex(..., ...)
notation -- it's too verbose.

FWIW, I'd be +1 on changing the complex repr, but given Guido's opposition 
we're probably looking at a PEP to make that happen, and I don't have the 
bandwidth or the energy to push such a PEP through.

--

___
Python tracker 

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



[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Mark Dickinson


Mark Dickinson  added the comment:

Closing here; to the extent that it's possible, let's keep the discussion in 
one place (comments can still be posted on closed issues). I'll add a comment 
on #17336.

--
resolution:  -> duplicate
stage:  -> resolved
status: open -> closed
superseder:  -> Complex number representation round-trip doesn't work with 
signed zero values

___
Python tracker 

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



[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Mark Dickinson


Change by Mark Dickinson :


--
nosy: +mark.dickinson

___
Python tracker 

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



[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Rémi Lapeyre

Rémi Lapeyre  added the comment:

This is a known issue and I have a PR that does this that I could post but it 
was rejected when it was previously discussed: 
https://bugs.python.org/issue23229#msg233963

--

___
Python tracker 

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



[issue41487] Builtin bigint modulo operation can be made faster when the base is divisible by a large power of 2 (i.e: has many trailing 0 digits in binary)

2020-08-05 Thread Shlomi Fish


New submission from Shlomi Fish :

As the pure-Python code below demonstrates, when called as `python3 test.py 
jitshift` it is much faster than when called as `python3 test.py builtinops` 
(which takes many seconds/minutes past the 24th iteration). I am using fedora 
32 x86-64 on a Cannon lake intel core i5 NUC. Tested with latest cpython3 git 
master and with /usr/bin/pypy3

The improvement was done in pure-python / userland and may be improved upon 
further given these or others: https://gmplib.org/ and 
https://github.com/ridiculousfish/libdivide .

```
#!/usr/bin/env python3

# The Expat License
#
# Copyright (c) 2020, Shlomi Fish
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
import sys

OPT = "builtinops"


def mytest(p):
pint2p = p << p
myrange = range(1000)
if OPT == "builtinpow":
ret = pow(2, (1 << p), pint2p)
elif OPT == "builtinops":
ret = 2
for i in myrange:
print('sq', i, flush=True)
ret *= ret
print('mod', i, flush=True)
ret %= pint2p
print('after mod', i, (ret % 10 ** 20), flush=True)
else:
class ShiftMod:
"""docstring for ShiftMod:d"""
def __init__(self, base, shift):
self.base = base
self.shift = shift
self.mask = (1 << shift) - 1
self.n = base << shift

def mod(self, inp):
if inp < self.n:
return inp
return inp >> self.shift) % self.base)
 << self.shift) | (inp & self.mask))

def gen_shift_mod(x):
s = 0
for offset in (20, 2, 2000, 200, 20, 1):
bits_mask = (1 << offset) - 1
while x & bits_mask == 0:
s += offset
x >>= offset
return ShiftMod(x, s)

ret = 2
if OPT == "shiftmodpre":
m = ShiftMod(p, p)
for i in myrange:
print('sq', i, flush=True)
ret *= ret
print('mod', i, flush=True)
# m = gen_shift_mod(pint2p)
ret = m.mod(ret)
print('after mod', i, (ret % 10 ** 20), flush=True)
elif OPT == "gen_shift_mod":
m = gen_shift_mod(pint2p)
for i in myrange:
print('sq', i, flush=True)
ret *= ret
print('mod', i, flush=True)
ret = m.mod(ret)
print('after mod', i, (ret % 10 ** 20), flush=True)
elif OPT == "jitshift":
for i in myrange:
print('sq', i, flush=True)
ret *= ret
print('mod', i, flush=True)
ret = gen_shift_mod(pint2p).mod(ret)
print('after mod', i, (ret % 10 ** 20), flush=True)
return ret % (p*p) // p


def main(which):
global OPT
OPT = which
'''
if which == "builtinpow":
OPT = 1
elif which == "builtinops":
OPT = 0
elif which == "shiftmod":
OPT = 2
else:
raise Exception("unknown choice")
'''
x = mytest(9816593)
print(x)
return


if __name__ == "__main__":
main(sys.argv[1])

```

--
components: Interpreter Core
files: modtest.py
messages: 374869
nosy: shlomif2
priority: normal
severity: normal
status: open
title: Builtin bigint modulo operation can be made faster when the base is 
divisible by a large power of 2 (i.e: has many trailing 0 digits in binary)
type: performance
versions: Python 3.10
Added file: https://bugs.python.org/file49369/modtest.py

___
Python tracker 

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



[issue41265] lzma/bz2 module: inefficient buffer growth algorithm

2020-08-05 Thread Ma Lin


Ma Lin  added the comment:

A more thorough solution was used, see issue41486.

So I close this issue.

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



[issue41486] Add _BlocksOutputBuffer for bz2/lzma/zlib module

2020-08-05 Thread Ma Lin


Change by Ma Lin :


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

___
Python tracker 

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



[issue41486] Add _BlocksOutputBuffer for bz2/lzma/zlib module

2020-08-05 Thread Ma Lin


Change by Ma Lin :


Added file: https://bugs.python.org/file49368/benchmark_real.py

___
Python tracker 

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



[issue41486] Add _BlocksOutputBuffer for bz2/lzma/zlib module

2020-08-05 Thread Ma Lin


Change by Ma Lin :


Added file: https://bugs.python.org/file49367/benchmark.py

___
Python tracker 

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



[issue41486] Add _BlocksOutputBuffer for bz2/lzma/zlib module

2020-08-05 Thread Ma Lin


Change by Ma Lin :


Added file: https://bugs.python.org/file49365/0to200MB_step2MB.png

___
Python tracker 

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



[issue41486] Add _BlocksOutputBuffer for bz2/lzma/zlib module

2020-08-05 Thread Ma Lin


Change by Ma Lin :


Added file: https://bugs.python.org/file49366/0to20MB_step64KB.png

___
Python tracker 

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



[issue41486] Add _BlocksOutputBuffer for bz2/lzma/zlib module

2020-08-05 Thread Ma Lin


Change by Ma Lin :


Added file: https://bugs.python.org/file49364/0to2GB_step30MB.png

___
Python tracker 

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



[issue41486] Add _BlocksOutputBuffer for bz2/lzma/zlib module

2020-08-05 Thread Ma Lin

New submission from Ma Lin :

  bz2/lzma module's current growth algorithm

bz2/lzma module's initial output buffer size is 8KB [1][2], and they are using 
this output buffer growth algorithm [3][4]:

newsize = size + (size >> 3) + 6

[1] https://github.com/python/cpython/blob/v3.9.0b4/Modules/_bz2module.c#L109
[2] https://github.com/python/cpython/blob/v3.9.0b4/Modules/_lzmamodule.c#L124
[3] https://github.com/python/cpython/blob/v3.9.0b4/Modules/_lzmamodule.c#L133
[4] https://github.com/python/cpython/blob/v3.9.0b4/Modules/_bz2module.c#L121

For many case, the output buffer is resized too many times.
You may paste this code to REPL to see the growth step:

size = 8*1024
for i in range(1, 120):
print('Step %d ' % i, format(size, ','), 'bytes')
size = size + (size >> 3) + 6

Step 1  8,192 bytes
Step 2  9,222 bytes
Step 3  10,380 bytes
Step 4  11,683 bytes
Step 5  13,149 bytes
Step 6  14,798 bytes
...

  zlib module's current growth algorithm

zlib module's initial output buffer size is 16KB [5], in each growth the buffer 
size doubles [6]. 

[5] https://github.com/python/cpython/blob/v3.9.0b4/Modules/zlibmodule.c#L32
[6] https://github.com/python/cpython/blob/v3.9.0b4/Modules/zlibmodule.c#L174

This algorithm has a higher risk of running out of memory:

...
Step 14  256 MB
Step 15  512 MB
Step 16  1 GB
Step 17  2 GB
Step 18  4 GB
Step 19  8 GB
Step 20  16 GB
Step 21  32 GB
Step 22  64 GB
...

  Add _BlocksOutputBuffer for bz2/lzma/zlib module

Proposed PR uses a list of bytes object to represent output buffer.
It can eliminate the overhead of resizing (bz2/lzma), and prevent excessive 
memory footprint (zlib).

I only tested decompression, because the result is more obvious than 
compression.

For special data benchmark (all data consists of b'a'), see these attached 
pictures, _BlocksOutputBuffer has linear performance:
(Benchmark by attached file benchmark.py)

0to2GB_step30MB.png(Decompress from 0 to 2GB, 30MB step)
0to200MB_step2MB.png   (Decompress from 0 to 200MB, 2MB step)
0to20MB_step64KB.png   (Decompress from 0 to 20MB, 64KB step)

After switching to _BlocksOutputBuffer, the code of bz2/lzma is more concise, 
the code of zlib is basically translated statement by statement, IMO it's safe 
and easy for review.

  Real data benchmark

For real data, the weight of resizing output buffer is not big, so the 
performance improvement is not as big as above pictures:
(Benchmark by attached file benchmark_real.py)

- bz2 -

linux-2.6.39.4.tar.bz2
input size: 76,097,195, output size: 449,638,400
best of 5: [baseline_raw] 12.954 sec -> [patched_raw] 11.600 sec, 1.12x faster 
(-10%)

firefox-79.0.linux-i686.tar.bz2
input size: 74,109,706, output size: 228,055,040
best of 5: [baseline_raw] 8.511 sec -> [patched_raw] 7.829 sec, 1.09x faster 
(-8%)

ffmpeg-4.3.1.tar.bz2
input size: 11,301,038, output size: 74,567,680
best of 5: [baseline_raw] 1.915 sec -> [patched_raw] 1.671 sec, 1.15x faster 
(-13%)

gimp-2.10.20.tar.bz2
input size: 33,108,938, output size: 214,179,840
best of 5: [baseline_raw] 5.794 sec -> [patched_raw] 4.964 sec, 1.17x faster 
(-14%)

sde-external-8.56.0-2020-07-05-lin.tar.bz2
input size: 26,746,086, output size: 92,129,280
best of 5: [baseline_raw] 3.153 sec -> [patched_raw] 2.835 sec, 1.11x faster 
(-10%)

- lzma -

linux-5.7.10.tar.xz
input size: 112,722,840, output size: 966,062,080
best of 5: [baseline_raw] 9.813 sec -> [patched_raw] 7.434 sec, 1.32x faster 
(-24%)

linux-2.6.39.4.tar.xz
input size: 63,243,812, output size: 449,638,400
best of 5: [baseline_raw] 5.256 sec -> [patched_raw] 4.200 sec, 1.25x faster 
(-20%)

gcc-9.3.0.tar.xz
input size: 70,533,868, output size: 618,608,640
best of 5: [baseline_raw] 6.398 sec -> [patched_raw] 4.878 sec, 1.31x faster 
(-24%)

Python-3.8.5.tar.xz
input size: 18,019,640, output size: 87,531,520
best of 5: [baseline_raw] 1.315 sec -> [patched_raw] 1.098 sec, 1.20x faster 
(-16%)

firefox-79.0.source.tar.xz
input size: 333,220,776, output size: 2,240,573,440
best of 5: [baseline_raw] 25.339 sec -> [patched_raw] 19.661 sec, 1.29x faster 
(-22%)

- zlib -

linux-5.7.10.tar.gz
input size: 175,493,557, output size: 966,062,080
best of 5: [baseline_raw] 2.360 sec -> [patched_raw] 2.401 sec, 1.02x slower 
(+2%)

linux-2.6.39.4.tar.gz
input size: 96,011,459, output size: 449,638,400
best of 5: [baseline_raw] 1.215 sec -> [patched_raw] 1.216 sec, 1.00x slower 
(+0%)

gcc-9.3.0.tar.gz
input size: 124,140,228, output size: 618,608,640
best of 5: [baseline_raw] 1.668 sec -> [patched_raw] 1.555 sec, 1.07x faster 
(-7%)

Python-3.8.5.tgz
input size: 24,149,093, output size: 87,531,520
best of 5: [baseline_raw] 0.263 sec -> [patched_raw] 0.253 sec, 1.04x faster 
(-4%)

openjdk-14.0.2_linux-x64_bin.tar.gz
input size: 198,606,190, output size: 335,175,680
best of 5: [baseline_raw] 1.273 sec -> [patched_raw] 1.221 sec, 1.04x faster 

[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Rémi Lapeyre

Change by Rémi Lapeyre :


--
nosy: +remi.lapeyre
versions: +Python 3.10, Python 3.9

___
Python tracker 

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



[issue41480] python won't save

2020-08-05 Thread E. Paine


E. Paine  added the comment:

Sorry for this issue, IDLE 3.8.5 has a known (and now resolved) issue with 
saving if the file was empty when opened (see #41373). If this is not your 
problem, please do come back and say so, but otherwise this issue should be 
closed as a duplicate.

--
nosy: +epaine

___
Python tracker 

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



[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Eric Wieser


Eric Wieser  added the comment:

This was reported and closed in https://bugs.python.org/issue17336, but it 
seems to me that this is easy to avoid - have `__repr__` return `complex(...)` 
for values which do not round-trip.

--

___
Python tracker 

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



[issue41485] Repr of complex number with signed zero does not roundtrip

2020-08-05 Thread Eric Wieser


New submission from Eric Wieser :

Python distinguishes signed zeros by their repr:

# floats
>>> 0.0
0.0
>>> -0.0
-0.0

# complex
>>> complex(0.0, 0.0)  # A
0j
>>> complex(0.0, -0.0)  # B
-0j
>>> complex(-0.0, 0.0)  # C
(-0+0j)
>>> complex(-0.0, -0.0)  # D
(-0+0j)

However, only one of these `complex` reprs round-trips:

>>> 0j   # ok
0j
>>> -0j   # doesn't round-trip
(-0-0j)
>>> (-0+0j)  # doesn't round-trip
0j
>>> (-0-0j)
0j

--
components: Interpreter Core
messages: 374864
nosy: Eric Wieser
priority: normal
severity: normal
status: open
title: Repr of complex number with signed zero does not roundtrip
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



[issue38628] Issue with ctypes in AIX

2020-08-05 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

Relevant libffi documentation: 
https://github.com/libffi/libffi/blob/4661ba7928b49588aec9e6976673208c8cbf0295/doc/libffi.texi#L505

--

___
Python tracker 

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



[issue41484] Overriding dictionary value under wrong key.

2020-08-05 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

This is expected behaviour. the assessment to retProduct[productKey] is not a 
copy. If those variants have the same parent and a different color you'll end 
up with a baseProduct where 'variants' refers to the same variant dict (and the 
second color seen will overwrite the value of 'variants')

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



[issue38628] Issue with ctypes in AIX

2020-08-05 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

As I mentioned earlier the code in sgtdict.c seems dodgy, the libffi 
representation for an array in a dict should be the same regardless of the size 
of the dictionary.  

That said, I haven't studied the ctypes code yet and am not sure if my analysis 
is correct.

In the end we'll need some unit tests that demonstrate the issue as well as a 
patch that fixes it.

--

___
Python tracker 

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



[issue41484] Overriding dictionary value under wrong key.

2020-08-05 Thread Admir Ljubijankić

New submission from Admir Ljubijankić :

I'm writing a function that combines two dictionaries called "baseProducts" and 
"variantProducts".
The logic behind is simple, I loop trough variantProducts, create a string that 
will be used as a key for that combined product. Add all values of baseProduct 
under that key, and add all fitting variants to this new nested dictionary 
under key "variants". And return the new dict once all variants are grouped 
correctly.
The code looks something like this:

def combineProductsByColor(baseProducts, variantProducts):
retDict = {}

for key, variant in variantProducts.items():
productKey = variant['parent'] + '_' + variant['color']
if productKey not in retDict:
retDict[productKey] = baseProducts[variant['parent']]
retDict[productKey]['variants'] = {}
retDict[productKey]['variants'][key] = variant

return retDict

Now with my test data, baseProducts only contains one item in it. While 
variantProducts contain 4 items. When the first two loops happen it creates a 
new key, and adds the first and second variant under that key correctly (this 
was tested using ms code debugger) but when it looks at the 3rd item, it 
creates a new key, and adds the variant to that key, but it also overrides all 
the variants in the previous key, even if the variable productKey is the new 
key. And when the 4th item gets processed it again gets added to both.
So to make sure that I'm not getting some wrong key somehow. I also tried to 
implement it like this:

def combineProductsByColor(baseProducts, variantProducts):
retDict = {}
keys = list(variantProducts.keys())

for k in keys:
productKey = variantProducts[k]['parent'] + '_' + 
variantProducts[k]['color']
if productKey not in retDict:
retDict[productKey] = baseProducts[variantProducts[k]['parent']]
retDict[productKey]['variants'] = {}
retDict[productKey]['variants'][k] = variantProducts[k]

return retDict

But the result was identical. Again following the whole procedure with ms code 
debugger.
I've also tried making the productKey simpler, but the problem still remains.

Now I do have an idea how to implement this in a different way, but I don't see 
and understand why the code I provided doesn't work. Because when the new key 
gets generated, its not the same as the old, but it still can change values 
under the old key.

Here is what the data looks like before and after processing it.

baseProducts:

{
'232196304': {
'code': 'P20-0002',
'name': 'Ženske hlače',
'regular_price': '22,99',
'vat': '22,00',
'attrib': {
'material': '97% bombaž, 3% elastan, 20% viskoza, 5% elastan'
},
'categories': ['01', '0101', '010104']
}
}

variantProducts:

{
'2321963991029': {
'parent': '232196304',
'color': '99',
'size': '102',
'title': None,
'name': None,
'regular_price': None,
'vat': None,
'attrib': None,
'categories': None
},
'2321963991036': {
'parent': '232196304',
'color': '99',
'size': '103',
'title': None,
'name': None,
'regular_price': '25,99',
'vat': '22,00',
'attrib': None,
'categories': None
},
'2321963981029': {
'parent': '232196304',
'color': '98',
'size': '102',
'title': None,
'name': None,
'regular_price': None,
'vat': None,
'attrib': None,
'categories': None
},
'2321963981036': {
'parent': '232196304',
'color': '98',
'size': '103',
'title': None,
'name': None,
'regular_price': None,
'vat': None,
'attrib': None,
'categories': None
}
}

And last combined data:

{
'232196304_99': {
'code': 'P20-0002',
'name': 'Ženske hlače',
'regular_price': '22,99',
'vat': '22,00',
'attrib': {
'material': '97% bombaž, 3% elastan, 20% viskoza, 5% elastan'
},
'categories': ['01', '0101', '010104'],
'variants': {
'2321963981029': {
'parent': '232196304',
'color': '98',
'size': '102',
'title': None,
'name': None,
'regular_price': None,
'vat': None,
'attrib': None,
'categories': None
},
'2321963981036': {
'parent': '232196304',
'color': '98',
'size': '103',
'title': None,
'name': None,
'regular_price': None,
'vat': None,
'attrib': None,
'categories': None
}
}
},
'232196304_98': {
  

[issue41483] Do not acquire lock in MemoryHandler.flush() if no target defined

2020-08-05 Thread Kostis Anagnostopoulos


New submission from Kostis Anagnostopoulos :

The `logging.handlers.MemoryHandler.flush()` method acquire the lock even if 
target has not been set, and the method is a noop:

```
def flush(self):
# (Docstring skipped)
self.acquire()
try:
if self.target:
for record in self.buffer:
self.target.handle(record)
self.buffer..clear()
finally:
self.release()
```

An optimized version would re-arrrange the nesting to avoid the locking:

```
def flush(self):
# (Docstring skipped)
if self.target:
self.acquire()
try:
for record in self.buffer:
self.target.handle(record)
self.buffer.clear()
finally:
self.release()
```

- There is no use-case, beyond the expected performance gain.
- Without having searched, i would deem highly improbable the existence of code 
in the std-library or 3rdp code that depends on the current noop-locking when 
`flush()` is called.

--
components: Library (Lib)
messages: 374859
nosy: ankostis, penlect, vinay.sajip
priority: normal
severity: normal
status: open
title: Do not acquire lock in MemoryHandler.flush() if no target defined
type: performance
versions: Python 3.10, Python 3.9

___
Python tracker 

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