[issue41850] inspect.py: access block stack

2021-12-28 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

With the advent of zero-cost exception handling in Python 3.10, there is no 
block stack, neither for exceptions nor for loops. These were always regarded 
as an implementation detail of the compiler. If you have any new ideas for a 
feature like this, I would suggest sending them to the Python-Ideas mailing 
list, but I'm closing this for now.

--
resolution:  -> out of date
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



[issue46190] Omit k in random.sample()

2021-12-28 Thread Tilman Krummeck


Tilman Krummeck  added the comment:

Well, it's not bizarre, it's a use-case I'm facing quite often.

But thanks for the clarification, I haven't had very large populations in mind 
- this makes indeed sense.

--

___
Python tracker 

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



[issue46190] Omit k in random.sample()

2021-12-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> My suggestion is not to set k=1 when omitted but to assign it a random value 

Sorry, I think that is just bizarre.  Also, some populations are *very* large, 
so a minor user accident of omitting a parameter would result in a large 
unexpected output.  For choices(), it would have been nice to have k default 
the population size (because resampling is a common use case) but we didn't go 
that path because of the likelihood of a large unexpected output.  The same 
reasoning holds here a well.

If you want to go down this path, I recommend making your code explicit about 
what it is trying to do.  Something this unexpected should not be the implicit 
and default behavior.

--

___
Python tracker 

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



[issue46190] Omit k in random.sample()

2021-12-28 Thread Tilman Krummeck


Tilman Krummeck  added the comment:

My suggestion is not to set k=1 when omitted but to assign it a random value 
that is something between 0 and the maximum possible value which is:

sum(counts) if counts else len(population)

--

___
Python tracker 

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



[issue45508] Specialize INPLACE_ADD

2021-12-28 Thread Dennis Sweeney


Change by Dennis Sweeney :


--
resolution:  -> out of date
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



[issue46190] Omit k in random.sample()

2021-12-28 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

For completeness:

def random_subset_with_counts(sequence, counts):
result = []
for x, k in zip(sequence, counts):
result.extend([x] * random.getrandbits(k).bit_count())
return result

--

___
Python tracker 

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



[issue46190] Omit k in random.sample()

2021-12-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Okay. Thank for the quick response and the suggestion.  I'm going to mark this 
one as closed.  AFAICT, it distracts users from better solutions.  

I did a quick code search for sample().  The k==1 case is rare and in most 
cases the code should have used choice() or choices() instead.  Accordingly, it 
doesn't make sense to make k==1 the default.  

Also, I suspect (but don't no for sure) that most users benefit by having the 
error message when k is omitted.  That is more likely a user mistake than a 
correct design choice.

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

___
Python tracker 

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



[issue46190] Omit k in random.sample()

2021-12-28 Thread Tilman Krummeck


Tilman Krummeck  added the comment:

I use this mostly in tests to randomize my inputs. So currently I'm doing 
something like this:

result = random.sample(items, random.randint(0, len(items)))

I guess if someone would omit 'k' he wouldn't care about the result (which is 
probably a use-case when using random functions). This would mostly be a 
convenience improvement for lazy guys like myself.

--

___
Python tracker 

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



[issue46190] Omit k in random.sample()

2021-12-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

If all you want is a sample where k==1, then use choice().  That is clearer and 
more efficient.  

The sample() function is for sampling without replacement which only makes 
sense when k > 1; otherwise, choice() or choices() is usually what you want.

--
assignee:  -> rhettinger

___
Python tracker 

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



[issue46190] Omit k in random.sample()

2021-12-28 Thread Dennis Sweeney


Dennis Sweeney  added the comment:

Can you describe more about your use-case for this?

You can already do something like this now with something like the following:

def random_subset(sequence):
source = random.randbytes(len(sequence))
return [x for x, r in zip(sequence, source) if r & 1]

You could add a random.shuffle() call at the end if your application needs it.

For the case with counts, you could do getrandbits(i).bit_count() to get a 
binomial distribution to choose how many of each element to include.

