[issue45020] Freeze all modules imported during startup.

2021-09-30 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +27030
pull_request: https://github.com/python/cpython/pull/28665

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-30 Thread Eric Snow


Eric Snow  added the comment:


New changeset 7e5c107541726b90d3f2e6e69ef37180cf58335d by Eric Snow in branch 
'main':
bpo-45020: Add more test cases for frozen modules. (gh-28664)
https://github.com/python/cpython/commit/7e5c107541726b90d3f2e6e69ef37180cf58335d


--

___
Python tracker 

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



[issue17792] Unhelpful UnboundLocalError due to del'ing of exception target

2021-09-30 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

Aaron: Your understanding of how LEGB works in Python is a little off.

Locals are locals for the *entire* scope of the function, bound or unbound; 
deleting them means they hold nothing (they're unbound) but del can't actually 
stop them from being locals. The choice of whether to look something up in the 
L, E or GB portions of LEGB scoping rules is a *static* choice made when the 
function is defined, and is solely about whether they are assigned to anywhere 
in the function (without an explicit nonlocal/global statement to prevent them 
becoming locals as a result).

Your second example can be made to fail just by adding a line after the print:

def doSomething():
print(x)
x = 1

and it fails for the same reason:

def doSomething():
x = 10
del x
print(x)

fails; a local is a local from entry to exit in a function. Failure to assign 
to it for a while doesn't change that; it's a local because you assigned to it 
at least once, along at least one code path. del-ing it after assigning doesn't 
change that, because del doesn't get rid of locals, it just empties them. 
Imagine how complex the LOAD_FAST instruction would get if it needed to handle 
not just loading a local, but when the local wasn't bound, had to choose 
*dynamically* between:

1. Raising UnboundLocalError (if the value is local, but was never assigned)
2. Returning a closure scoped variable (if the value was local, but got del-ed, 
and a closure scope exists)
3. Raising NameError (if the closure scope variable exists, but was never 
assigned)
4. Returning a global/builtin variable (if there was no closure scope variable 
*or* the closure scope variable was created, but explicitly del-ed)
5. Raising NameError (if no closure, global or builtin name exists)

That's starting to stretch the definition of "fast" in LOAD_FAST. :-)

--
nosy: +josh.r

___
Python tracker 

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



[issue45020] Freeze all modules imported during startup.

2021-09-30 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +27029
pull_request: https://github.com/python/cpython/pull/28664

___
Python tracker 

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



[issue45333] += operator and accessors bug?

2021-09-30 Thread Josh Rosenberg


Josh Rosenberg  added the comment:

This has nothing to do with properties, it's 100% about using augmented 
assignment with numpy arrays and mixed types. An equivalent reproducer is:

a = np.array([1,2,3])  # Implicitly of dtype np.int64

a += 0.5  # Throws the same error, no properties involved

The problem is that += is intended to operate in-place on mutable types, numpy 
arrays *are* mutable types (unlike normal integers in Python), you're trying to 
compute a result that can't be stored in a numpy array of integers, and numpy 
isn't willing to silently make augmented assignment with incompatible types 
make a new copy with a different dtype (they *could* do this, but it would lead 
to surprising behavior, like += on the *same* numpy array either operating in 
place or creating a new array with a different dtype and replacing the original 
based on the type on the right-hand side).

The short form is: If your numpy computation is intended to produce a new array 
with a different data type, you can't use augmented assignment. And this isn't 
a bug in CPython in any event; it's purely about the choices (reasonable ones 
IMO) numpy made implementing their __iadd__ overload.

--
nosy: +josh.r
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



[issue45337] Create venv with pip fails when target dir is under userappdata using Microsoft Store python

2021-09-30 Thread Steve Dower


Change by Steve Dower :


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

___
Python tracker 

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



[issue44751] crypt.h should be in _cryptmodule.c, not in public header

2021-09-30 Thread STINNER Victor


STINNER Victor  added the comment:

> See issue #32635, where Victor Stinner backported some commit (with 
> problematic location of '#include ') to 2.7 and 3.6 branches (which 
> was released in >=2.7.15 and >=3.6).

crypt.h was added to Python.h by: 
https://github.com/python/cpython/pull/5284/files

And this change was then backported to 2.7 and 3.6. Ok, now I understand.

Well, it's now fixed in all branches accepting bugfixes.

--

___
Python tracker 

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



[issue45333] += operator and accessors bug?

2021-09-30 Thread chovey


chovey  added the comment:

import sys

import numpy as np


class Kinematics:
def __init__(self, *, initial_position: np.ndarray, initial_velocity: 
np.ndarray):
self._position = initial_position  # meters
self._velocity = initial_velocity  # meters per second

@property
def position(self) -> np.ndarray:
return self._position

@position.setter
def position(self, val: np.ndarray):
self._position = val

@property
def velocity(self) -> np.ndarray:
return self._velocity

@velocity.setter
def velocity(self, val: np.ndarray):
self._velocity = val

def update_shows_bug(self, *, delta_t: float):
# Tries to combine the getter and setter for self.position
# with the += operator, which will not work.
# Will cause this error:
# Exception has occurred: _UFuncOutputCastingError
# Cannot cast ufunc 'add' output from dtype('float64') to 
dtype('int64') with casting rule 'same_kind'
self.position += self.velocity * delta_t

def update_fixes_bug(self, *, delta_t: float):
# Fixes the bug exibited in the 'update_shows_bug' method.
self._position = self.velocity * delta_t + self.position


def main(argv):

# after an elapsed time of 2 seconds, calucate the new position
dt = 2.0  # seconds, elapsed time step

# construct a Kinematics object
x0, y0 = 1000, 2000  # meters
xdot0, ydot0 = 20, 30  # meters per second
k1 = Kinematics(
initial_position=np.array([x0, y0]), initial_velocity=np.array([xdot0, 
ydot0])
)  # m and m/s
k2 = Kinematics(
initial_position=np.array([x0, y0]), initial_velocity=np.array([xdot0, 
ydot0])
)  # m and m/s

# expected updated position is rate * time + initial_position
#
# x-direction
# = (20 m/s) * (2 s) + 1000 m
# = 40 m + 1000 m
# = 1040 m
#
# y-direction
# = (30 m/s) * (2 s) + 2000 m
# = 60 m + 2000 m
# = 2060 m

xf, yf = 1040, 2060  # meters

# k1.update_shows_bug(delta_t=dt)  # will trigger error
# new_position_with_bug = k1.position
# assert new_position_with_bug[0] == xf  # meters, succeeds
# assert new_position_with_bug[1] == yf  # meters, succeeds

k2.update_fixes_bug(delta_t=dt)
new_position_without_bug = k2.position
assert new_position_without_bug[0] == xf  # meters, succeeds
assert new_position_without_bug[1] == yf  # meters, succeeds

print("Finished.")


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

--
Added file: https://bugs.python.org/file50319/bug_plus_equals_numpy.py

