[issue44820] subprocess hungs when processing value from mariadb

2021-08-03 Thread jb


New submission from jb :

I am doing an insert in mariadb databases. For example, INSERT INTO t (a, b, c) 
VALUES (1, 3, None) RETURNING a, b. Upon execution, I get the value as (, 
). When accessing the zero element, my subroutine hangs.

--
components: Interpreter Core
messages: 398862
nosy: zh.bolatbek
priority: normal
severity: normal
status: open
title: subprocess hungs when processing  value from mariadb
type: behavior
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



[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-03 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Here's the latest effort:

---

def __get__(self, instance, owner=None):
if instance is None:
return self
if self.attrname is None:
raise TypeError(
"Cannot use cached_property instance without calling 
__set_name__ on it.")
try:
cache = instance.__dict__
except AttributeError:  # not all objects have __dict__ (e.g. class 
defines slots)
msg = (
f"No '__dict__' attribute on {type(instance).__name__!r} "
f"instance to cache {self.attrname!r} property."
)
raise TypeError(msg) from None

# Quickly and atomically determine which thread is reponsible
# for doing the update, so other threads can wait for that
# update to complete.  If the update is already done, don't
# wait.  If the updating thread is reentrant, don't wait.
key = id(self)
this_thread = get_ident()
with self.updater_lock:
val = cache.get(self.attrname, _NOT_FOUND)
if val is not _NOT_FOUND:
return val
wait = self.updater.setdefault(key, this_thread) != this_thread

# ONLY if this instance currently being updated, block and wait
# for the computed result. Other instances won't have to wait.
# If an exception occurred, stop waiting.
if wait:
with self.cv:
while cache.get(self.attrname, _NOT_FOUND) is _NOT_FOUND:
self.cv.wait()
val = cache[self.attrname]
if val is not _EXCEPTION_RAISED:
return val

# Call the underlying function to compute the value.
try:
val = self.func(instance)
except Exception:
val = _EXCEPTION_RAISED

# Attempt to store the value
try:
cache[self.attrname] = val
except TypeError:
# Note: we have no way to communicate this exception to
# threads waiting on the condition variable.  However, the
# inability to store an attribute is a programming problem
# rather than a runtime problem -- this exception would
# likely occur early in testing rather than being runtime
# event triggered by specific data.
msg = (
f"The '__dict__' attribute on {type(instance).__name__!r} 
instance "
f"does not support item assignment for caching 
{self.attrname!r} property."
)
raise TypeError(msg) from None

# Now that the value is stored, threads waiting on the condition
# variable can be awakened and the updater dictionary can be
# cleaned up.
with self.updater_lock:
self.updater.pop(key, None)
cache[self.attrname] = _EXCEPTION_RAISED
self.cv.notify_all()

if val is _EXCEPTION_RAISED:
raise
return val

--

___
Python tracker 

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



[issue44819] assertSequenceEqual does not use _getAssertEqualityFunc

2021-08-03 Thread Jack DeVries


Jack DeVries  added the comment:

Brian, can you be more specific about what problem is caused by the fact that 
assertSequenceEqual does not use _getAssertEqualityFunc? Also, I'm not sure 
what your example is trying to demonstrate. Can you provide a minimal example 
that shows the problem, but also defines what ``MyObject``, etc. are?

Let me know if I'm missing something.

--
nosy: +jack__d

___
Python tracker 

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



[issue44019] operator.call/operator.__call__

2021-08-03 Thread Antony Lee


Antony Lee  added the comment:

Actually, upon further thought, the semantics I suggested above should go into 
`operator.caller` (cf. `operator.methodcaller`), and 
`operator.call`/`operator.__call__` should instead be defined as 
`operator.call(f, *args, **kwargs) == f(*args, **kwargs)`, so that the general 
rule `operator.opname(a, b) == a.__opname__(b)` (modulo dunder lookup rules) 
remains applicable.

--

___
Python tracker 

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



[issue32397] textwrap output may change if you wrap a paragraph twice

2021-08-03 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I've added an initial draft PR: 
https://github.com/python/cpython/pull/27587/files

I will add docs and news if this looks good in general.

--

___
Python tracker 

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



[issue32397] textwrap output may change if you wrap a paragraph twice

2021-08-03 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
pull_requests: +26089
pull_request: https://github.com/python/cpython/pull/27587

___
Python tracker 

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



[issue44772] Regression in memory use of instances due to dictionary ordering

2021-08-03 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

ISTM this was mostly a net win.  We get compactness and sharing most of the 
time, and lose sharing only in cases like this where different instances of the 
same class happen to have different attributes.  Personally, I would not have 
expected sharing to occur in those cases.

--
nosy: +rhettinger

___
Python tracker 

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



[issue43532] Add keyword-only fields to dataclasses

2021-08-03 Thread jack1142


jack1142  added the comment:

Does this change deserve an entry in the What's New in Python document in 
addition to the changelog entry?

--

___
Python tracker 

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



[issue42524] [doc] pdb access to return value

2021-08-03 Thread Irit Katriel


Change by Irit Katriel :


--
Removed message: https://bugs.python.org/msg398854

___
Python tracker 

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



[issue42524] [doc] pdb access to return value

2021-08-03 Thread Irit Katriel


Irit Katriel  added the comment:

I just noticed your PR. Would you like to continue working on this?

I think we should update the documentation of retval (in the doc and in the 
function's doctring) to say:

"""
retval
Print the return value for the last return of a function.  Alternatively, the 
return value can be accessed with ``locals()['__return__']``.
"""

Then add unit tests and examples as you did.

--

___
Python tracker 

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



[issue42524] [doc] pdb access to return value

2021-08-03 Thread Irit Katriel


Irit Katriel  added the comment:

I just noticed your PR. Would you like to continue working on this?

I think we should update the documentation of retval (in the doc and in the 
functions' doctring) to say:

"""
retval
Print the return value for the last return of a function.  Alternatively, the 
return can be accessed with ``locals()['__return__']``.
"""

Then add unit tests and examples as you did.

--
title: pdb access to return value -> [doc] pdb access to return value
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



[issue42524] pdb access to return value

2021-08-03 Thread Irit Katriel


Irit Katriel  added the comment:

It actually is in the locals, and it's called __return__. So you can access it 
with 

locals()['__return__']

I'll try to see where that can be documented.

--
nosy: +iritkatriel

___
Python tracker 

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



[issue20703] RuntimeError caused by lazy imports in pdb

2021-08-03 Thread Irit Katriel


Irit Katriel  added the comment:

Closing as this is not a problem with pdb, it's a general problem with 
iterating sys.modules while doing things that can cause imports.

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



[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread Łukasz Langa

Change by Łukasz Langa :


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



[issue44819] assertSequenceEqual does not use _getAssertEqualityFunc

2021-08-03 Thread Brian


New submission from Brian :

Like the title says, TestCase.assertSequenceEqual does not behave like 
TestCase.assertEqual where it uses TestCase._getAssertEqualityFunc. Instead, 
TestCase.assertSequenceEqual uses `item1 != item2`. That way I can do something 
like this:

```
def test_stuff(self):
   self.addTypeEqualityFunc(
  MyObject,
  comparison_method_which_compares_how_i_want,
   )
   self.assertListEqual(
  get_list_of_objects(),
  [MyObject(...), MyObject(...)],
   )
```

--
components: Tests
messages: 398851
nosy: Rarity
priority: normal
severity: normal
status: open
title: assertSequenceEqual does not use _getAssertEqualityFunc
type: behavior
versions: Python 3.6, Python 3.9

___
Python tracker 

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



[issue44037] Broad performance regression from 3.10a7 to 3.10b2 with python.org macOS binaries

2021-08-03 Thread Ned Deily


Ned Deily  added the comment:

Summary: With the 3.10.0rc1 release, this performance regression in the 
var_access_benchmark starting with the 3.10.0b1 binaries in the python.org 
macOS universal2 installer is now resolved. With the rc1 release, the 
performance of this micro benchmark has actually improved over alpha7 in many 
cases, most notably on Intel Macs.  We have also taken some steps to reduce the 
chances of significant performance regressions in future releases of the macOS 
binaries going undetected prior to release.

Details: All var_access_benchmark results (Appendix A and B) are from running 
macOS Big Sur 11.5.1 (the current release at the moment). The rc1 binaries were 
also built on 11.5.1 using the current Apple (Xcode) Command Line Tools 12.5.1. 
In general, we build the python.org macOS installers on the most current macOS 
and Command Line Tools that have been released by Apple prior to that Python 
release. The a7 and b2 released universal2 binaries were thus made on then 
current versions of macOS Big Sur and the Command Line Tools, each different 
from rc1.

To put these results in context, let me once again note that the primary goal 
of the python.org macOS installers for many years has been to provide a 
convenient way to run Python on macOS on as many different Mac systems as 
possible with one download. For 3.10, the universal2 installer variant we 
provide is designed to run natively on all Macs that can run any version of 
macOS from 10.9 through the current macOS 11 Big Sur (and soon to include macOS 
12 Monterey), both Intel and Apple Silicon (M1) Macs.  To be able to run on 
such a wide variety of systems obviously requires some compromises. Thus 
providing optimum performance in every situation has *never* been a goal for 
these installers.  That doesn't mean we should totally ignore performance 
issues and I am grateful to Raymond for bringing this issue forward.  But, and 
not to belabor the point: for those situations where optimum performance is 
important, there is no substitute to using a Python built and optimized 
explicitly for th
 at environment; in other words, don't look to the python.org binaries for 
those cases.

As an example, with 3.10.0b1, we introduced the first python.org macOS builds 
that use newer compile- and link-time optimizations (--enable-optimizations and 
--with-lto). There were some kinks with that that have been subsequently ironed 
out. But the performance improvements aren't uniform across all systems. It 
appears that Intel Macs see much more of an improvement than Apple Silicon Macs 
do. There are probably a couple of reasons for that: for one, the longer 
experience with the tool chain for Intel archs, but, perhaps more importantly, 
we currently build universal2 binaries on Intel-based Macs which means 
performance-based optimizations by the tool chain are based on the performance 
on an Intel arch which may not be the same as performance on an Apple Silicon 
(arm64) CPU. That's a topic for future investigation but it is an example of 
the potential pitfalls when looking at performance.

Another example is that while there are some significant differences in the 
var_access_benchmark results, which targets specific micro-operations in the 
Python virtual machine, there is a different story looking at the larger-scale 
"realworld" benchmarks in the pyperformance package.  When I first started 
looking at this issue, I ran pyperformance and var_access_benchmark and found 
that, in general, there were *significant* performance improvements in most 
pyperformance benchmarks between 3.10.0a7 and 3.10.0b2 even though the 
var_access_benchmark showed performance regressions.  For 3.10.0rc1, the 
pyperformance results have mostly improved even more.  I have with some 
trepidation included some pyperformance results in Appendix C (3.10.0a7 vs 
3.10.0b2) and Appendix D (3.10.0a7 vs 3.10.0rc1).  Note that these results were 
run on a different, faster Intel Mac than the var_access_benchmark results and 
were run under different updates of macOS 11 so they should be viewed 
cautiously; as al
 ways with performance issues, your mileage may vary.

So by now, one might be curious as to how the performance regression was fixed 
in rc1. The answer at the moment is: I'm not totally sure! There are a *lot* of 
moving parts in making a Python release and the binaries that we provide for 
macOS. While I do try to control the build environments as much as possible 
(for example, by using dedicated virtual machines for builds) and be 
conservative about making changes to the build process and environments, 
especially later in a development/release cycle, as noted above I normally try 
to keep up with the most recent Apple updates to a given macOS version and 
build tools to ensure everyone is getting the benefit of the latest security 
and performance fixes. There have been Apple updates along the way between a7, 
b2, and rc1. So I can't rule those out 

[issue43874] argparse crashes on subparsers with no dest/metava

2021-08-03 Thread Terence Honles


Terence Honles  added the comment:

Closing as a duplicate of https://bugs.python.org/issue29298 (which was 
recently merged and caused conflicts with my patch)

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



[issue44801] Type expression is coerced to a list of parameter arguments in substitution of ParamSpec

2021-08-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


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

___
Python tracker 

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



[issue44756] In ./Doc, "make html" and "make build" should depend on "make venv"

2021-08-03 Thread Jack DeVries


Jack DeVries  added the comment:

Actually, I tested out that idea 
(https://github.com/python/cpython/compare/main...jdevries3133:bpo-44756-doc-make),
 and I don't think its as nice of a solution. I think it is valuable for new 
contributors to be able to type "make html" and have it work. Look at how much 
the change simplifies the README for new contributors to setup their 
documentation build toolchain. Then, look at how many ``docs@python`` open 
issues there are. We need documentation contributors, and there is value in 
simplifying the process for them.

Additionally, this is the extent of the "downloading code from the internet and 
running it" that occurs::

pip install -U pip setuptools
pip install sphynx blurb python-docs-theme

If running that is ever unsafe, we have big problems!

--

___
Python tracker 

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



[issue32397] textwrap output may change if you wrap a paragraph twice

2021-08-03 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Note that I'm not handling a single '\r' because that was before Mac OS X; but 
it is handled by the following line (i.e. by the old logic):

text = text.translate(self.unicode_whitespace_trans)

--

___
Python tracker 

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



[issue32397] textwrap output may change if you wrap a paragraph twice

2021-08-03 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Irit: I assume you mean r' \r?\n', that's a great idea, it's much faster than 
adding a separate replacement step.

Latest version I came up with is this:

if re.search(r' \r?\n', text):
text = re.sub(r' \r?\n', ' ', text)
if re.search(r'\r?\n ', text):
text = re.sub(r'\r?\n ', ' ', text)

This optimizes the case when there's no newlines, which is likely the most 
common case for small fragments of text, but it may be the less common case for 
larger fragments where performance is more important; so I'm not sure if it's 
worth it.

Timings:
# sub() has to run
2904 (~/opensource/cpython) % ./python.exe -mtimeit 'import textwrap' 
'textwrap.wrap("abc foo\n bar baz", 5)'   VICMD
5000 loops, best of 5: 67.6 usec per loop

# search() runs; but sub() does NOT because there's no adjacent space
2906 (~/opensource/cpython) % ./python.exe -mtimeit 'import textwrap' 
'textwrap.wrap("abc foo\nbar baz", 5)'VICMD
5000 loops, best of 5: 60.3 usec per loop

--

___
Python tracker 

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



[issue41886] PyType_Type is documented incorrectly

2021-08-03 Thread Ammar Askar


Ammar Askar  added the comment:

Thank you for spotting this and the patch da-woods!

--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed
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



[issue41886] PyType_Type is documented incorrectly

2021-08-03 Thread miss-islington


miss-islington  added the comment:


New changeset 952aa31c89f70d3c53596449bd2ed9a4817a2364 by Miss Islington (bot) 
in branch '3.10':
bpo-41886: Fix documented type of PyType_Type (GH-22454)
https://github.com/python/cpython/commit/952aa31c89f70d3c53596449bd2ed9a4817a2364


--

___
Python tracker 

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



[issue41886] PyType_Type is documented incorrectly

2021-08-03 Thread miss-islington


miss-islington  added the comment:


New changeset f26fec4f74ae7da972595703bc39d3d30b8cfdf9 by Miss Islington (bot) 
in branch '3.9':
bpo-41886: Fix documented type of PyType_Type (GH-22454)
https://github.com/python/cpython/commit/f26fec4f74ae7da972595703bc39d3d30b8cfdf9


--

___
Python tracker 

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



[issue44801] Type expression is coerced to a list of parameter arguments in substitution of ParamSpec

2021-08-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Thank you Ken Jin. So the problem is the __args__ (x, str) is interpreted 
differently depending on x, and after substituting x the interpretation can be 
changed. If x was ParamSpec, it was interpreted in one way, but if it becomes 
int, it is now interpreted in other way.

The solution is to forbid substitution of P with wrong values (not parameters 
expression). Some normalization is also needed, before and after substitution.

Other related example is:

>>> from typing import *
>>> P = ParamSpec("P")
>>> class Z(Generic[P]): pass
... 
>>> A = Z[[int]]
>>> B = Z[int]
>>> A
__main__.Z[(,)]
>>> B
__main__.Z[int]
>>> A.__args__
((,),)
>>> B.__args__
(,)

It is expected that A and B should the same.

--

___
Python tracker 

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



[issue41886] PyType_Type is documented incorrectly

2021-08-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26087
pull_request: https://github.com/python/cpython/pull/27584

___
Python tracker 

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



[issue41886] PyType_Type is documented incorrectly

2021-08-03 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue41886] PyType_Type is documented incorrectly

2021-08-03 Thread Ammar Askar


Ammar Askar  added the comment:


New changeset ac811f9b5a68ce8756911ef2c8be83b46696018f by da-woods in branch 
'main':
bpo-41886: Fix documented type of PyType_Type (GH-22454)
https://github.com/python/cpython/commit/ac811f9b5a68ce8756911ef2c8be83b46696018f


--
nosy: +ammar2

___
Python tracker 

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



[issue41886] PyType_Type is documented incorrectly

2021-08-03 Thread Ammar Askar


Change by Ammar Askar :


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

___
Python tracker 

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



[issue44756] In ./Doc, "make html" and "make build" should depend on "make venv"

2021-08-03 Thread Jack DeVries


Jack DeVries  added the comment:

@petr.viktorin a whatsnew entry was added, what more notice could have been 
provided?

I have an idea for an alternative that might be better. What if ``make clean`` 
deletes and restores the venv only if it already existed in the first place?

--

___
Python tracker 

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



[issue32397] textwrap output may change if you wrap a paragraph twice

2021-08-03 Thread Irit Katriel


Irit Katriel  added the comment:

You should be able to do them in one re, something like 

text = re.sub(r' ?\n', ' ', text)

--
nosy: +iritkatriel

___
Python tracker 

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



[issue44816] PEP 626 does not explain the handling of constants, at all.

2021-08-03 Thread Brandt Bucher


Brandt Bucher  added the comment:

Thanks for clarifying.

I'm worried, though, that the PEP's emphasis on "*all* lines of code executed 
and *only* for lines of code that are executed" could be problematic for other 
optimizations we perform. Consider:

if (  # <--
True  # <--
):
pass  # <--

I understand why lines 1 and 4 are covered, since PEP 626 defines "if" and 
"pass" keywords as executable code. But line 2 isn't executed at runtime (it's 
peepholed into a NOP)... is it a bug that it creates a line event?

--

___
Python tracker 

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



[issue43468] functools.cached_property incorrectly locks the entire descriptor on class instead of per-instance locking

2021-08-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

> It should use "(id(instance), instance)" rather than just "instance" as the 
> key.

It should use a dict with id(instance) as a key and instance as value. An 
instance can be non-hashable.

--

___
Python tracker 

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



[issue32397] textwrap output may change if you wrap a paragraph twice

2021-08-03 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

I think fix to make `drop_whitespace=False` stable, can be as simple as adding 
two lines in `_munge_whitespace()`:

+text = re.sub(r' \n', ' ', text)
+text = re.sub(r'\n ', ' ', text)
 text = text.translate(self.unicode_whitespace_trans)

The perf impact is not small though, 12% :

2892 (~/opensource/cpython) % ./python.exe -mtimeit 'import textwrap' 
'textwrap.wrap("abc foo\nbar baz", 5)'  --INS--
5000 loops, best of 5: 60.2 usec per loop

2893 (~/opensource/cpython) % r 
  --INS--
./python.exe -mtimeit 'import textwrap' 'textwrap.wrap("abc foo\nbar baz", 5)'
5000 loops, best of 5: 52.9 usec per loop


I don't know if it's worth doing, but if yes, the options are:

 - just add this change for drop_whitespace=False, which is not the default, so 
perf regression will not affect default usage of wrap.

 - add a new arg that will only have effect when drop_whitespace=False, and 
will run these 2 lines. Name could be something like `collapse_space_newline`. 
It's hard to think of a good name.

If '\r\n' is handled, it needs one additional `sub()` line, and the perf. 
difference is 22%.

--

___
Python tracker 

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



[issue44817] os.path.realpath fails with WinError 161

2021-08-03 Thread Eryk Sun


Eryk Sun  added the comment:

It should also ignore ERROR_BAD_NETPATH (53).

--
nosy: +eryksun

___
Python tracker 

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



[issue44301] Is there a way to provide destructor for module written using C API?

2021-08-03 Thread Petr Viktorin


Change by Petr Viktorin :


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

___
Python tracker 

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



[issue44818] '\t' (tab) support

2021-08-03 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
status: open -> pending

___
Python tracker 

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



[issue44816] PEP 626 does not explain the handling of constants, at all.

2021-08-03 Thread Mark Shannon


Mark Shannon  added the comment:

This isn't a bug. Although PEP 626 is not at all clear about this.

The key word in the PEP is "executed".
Because compound and multi-line constants are constants, the parts of them are 
not "executed", but computed at compile time.

Having re-read the PEP, this is as clear as mud :(

I'll add a section to the PEP clarifying this.

--
assignee:  -> Mark.Shannon
title: Folded constants do not trace correctly. -> PEP 626 does not explain the 
handling of constants, at all.

___
Python tracker 

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



[issue20703] RuntimeError caused by lazy imports in pdb

2021-08-03 Thread Irit Katriel


Irit Katriel  added the comment:

Can we make sys.modules automatically return an iterator that has a copy of its 
contents?  Otherwise it's an odd API - it's iterable but we tell people not to 
iterate it.

--

___
Python tracker 

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



[issue20703] RuntimeError caused by lazy imports in pdb

2021-08-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

My concern about importing readline at the top of the module is that importing 
readline has a side effect. The only module which imports it unconditionally at 
the top is rlcompleter. In all other places it is imported lazily.

And importing readline ahead may not fix the original issue, because there are 
other modules lazily imported in pdb: runpy, shlex, pydoc.

Perhaps we should just say that sys.modules should not be iterated directly, 
you should first make a copy. There are other issues about RuntimeError raised 
during iterating sys.modules.

--

___
Python tracker 

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



[issue34782] Pdb raises exception when code is executed in a mapping that does not define `__contains__`

2021-08-03 Thread Irit Katriel


Irit Katriel  added the comment:

I think we should close this. It's not a problem you will come across if you're 
not looking for trouble, so there's no point trying to make the error message a 
little nicer.

--
resolution:  -> not a bug
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



[issue44817] os.path.realpath fails with WinError 161

2021-08-03 Thread Eryk Sun


Change by Eryk Sun :


--
components: +Windows
nosy: +paul.moore, steve.dower, tim.golden, zach.ware
type:  -> behavior
versions: +Python 3.10, Python 3.11, Python 3.9 -Python 3.8

___
Python tracker 

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



[issue34782] Pdb raises exception when code is executed in a mapping that does not define `__contains__`

2021-08-03 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

You cannot expect that running code under debugger does not have any effect. 
Otherwise there would not be any meaning in debugger. Running code under 
debugger has some side effects, and setting locals __return__ and __exception__ 
is one of them. If it exposes bugs in user code -- well, it is a purpose of 
debugger.

I think that there are two options for this issue.

1. Add a type check for locals in the frame constructor (and maybe at higher 
levels).

2. Close it as "not a bug". Using functions outside of documented scope has 
undefined behavior. Python usually does not check types of arguments. If it 
works -- it works, if not -- blame on you.

--

___
Python tracker 

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



[issue30256] Adding a SyncManager Queue proxy to a SyncManager dict or Namespace proxy raises an exception

2021-08-03 Thread Ken Jin


Ken Jin  added the comment:

> Just chiming in to say that this is still broken for me on Python 3.9.6

>From what I understand, the patch landed on 2021-07-02, 4 days after Python 
>3.9.6's release date of 2021-06-28, so it wasn't included.

It should come in 3.9.7, which should be out on 2021-08-30 according to PEP 596.

--

___
Python tracker 

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



[issue30256] Adding a SyncManager Queue proxy to a SyncManager dict or Namespace proxy raises an exception

2021-08-03 Thread Stephen Carboni


Stephen Carboni  added the comment:

Just chiming in to say that this is still broken for me on Python 3.9.6, 
Win10/64: https://pastebin.com/64F2iKaj

But, works for 3.10.0b4.

--
nosy: +stephen.entropy

___
Python tracker 

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



[issue44756] In ./Doc, "make html" and "make build" should depend on "make venv"

2021-08-03 Thread Petr Viktorin


Petr Viktorin  added the comment:

I'm one of those who disagree with "make html" suddenly downloading code from 
the internet and running it, but I guess I'm in a minority. I'll switch to 
using `sphinx-build` directly.

Still, I'd have appreciated a heads-up notice.

--
nosy: +petr.viktorin

___
Python tracker 

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



[issue44301] Is there a way to provide destructor for module written using C API?

2021-08-03 Thread Petr Viktorin


Petr Viktorin  added the comment:

You are missing m_free.
The clear function is used to break reference counts. In this case, there are 
no reference counts to be broken, so it is not called.

Your custom_clear function is idempotent, so you can use it in both free and 
clear and let Python call it either once or twice:
.m_clear = custom_clear,
.m_free = custom_clear,

I agree that this is not at all clear from the documentation. I'm going to 
spend some time organizing the info around the GC API and writing it up.

--
nosy: +petr.viktorin

___
Python tracker 

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



[issue44808] test_inspect fails in refleak mode

2021-08-03 Thread miss-islington


miss-islington  added the comment:


New changeset bc2841c7a9fe2b05ef77ebdf77701188dc83b2ce by Miss Islington (bot) 
in branch '3.10':
bpo-44808: fixes test for interactive inspect getsource of a class (GH-27571)
https://github.com/python/cpython/commit/bc2841c7a9fe2b05ef77ebdf77701188dc83b2ce


--

___
Python tracker 

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



[issue44808] test_inspect fails in refleak mode

2021-08-03 Thread Łukasz Langa

Change by Łukasz Langa :


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



[issue44808] test_inspect fails in refleak mode

2021-08-03 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 58325971de0faf330c9c38269dae8315a0746e59 by andrei kulakov in 
branch 'main':
bpo-44808: fixes test for interactive inspect getsource of a class (GH-27571)
https://github.com/python/cpython/commit/58325971de0faf330c9c38269dae8315a0746e59


--

___
Python tracker 

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



[issue44808] test_inspect fails in refleak mode

2021-08-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26084
pull_request: https://github.com/python/cpython/pull/27578

___
Python tracker 

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



[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread miss-islington


miss-islington  added the comment:


New changeset 84494db41902774ea6ac72e5b308b429850bbf71 by Miss Islington (bot) 
in branch '3.10':
bpo-41737: expand doc for NotADirectoryError (GH-27471)
https://github.com/python/cpython/commit/84494db41902774ea6ac72e5b308b429850bbf71


--

___
Python tracker 

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



[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset b5f026112768eb0a06622263bdea86d7d85981c5 by Miss Islington (bot) 
in branch '3.9':
bpo-41737: expand doc for NotADirectoryError (GH-27471) (GH-27577)
https://github.com/python/cpython/commit/b5f026112768eb0a06622263bdea86d7d85981c5


--

___
Python tracker 

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



[issue18255] CPython setup.py problems

2021-08-03 Thread Ronald Oussoren


Ronald Oussoren  added the comment:

This is no longer relevant now that distutils is deprecated.

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



[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread miss-islington


Change by miss-islington :


--
nosy: +miss-islington
nosy_count: 5.0 -> 6.0
pull_requests: +26082
pull_request: https://github.com/python/cpython/pull/27576

___
Python tracker 

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



[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset f7c23a99cd4f8179b6ba2cffaeb78b852c0f6488 by andrei kulakov in 
branch 'main':
bpo-41737: expand doc for NotADirectoryError (GH-27471)
https://github.com/python/cpython/commit/f7c23a99cd4f8179b6ba2cffaeb78b852c0f6488


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue41737] Improper NotADirectoryError when opening a file in a fake directory

2021-08-03 Thread miss-islington


Change by miss-islington :


--
pull_requests: +26083
pull_request: https://github.com/python/cpython/pull/27577

___
Python tracker 

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



[issue27275] KeyError thrown by optimised collections.OrderedDict.popitem()

2021-08-03 Thread Łukasz Langa

Change by Łukasz Langa :


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



[issue27275] KeyError thrown by optimised collections.OrderedDict.popitem()

2021-08-03 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 8c9f847997196aa76500d1ae104cbe7fe2a467ed by Serhiy Storchaka in 
branch 'main':
bpo-27275: Change popitem() and pop() methods of collections.OrderedDict 
(GH-27530)
https://github.com/python/cpython/commit/8c9f847997196aa76500d1ae104cbe7fe2a467ed


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue39091] _PyErr_CreateException() must check that the result is an exception (CPython Segfault in 5 lines of code)

2021-08-03 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 0b551db04a99a97abb1e44a071c688c3ca704b67 by Miss Islington (bot) 
in branch '3.9':
bpo-39091: Fix segfault when Exception constructor returns non-exception for 
gen.throw. (GH-17658) (GH-27573)
https://github.com/python/cpython/commit/0b551db04a99a97abb1e44a071c688c3ca704b67


--

___
Python tracker 

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



[issue39091] _PyErr_CreateException() must check that the result is an exception (CPython Segfault in 5 lines of code)

2021-08-03 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 8ce7f2f4ef04e19209f1dfd2a0cf50ddcd0e999f by Miss Islington (bot) 
in branch '3.10':
bpo-39091: Fix segfault when Exception constructor returns non-exception for 
gen.throw. (GH-17658) (GH-27572)
https://github.com/python/cpython/commit/8ce7f2f4ef04e19209f1dfd2a0cf50ddcd0e999f


--
nosy: +lukasz.langa

___
Python tracker 

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



[issue44818] '\t' (tab) support

2021-08-03 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

I don't understand what you mean by "Python can't use '\t' character." Can you 
demonstrate an example? It works for me.

--
nosy: +steven.daprano

___
Python tracker 

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



[issue44818] '\t' (tab) support

2021-08-03 Thread Pooia


New submission from Pooia :

Python can't use '\t' character. if I want fix it I will work a long time but a 
shorter fashion is replacing '\t' character with 4 space (by first clause of 
pep: 8)

--
components: Parser
messages: 398815
nosy: Pooia, lys.nikolaou, pablogsal
priority: normal
severity: normal
status: open
title: '\t' (tab) support
type: behavior
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