--
components: +Library (Lib) -Extension Modules
nosy: +Dennis Sweeney, rhettinger
versions: +Python 3.11

___
Python tracker 

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



[issue43118] inspect.signature() raises RuntimeError on failed to resolve the default argument value

2021-12-28 Thread hongweipeng


Change by hongweipeng :


--
nosy: +hongweipeng
nosy_count: 1.0 -> 2.0
pull_requests: +28499
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30285

___
Python tracker 

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



[issue46190] Omit k in random.sample()

2021-12-28 Thread Tilman Krummeck


New submission from Tilman Krummeck :

random.sample can be used to choose k items from a given sequence. Currently, k 
is a mandatory parameter. 

I suggest to make k optional and instead, if omitted, pick a random value from 
the range of 0 and the length of the sequence.

Of course, doing this must also consider any possible value of 'count'

--
components: Extension Modules
messages: 409283
nosy: TilmanKrummeck
priority: normal
severity: normal
status: open
title: Omit k in random.sample()
type: enhancement

___
Python tracker 

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



[issue46171] venv module produces spurious warning that location has moved

2021-12-28 Thread Eryk Sun


Eryk Sun  added the comment:

> There are plenty of other ways to get a venv through a potentially 
> unexpected path (turns out I've been doing one for years)

Examples would be appreciated because I'm drawing a blank here. A junction or 
directory symlink in the parent path shouldn't be a problem. Otherwise I'd 
prefer that the solution for bpo-45337 was limited to an app container and 
paths in "%USERPROFILE%\AppData" (excluding "%TEMP%"). An app container can be 
detected via the package family name, if any, as returned by 
GetCurrentPackageFamilyName().

--

___
Python tracker 

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



[issue46187] Optionally support rounding for math.isqrt()

2021-12-28 Thread Tim Peters


Tim Peters  added the comment:

FYI, I had a simpler derivation in mind. Say

sqrt(n) = r + f

where r = isqrt(n) and 0 <= f < 1. Then

sqrt(4n) = 2 * sqrt(n) = 2*(r + f) = 2r + 2f, with 0 <= 2f < 2.

If f < 0.5, 2f < 1, so isqrt(4n) = 2r, and we shouldn't round r up either.

If f > 0.5, 2f > 1, so sqrt(4n) = 2r + 1 + (2f - 1), with 0 <= 2f - 1 < 1, so 
isqrt(4n) = 2*r + 1. In this case (f > 0.5) we need to round r up.

f = 0.5 can't happen.

Regardless, I don't believe I would have thought of this myself! It was an 
unexpected delight :-

--

___
Python tracker 

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



[issue41585] policy.max_line_length is incorrectly assumed to never be None

2021-12-28 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

Seems to be a duplicate of #34800

--
nosy: +andrei.avk

___
Python tracker 

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



[issue46187] Optionally support rounding for math.isqrt()

2021-12-28 Thread Tim Peters


Tim Peters  added the comment:

>> can we use the decimal module's names for the supported
>> rounding modes?

> I'm not sure those make sense because we never get to
> exactly half.  There is only floor, ceil, and round,
> not half_up, half_even, etc.

So use decimal's ROUND_CEILING, ROUND_FLOOR, and ROUND_HALF_EVEN. It's 
irrelevant that the halfway case can't occur: it's still following the 
ROUND_HALF_EVEN rules, it's just that one of those rules never happens to apply 
in this context. So what? Your _intent_ is to supply "best possible rounding", 
and that's what ROUND_HALF_EVEN means. It's not doing any favors to make up a 
new name for a rounding mode that only applies to values that can never tie. 
Tail. dog, wag ;-) If someone knows what half/even does, they already know what 
_this_ rounding mode does. Why complicate it with a useless distinction?

--

___
Python tracker 

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



[issue46187] Optionally support rounding for math.isqrt()

2021-12-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

> Sweet! New one on me 

Tim already knows this but for the record the derivation is isn't tricky.