___
Python tracker 

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



[issue45333] += operator and accessors bug?

2021-09-30 Thread chovey


chovey  added the comment:

I confirm I do get this error:
Exception has occurred: _UFuncOutputCastingError
Cannot cast ufunc 'add' output from dtype('float64') to dtype('int64') with 
casting rule 'same_kind'

I next will paste a minimum working example.

--

___
Python tracker 

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



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


STINNER Victor  added the comment:

On Unix, PyCOND_TIMEDWAIT() is implemented with pthread_cond_timedwait(). If 
pthread_condattr_setclock() is available, it uses CLOCK_MONOTONIC. Otherwise, 
it uses CLOCK_REALTIME.

The glibc 2.30 adds pthread_cond_clockwait() which could be used to use 
CLOCK_MONOTONIC. But if pthread_cond_clockwait() is available (glibc 2.30 or 
newer), it expects that pthread_condattr_setclock() is also available. So I'm 
not sure that it's worth it to change PyCOND_TIMEDWAIT().

See the _PyThread_cond_after() function which computes an absolute timestamp 
(timespec) from a relative timeout in microseconds.

--

___
Python tracker 

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



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27027
pull_request: https://github.com/python/cpython/pull/28662

___
Python tracker 

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



[issue45337] Create venv with pip fails when target dir is under userappdata using Microsoft Store python

2021-09-30 Thread Steve Dower


Steve Dower  added the comment:

Thanks Adam.

This analysis is correct, and I think there are two parts to this.

First, we probably need to add an os.path.realpath(path_to_venv) before we try 
and launch the environment. We *could* limit this to when it's under AppData, 
but I think limiting it to Windows is enough.

Second, if the realpath generated a different path, we should warn the caller. 
That wouldn't have helped in this (programmatic) case, but at least if someone 
is looking at the output they'll get an important hint.

(The docs describing this behaviour are at 
https://docs.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-behind-the-scenes
 )

--

___
Python tracker 

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



[issue44751] crypt.h should be in _cryptmodule.c, not in public header

2021-09-30 Thread Arfrever Frehtes Taifersar Arahesis


Arfrever Frehtes Taifersar Arahesis  added the comment:

> > This is fix for regression which was previously backported to 2.7 and 3.6 
> > branches.
> 
> I'm not sure what you mean.
> 
> In Python 2.7 and Python 3.6,  was already included by 
> Include/Python.h:

See issue #32635, where Victor Stinner backported some commit (with problematic 
location of '#include ') to 2.7 and 3.6 branches (which was released 
in >=2.7.15 and >=3.6).

--

___
Python tracker 

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



[issue45333] += operator and accessors bug?

2021-09-30 Thread chovey


chovey  added the comment:

Let me get a minimum working example (MWE) developed and then I will return and 
paste it in here.  Ball in my court.  Than, you.

--

___
Python tracker 

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



[issue45337] Create venv with pip fails when target dir is under userappdata using Microsoft Store python

2021-09-30 Thread Adam Yoblick


Change by Adam Yoblick :


--
type:  -> behavior

___
Python tracker 

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



[issue45337] Create venv with pip fails when target dir is under userappdata using Microsoft Store python

2021-09-30 Thread Adam Yoblick


New submission from Adam Yoblick :

Repro steps:

1. Install Python 3.9 from the Microsoft Store
2. Try to create a virtual environment under the userappdata folder, using a 
command line similar to the following:

"C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\python3.9.exe"
 -m venv "C:\Users\advolker\AppData\Local\Microsoft\CookiecutterTools\env"

3. Observe the following error:

Error: Command 
'['C:\\Users\\advolker\\AppData\\Local\\Microsoft\\CookiecutterTools\\env\\Scripts\\python.exe',
 '-Im', 'ensurepip', '--upgrade', '--default-pip']' returned non-zero exit 
status 106.

Note that creating a venv without pip DOES work:

"C:\Program 
Files\WindowsApps\PythonSoftwareFoundation.Python.3.9_3.9.2032.0_x64__qbz5n2kfra8p0\python3.9.exe"
 -m venv "C:\Users\advolker\AppData\Local\Microsoft\CookiecutterTools\env" 
--without-pip

BUT the venv is NOT at the specified location. This is because the Windows 
Store app creates a redirect when creating the venv, and that redirect is only 
visible from within the python executable.

This means that python doesn't respect the redirect when trying to install pip 
into the newly created venv.

--
components: Windows
messages: 402983
nosy: AdamYoblick, paul.moore, steve.dower, tim.golden, zach.ware
priority: normal
severity: normal
status: open
title: Create venv with pip fails when target dir is under userappdata using 
Microsoft Store python
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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 2cf76cf4ccd177b8d6d2bf21b5462258ae87522d by Łukasz Langa in 
branch '3.9':
Revert "bpo-45229: Make datetime tests discoverable (GH-28615). (GH-28645)" 
(GH-28660)
https://github.com/python/cpython/commit/2cf76cf4ccd177b8d6d2bf21b5462258ae87522d


--

___
Python tracker 

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



[issue45336] Issue with xml.tree.ElementTree.write

2021-09-30 Thread ed wolf

New submission from ed wolf :

When executing the following command after modifiy an xml file an error is 
prodcued.

import xml.etree.ElementTree as ET
rtexmlFile = 'Fox_CM3550A_SWP1_Rte_ecuc.arxml'
rte_ecu_tree = ET.parse(rtexmlFile)
root = rte_ecu_tree.getroot()

rte_ecu_tree.write(rtexmlFile, encoding="UTF-8", xml_declaration="True", 
default_namespace="None" method="xml",short_empty_elements="True" )

ValueError: cannot use non-qualified names with default_namespace option

The documentation for the ElementTree.write function indicates the following 
format for this command but this format does not seem to wrok

The write command does not also take into account when having standalone in the 
xml defintion. For ex,



ElementTree.write will not add standalone back to the xml file

Is this a bug in version 3.7?


write(file, encoding="us-ascii", xml_declaration=None, default_namespace=None, 
method="xml", *, short_empty_elements=True)
Writes the element tree to a file, as XML. file is a file name, or a file 
object opened for writing. encoding 1 is the output encoding (default is 
US-ASCII). xml_declaration controls if an XML declaration should be added to 
the file. Use False for never, True for always, None for only if not US-ASCII 
or UTF-8 or Unicode (default is None). default_namespace sets the default XML 
namespace (for “xmlns”). method is either "xml", "html" or "text" (default is 
"xml"). The keyword-only short_empty_elements parameter controls the formatting 
of elements that contain no content. If True (the default), they are emitted as 
a single self-closed tag, otherwise they are emitted as a pair of start/end 
tags.

The output is either a string (str) or binary (bytes). This is controlled by 
the encoding argument. If encoding is "unicode", the output is a string; 
otherwise, it’s binary. Note that this may conflict with the type of file if 
it’s an open file object; make sure you do not try to write a string to a 
binary stream and vice versa.

