Re: How to create a binary tree hierarchy given a list of elements as its leaves

2024-01-28 Thread MRAB via Python-list

On 2024-01-28 18:16, marc nicole via Python-list wrote:

So I am trying to build a binary tree hierarchy given numerical elements
serving for its leaves (last level of the tree to build). From the leaves I
want to randomly create a name for the higher level of the hierarchy and
assign it to the children elements. For example: if the elements inputted
are `0,1,2,3` then I would like to create firstly 4 elements (say by random
giving them a label composed of a letter and a number) then for the second
level (iteration) I assign each of 0,1 to a random name label (e.g. `b1`)
and `2,3` to another label (`b2`) then for the third level I assign a
parent label to each of `b1` and `b2` as `c1`.

An illustation of the example is the following tree:


[image: tree_exp.PNG]

This list strips images, and discussion has mostly moved to 
https://discuss.python.org.


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


How to create a binary tree hierarchy given a list of elements as its leaves

2024-01-28 Thread marc nicole via Python-list
So I am trying to build a binary tree hierarchy given numerical elements
serving for its leaves (last level of the tree to build). From the leaves I
want to randomly create a name for the higher level of the hierarchy and
assign it to the children elements. For example: if the elements inputted
are `0,1,2,3` then I would like to create firstly 4 elements (say by random
giving them a label composed of a letter and a number) then for the second
level (iteration) I assign each of 0,1 to a random name label (e.g. `b1`)
and `2,3` to another label (`b2`) then for the third level I assign a
parent label to each of `b1` and `b2` as `c1`.

An illustation of the example is the following tree:


[image: tree_exp.PNG]

For this I use numpy's `array_split()` to get the chunks of arrays based on
the iteration needs.
for example to get the first iteration arrays I use `np.array_split(input,
(input.size // k))` where `k` is an even number. In order to assign a
parent node to the children the array range should enclose the children's.
For example to assign the parent node with label `a1` to children `b1` and
`b2` with range respectively [0,1] and [2,3], the parent should have the
range [0,3].

All is fine until a certain iteration (k=4) returns parent with range [0,8]
which is overlapping to children ranges and therefore cannot be their
parent.

My question is how to evenly partition such arrays in a binary way and
create such binary tree so that to obtain for k=4 the first range to be
[0,7] instead of [0,8]?

My code is the following:

#!/usr/bin/python
# -*- coding: utf-8 -*-
import string
import random
import numpy as np


def generate_numbers_list_until_number(stop_number):
if str(stop_number).isnumeric():
return np.arange(stop_number)
else:
raise TypeError('Input should be a number!')


def generate_node_label():
return random.choice(string.ascii_lowercase) \
+ str(random.randint(0, 10))