With y=isqrt(x), then next root is at y+1 and the half way point is y+1/2 which 
isn't an integer.  The corresponding squares are y**2, (y+1/2)**2, and 
(y+1)**2.  With a multiple of four, those become 4*y**2, 4*(y+1/2)**2, and 
4*y+1)**2 which are equivalent to the squares of consecutive integers: (2y)**2, 
(2y+1)**2, and (2y+2)**2.  Adding one gives the roots 2y+1, 2y+2, and 2y+3.  
The floor division eliminates the constant term giving the desired roots y, 
y+1, and y+1.

> can we use the decimal module's names for the supported rounding modes?

I'm not sure those make sense because we never get to exactly half.  There is 
only floor, ceil, and round, not half_up, half_even, etc.

--

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

Also, it would help Serhiy's divide and conquer algorithm if the fast cases 
included the sides of Pascal's triangle rather than just the top:

   if n < TableSize and k < limits[n]:
   return comb_small(n, k)
   return comb_slow(n, k)

Build the table like this:

TableSize = 101
limits = bytearray(TableSize)
for n in range(0, TableSize):
for k in range(0, n+1):
if comb(n, k) != comb_small(n, k):
break
else:
k += 1
limits[n] = k

--

___
Python tracker 

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



[issue34498] Python 3.7+ break on singledispatch_function.register(pseudo_type), which Python 3.6 accepted

2021-12-28 Thread Alex Waygood


Alex Waygood  added the comment:

Guido: Serhiy fixed this very recently in Issue46032.

The documentation should probably be improved, however, in my opinion; there's 
currently nothing officially stating that GenericAlias/NewType/typing aliases 
are unsupported.

Support for singledispatch.register(union_type) was also recently added in 
Issue46014, but has yet to be documented.

--

___
Python tracker 

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



[issue34498] Python 3.7+ break on singledispatch_function.register(pseudo_type), which Python 3.6 accepted

2021-12-28 Thread Guido van Rossum


Guido van Rossum  added the comment:

There's no point in lamenting the compatibility with Python 3.6, it's water 
under the bridge. Dispatching on types like list[int] or types generated by 
NewType is not realistic. Maybe the only thing left to do is to raise an error 
on registration when the type is e.g. list[int]? Currently that passes, but 
then attempting to dispatch on *anything* fails with TypeError: issubclass() 
argument 2 cannot be a parameterized generic

--
nosy: +gvanrossum, serhiy.storchaka

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-28 Thread Tim Peters


Tim Peters  added the comment:

A timing confounder: I see that CPython's _Py_popcount32() only tries to use 
the relevant blazing fast hardware instruction if defined(__clang__) || 
defined(__GNUC__). On Windows, it's a long-winded bit-fiddling dance.

So which of xor-popcount and add-up-up-trailing-zero-counts is faster may well 
depend on platform.

--

___
Python tracker 

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



[issue46124] Deprecation warning in zoneinfo module

2021-12-28 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

Normalize_path from legacy implementation: 
https://github.com/python/importlib_resources/blob/3beb2fd5831e65f7b45033e1ec276c4a6b4ca973/importlib_resources/_legacy.py#L30-L40

--

___
Python tracker 

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



[issue46124] Deprecation warning in zoneinfo module

2021-12-28 Thread Jason R. Coombs


Jason R. Coombs  added the comment:

> Does `joinpath` have less validation?

Yes. Previously, resources.* would perform some validation on the path to 
ensure that it didn't contain path separators (to avoid users attempting to get 
resources in subdirectories or perhaps manipulating the path in other ways).

So no, they're not equivalent. If `resource_name` or "zones" ever contained 
path separators, the former implementation would raise an error whereas this 
implementation would attempt to join those characters to the path. Since 
"zones" is a static string, it's clearly not affected. And `resource_name` 
can't have posixpath.sep. If `key` had an ntpath.sep, that might behave 
differently, but that seemed like an edge case not worth exploring.

If it is worth exploring, I would recommend not to use normalize_path, but 
instead to implement the validation in zoneinfo._common. That is, wrap key in 
`_validate_key()` that protects against invalid paths. But in practice, it's 
better to do that closer to where the unsanitized data would be encountered (if 
at all).