--
assignee: docs@python
components: Documentation
messages: 402981
nosy: docs@python, twowolfs
priority: normal
severity: normal
status: open
title: Issue with xml.tree.ElementTree.write
type: performance
versions: Python 3.7

___
Python tracker 

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



[issue17792] Unhelpful UnboundLocalError due to del'ing of exception target

2021-09-30 Thread Aaron Smith


Aaron Smith  added the comment:

I encountered the similar behavior unexpectedly when dealing with LEGB scope of 
names. Take the following example run under Python 3.9.2:

def doSomething():
x = 10
del x
print(x)

x = 5
doSomething()

This produces a UnboundLocalError at print(x) even though "x" can still be 
found in the global scope. Indeed if your add print(globals()) before the 
print(x) line, you can see "x" listed.

By contrast, LEGB scope behavior works as expected in this example:

def doSomething():
print(x)

x = 5
doSomething()

The former example yielding the UnboundLocalError when dealing with name scope 
feels like a bug that lines up with the original behavior described in this 
enhancement request, as I believe "x" is still a bounded name in the global 
scope, but was explicitly deleted from the local scope.

--
nosy: +aaronwsmith

___
Python tracker 

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



[issue45310] test_multiprocessing_forkserver: test_shared_memory_basics() failed with FileExistsError: [Errno 17] File exists: '/test01_tsmb'

2021-09-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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



[issue45310] test_multiprocessing_forkserver: test_shared_memory_basics() failed with FileExistsError: [Errno 17] File exists: '/test01_tsmb'

2021-09-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
keywords: +patch
nosy: +serhiy.storchaka
nosy_count: 1.0 -> 2.0
pull_requests: +27026
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28661

___
Python tracker 

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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Łukasz Langa

Change by Łukasz Langa :


--
pull_requests: +27025
pull_request: https://github.com/python/cpython/pull/28660

___
Python tracker 

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



[issue45335] Default TIMESTAMP converter in sqlite3 ignores time zone

2021-09-30 Thread Ian Fisher


New submission from Ian Fisher :

The SQLite converter that the sqlite3 library automatically registers for 
TIMESTAMP columns 
(https://github.com/python/cpython/blob/main/Lib/sqlite3/dbapi2.py#L66) ignores 
the time zone even if it is present and always returns a naive datetime object.

I think that the converter should return an aware object if the time zone is 
present in the database. As it is, round trips of TIMESTAMP values from the 
database to Python and back might erase the original time zone info.

Now that datetime.datetime.fromisoformat is in Python 3.7, this should be easy 
to implement.

--
components: Library (Lib)
messages: 402979
nosy: iafisher
priority: normal
severity: normal
status: open
title: Default TIMESTAMP converter in sqlite3 ignores time zone
type: enhancement

___
Python tracker 

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



[issue45330] dulwich_log performance regression in 3.10

2021-09-30 Thread Irit Katriel


Irit Katriel  added the comment:

Looks like this is using a 3rd party module (dulwitch.repo). Could it be a new 
version of that?

--

___
Python tracker 

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



[issue44841] filemode in repr of ZipInfo, but is not a ZipInfo attribute

2021-09-30 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

The repr() output of a ZipInfo contains filemode, but it is not an attribute of 
those objects, see 
 for a list of 
attributes and methods.

Adding an @property for mode that extracts the mode (as an integer) from the 
external_attr could be useful, that avoids having to know about that encoding 
in users of the library.

You currently have to extract the mode yourself. Luckily that isn't too hard, 
basically: ```mode = info.external_attr >> 16```. Only use this when the value 
is not 0, as it will be zero when the archive was created by software that 
doesn't store a mode.   You can convert this integer to a human readable string 
using the function stat.filemode(). 

I've changed the version to 3.11 because adding a mode attribute to ZipInfo 
would be a new feature and is therefore only possible in a new feature release.

--
title: ZipInfo crashes on filemode -> filemode in repr of ZipInfo, but is not a 
ZipInfo attribute
versions: +Python 3.11 -Python 3.7

___
Python tracker 

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



[issue45331] Can create enum of ranges, cannot create range enum. Range should be subclassable... or EnumMeta.__new__ should be smarter.

2021-09-30 Thread Ethan Furman


Change by Ethan Furman :


--
assignee:  -> ethan.furman
nosy: +ethan.furman
versions: +Python 3.11 -Python 3.9

___
Python tracker 

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



[issue45333] += operator and accessors bug?

2021-09-30 Thread Mark Dickinson


Mark Dickinson  added the comment:

Did you by any chance get an error message resembling the following?

> "Cannot cast ufunc 'add' output from dtype('float64') to dtype('int64') with 
> casting rule 'same_kind'"

(If you can give us a complete piece of code that we can run ourselves, that 
would save us from having to guess what the issue is.)

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue40173] test.support.import_fresh_module fails to correctly block submodules when fresh is specified

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

_save_and_remove_module in the old code did too much and too little. It tested 
that the fresh module is importable, saved the current state of the fresh 
module and its submodules and removed the fresh module and its submodules. 
Since it tested importability before saving all states, it can have a side 
effect of importing other fresh module, and since it did it before blocking, 
the imported "fresh" module could import the blocked modules.

> 1. Switching the order of how "fresh" and "blocked" are resolved or

It does not help, because the step of resolving "fresh" includes saving the 
sys.modules state, and the step of resolving "blocked" modifies sys.modules. 
Also the step of resolving "fresh" can modify sys.modules before saving its 
sate.