def main():
data = generate_numbers_list_until_number(100)
k = 1
hierarchies = []
cells_arrays = np.array_split(data, data.size // k)
print cells_arrays
used_node_hierarchy_name = []
node_hierarchy_name = [generate_node_label() for _ in range(0,
   len(cells_arrays))]
used_node_hierarchy_name.extend(node_hierarchy_name)
while len(node_hierarchy_name) > 1:
k = k * 2

# bug here in the following line

cells_arrays = list(map(lambda x: [x[0], x[-1]],
np.array_split(data, data.size // k)))
print cells_arrays
node_hierarchy_name = []

# node hierarchy names should not be redundant in another level

for _ in range(0, len(cells_arrays)):
node_name = generate_node_label()
while node_name in used_node_hierarchy_name:
node_name = generate_node_label()
node_hierarchy_name.append(node_name)
used_node_hierarchy_name.extend(node_hierarchy_name)
print used_node_hierarchy_name
hierarchies.append(list(zip(node_hierarchy_name, cells_arrays)))
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue531901] binary packagers

2022-04-10 Thread admin


Change by admin :


--
github: None -> 36282

___
Python tracker 

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



[issue400903] put back _Length functions for binary compatibility

2022-04-10 Thread admin


Change by admin :


___
Python tracker 

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



[issue498124] base64 mishandles binary on Win32

2022-04-10 Thread admin


Change by admin :


--
github: None -> 35852

___
Python tracker 

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



[issue415226] new base class for binary packaging

2022-04-10 Thread admin


Change by admin :


--
github: None -> 34304

___
Python tracker 

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



[issue414391] Inplace optimization for binary ops

2022-04-10 Thread admin


Change by admin :


--
github: None -> 34294

___
Python tracker 

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



[issue229293] zlib library used for binary win32 distribution can crash

2022-04-10 Thread admin


Change by admin :


--
github: None -> 33754

___
Python tracker 

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



[issue216048] BeOpen Python 2.0b2 RPM does not include python2.0 binary

2022-04-10 Thread admin


Change by admin :


___
Python tracker 

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



[issue212759] open('file').read() can not read entire binary file

2022-04-10 Thread admin


Change by admin :


___
Python tracker 

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



[issue210674] memory bloat in binary file upload (PR#381)

2022-04-10 Thread admin


Change by admin :


___
Python tracker 

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



[issue212760] python can not read binary file fully

2022-04-10 Thread admin


Change by admin :


___
Python tracker 

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



[issue216048] BeOpen Python 2.0b2 RPM does not include python2.0 binary

2022-04-10 Thread admin


Change by admin :


--
github: None -> 33281

___
Python tracker 

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



[issue212760] python can not read binary file fully

2022-04-10 Thread admin


Change by admin :


--
github: None -> 32988

___
Python tracker 

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



[issue212759] open('file').read() can not read entire binary file

2022-04-10 Thread admin


Change by admin :


--
github: None -> 32987

___
Python tracker 

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



[issue210674] memory bloat in binary file upload (PR#381)

2022-04-10 Thread admin


Change by admin :


--
github: None -> 32744

___
Python tracker 

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



[issue400903] put back _Length functions for binary compatibility

2022-04-10 Thread admin


Change by admin :


--
github: None -> 32627

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-03 Thread Ned Deily


Ned Deily  added the comment:


New changeset 387f93c156288c170ff0016a75af06e109d48ee1 by Miss Islington (bot) 
in branch '3.7':
bpo-47194: Update zlib to v1.2.12 on Windows to resolve CVE-2018-25032 
(GH-32241) (GH-32251)
https://github.com/python/cpython/commit/387f93c156288c170ff0016a75af06e109d48ee1


--

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-02 Thread miss-islington


miss-islington  added the comment:


New changeset 16a809ffb7af14898ce9ec8165960d96cbcd4ec3 by Miss Islington (bot) 
in branch '3.10':
bpo-47194: Update zlib to v1.2.12 on Windows to resolve CVE-2018-25032 
(GH-32241)
https://github.com/python/cpython/commit/16a809ffb7af14898ce9ec8165960d96cbcd4ec3


--

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-02 Thread miss-islington


miss-islington  added the comment:


New changeset 0f0f85e9d8088eb789cda35477900df32adff546 by Miss Islington (bot) 
in branch '3.9':
bpo-47194: Update zlib to v1.2.12 on Windows to resolve CVE-2018-25032 
(GH-32241)
https://github.com/python/cpython/commit/0f0f85e9d8088eb789cda35477900df32adff546


--

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-02 Thread miss-islington


Change by miss-islington :


--
pull_requests: +30322
pull_request: https://github.com/python/cpython/pull/32251

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-02 Thread miss-islington


Change by miss-islington :


--
pull_requests: +30321
pull_request: https://github.com/python/cpython/pull/32250

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-02 Thread miss-islington


Change by miss-islington :


--
pull_requests: +30320
pull_request: https://github.com/python/cpython/pull/32249

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-02 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 8.0 -> 9.0
pull_requests: +30319
pull_request: https://github.com/python/cpython/pull/32248

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-02 Thread Steve Dower


Steve Dower  added the comment:


New changeset 6066739ff7794e54c98c08b953a699cbc961cd28 by Zachary Ware in 
branch 'main':
bpo-47194: Update zlib to v1.2.12 on Windows to resolve CVE-2018-25032 
(GH-32241)
https://github.com/python/cpython/commit/6066739ff7794e54c98c08b953a699cbc961cd28


--

___
Python tracker 

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



[issue47193] Use zlib-ng rather than zlib in binary releases

2022-04-02 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-01 Thread Zachary Ware


Change by Zachary Ware :


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

___
Python tracker 

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



[issue47193] Use zlib-ng rather than zlib in binary releases

2022-04-01 Thread Oleg Iarygin


Change by Oleg Iarygin :


--
nosy: +arhadthedev

___
Python tracker 

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



[issue47194] Upgrade to zlib v1.2.12 in CPython binary releases

2022-04-01 Thread Gregory P. Smith


New submission from Gregory P. Smith :

zlib v1.2.11 as used in Windows binary releases contains a security issue that, 
while fixed in its git repo years ago, never wound up in a release or a CVE 
until just now.

Folllow the https://www.openwall.com/lists/oss-security/2022/03/24/1 thread and 
the and recently assigned CVE-2018-25032.

I believe we only ship our own zlib on Windows so this issue is tagged as such. 
 The above oss-security thread is where an idea of severity will come out.

--
components: Extension Modules, Windows
messages: 416510
nosy: gregory.p.smith, lukasz.langa, ned.deily, pablogsal, paul.moore, 
steve.dower, tim.golden, zach.ware
priority: release blocker
severity: normal
stage: needs patch
status: open
title: Upgrade to zlib v1.2.12 in CPython binary releases
type: security
versions: Python 3.10, Python 3.11, Python 3.7, Python 3.8, Python 3.9

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



[issue47193] Use zlib-ng rather than zlib in binary releases

2022-04-01 Thread Gregory P. Smith


New submission from Gregory P. Smith :

zlib-ng is an optimized zlib library with better performance on most 
architectures (with contributions from the likes of Google, Cloudflare, and 
Intel).  It is API compatible with zlib.  https://github.com/zlib-ng/zlib-ng

I believe the only platform we don't use the OS's own zlib on is Windows so I'm 
tagging this issue Windows.

--
components: Windows
messages: 416508
nosy: gregory.p.smith, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
stage: needs patch
status: open
title: Use zlib-ng rather than zlib in binary releases
type: performance
versions: Python 3.11

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



[issue6778] False positives given through bisect module (binary search)

2022-03-01 Thread Mark Dickinson


Change by Mark Dickinson :


--
components: +Extension Modules

___
Python tracker 

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



[issue6778] False positives given through bisect module (binary search)

2022-03-01 Thread Mark Dickinson


Change by Mark Dickinson :


--
components:  -Distutils, Documentation, Extension Modules, Installation, 
Parser, email
nosy:  -barry, docs@python, dstufft, eric.araujo, lys.nikolaou, pablogsal
type: security -> behavior

___
Python tracker 

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



[issue6778] False positives given through bisect module (binary search)

2022-02-28 Thread Paola Cosio


Change by Paola Cosio :


--
assignee:  -> docs@python
components: +Distutils, Documentation, Installation, Parser, email
nosy: +barry, docs@python, dstufft, eric.araujo, lys.nikolaou, pablogsal
type: behavior -> security

___
Python tracker 

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



[issue46802] Wrong result unpacking binary data with ctypes bitfield.

2022-02-19 Thread Jonathan


Jonathan  added the comment:

True, have to admit, that I forgot to search first, that really looks like it 
is the same problem, especially when looking at 
https://bugs.python.org/msg289212. Would say this one can be closed.

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



[issue46802] Wrong result unpacking binary data with ctypes bitfield.

2022-02-19 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Possible duplicate of https://bugs.python.org/issue29753

--
nosy: +Dennis Sweeney

___
Python tracker 

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



[issue46802] Wrong result unpacking binary data with ctypes bitfield.

2022-02-19 Thread Jonathan


Change by Jonathan :


--
nosy:  -helo9

___
Python tracker 

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



[issue46802] Wrong result unpacking binary data with ctypes bitfield.

2022-02-19 Thread Jonathan


New submission from Jonathan :

I have issues unpacking binary data, produced by C++. The appended jupyter 
notebook shows the problem. It is also uploaded to github gist: 
https://gist.github.com/helo9/04125ae67b493e505d5dce4b254a2ccc

--
components: ctypes
files: ctypes_bitfield_problem.ipynb
messages: 413559
nosy: helo9
priority: normal
severity: normal
status: open
title: Wrong result unpacking binary data with ctypes bitfield.
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50633/ctypes_bitfield_problem.ipynb

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



[issue46378] Experiment with LLVM BOLT binary optimizer

2022-01-27 Thread Dong-hee Na


Dong-hee Na  added the comment:

Only 1% gain, so we decided not to adopt it yet.
see: https://github.com/faster-cpython/ideas/issues/224#issuecomment-1022371595

--
resolution:  -> rejected
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue46378] Experiment with LLVM BOLT binary optimizer

2022-01-15 Thread Brandt Bucher


Change by Brandt Bucher :


--
nosy: +brandtbucher

___
Python tracker 

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



[issue46378] Experiment with LLVM BOLT binary optimizer

2022-01-15 Thread Dong-hee Na


Change by Dong-hee Na :


--
components: +Build

___
Python tracker 

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



[issue46378] Experiment with LLVM BOLT binary optimizer

2022-01-14 Thread Dong-hee Na


New submission from Dong-hee Na :

Just experiment how it will be worth :)

Thread: https://github.com/faster-cpython/ideas/issues/224

--
assignee: corona10
messages: 410570
nosy: corona10
priority: normal
severity: normal
status: open
title: Experiment with LLVM BOLT binary optimizer
type: performance
versions: Python 3.11

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



[issue46055] Speed up binary shifting operators

2021-12-27 Thread Mark Dickinson


Change by Mark Dickinson :


--
pull_requests: +28493
pull_request: https://github.com/python/cpython/pull/30277

___
Python tracker 

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



[issue46055] Speed up binary shifting operators

2021-12-27 Thread Mark Dickinson


Mark Dickinson  added the comment:

Two separate significant improvements have been pushed: thanks, Xinhang Xu!

The original PR also contained a reworking of the general case for 
right-shifting a negative integer. The current code (in main) for that case 
does involve some extra allocations, and it ought to be possible to write 
something that doesn't need to allocate temporary PyLongs.

--

___
Python tracker 

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



[issue46055] Speed up binary shifting operators

2021-12-27 Thread Mark Dickinson


Mark Dickinson  added the comment:


New changeset 3581c7abbe15bad6ae08fc38887e5948f8f39e08 by Xinhang Xu in branch 
'main':
bpo-46055: Speed up binary shifting operators (GH-30044)
https://github.com/python/cpython/commit/3581c7abbe15bad6ae08fc38887e5948f8f39e08


--

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



[issue46055] Speed up binary shifting operators

2021-12-27 Thread Mark Dickinson


Mark Dickinson  added the comment:


New changeset 360fedc2d2ce6ccb0dab554ef45fe83f7aea1862 by Mark Dickinson in 
branch 'main':
bpo-46055: Streamline inner loop for right shifts (#30243)
https://github.com/python/cpython/commit/360fedc2d2ce6ccb0dab554ef45fe83f7aea1862


--

___
Python tracker 

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



[issue46055] Speed up binary shifting operators

2021-12-23 Thread Mark Dickinson


Change by Mark Dickinson :


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

___
Python tracker 

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



[issue46055] Speed up binary shifting operators

2021-12-23 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



[issue46154] MIMEMultipart enforces line endings also for binary subparts

2021-12-22 Thread Sophonet


New submission from Sophonet :

For an activity with fastapi, I am preparing a Response object with the content 
of a email.mime.multipart MIMEMultipart object. Adhering to the standards 
(RFC), a MIMEMultipart response uses CRLF line endings (policy=HTTP). However, 
the binary attachment I am adding with MIMEApplication() and multipart.attach() 
in that case gets corrupted since all bytes corresponding to newlines (LF) are 
replaces with CRLF.

Am I doing something wrong or is this a bug that needs to be fixed?

What I would like to achieve is building a RFC-compliant MIMEMultipart payload 
in which the subparts do not get altered (in case of application/octet-stream).

Thanks, Sophonet

--
components: email
messages: 409041
nosy: barry, r.david.murray, sophonet
priority: normal
severity: normal
status: open
title: MIMEMultipart enforces line endings also for binary subparts
type: behavior
versions: Python 3.9

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



[issue24116] --with-pydebug has no effect when the final python binary is compiled

2021-12-13 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed

___
Python tracker 

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



[issue46055] Speed up binary shifting operators

2021-12-12 Thread Xinhang Xu


Xinhang Xu  added the comment:

I post a comment to the PR showing its performance improvement. I paste it 
below. I think the result not bad.

-

I use timeit to measure time costs and any other operators or calls are 
excluded. For each testcase, the former is dcd2796 and the latter is this PR's 
base 036bbb1.

64-bit Release building. Run in Windows 10 1709 (64-bit)

python -m timeit " i = 1; i <<= 3; i >>= 3"  # small value (cost down by 36%)
500 loops, best of 5: 92.7 nsec per loop
200 loops, best of 5: 145 nsec per loop

python -m timeit " i = 1; i <<= 10; i >>= 10"  # medium value (-25%)
200 loops, best of 5: 114 nsec per loop
200 loops, best of 5: 151 nsec per loop

python -m timeit " i = 1; i <<= 100; i >>= 100"  # big value  (-12%)
100 loops, best of 5: 209 nsec per loop
100 loops, best of 5: 238 nsec per loop

--

___
Python tracker 

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



[issue46055] Speed up binary shifting operators

2021-12-12 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Could you please show any microbenchmarking results?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue46055] Speed up binary shifting operators

2021-12-11 Thread Xinhang Xu


New submission from Xinhang Xu :

See its PR.

-

Inspired by [bpo-44946](https://bugs.python.org/issue44946), I found there were 
no special shortcuts for shifting operation applied to "medium value" long 
object. So I modified CPython's VM to accelerate my python project where there 
is plenty of binary shifting operation. I guess somebody else might also need 
it.

--
components: Interpreter Core
messages: 408362
nosy: xuxinhang
priority: normal
pull_requests: 28289
severity: normal
status: open
title: Speed up binary shifting operators
type: performance
versions: Python 3.11

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



[issue20123] pydoc.synopsis fails to load binary modules

2021-12-11 Thread Irit Katriel


Irit Katriel  added the comment:

Re-enabling the test is tracked on 20128, so this issue is no longer needed.

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



[issue34557] When sending binary file to a Microsoft FTP server over FTP TLS, the SSL unwind method hangs

2021-12-11 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 2.7, Python 3.4, Python 
3.5, Python 3.6, Python 3.7, Python 3.8

___
Python tracker 

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



[issue10954] csv.reader/writer to raise exception if mode is binary or newline is not ''

2021-10-20 Thread Irit Katriel


Change by Irit Katriel :


--
resolution:  -> wont fix
stage:  -> resolved
status: open -> closed
superseder:  -> Close 2to3 issues and list them here

___
Python tracker 

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



[issue34557] When sending binary file to a Microsoft FTP server over FTP TLS, the SSL unwind method hangs

2021-09-08 Thread Irit Katriel


Change by Irit Katriel :


--
nosy: +christian.heimes

___
Python tracker 

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



Re: Reading binary data with the CSV module

2020-11-30 Thread MRAB

On 2020-11-30 03:59, Jason Friedman wrote:


csv.DictReader appears to be happy with a list of strings representing
the lines.

Try this:

contents = source_file.content()

for row in csv.DictReader(contents.decode('utf-8').splitlines()):
 print(row)



Works great, thank you! Question ... will this form potentially use less
memory?

for row in
csv.DictReader(source_file.content().decode('utf-8').splitlines()):
 print(row)


Yes, but it won't matter that much unless there's a _lot_ of data.
--
https://mail.python.org/mailman/listinfo/python-list


Re: Reading binary data with the CSV module

2020-11-29 Thread Jason Friedman
>
> csv.DictReader appears to be happy with a list of strings representing
> the lines.
>
> Try this:
>
> contents = source_file.content()
>
> for row in csv.DictReader(contents.decode('utf-8').splitlines()):
>  print(row)
>

Works great, thank you! Question ... will this form potentially use less
memory?

for row in
csv.DictReader(source_file.content().decode('utf-8').splitlines()):
print(row)
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: Reading binary data with the CSV module

2020-11-29 Thread MRAB

On 2020-11-30 01:31, Jason Friedman wrote:

Using the Box API:


print(source_file.content())


returns


b'First Name,Last Name,Email Address,Company,Position,Connected
On\nPeter,van

(and more data, not pasted here)


Trying to read it via:

with io.TextIOWrapper(source_file.content(), encoding='utf-8') as text_file:

reader = csv.DictReader(text_file)

for row in reader:

print(row)


Getting this error:

Traceback (most recent call last):
   File "/home/jason/my_box.py", line 278, in 
 with io.TextIOWrapper(source_file.content(), encoding='utf-8') as
text_file:
AttributeError: 'bytes' object has no attribute 'readable'



csv.DictReader appears to be happy with a list of strings representing 
the lines.


Try this:

contents = source_file.content()

for row in csv.DictReader(contents.decode('utf-8').splitlines()):
print(row)
--
https://mail.python.org/mailman/listinfo/python-list


Reading binary data with the CSV module

2020-11-29 Thread Jason Friedman
Using the Box API:


print(source_file.content())


returns


b'First Name,Last Name,Email Address,Company,Position,Connected
On\nPeter,van

(and more data, not pasted here)


Trying to read it via:

with io.TextIOWrapper(source_file.content(), encoding='utf-8') as text_file:

reader = csv.DictReader(text_file)

for row in reader:

print(row)


Getting this error:

Traceback (most recent call last):
  File "/home/jason/my_box.py", line 278, in 
with io.TextIOWrapper(source_file.content(), encoding='utf-8') as
text_file:
AttributeError: 'bytes' object has no attribute 'readable'
-- 
https://mail.python.org/mailman/listinfo/python-list


[issue17083] can't specify newline string for readline for binary files

2020-11-27 Thread Alex Shpilkin


Change by Alex Shpilkin :


--
nosy: +Alex Shpilkin

___
Python tracker 

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



[issue10479] cgitb.py should assume a binary stream for output

2020-11-16 Thread Irit Katriel


Change by Irit Katriel :


--
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.1, Python 3.2

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-10 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-10 Thread Ned Deily


Ned Deily  added the comment:


New changeset a63234c49b2fbfb6f0aca32525e525ce3d43b2b4 by Serhiy Storchaka in 
branch '3.6':
[3.6] bpo-42103: Improve validation of Plist files. (GH-22882) (GH-23118)
https://github.com/python/cpython/commit/a63234c49b2fbfb6f0aca32525e525ce3d43b2b4


--

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-10 Thread Ned Deily


Ned Deily  added the comment:


New changeset 225e3659556616ad70186e7efc02baeebfeb5ec4 by Serhiy Storchaka in 
branch '3.7':
[3.7] bpo-42103: Improve validation of Plist files. (GH-22882) (#23117)
https://github.com/python/cpython/commit/225e3659556616ad70186e7efc02baeebfeb5ec4


--

___
Python tracker 

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



[issue6304] Confusing error message when passing bytes to print with file pointing to a binary file

2020-11-06 Thread Irit Katriel


Change by Irit Katriel :


--
stage: test needed -> 
versions: +Python 3.10, Python 3.8, Python 3.9 -Python 3.2, Python 3.3

___
Python tracker 

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



[issue42249] Plistlib cannot create binary Plist file larger than 4GiB

2020-11-04 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue42249] Plistlib cannot create binary Plist file larger than 4GiB

2020-11-03 Thread miss-islington


miss-islington  added the comment:


New changeset 9bc07874e34930d4e816a9a3330aab009404991e by Miss Skeleton (bot) 
in branch '3.9':
bpo-42249: Fix writing binary Plist files larger than 4 GiB. (GH-23121)
https://github.com/python/cpython/commit/9bc07874e34930d4e816a9a3330aab009404991e


--

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



[issue42249] Plistlib cannot create binary Plist file larger than 4GiB

2020-11-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +22045
pull_request: https://github.com/python/cpython/pull/23129

___
Python tracker 

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



[issue42249] Plistlib cannot create binary Plist file larger than 4GiB

2020-11-03 Thread miss-islington


miss-islington  added the comment:


New changeset ac70175fc038e0f06034c4d61c577ef4b923464a by Miss Skeleton (bot) 
in branch '3.8':
bpo-42249: Fix writing binary Plist files larger than 4 GiB. (GH-23121)
https://github.com/python/cpython/commit/ac70175fc038e0f06034c4d61c577ef4b923464a


--

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



[issue42249] Plistlib cannot create binary Plist file larger than 4GiB

2020-11-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 212d32f45c91849c17a82750df1ac498d63976be by Serhiy Storchaka in 
branch 'master':
bpo-42249: Fix writing binary Plist files larger than 4 GiB. (GH-23121)
https://github.com/python/cpython/commit/212d32f45c91849c17a82750df1ac498d63976be


--

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



[issue42249] Plistlib cannot create binary Plist file larger than 4GiB

2020-11-03 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 3.0 -> 4.0
pull_requests: +22044
pull_request: https://github.com/python/cpython/pull/23128

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-02 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +lukasz.langa
priority: normal -> release blocker

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-02 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 547d2bcc55e348043b2f338027c1acd9549ada76 by Serhiy Storchaka in 
branch '3.8':
[3.8] bpo-42103: Improve validation of Plist files. (GH-22882) (GH-23116)
https://github.com/python/cpython/commit/547d2bcc55e348043b2f338027c1acd9549ada76


--

___
Python tracker 

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



[issue42249] Plistlib cannot create binary Plist file larger than 4GiB

2020-11-02 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue42249] Plistlib cannot create binary Plist file larger than 4GiB

2020-11-02 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

Due to a typo plistlib uses at most 32 bits for references and offsets. It will 
fail if try to create a file larger than 4GiB or containing more than 2**32 
unique objects (the latter of course implies the former).

--
components: Library (Lib), macOS
messages: 380263
nosy: ned.deily, ronaldoussoren, serhiy.storchaka
priority: normal
severity: normal
status: open
title: Plistlib cannot create binary Plist file larger than 4GiB
type: behavior
versions: Python 3.10, Python 3.8, Python 3.9

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-02 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22035
pull_request: https://github.com/python/cpython/pull/23118

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-02 Thread miss-islington


miss-islington  added the comment:


New changeset e277cb76989958fdbc092bf0b2cb55c43e86610a by Miss Skeleton (bot) 
in branch '3.9':
bpo-42103: Improve validation of Plist files. (GH-22882)
https://github.com/python/cpython/commit/e277cb76989958fdbc092bf0b2cb55c43e86610a


--

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-02 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22034
pull_request: https://github.com/python/cpython/pull/23117

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-02 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +22033
pull_request: https://github.com/python/cpython/pull/23116

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-02 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-11-02 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 34637a0ce21e7261b952fbd9d006474cc29b681f by Serhiy Storchaka in 
branch 'master':
bpo-42103: Improve validation of Plist files. (GH-22882)
https://github.com/python/cpython/commit/34637a0ce21e7261b952fbd9d006474cc29b681f


--

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-10-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

No, with recursive collections all is good.

Then I'll just add a NEWS entry and maybe few more tests.

--

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-10-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

PR 22882 fixes problem in _read_ints(), adds validation for string size, and 
adds many tests for mailformed binary Plists.

There may be problems with recursive collections. I'll try to solve them too.

--

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-10-22 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

Serhiy, thanks. Just the change in the format string would fix this particular 
example.

I see you're working on a PR with better validation. The current state of the 
draft looks good to me, but I haven't checked yet if there are other potential 
problems that can be added to the list of invalid binary plists.

--

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-10-22 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-10-21 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

There are two issues here.

The simple one is building a large format string for struct.unpack(). It has 
simple solution: use f'>{n}{_BINARY_FORMAT[size]}'.

The hard issue is that read(n) allocates n bytes in memory even if there are 
not so many bytes in the file. It affects not only plistlib and should be fixed 
in the file implementation itself. There is an open issue for this.

--

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-10-21 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

One Apple implementation of binary plist parsing is here: 
https://opensource.apple.com/source/CF/CF-550/CFBinaryPList.c.

That seems to work from a buffer (or mmap) of the entire file, making 
consistency checks somewhat easier, and I don't think they have a hardcoded 
limit on the number of items in the plist (but: it's getting late and might 
have missed that).

An easy fix for this issue is to limit the amount of values read by _read_ints, 
but that immediately begs the question what that limit should be. It is clear 
that 1B items in the array is too much (in this case 1B object refs for 
dictionary keys). 

I don't know what a sane limit would be. The largest plist file on my system is 
10MB. Limiting *n* to 20M would be easily enough to parse that file, and 
doesn't consume too much memory (about 160MB for the read buffer at most). 

Another thing the current code doesn't do is check that the "ref" argument to 
_read_object is in range. That's less problematic because the code will raise 
an exception regardless (IndexErrox, instead of the nicer InvalidFileException).

--

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-10-21 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

Thanks for the report. I can reproduce the issue.

--

___
Python tracker 

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



[issue42103] [security] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-10-20 Thread Ned Deily


Change by Ned Deily :


--
components: +Library (Lib) -Interpreter Core
keywords: +security_issue
nosy: +ned.deily, ronaldoussoren, serhiy.storchaka
title: DoS (MemError via CPU and RAM exhaustion) when processing malformed 
Apple Property List files in binary format -> [security] DoS (MemError via CPU 
and RAM exhaustion) when processing malformed Apple Property List files in 
binary format

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



[issue42103] DoS (MemError via CPU and RAM exhaustion) when processing malformed Apple Property List files in binary format

2020-10-20 Thread Robert Wessen


New submission from Robert Wessen :

In versions of Python from 3.4-3.10, the Python core plistlib library supports 
Apple's binary plist format. When given malformed input, the implementation can 
be forced to create an argument to struct.unpack() which consumes all available 
CPU and memory until a MemError is thrown as it builds the 'format' argument to 
unpack().

This can be seen with the following malformed example binary plist input:

```
$ xxd binary_plist_dos.bplist
: 6270 6c69 7374 3030 d101 0255 614c 6973  bplist00...UaLis
0010: 74a5 0304 0506  00df 4251 4351 44a3  t.BQCQD.
0020: 0809 0a10 0110 0210 0308 0b11 1719 1b1d  
0030:  0101    000b    
0040:      0029...)

```
The error is reached in the following lines of plistlib.py:
(https://github.com/python/cpython/blob/e9959c71185d0850c84e3aba0301fbc238f194a9/Lib/plistlib.py#L485)

```
def _read_ints(self, n, size):
data = self._fp.read(size * n)
if size in _BINARY_FORMAT:
return struct.unpack('>' + _BINARY_FORMAT[size] * n, data)
```
When the malicious example above is opened by plistlib, it results in 'n' being 
controlled by the input and it can be forced to be very large. Plistlib 
attempts to build a string which is as long as 'n', consuming excessive 
resources.

Apple's built in utilities for handling plist files detects this same file as 
malformed and will not process it.

--
components: Interpreter Core
messages: 379175
nosy: wessen
priority: normal
severity: normal
status: open
title: DoS (MemError via CPU and RAM exhaustion) when processing malformed 
Apple Property List files in binary format
type: resource usage
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9

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



[issue41584] Clarify documentation for binary arithmetic operation subclass __r*__ precedence

2020-10-05 Thread Brett Cannon


Change by Brett Cannon :


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



[issue41584] Clarify documentation for binary arithmetic operation subclass __r*__ precedence

2020-10-05 Thread miss-islington


miss-islington  added the comment:


New changeset 4aad1e5770fab72908f922a7876075d3d5a7c0d0 by Miss Skeleton (bot) 
in branch '3.9':
bpo-41584: clarify when the reflected method of a binary arithemtic operator is 
called (GH-22505)
https://github.com/python/cpython/commit/4aad1e5770fab72908f922a7876075d3d5a7c0d0


--

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



[issue41584] Clarify documentation for binary arithmetic operation subclass __r*__ precedence

2020-10-05 Thread miss-islington


miss-islington  added the comment:


New changeset 31ceccb2c77854893f3a754aca04bedd74bedb10 by Miss Skeleton (bot) 
in branch '3.8':
bpo-41584: clarify when the reflected method of a binary arithemtic operator is 
called (GH-22505)
https://github.com/python/cpython/commit/31ceccb2c77854893f3a754aca04bedd74bedb10


--

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



[issue41584] Clarify documentation for binary arithmetic operation subclass __r*__ precedence

2020-10-05 Thread miss-islington


Change by miss-islington :


--
pull_requests: +21565
pull_request: https://github.com/python/cpython/pull/22569

___
Python tracker 

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



[issue41584] Clarify documentation for binary arithmetic operation subclass __r*__ precedence

2020-10-05 Thread Brett Cannon


Brett Cannon  added the comment:


New changeset d02d824e05e2cb86f4df381be18832e76e2c475f by Brett Cannon in 
branch 'master':
bpo-41584: clarify when the reflected method of a binary arithemtic operator is 
called (#22505)
https://github.com/python/cpython/commit/d02d824e05e2cb86f4df381be18832e76e2c475f


--

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



[issue41584] Clarify documentation for binary arithmetic operation subclass __r*__ precedence

2020-10-05 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 4.0 -> 5.0
pull_requests: +21564
stage: commit review -> patch review
pull_request: https://github.com/python/cpython/pull/22568

___
Python tracker 

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



[issue41935] Add binary operator!

2020-10-04 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

You can already do:

my_counter = 0

for i in rage(1000):
my_counter += (1 if (i % 2) == 0 else 0)

--
nosy: +pablogsal

___
Python tracker 

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



[issue41935] Add binary operator!

2020-10-04 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

In any case, for modifications about the Python syntax, please, open first some 
debate in the python-ideas mailing list.

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



[issue41935] Add binary operator!

2020-10-04 Thread Hadi Alqattan


New submission from Hadi Alqattan :

What are your opinions about adding a binary operator to Python in order to 
make this code possible?
```
my_counter = 0

for i in rage(1000):
my_counter += 1 if (i % 2) == 0
```

--
components: Interpreter Core
messages: 377976
nosy: hadialqattan
priority: normal
severity: normal
status: open
title: Add binary operator!
type: enhancement
versions: Python 3.10

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



  1   2   3   4   5   6   7   8   9   10   >