--

___
Python tracker 

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



[issue46189] Text containing "wide" character not correctly refreshed

2021-12-28 Thread E. Paine

E. Paine  added the comment:

I have been able to reproduce this in Wish built from the current head. 
Interestingly, the cut-off seems to be 1px off what `font measure` gives (see 
attached). Though in this behaviour is a problem, the man page does note the 
following:
> The return value is the total width in pixels of text, not including the 
> extra pixels used by highly exaggerated characters such as cursive “f” 
> [https://www.tcl.tk/man/tcl/TkCmd/font.html#M10]

Tkinter is simply a thin wrapper of Tk, so I suggest you take it up with that 
team so they can fix it upstream (a minimal equivalent of your code in Tcl can 
be found below): https://core.tcl-lang.org/tk/reportlist

pack [canvas .c -width 250 -height 500]
font create .f -family "Times New Roman" -size -500
set t [.c create text 0 250 -text f -font .f -anchor w]
update ; # A window render is required for the bug to occur
.c itemconfigure $t -fill red
set x [font measure .f f]
.c create line $x 0 $x 500

--
nosy: +epaine, serhiy.storchaka
Added file: https://bugs.python.org/file50525/Screenshot 2021-12-28 201447.png

___
Python tracker 

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



[issue38522] Py_USING_MEMORY_DEBUGGER is referenced in docs but not present in code

2021-12-28 Thread Carlos Damázio

Change by Carlos Damázio :


--
keywords: +patch
nosy: +dmzz
nosy_count: 3.0 -> 4.0
pull_requests: +28498
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/30284

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-28 Thread Tim Peters


Tim Peters  added the comment:

Raymond, using the count of trailing zeroes instead is exactly what I suggested 
before, here:

https://bugs.python.org/issue37295#msg409000

So Mark & I already batted that around. For whatever reasons he had, though, he 
stuck with the xor-popcount approach. Presumably he found that was faster than 
looking up trailing zero counts.

--

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

The shift table is an array of uint8_t, so it would be tiny (nearly fitting in 
one cache line).

--

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-28 Thread Raymond Hettinger


Raymond Hettinger  added the comment:

It's a little late, but I had a thought that code could be made more general, 
slightly faster, and much easier to understand if the popcount logic were to be 
replaced with a table that records how many bits of the factorial were shifted 
out to make it odd.

from math import comb, perm, factorial as fact

Modulus = 2 ** 64
Cmax = 67
Pmax = 25
Fmax = Pmax

F = []  # odd factorial
S = []  # shift back to factorial
Finv = []   # multiplicative inverse of odd fact
for n in range(Cmax+1):
f = fact(n)
s = (f & -f).bit_length() - 1
odd_f = (f >> s) % Modulus
inv_f = pow(odd_f, -1, Modulus)
assert odd_f * inv_f % Modulus == 1
assert (odd_f << s) % Modulus == f % Modulus
F.append(odd_f)
S.append(s)
Finv.append(inv_f)

def fact_small(n):
return F[n] << S[n]

def perm_small(n, k):
return (F[n] * Finv[n-k] % Modulus) << (S[n] - S[n-k])

def comb_small(n, k):
return (F[n] * Finv[k] * Finv[n-k] % Modulus) << (S[n] - S[k] - S[n-k])

assert all(fact_small(n) == fact(n) for n in range(Fmax+1))
assert all(perm_small(n, k) == perm(n, k) for n in range(Pmax+1) for k in 
range(0, n+1))
assert all(comb_small(n, k) == comb(n, k) for n in range(Cmax+1) for k in 
range(0, n+1))

--

___
Python tracker 

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



[issue2756] urllib.request.add_header fails with existing unredirected_header

2021-12-28 Thread Carlos Damazio


Carlos Damazio  added the comment:

And here's the code to reproduce the bug in 3.10.

--
Added file: https://bugs.python.org/file50524/bug310.py

___
Python tracker 

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



[issue2756] urllib.request.add_header fails with existing unredirected_header

2021-12-28 Thread Carlos Damazio


Carlos Damazio  added the comment:

This is the server for testing in 3.10.

--
nosy: +carlosdamazio
Added file: https://bugs.python.org/file50523/server310.py

___
Python tracker 

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



[issue21987] TarFile.getmember on directory requires trailing slash iff over 100 chars

2021-12-28 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Well, the tar command strips trailing slashes (even from file paths), so it is 
reasonable to do this in getmember().

$ mkdir dir
$ touch dir/file
$ tar cf archive.tar dir
$ tar tf archive.tar dir
dir/
dir/file
$ tar tf archive.tar dir/
dir/
dir/file
$ tar tf archive.tar dir/file
dir/file
$ tar tf archive.tar dir/file/
dir/file
$ tar tf archive.tar dir/file
dir/file

--

___
Python tracker 

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



[issue46187] Optionally support rounding for math.isqrt()

2021-12-28 Thread Tim Peters


Tim Peters  added the comment:

[Mark]
> def risqrt(n):
>return (isqrt(n<<2) + 1) >> 1

Sweet! New one on me - did you invent this? It's slick :-)

I'd be happy to see recipes added to the docs for rounded and ceiling flavors 
of isqrt, but am dubious about the value of building them in.

If they are added via an optional rounding argument, can we use the decimal 
module's names for the supported rounding modes?

--

___
Python tracker 

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



[issue46175] Zero argument super() does not function properly inside generator expressions

2021-12-28 Thread Carlos Damazio


Carlos Damazio  added the comment:

Josh: My mistake, I've seen a similar issue, then. And agreed, I think #2 is a 
great candidate since we don't need to re-design existing structures. I don't 
know a better option... yet.

--

___
Python tracker 

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



[issue46090] C extensions can't swap out live frames anymore

2021-12-28 Thread Brandt Bucher


Brandt Bucher  added the comment:


New changeset 77195cd44b2506cda88a3cfc98918526068b1d46 by Brandt Bucher in 
branch 'main':
bpo-46090: Allow PyThreadState.datastack_* members to be NULL (GH-30234)
https://github.com/python/cpython/commit/77195cd44b2506cda88a3cfc98918526068b1d46


--

___
Python tracker 

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



[issue46090] C extensions can't swap out live frames anymore

2021-12-28 Thread Brandt Bucher


Change by Brandt Bucher :


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



[issue42259] pprint: infinite recursion for saferepr() when using nested objects, but str() works

2021-12-28 Thread Irit Katriel


Change by Irit Katriel :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue21987] TarFile.getmember on directory requires trailing slash iff over 100 chars