2. Deleting `sys.modules[name]` if it exists immediately before calling 
`importlib.import_module(name)

It would be not enough, because the problem can occur in one of additional 
fresh modules imported by the initial module. We need to remove all fresh 
modules before attempting to import them.

The new import_fresh_module() consists of the following steps:

1. Save the state of all fresh and blocked modules and their submodules.
2. Remove the fresh modules and their submodules and block the blocked modules 
and their submodules.
3. Import all additional fresh modules and return None if any of them is not 
importable.
4. Import the initial module and raise ImportError if it is not importable.
5. Restore states of all fresh and blocked modules and their submodules.

It does not save and restore the state of all modules, because some indirectly 
imported modules can not support repeated importing. It can be reconsidered in 
new versions.

--

___
Python tracker 

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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 993a130d3abe7684dc9c999874b4dd1d8ea55a2a by Serhiy Storchaka in 
branch '3.9':
[3.9] bpo-45229: Make datetime tests discoverable (GH-28615). (GH-28645)
https://github.com/python/cpython/commit/993a130d3abe7684dc9c999874b4dd1d8ea55a2a


--

___
Python tracker 

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



[issue40173] test.support.import_fresh_module fails to correctly block submodules when fresh is specified

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset f7e99c98130a705f88348dde60adb98d5bfd8b98 by Serhiy Storchaka in 
branch '3.9':
[3.9] bpo-40173: Fix test.support.import_helper.import_fresh_module() 
(GH-28654) (GH-28658)
https://github.com/python/cpython/commit/f7e99c98130a705f88348dde60adb98d5bfd8b98


--

___
Python tracker 

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



[issue40173] test.support.import_fresh_module fails to correctly block submodules when fresh is specified

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset 7873884d4730d7e637a968011b8958bd79fd3398 by Serhiy Storchaka in 
branch '3.10':
[3.10] bpo-40173: Fix test.support.import_helper.import_fresh_module() 
(GH-28654) (GH-28657)
https://github.com/python/cpython/commit/7873884d4730d7e637a968011b8958bd79fd3398


--

___
Python tracker 

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



[issue45334] String Strip not working

2021-09-30 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

Serhiy is correct. Please see the documentation.

https://docs.python.org/3/library/stdtypes.html#str.strip

If you are using version 3.9 or better, you can use removeprefix instead:

https://docs.python.org/3/library/stdtypes.html#str.removeprefix

--
nosy: +steven.daprano

___
Python tracker 

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



[issue40173] test.support.import_fresh_module fails to correctly block submodules when fresh is specified

2021-09-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +27024
pull_request: https://github.com/python/cpython/pull/28658

___
Python tracker 

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



[issue45332] Decimal test and benchmark are broken

2021-09-30 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



[issue40173] test.support.import_fresh_module fails to correctly block submodules when fresh is specified

2021-09-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +27023
pull_request: https://github.com/python/cpython/pull/28657

___
Python tracker 

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



[issue40173] test.support.import_fresh_module fails to correctly block submodules when fresh is specified

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:


New changeset ec4d917a6a68824f1895f75d113add9410283da7 by Serhiy Storchaka in 
branch 'main':
bpo-40173: Fix test.support.import_helper.import_fresh_module() (GH-28654)
https://github.com/python/cpython/commit/ec4d917a6a68824f1895f75d113add9410283da7


--

___
Python tracker 

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



[issue45333] += operator and accessors bug?

2021-09-30 Thread Eric V. Smith


Eric V. Smith  added the comment:

Please show what result you're getting, and what result you're expecting. "will 
not work" is not very helpful for us to replicate it.

--
components:  -2to3 (2.x to 3.x conversion tool)
nosy: +eric.smith

___
Python tracker 

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



[issue45334] String Strip not working

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

It works as intended (please re-read the documentation carefully). It strips 
all characters specified in the argument. It strips characters "c" and "p" and 
stops before character "u" because "monitorScript_" contains "c" and "p", but 
not "u".

--
nosy: +serhiy.storchaka
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



[issue45334] String Strip not working

2021-09-30 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
components:  -Parser
nosy:  -pablogsal

___
Python tracker 

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



[issue45334] String Strip not working

2021-09-30 Thread Vigneshwar Elangovan


New submission from Vigneshwar Elangovan :

string = "monitorScript_cpu.py"
a = string.strip("monitorScript_")
print(a)
  > getting output => u.py
Should stip only "monitorScript_" but stripping additional 2 charaters 
"monitorScript_cp" 

Below code working fine:
string = "monitorScript_send_user.py"
a = string.strip("monitorScript_")
print(a)

--
components: Parser
files: capture.PNG
messages: 402967
nosy: lys.nikolaou, pablogsal, vigneshwar.e14
priority: normal
severity: normal
status: open
title: String Strip not working
type: behavior
versions: Python 3.6
Added file: https://bugs.python.org/file50318/capture.PNG

___
Python tracker 

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



[issue21736] Add __file__ attribute to frozen modules

2021-09-30 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +27022
pull_request: https://github.com/python/cpython/pull/28656

___
Python tracker 

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



[issue45333] += operator and accessors bug?

2021-09-30 Thread chovey


New submission from chovey :

We used get/set attribute accessors with private data, and suspect the beaviour 
we see with the += operator contains a bug.  Below is our original 
implementation, followed by our fix.  But, we feel the original implementation 
should have worked.  Please advise.  Thank you.

@property
def position(self) -> np.ndarray:
return self._position

@position.setter
def position(self, val: np.ndarray):
self._position = val

def update(self, *, delta_t: float):
# Nope! Bug! (?)  
# Tried to combine the getter and setter for self.position
# with the += operator, which will not work.
# self.position += self.velocity * delta_t
#
# This fixes the behaviour.
self._position = self.velocity * delta_t + self.position

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 402966
nosy: chovey
priority: normal
severity: normal
status: open
title: += operator and accessors bug?
type: behavior
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



[issue45325] Allow "p" in Py_BuildValue

2021-09-30 Thread Matt Wozniski


Matt Wozniski  added the comment:

> "!value" or "!!value" also has the issue if I understood correctly.

No, just as "value != 0" is an int, so is "!value".

--

___
Python tracker 

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



[issue45332] Decimal test and benchmark are broken

2021-09-30 Thread Serhiy Storchaka


New submission from Serhiy Storchaka :

The test and the benchmark for the decimal module are broken in 3.10+.

$ ./python Modules/_decimal/tests/deccheck.py
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Modules/_decimal/tests/deccheck.py", line 50, 
in 
from test.support import import_fresh_module

ImportError: cannot import name 'import_fresh_module' from 'test.support' 
(/home/serhiy/py/cpython/Lib/test/support/__init__.py)

$ ./python Modules/_decimal/tests/bench.py
Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Modules/_decimal/tests/bench.py", line 11, in 

from test.support import import_fresh_module

ImportError: cannot import name 'import_fresh_module' from 'test.support' 
(/home/serhiy/py/cpython/Lib/test/support/__init__.py)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/serhiy/py/cpython/Modules/_decimal/tests/bench.py", line 13, in 

from test.test_support import import_fresh_module
^
ImportError: cannot import name 'import_fresh_module' from 'test.test_support' 
(/home/serhiy/py/cpython/Lib/test/test_support.py)


Modules/_decimal/tests/bench.py

--
components: Demos and Tools
messages: 402964
nosy: serhiy.storchaka, vstinner
priority: normal
severity: normal
status: open
title: Decimal test and benchmark are broken
type: behavior
versions: Python 3.10, Python 3.11

___
Python tracker 

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



[issue45330] dulwich_log performance regression in 3.10

2021-09-30 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



[issue21736] Add __file__ attribute to frozen modules

2021-09-30 Thread Eric Snow


Change by Eric Snow :


--
pull_requests: +27021
pull_request: https://github.com/python/cpython/pull/28655

___
Python tracker 

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



[issue32523] inconsistent spacing in changelog.html

2021-09-30 Thread Julien Palard


Julien Palard  added the comment:

This still happen, but it's hard to tell if it'll happen from blurb, as when 
it's two paragraphs consisting of a text and a list it does not happen, sphinx 
just put the list as a sublist and it's clean.

I don't want to tell people stop using list, it's very readable.

Also sometimes having a paragraph, a list, then one or two more paragraphs 
looks usefull, see examples in [1].

[1]: https://github.com/python/core-workflow/pull/274#issuecomment-931387938

So I'm no longer trying to fix it in blurb.

--

___
Python tracker 

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



[issue10716] Modernize pydoc to use better HTML and separate CSS

2021-09-30 Thread Julien Palard


Julien Palard  added the comment:

Tried myself at it.

I'm not a front-end guy, fasten your seatbelts.

I tried to keep it minimal, but after some work the change is not that small, I 
focused on the HTML modernization only, not the design (to try to land at least 
a first step toward modernization).

--

___
Python tracker 

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



[issue40173] test.support.import_fresh_module fails to correctly block submodules when fresh is specified

2021-09-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +27020
pull_request: https://github.com/python/cpython/pull/28654

___
Python tracker 

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



[issue40173] test.support.import_fresh_module fails to correctly block submodules when fresh is specified

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

I just encountered this bug after rewriting datetime tests in issue45229. It is 
also the cause of issue40058.

Not knowing about this issue I have wrote different patch than Hai Shi. It 
makes the code of import_fresh_module() clearer and fixes many other issues.

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue40173] test.support.import_fresh_module fails to correctly block submodules when fresh is specified

2021-09-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
versions: +Python 3.10, Python 3.11 -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



[issue45331] Can create enum of ranges, cannot create range enum. Range should be subclassable... or EnumMeta.__new__ should be smarter.

2021-09-30 Thread Sam Bishop


New submission from Sam Bishop :

Range types are perfectly valid as values in an enum, like so.

class EnumOfRanges(Enum):
ZERO = range(0, 0)
RANGE_A = range(1, 11)
RANGE_B = range(11, 26)


However unlike the other base types , 'int', 'str', 'float', etc. You cannot 
create a "range enum" 

class RangeEnum(range, Enum):
ZERO = range(0, 0)
RANGE_A = range(1, 11)
RANGE_B = range(11, 26)

produces `TypeError: type 'range' is not an acceptable base type` when you try 
and import `RangeEnum`.

The current documentation for `enum` implicitly says this should work by not 
mentioning anything special here 
https://docs.python.org/3/library/enum.html#others

It also allows the use of range objects as value types, another implicit 
suggestion that we should be able to restrict an enum class to just range 
values like we can for other builtin class types.

Also to keep this a concise issue:
- Yes I'm aware not all of the base classes can be subclassed.
- Yes I know I that there are good reasons bool should not be subclassable.

So I'd like to suggest one of three things should be done to improve the 
situation:

A: Solve https://bugs.python.org/issue17279 and by documenting the special base 
class objects that cannot be subclassed and reference this in the documentation 
for Enums.

B: Make a decision as to which base class objects we should be able to 
subclass, and then improve their C implementations to allow subclassing. (It's 
also probably worth documenting the final list of special objects and solving 
https://bugs.python.org/issue17279 should this approach be selected.) 

C: The __new__ method on EnumMeta should be made smarter so that it either 
emits a more useful warning (I had to head to the CPython source code to work 
out what the error `TypeError: type 'range' is not an acceptable base type` 
meant) or somehow being more smart about how it handles the special classes 
which can't cannot be subclassed allowing them to be used anyway.  which again 
sort of involves solving https://bugs.python.org/issue17279, and in the case 
that its just made magically smarter, I'll admit could confuse some people as 
to why "Enum" is special and can subclass these but their own code can't just 
do `class MyRange(range):` 

Regardless of the outcome, it would be good to fill in this pitfall one way or 
the other for the sake of future developers, I'm a reasonably experienced 
Python developer and it caught me by surprise I'm likely not the first and 
probably wont be the last if the behaviour remains as it currently is.

--
components: Interpreter Core
messages: 402960
nosy: techdragon
priority: normal
severity: normal
status: open
title: Can create enum of ranges, cannot create range enum. Range should be 
subclassable... or EnumMeta.__new__ should be smarter.
type: enhancement
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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:


New changeset b07fddd527efe67174ce6b0fdbe8dac390b16e4e by Pablo Galindo Salgado 
in branch 'main':
Revert "bpo-45229: Make datetime tests discoverable (GH-28615)" (GH-28650)
https://github.com/python/cpython/commit/b07fddd527efe67174ce6b0fdbe8dac390b16e4e


--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-09-30 Thread Irit Katriel

Irit Katriel  added the comment:

It’s not clear that LOAD_NONE/LOAD_COMMON_CONST are worth doing. Any way the 
docstring question is not necessarily related to that.

--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-09-30 Thread Mark Shannon


Mark Shannon  added the comment:

Since the docstring itself will always be present (attached to the function 
object), removing a docstring from a co_consts tuple will only save one pointer 
(8 bytes).

Given that, it would appear that (d) uses *more* memory than (b).

For the sqlalchemy example: the saving in co_consts is about 1.6k (200 
pointers), but an increase in bytecode size of 2.4k.

Either way, the difference is a tiny fraction of the total memory used for code 
objects.

--

___
Python tracker 

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



[issue10716] Modernize pydoc to use better HTML and separate CSS

2021-09-30 Thread Julien Palard


Change by Julien Palard :


--
pull_requests: +27019
pull_request: https://github.com/python/cpython/pull/28651

___
Python tracker 

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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

See issue40058 and issue40173.

--
dependencies: +Running test_datetime twice fails with: module 'datetime' has no 
attribute '_divide_and_round', test.support.import_fresh_module fails to 
correctly block submodules when fresh is specified

___
Python tracker 

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



[issue45330] dulwich_log performance regression in 3.10

2021-09-30 Thread Ken Jin


New submission from Ken Jin :

Somewhere between May02-May11, dulwich_log benchmark on pyperformance had a 
major performance regression on the 3.10 branch. 
https://speed.python.org/timeline/?exe=12==dulwich_log=1=200=off=on=on

For a start, we could git bisect with pyperformance. FWIW, I couldn't reproduce 
the perf regression on Windows. So it might be a Linux-only thing.

--
messages: 402955
nosy: iritkatriel, kj
priority: normal
severity: normal
status: open
title: dulwich_log performance regression in 3.10
type: performance
versions: Python 3.10, Python 3.11

___
Python tracker 

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



[issue45116] Performance regression 3.10b1 and later on Windows: Py_DECREF() not inlined in PGO build

2021-09-30 Thread Ken Jin


Ken Jin  added the comment:

@Pablo
> I disagree. This is a regression/bug and we don't advertise "known bugs" in 
> the what's new, the same for any other bugfix that has been delayed until 
> 3.10.1

Alright, in hindsight 3.10 What's New was a bad suggestion on my part. I wonder 
if there's a better location for such news though.

>>  Some use cases are slower (by >10%!)
> Can you still reproduce this with PR 28475?

Yes that number is *with* PR28475. Without that PR it was worse. The second 
pyperformance comparison in this file is 3.10a7 vs PR28475 
https://bugs.python.org/file50293/PR28475_vs_310rc2_vs_310a7.txt. Omitting 
python_startup (unstable on Windows) and unpack_sequence (microbenchmark):

- logging_silent: 250 ns +- 7 ns -> 291 ns +- 10 ns: 1.16x slower
- hexiom: 14.0 ms +- 0.3 ms -> 15.7 ms +- 3.0 ms: 1.12x slower
- logging_simple: 16.1 us +- 0.2 us -> 18.0 us +- 0.5 us: 1.12x slower
- nbody: 215 ms +- 7 ms -> 235 ms +- 4 ms: 1.09x slower
- logging_format: 17.8 us +- 0.3 us -> 19.4 us +- 0.5 us: 1.09x slower
- richards: 104 ms +- 6 ms -> 112 ms +- 3 ms: 1.08x slower
- xml_etree_parse: 218 ms +- 3 ms -> 235 ms +- 3 ms: 1.08x slower
- sqlalchemy_imperative: 34.5 ms +- 0.9 ms -> 37.1 ms +- 1.1 ms: 1.08x slower
- xml_etree_iterparse: 158 ms +- 2 ms -> 168 ms +- 2 ms: 1.06x slower
- pathlib: 255 ms +- 6 ms -> 271 ms +- 3 ms: 1.06x slower
- pyflate: 963 ms +- 10 ms -> 1.02 sec +- 0.02 sec: 1.06x slower
- unpickle_pure_python: 446 us +- 11 us -> 471 us +- 9 us: 1.06x slower
 anything <= 1.05x slower is snipped since it could be noise -

At this point I don't know if we have any quick fixes left. So maybe we should 
open another issue for 3.11 and consider factoring out uncommon opcodes into 
functions like Victor and Mark suggested. We could make use of the opcode stats 
the faster-cpython folks have collected https://github.com/faster-cpython/tools.

--

___
Python tracker 

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



[issue36841] Supporting customization of float encoding in JSON

2021-09-30 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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +27018
pull_request: https://github.com/python/cpython/pull/28650

___
Python tracker 

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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> Seems this is not a new bug:

I agree, is unfortunate. But sadly is breaking all buildbots and therefore is 
hiding other issues and making the 'test-with-buildbots' label not useful. I 
would prefer to revert until we have a fix (and not land the backports until 
then).

--

___
Python tracker 

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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Seems this is not a new bug:

$ ./python -m test test_datetime test_datetime -m test_divide_and_round
0:00:00 load avg: 2.36 Run tests sequentially
0:00:00 load avg: 2.36 [1/2] test_datetime
0:00:00 load avg: 2.36 [2/2] test_datetime
test test_datetime failed -- Traceback (most recent call last):
  File "/home/serhiy/py/cpython3.9/Lib/test/datetimetester.py", line 88, in 
test_divide_and_round
dar = datetime_module._divide_and_round
AttributeError: module 'datetime' has no attribute '_divide_and_round'

test_datetime failed (1 error)

== Tests result: FAILURE ==


But for some causes it was not reproduced with refleak tests.

--

___
Python tracker 

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



[issue45325] Allow "p" in Py_BuildValue

2021-09-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> But I am not in strict opposition against this feature. It is just that I 
> have fixed so many bugs, that I try to search potential flaws and drawbacks 
> in any new feature. Now you know about this, and you can decide whether the 
> benefit is larger than the risk of potential damages. To me they look equally 
> small.

Thanks, Serhiy, for your insights and careful consideration. Among many things, 
your attention to detail, experience and careful consideration are what I 
admire the most! You rock :)

I will look at the stdlib examples and will incorporated them into the PR and 
then I will carefully consider the change again.

Thanks for the comments!

--

___
Python tracker 

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



[issue45329] pyexpat: segmentation fault when `--with-system-expat` is specified

2021-09-30 Thread STINNER Victor


Change by STINNER Victor :


--
nosy: +vstinner

___
Python tracker 

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



[issue45329] pyexpat: segmentation fault when `--with-system-expat` is specified

2021-09-30 Thread TAGAMI Yukihiro


Change by TAGAMI Yukihiro :


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

___
Python tracker 

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



[issue36841] Supporting customization of float encoding in JSON

2021-09-30 Thread Min RK


Min RK  added the comment:

We just ran into this in Jupyter where we've removed a pre-processing step for 
data structures passed to json.dumps, which took care of this, but was 
expensive https://github.com/jupyter/jupyter_client/pull/706

My expectation was that our `default` would be called for the unsupported 
value, but it isn't. I see the PR proposes a new option, but would it be 
sensible to use the already-existing `default` callback for this? It seems like 
what `default` is for.

--

___
Python tracker 

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



[issue45329] pyexpat: segmentation fault when `--with-system-expat` is specified

2021-09-30 Thread TAGAMI Yukihiro


New submission from TAGAMI Yukihiro :

Some tests, which are related to pyexpat, get failed with `./configure 
--with-system-expat`.
```
11 tests failed:   
test_minidom test_multiprocessing_fork  
 