2021-12-28 Thread Andrei Kulakov


Andrei Kulakov  added the comment:

The original issue was twofold:
1. below 100 char not working with trailing slash
2. over 100 char not working WITHOUT trailing slash

The second part is no longer an issue -- tested in 3.9 and 3.11 on MacOS.

Currently the issue is that a trailing slash now doesn't work for lookup of 
dirs, no matter the size of name.

This is inconsistent with the way shell commands work as well as various Python 
path related modules that tolerate trailing slash for dirs.

This can cause users to wrongly assume a dir is absent in a tarfile, so I think 
it's worth fixing and I've added a PR with a test for both old and new issue.

--

___
Python tracker 

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



[issue21987] TarFile.getmember on directory requires trailing slash iff over 100 chars

2021-12-28 Thread Andrei Kulakov


Change by Andrei Kulakov :


--
nosy: +andrei.avk
nosy_count: 8.0 -> 9.0
pull_requests: +28497
pull_request: https://github.com/python/cpython/pull/30283

___
Python tracker 

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



[issue46124] Deprecation warning in zoneinfo module

2021-12-28 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

I just copied the implementation and normalize_path function was part of it. 
Looking into the implementation of normalize_path it validates the given 
argument to be a filename without any separator. I will leave it to Jason for a 
better understanding of the API and compatibility here.

--

___
Python tracker 

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



[issue46124] Deprecation warning in zoneinfo module