test_multiprocessing_forkserver test_multiprocessing_spawn
test_plistlib test_pulldom test_pyexpat test_sax test_xml_etree
test_xml_etree_c test_xmlrpc
```

Since 3.10.0b2, `Modules/pyexpat.c` has been broken.
I guess this is caused by accessing freed memory.
For more detail, please refer to the attached file.

--
components: Extension Modules
files: pyexpat-log.txt
messages: 402949
nosy: y-tag
priority: normal
severity: normal
status: open
title: pyexpat: segmentation fault when `--with-system-expat` is specified
type: crash
versions: Python 3.10, Python 3.11
Added file: https://bugs.python.org/file50317/pyexpat-log.txt

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-09-30 Thread Inada Naoki


Inada Naoki  added the comment:

My machine at the office (used for benchmarking) is hanged up and I need to go 
to the office to reboot. So I don't have benchmark machine for now.

Please prioritize LOAD_NONE/LOAD_COMMON_CONST than this. It is hard to maintain 
merged branches. Merging LOAD_NONE/LOAD_COMMON_CONST into main branch makes 
this issue easier.

--

___
Python tracker 

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



[issue36841] Supporting customization of float encoding in JSON

2021-09-30 Thread Min RK


Change by Min RK :


--
nosy: +minrk
nosy_count: 5.0 -> 6.0
pull_requests: +27016
pull_request: https://github.com/python/cpython/pull/28648

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-09-30 Thread Inada Naoki


Inada Naoki  added the comment:

I used this tool to count co_const size and numbers.
https://github.com/faster-cpython/tools/pull/6

Target is asyncio in the main branch.

main (b34dd58f):
Total: 31 files; 1,068 code objects; 12,741 lines; 39,208 opcodes; 3,880 total 
size of co_consts; 738 number of co_consts

LOAD_NONE (https://github.com/python/cpython/pull/28376):
Total: 31 files; 1,068 code objects; 12,741 lines; 39,208 opcodes; 3,617 total 
size of co_consts; 743 number of co_consts

(b) LOAD_NONE + CO_DOCSTRING (b: https://github.com/methane/cpython/pull/36):
Total: 31 files; 1,068 code objects; 12,741 lines; 39,208 opcodes; 3,272 total 
size of co_consts; 732 number of co_consts

(d) LOAD_NONE + remove docstring from code (d: 
https://github.com/methane/cpython/pull/37):
Total: 31 files; 1,068 code objects; 12,741 lines; 39,469 opcodes;  3,255 total 
size of co_consts; 574 number of co_consts

number of co_consts:
main -> (b) = 738 -> 732 (-6, -0.8%)
(b) -> (d) = 732 -> 574   (-158, -21.6%)

total size of co_consts:
main -> (b) = 3880 -> 3272 (-608, -15.7%)
(b) -> (d) = 3272 -> 3255  (-17, -0.5%)  (*)

(*) It seems tiny difference. But note that code objects for modules and 
classes will be released after execution. So (d) will have smaller total size 
of remaining co_consts after execution.

---

Another target is SQLAlchemy-1.4.25/lib

main (b34dd58f):
Total: 236 files; 11,802 code objects; 179,284 lines; 372,983 opcodes; 46,091 
total size of co_consts; 7,979 number of co_consts

LOAD_NONE (https://github.com/python/cpython/pull/28376):
Total: 236 files; 11,802 code objects; 179,284 lines; 372,983 opcodes; 43,272 
total size of co_consts; 7,980 number of co_consts

(b) LOAD_NONE + CO_DOCSTRING (b: https://github.com/methane/cpython/pull/36):
Total: 236 files; 11,802 code objects; 179,284 lines; 372,983 opcodes; 39,599 
total size of co_consts; 7,833 number of co_consts

(d) LOAD_NONE + remove docstring from code (d: 
https://github.com/methane/cpython/pull/37):
Total: 236 files; 11,802 code objects; 179,284 lines; 375,396 opcodes; 39,418 
total size of co_consts; 6,526 number of co_consts

number of co_consts:
main -> (b) = 7979 -> 7833 (-146, -1.83%)
(b) -> (d) = 7833 -> 6526   (-1307, -16.7%)

total size of co_consts:
main -> (b) = 46091 -> 39599 (-6492, -14.1%)
(b) -> (d) = 39599 -> 39418  (-141, -0.36%)

---

Conclusion: (b) reduces total size of co_consts significantly, and (d) reduces 
both of total size and number of co_consts significantly.

--

___
Python tracker 

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



[issue36521] Consider removing docstrings from co_consts in code objects

2021-09-30 Thread Mark Shannon


Mark Shannon  added the comment:

I strongly favor (b) over (d).

(d) adds more complexity to MAKE_FUNCTION.

MAKE_FUNCTION represents a measurable fraction of execution time for many 
programs. The more flags and branches it has, the harder it is to optimize.

--

___
Python tracker 

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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Unfortunately, this PR28615 seems to have broken a bunch of buildbots. For 
instance:

https://buildbot.python.org/all/#/builders/75/builds/172/steps/5/logs/stdio

```
test_divide_and_round (test.datetimetester.TestModule_Pure) ... ok
test_divide_and_round (test.datetimetester.TestModule_Fast) ... skipped 'Only 
run for Pure Python implementation'
--
Ran 2 tests in 0.000s
OK (skipped=1)
test_divide_and_round (test.datetimetester.TestModule_Pure) ... ERROR
.test test_datetime failed
test_divide_and_round (test.datetimetester.TestModule_Fast) ... skipped 'Only 
run for Pure Python implementation'
==
ERROR: test_divide_and_round (test.datetimetester.TestModule_Pure)
--
Traceback (most recent call last):
  File 
"/home/dje/cpython-buildarea/3.x.edelsohn-rhel8-z.refleak/build/Lib/test/datetimetester.py",
 line 88, in test_divide_and_round
dar = datetime_module._divide_and_round
  ^
AttributeError: module 'datetime' has no attribute '_divide_and_round'
--
Ran 2 tests in 0.003s
FAILED (errors=1, skipped=1)
1 test failed again:
test_datetime
== Tests result: FAILURE then FAILURE ==
```

--
nosy: +pablogsal

___
Python tracker 

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



[issue41226] Supporting `strides` in `memoryview.cast`

2021-09-30 Thread Vedran Čačić

Vedran Čačić  added the comment:

I surely don't understand what the third argument means. What's (1, 2) there, 
and what stride does it produce?

--
nosy: +veky

___
Python tracker 

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



[issue45323] unexpected behavior on first match case _

2021-09-30 Thread Joël Bourgault

Joël Bourgault  added the comment:

Complement: the Python tutorial presents the "magic _" in the following 
section, close to its end: 
https://docs.python.org/3/tutorial/introduction.html#numbers

> In interactive mode, the last printed expression is assigned to the variable 
> _.

--

___
Python tracker 

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



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset b34dd58fee707b8044beaf878962a6fa12b304dc by Victor Stinner in 
branch 'main':
bpo-41710: Document _PyTime_t API in pytime.h (GH-28647)
https://github.com/python/cpython/commit/b34dd58fee707b8044beaf878962a6fa12b304dc


--

___
Python tracker 

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



[issue45325] Allow "p" in Py_BuildValue

2021-09-30 Thread STINNER Victor


STINNER Victor  added the comment:

> I think that the risk for other formatting parameters is smaller, because you 
> know, that there are different formatting parameters for different integer 
> and floating point types, and for pointers, and you know that you should care 
> about truncation and overflow if the type of the argument is different from 
> the type of the parameter.

IMO such problem can be solved with documentation.

Pablo: can you try to explain the problem in the documentation, and maybe 
provide an example in the doc showing how to avoid it?

I guess that a generic fix is to replace "value" with "value != 0". In C, "expr 
!= 0" is an int, no?

What I understood is that Py_BuildValue("p", value) is problematic if value 
type is not int.

"!value" or "!!value" also has the issue if I understood correctly. Like:

long value = 3; Py_BuildValue("p", !value);

I agree with Serhiy that Py_BuildValue() is ok-ish with other formats, but IMO 
it's the responsibility of the developer to pass the expect type (int for "p" 
format).

This problem is not specific to Py_BuildValue(). printf() also has exactly the 
same issue. Such code has an undefined behavior:

  long long x = 1; print("%d\n", x);

You must cast explicitly:

  long long x = 1; print("%d\n", (int)x);

Or use a different format, like:

  long long x = 1; print("%lld\n", x);

--

___
Python tracker 

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



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +27015
pull_request: https://github.com/python/cpython/pull/28647

___
Python tracker 

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



[issue45309] asyncio task can not be used to open_connection and read data.

2021-09-30 Thread 穆兰

Change by 穆兰 :


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



[issue45309] asyncio task can not be used to open_connection and read data.

2021-09-30 Thread 穆兰

Change by 穆兰 :


--
resolution:  -> not a bug

___
Python tracker 

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



[issue45323] unexpected behavior on first match case _

2021-09-30 Thread Joël Bourgault

Change by Joël Bourgault :


--
assignee:  -> docs@python
components: +Documentation
nosy: +docs@python

___
Python tracker 

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



[issue45323] unexpected behavior on first match case _

2021-09-30 Thread Joël Bourgault

Joël Bourgault  added the comment:

I obtain the reported behaviour using `python -m doctests .md` in 
a Gitlab pipeline, so it is likely that the execution is similar to the Python 
interpreter.

Therefore, I am satisfied by your answer, so I close this 'bug'; thanks a lot!

Now, about the fact that `x` is assigned when matched even if "guarded-out" 
afterwards: this is exposed in the tutorial, so I consider this to be the 
expected behavior; see last sentence of 
https://www.python.org/dev/peps/pep-0636/#adding-conditions-to-patterns.

Note: I discovered the observed behavior while writing a presentation, sourced 
in a markdown file and then rendered as a RevealJS presentation, visible here 
(French): 
https://poles.pages.forge.kaizen-solutions.net/pole-python/pr-sentations/python-structural-pattern-matching.

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



[issue45328] http.client.HTTPConnection doesn't work without TCP_NODELAY

2021-09-30 Thread Rodrigo


Change by Rodrigo :


--
nosy: +rtobar
nosy_count: 1.0 -> 2.0
pull_requests: +27014
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/28646

___
Python tracker 

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



[issue41710] acquire(timeout) of threading.Lock and threading.Condition is affected by jumps in system time: Python should use sem_clockwait(CLOCK_MONOTONIC)

2021-09-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 37b8294d6295ca12553fd7c98778be71d24f4b24 by Victor Stinner in 
branch 'main':
bpo-41710: PyThread_acquire_lock_timed() clamps the timout (GH-28643)
https://github.com/python/cpython/commit/37b8294d6295ca12553fd7c98778be71d24f4b24


--

___
Python tracker 

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



[issue45325] Allow "p" in Py_BuildValue

2021-09-30 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

> But isn't that risk the same for other formatting parameters?

I think that the risk for other formatting parameters is smaller, because you 
know, that there are different formatting parameters for different integer and 
floating point types, and for pointers, and you know that you should care about 
truncation and overflow if the type of the argument is different from the type 
of the parameter.

But I am not in strict opposition against this feature. It is just that I have 
fixed so many bugs, that I try to search potential flaws and drawbacks in any 
new feature. Now you know about this, and you can decide whether the benefit is 
larger than the risk of potential damages. To me they look equally small.

Technically PR 28634 LGTM.

--

___
Python tracker 

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



[issue45328] http.client.HTTPConnection doesn't work without TCP_NODELAY

2021-09-30 Thread R


New submission from R :

I'm working on trying to run python under SerenityOS.

At the moment, SerenityOS doesn't implement the TCP_NODELAY socket option. This 
makes the HTTPConnection.connect() method raise an OSError for an operation 
that is otherwise optional. Additionally, the connection object can be left in 
an intermediate state: the underlying socket is always created, but depending 
on what method was invoked (either connect() directly or a higher-level one 
such as putrequest()) the connection object can be in IDLE or REQ_STARTED state.

I have a patch that works (attached), and I'll be working on submitting a PR 
now.

Usage of TCP_NODELAY was introduced in 3.5 (#23302), so even though I've been 
testing against 3.10rc2 for the time being I'm sure it will affect all versions 
in between.

--
components: Library (Lib)
files: http-client.patch
keywords: patch
messages: 402937
nosy: rtobar2
priority: normal
severity: normal
status: open
title: http.client.HTTPConnection doesn't work without TCP_NODELAY
type: behavior
versions: Python 3.10
Added file: https://bugs.python.org/file50316/http-client.patch

___
Python tracker 

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



[issue40059] Provide a toml module in the standard library

2021-09-30 Thread Chih-Hsuan Yen


Change by Chih-Hsuan Yen :


--
nosy: +yan12125

___
Python tracker 

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



[issue45229] Always use unittest for collecting tests in regrtests

2021-09-30 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
pull_requests: +27013
pull_request: https://github.com/python/cpython/pull/28645

___
Python tracker 

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



[issue45327] Reading from a file is stuck infinitely when the file name is Boolean

2021-09-30 Thread Vinayak Hosamani


Vinayak Hosamani  added the comment:

Thanks for the clarification Eric.

--

___
Python tracker 

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



[issue45327] Reading from a file is stuck infinitely when the file name is Boolean

2021-09-30 Thread Eric V. Smith


Eric V. Smith  added the comment:

The issue is that False is causing a read from stdin, since False == 0.

>>> open(0).readlines()
test
['test\n']

Here I typed "test", followed by Ctrl-D (end of file). readlines() then 
completed and printed its result.

I think the basic answer here is "don't do this". It's not a bug, and is 
documented.

https://docs.python.org/3/library/functions.html#open
says:
file is a path-like object giving the pathname (absolute or relative to the 
current working directory) of the file to be opened or an integer file 
descriptor of the file to be wrapped.

So an integer file descriptor False is causing stdin to be wrapped.

>>> False == 0
True
>>> isinstance(False, int)
True

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



[issue45327] Reading from a file is stuck infinitely when the file name is Boolean

2021-09-30 Thread Eric V. Smith


Change by Eric V. Smith :


--
components: +Interpreter Core -Library (Lib)
title: json loads is stuck infinitely when the file name is Boolean -> Reading 
from a file is stuck infinitely when the file name is Boolean
type:  -> behavior

___
Python tracker 

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



[issue45327] json loads is stuck infinitely when the file name is Boolean

2021-09-30 Thread Eric V. Smith


Eric V. Smith  added the comment:

You can demonstrate this without the json module:

# python2
>>> open(False)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: coercing to Unicode: need string or buffer, bool found

# python3
>>> open(False).readlines()

The python3 version doesn't return.

--
nosy: +eric.smith

___
Python tracker 

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



[issue45327] json loads is stuck infinitely when the file name is Boolean

2021-09-30 Thread Vinayak Hosamani


New submission from Vinayak Hosamani :

Below snippet works fine on Python2

>>> import json
>>> tc_report_file = False
>>> tc_data = json.load(open(tc_report_file))
Traceback (most recent call last):
  File "", line 1, in 
TypeError: coercing to Unicode: need string or buffer, bool found
>>>

as we can see it is throwing an exception

same piece of code is stuck at Python3.8.10

vinayakh@ats-engine:~/stf_files$ python3
Python 3.8.10 (default, Jun  2 2021, 10:49:15)
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import json
>>> tc_report_file = False
>>> tc_data = json.load(open(tc_report_file))

--
components: Library (Lib)
messages: 402933
nosy: vinayakuh
priority: normal
severity: normal
status: open
title: json loads is stuck infinitely when the file name is Boolean
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