2021-12-28 Thread Paul Ganssle


Paul Ganssle  added the comment:

Jason's patch looks good to me, but I don't understand why Karthikeyan 
originally suggested using `normalize_path`. Trying to dig through exactly how 
`files().joinpath().open` is implemented has so many layers of indirection and 
abstract classes that I can't quite figure out if the two things are equivalent 
or not. Seems like `joinpath()` is the right thing to do, but does it have less 
validation than the `normalize_path` method?

--

___
Python tracker 

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



[issue46189] Text containing "wide" character not correctly refreshed

2021-12-28 Thread hejin517


New submission from hejin517 :

When the app runs it first shows a black character "f" in Times New Roman.
By clicking the button, I expect that the color of the whole character will be 
changed to red, but actually only part is changed.

In FontForge (a font editor), I find the character "f" in Times New Roman is 
wider than its "width".
Please look into this problem. Thanks.

Code to reproduce:
--
import tkinter

def change_color():
canvas.itemconfig(text, fill="red")

root = tkinter.Tk()
canvas = tkinter.Canvas(root, width=500, height=500)
canvas.pack()

text = canvas.create_text((200, 200), text="f", font=("Times New Roman", 200), 
fill="black")

button = tkinter.Button(text="Change Color", command=change_color)
button.pack()

root.mainloop()

--
components: Tkinter
messages: 409258
nosy: hejin517
priority: normal
severity: normal
status: open
title: Text containing "wide" character not correctly refreshed
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



[issue46177] can't install launcher for all users

2021-12-28 Thread Steve Dower


Steve Dower  added the comment:

This normally happens because you've already installed the launcher "just for 
me". You can't change that setting later.

Open Add/Remove Programs and uninstall the Python Launcher first. Then you 
should be able to reinstall it for all users.

--

___
Python tracker 

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



[issue46171] venv module produces spurious warning that location has moved

2021-12-28 Thread Steve Dower


Steve Dower  added the comment:

There are plenty of other ways to get a venv through a potentially unexpected 
path (turns out I've been doing one for years), which is why I went with the 
general warning rather than limiting it to specific behaviours that are subject 
to change outside of our control.

I'm not opposed to strengthening this check to ignore DOS encoded names, but I 
think it should remain for anything where the realised executable path isn't 
the same as what you'd assume from the requested path. Without being very aware 
of how your directories are all configured, it could be near impossible to 
diagnose, so the warning in the command-line tool is appropriate.

--
nosy: +vinay.sajip

___
Python tracker 

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



[issue46070] _PyImport_FixupExtensionObject() regression causing a crash in subintepreters

2021-12-28 Thread Dong-hee Na


Dong-hee Na  added the comment:

I can reproduce the crash on my macOS with main branch version.

Fatal Python error: Segmentation fault

Thread 0x700010389000 (most recent call first):
  File "/Users/user/oss/cpython/bug.py", line 16 in doIt
  File "/Users/user/oss/cpython/Lib/threading.py", line 968 in run
  File "/Users/user/oss/cpython/Lib/threading.py", line 1031 in _bootstrap_inner
  File "/Users/user/oss/cpython/Lib/threading.py", line 988 in _bootstrap

Current thread 0x7f386000 (most recent call first):
  File "/Users/user/oss/cpython/bug.py", line 16 in doIt
  File "/Users/user/oss/cpython/Lib/threading.py", line 968 in run
  File "/Users/user/oss/cpython/Lib/threading.py", line 1031 in _bootstrap_inner
  File "/Users/user/oss/cpython/Lib/threading.py", line 988 in _bootstrap

Thread 0x7e383000 (most recent call first):
  File "/Users/user/oss/cpython/bug.py", line 16 in doIt
  File "/Users/user/oss/cpython/Lib/threading.py", line 968 in run
  File "/Users/user/oss/cpython/Lib/threading.py", line 1031 in _bootstrap_inner
  File "/Users/user/oss/cpython/Lib/threading.py", line 988 in _bootstrap

Thread 0x7d38 (most recent call first):
  File "/Users/user/oss/cpython/bug.py", line 16 in doIt
  File "/Users/user/oss/cpython/Lib/threading.py", line 968 in run
  File "/Users/user/oss/cpython/Lib/threading.py", line 1031 in _bootstrap_inner
  File "/Users/user/oss/cpython/Lib/threading.py", line 988 in _bootstrap

Thread 0x00010a590e00 (most recent call first):
  File "/Users/user/oss/cpython/Lib/threading.py", line 1125 in 
_wait_for_tstate_lock
  File "/Users/user/oss/cpython/Lib/threading.py", line 1105 in join
  File "/Users/user/oss/cpython/bug.py", line 23 in func
  File "/Users/user/oss/cpython/bug.py", line 25 in 

Extension modules: _testcapi (total: 1)
[1]9098 segmentation fault  ./python.exe bug.py

--

___
Python tracker 

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



[issue46070] _PyImport_FixupExtensionObject() regression causing a crash in subintepreters

2021-12-28 Thread Dong-hee Na


Change by Dong-hee Na :


--
nosy: +corona10

___
Python tracker 

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



[issue37295] Possible optimizations for math.comb()

2021-12-28 Thread Mark Dickinson


Mark Dickinson  added the comment:


New changeset 02b5417f1107415abaf81acab7522f9aa84269ea by Mark Dickinson in 
branch 'main':
bpo-37295: Speed up math.comb(n, k) for 0 <= k <= n <= 67 (GH-30275)
https://github.com/python/cpython/commit/02b5417f1107415abaf81acab7522f9aa84269ea


--

___
Python tracker 

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



[issue30420] Clarify kwarg handing for subprocess convenience APIs

2021-12-28 Thread Alex Waygood


Alex Waygood  added the comment:

The modern docs for these functions seem to:

* Document the cwd argument for these functions, following PR 1685 & PR 2253.
* Include an **other_popen_kwargs parameter for all these functions.

Nick, is there anything left to do here, or can this issue be closed now?

--
nosy: +AlexWaygood

___
Python tracker 

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



[issue46188] dictionary creation error

2021-12-28 Thread Steven D'Aprano


Steven D'Aprano  added the comment:

> I still can not figure out why the first two elements are inconsistent
from the rest of the dictionary, and why they appear in the first place.

Hi Tobias,

This is a bug tracker for reporting bugs in Python, not a help desk to ask for 
explanations. The behaviour you see is correct. Except for the last line, which 
is a copy-and-paste error on your part: the actual last line is

>>> dictionary
{0: None, None: None, 2: 2, 4: 4, 6: 6, 8: 8}

So there is no error here, everything is working as expected.

If you need help understanding why the code is correct, please take the 
discussion to the Python Discuss forum where you will be sure to get answers.

--
nosy: +steven.daprano
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



[issue46188] dictionary creation error

2021-12-28 Thread TobiasHT


New submission from TobiasHT :

I was creating a dictionary when I noticed something weird.
I had a function responsible for creating dictionary keys and then values were 
assigned to the keys in a for loop.
The code goes a little like this:

>>> def key_maker(n):
... if (n % 2) == 0:
... return n
... return None

>>> dictionary = {}
>>> for i in range(10):
... dictionary[key_maker(i)] = i if key_maker(i) else "error"

>>> dictionary
{0: 'error', None: 'error', 2: 2, 4: 4, 6: 6, 8: 8}


when I tried to print out the rest of the values in the "else" clause,
I realized that 0 appeared there as well, so 0 appeared twice.

>>> for i in range(10):
... dictionary[key_maker(i)] = i if key_maker(i) else print(i)
...
0
1
3
5
7
9
>>> dictionary
{0: 'error', None: 'error', 2: 2, 4: 4, 6: 6, 8: 8}

I still can not figure out why the first two elements are inconsistent
from the rest of the dictionary, and why they appear in the first place.

--
messages: 409251
nosy: TobiasHT
priority: normal
severity: normal
status: open
title: dictionary creation error
type: behavior

___
Python tracker 

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