[issue41618] [C API] How many slots of static types should be exposed in PyType_GetSlot()

2021-01-15 Thread hai shi


hai shi  added the comment:

>Not a function, shouldn't be used with PyType_Slot:
>  * tp_dict - I'd add a PyType_GetDict if there is a need to get this
>  * tp_mro - I'd add a PyType_GetMRO if there is a need to get this

I checked some other projects which use type fileds directly.
cpython doesn't expose the tp_dict and tp_mro directly in headers. 
I am not sure which way is more better(calling function vs using fileld 
directly).

refs:
https://gitlab.gnome.org/GNOME/pygobject/-/blob/master/gi/gimodule.c#L1168
https://github.com/biolab/orange2/blob/db40a9449cb45b507d63dcd5739b223f9cffb8e6/source/orange/cls_orange.cpp#L587

--

___
Python tracker 

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



[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-15 Thread William Pickard


William Pickard  added the comment:

Jumping in here to explain why '__class' doesn't crash when '__sizeof__' does:

When '__class__' is fetched, it returns a new reference to the object's type.

When '__sizeof__' is fetched on the otherhand, a new object is allocated on the 
heap ('types.MethodType') and is returned to the caller.

This object also has a '__sizeof__' that does the same (as it's implemented on 
'object'.

So yes, you are exhausting the C runtime stack by de-allocating over a THOUSAND 
objects.

You can see this happen by watching the memory usage of Python steadily climb.

--
nosy: +WildCard65

___
Python tracker 

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



[issue37006] Add top level await statement support for doctest

2021-01-15 Thread Austin "Paco" Rainwater


Change by Austin "Paco" Rainwater :


--
nosy: +pacorain

___
Python tracker 

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



[issue42889] Incorrect behavior after ast node visits

2021-01-15 Thread Xinmeng Xia

Xinmeng Xia  added the comment:

Thank you for your kindly explanations! The output of the first program in 
msg384799 behaves as expected from the view of AST compiling.  Yes,I see now. 
But for the second example in msg384879, the behaviors are inconsistent between 
old Python version(3.6,3.7,3.8) and new Python version(3.9,3.10). It is 
probably something wrong in "compile" parsing bool string, "False","True" in 
new version of Python(3.9,3.10). 

I think a checker in function "compile" will not be complicated. Like you said, 
the simplest way I can think is to re-perform lexical analysis and syntax 
analysis. e.g. unparse ast, then parse ast before compiling AST object. 

As for #42887, only part of attributes will lead to that bug. I think it's 
attribute-related. If that bug is triggered by c loop, all attributes should be 
involved.

--

___
Python tracker 

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



[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-15 Thread Xinmeng Xia


Xinmeng Xia  added the comment:

Thank you. But I am not sure this is a recursion problem. Please see the 
following example, I replace "__sizeof__" with "__class__". No segmentation 
fault. Everything goes well.


mystr  = "hello123"
print(dir(mystr))
for x in range(100):
mystr = mystr.__class__
print(mystr)
=
and

=
mystr  = "hello123"
for x in range(100):
mystr = mystr.__class__
input('>')  # Hit Enter to continue.
del mystr   # Expect crash here.
input('<')  # And never get here
=
No segmentation fault

--

___
Python tracker 

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



[issue42916] Support for DICOM image file format in imghdr module

2021-01-15 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Can you submit a patch, or post here an test_dicom function?

--
nosy: +terry.reedy
stage:  -> needs patch

___
Python tracker 

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



[issue42935] Pickle can't import builtins at exit

2021-01-15 Thread Guido van Rossum

Guido van Rossum  added the comment:

I don’t know there is much we can do about this. I recommend using ‘with’ to 
close the shelf earlier.

--
nosy: +gvanrossum

___
Python tracker 

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



[issue42889] Incorrect behavior after ast node visits

2021-01-15 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

The parser is not involved here.  The transformed code is *not* equivalent to 
"1=2; print(1)" because you replace 'a' with the string '1', not the int 1.  
The result is to transform
 "globals()['a']=2; print(globals()['a'])" to 
 "globals()['1']=2; print(globals()['1'])"
This works because globals() is a regular dict.

If one does try to make the code equivalent to "1=2; print(1)" by replacing 
with 1, the result is an error.

Traceback (most recent call last):
  File "F:\Python\a\tem4.py", line 19, in 
print(ast.unparse(newast))
  File "C:\Programs\Python310\lib\ast.py", line 1567, in unparse
return unparser.visit(ast_obj)
  File "C:\Programs\Python310\lib\ast.py", line 805, in visit
return "".join(self._source)
TypeError: sequence item 1: expected str instance, int found

With unparse removed, I get a compile error when the identifier type is checked.

Traceback (most recent call last):
  File "F:\Python\a\tem4.py", line 19, in 
c = compile(newast,'','exec')
TypeError: AST identifier must be of type str

In the binary example, unparsing gives an infinite recursion error with this 
repeated sequence.

  File "C:\Programs\Python310\lib\ast.py", line 1372, in visit_BinOp
self.traverse(node.left)
  File "C:\Programs\Python310\lib\ast.py", line 798, in traverse
super().visit(node)
  File "C:\Programs\Python310\lib\ast.py", line 410, in visit
return visitor(node)

Without unparse, the compile call crashes.  (In IDLE, this means there is an 
unrequested restart of the Shell subprocess that executes user code, without 
IDLE crashing.)  I suspect that there is a related loop in the compile C code 
that crashes the process before any checking is done.  If so, the situation 
would be similar to your #42887 and we may not be able to do anything.

--
nosy: +terry.reedy
title: Incorrect behavior of Python parser after ast node of test program  
being modified -> Incorrect behavior  after ast node visits
versions:  -Python 3.6, Python 3.7

___
Python tracker 

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



[issue42887] 100000 assignments of .__sizeof__ cause a segfault on del

2021-01-15 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Xinmeng, to verify Ronald's explanation, run this instead

mystr  = "hello123"
for x in range(100):
mystr = mystr.__sizeof__()
input('>')  # Hit Enter to continue.
del mystr   # Expect crash here.
input('<')  # And never get here.

--
nosy: +terry.reedy
title: Multiple assignments of attribute "__sizeof__" will cause a segfault -> 
10 assignments of .__sizeof__  cause a segfault on del

___
Python tracker 

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



[issue42888] Not installed “libgcc_s.so.1” causes exit crash.

2021-01-15 Thread Terry J. Reedy

Change by Terry J. Reedy :


--
components: +C API -Interpreter Core
title: Not installed “libgcc_s.so.1” causes parser crash. -> Not installed 
“libgcc_s.so.1” causes exit crash.

___
Python tracker 

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



[issue42937] 192.0.0.8 (IPv4 dummy address) considered globally reachable

2021-01-15 Thread CDirkx


New submission from CDirkx :

Currently the method `ipaddress.is_global` returns true for the IPv4 address 
192.0.0.8. This was correct when `is_global` was initially implemented, but in 
2015 192.0.0.8 got designated as the "IPv4 dummy address" and not globally 
reachable, see the IANA special purpose address registry: 
https://www.iana.org/assignments/iana-ipv4-special-registry/iana-ipv4-special-registry.xhtml.

The correct behaviour now, according to the documentation of `is_global` which 
refers to the IANA registry, would be to return false for 192.0.0.8.

--
messages: 385127
nosy: cdirkx
priority: normal
severity: normal
status: open
title: 192.0.0.8 (IPv4 dummy address) considered globally reachable
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



[issue42885] Regex performance problem with ^ aka AT_BEGINNING

2021-01-15 Thread Terry J. Reedy


Change by Terry J. Reedy :


--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue42849] pool worker can't be terminated

2021-01-15 Thread ppperry


ppperry  added the comment:

duplicate of issue22393?

--
nosy: +ppperry

___
Python tracker 

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



[issue42917] Block stack size for frame objects should be dynamically sizable

2021-01-15 Thread Thomas Anderson


Thomas Anderson  added the comment:

> Reducing the size of the frame object seems like a worthwhile goal, but 
> what's the point in increasing the maximum block stack?

No point for humans, but it may be useful for code generators.

--

___
Python tracker 

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



[issue42927] Inline cache for slots

2021-01-15 Thread Guido van Rossum


Guido van Rossum  added the comment:

I created a benchmark for this, see 
https://github.com/python/pyperformance/pull/86.

Next I'll add a blurb and then it's off to reviewers.

--

___
Python tracker 

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



[issue42931] Include randbytes in random.__all__

2021-01-15 Thread Raymond Hettinger


Raymond Hettinger  added the comment:


New changeset 17c1f0c8cb96637c36548edf6e4570ac7564004b by Miss Islington (bot) 
in branch '3.9':
bpo-42931: randbytes missing from random.__all__ (GH-24219) (GH-24225)
https://github.com/python/cpython/commit/17c1f0c8cb96637c36548edf6e4570ac7564004b


--

___
Python tracker 

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



[issue42931] Include randbytes in random.__all__

2021-01-15 Thread Raymond Hettinger


Change by Raymond Hettinger :


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



[issue42931] Include randbytes in random.__all__

2021-01-15 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue42931] Include randbytes in random.__all__

2021-01-15 Thread Raymond Hettinger


New submission from Raymond Hettinger :


New changeset 998ae1fa3fb05a790071217cf8f6ae3a928da13f by Setrak Balian in 
branch 'master':
bpo-42931: randbytes missing from random.__all__ (GH-24219)
https://github.com/python/cpython/commit/998ae1fa3fb05a790071217cf8f6ae3a928da13f


--

___
Python tracker 

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



[issue42911] Addition chains for pow saves 5-20% time for pow(int, int)

2021-01-15 Thread Mark Dickinson


Mark Dickinson  added the comment:

Thank you for the proposal and PR!

There are some tradeoffs to be considered here, between simplicity and 
performance; it's not always trivial to find the sweet spot.  Python's int 
implementation mostly favours the simplicity end of the spectrum. It's also 
focused on the sort of integer sizes that turn up in everyday problems, rather 
than crypto-sized (or worse, number-theoretic-sized) integers - those are more 
the province of libraries like cryptlib and GMP. That's why Python still has 
quadratic-time division and base-conversion algorithms.

For this particular case, my feeling is that the added complexity (~300 lines 
of C code) isn't worth the payoff.

That said, the existing integer powering implementation, like much else in 
longobject.c, goes back to Tim Peters. If Tim wants to champion this change and 
push it forward, I'm certainly not going to oppose that.

--

___
Python tracker 

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



[issue42917] Block stack size for frame objects should be dynamically sizable

2021-01-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Getting rid of hardcoded limits is good. And at first look the proposed PR 
looks good (some minor details can be discussed).

Although there is different approach to solve the same problem. The stack of 
blocks is used to set handlers for exceptions. For example, when enter the try 
block, it pushes the handler that points to except and/or finally clauses, when 
enter the with block, it pushes the handler that calls __exit__, etc. The stack 
of handlers is changed at run time, and it was the only solution to this 
problem. But after reorganizes of bytecode in latest Python versions (mainly by 
Mark) it is now possible to determine handlers for every instruction 
statically, at compile time. Instead of stack of blocks we would have a table 
of addresses of handlers. It is more efficient approach and it is used in 
modern C++ compilers. The only technical issue is compact and 
platform-independent representation of the table (because the size of the 
uncompressed table would be larger than the size of the code, but most of 
entries are repeated and usually are small integers).

It would make PR 24204 unneeded, so I suggest to wait some time before 
reviewing it.

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



[issue42377] allow typing.cast with TYPE_CHECKING

2021-01-15 Thread Ken Jin


Ken Jin  added the comment:

Sorry, I don't think this is a typing module issue.

The NameError stems from what you mentioned: 'A' not being defined since 
TYPE_CHECKING evaluates to false at runtime. This would raise an error in any 
Python code, not just typing. The equivalent is this::

>>> A
Traceback (most recent call last):
  File "", line 1, in 
NameError: name 'A' is not defined

Without the future import, def f(a: A): ... already throws that NameError. The 
reason why it works in your example is because 'A' isn't evaluated at function 
declaration time with the future import.

To appease your static type checker and not cause runtime errors, you might 
want to try:

f(cast("A", "anything"))

Which seems to work in mypy and pycharm. (Sorry, I don't have 
pyre/pytype/pyright to check with, though I would be surprised if this didn't 
pass on them.)

Please correct me if you feel anything I wrote was incorrect :).

--
nosy: +gvanrossum, kj, levkivskyi

___
Python tracker 

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



[issue42911] Addition chains for pow saves 5-20% time for pow(int, int)

2021-01-15 Thread Jurjen N.E. Bos


Change by Jurjen N.E. Bos :


--
title: Addition chains for pow saves 10 % time! -> Addition chains for pow 
saves 5-20% time for pow(int,int)

___
Python tracker 

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



[issue42911] Addition chains for pow saves 10 % time!

2021-01-15 Thread Jurjen N.E. Bos


Jurjen N.E. Bos  added the comment:

Well, measurements show that it saves more time than I thought (sometimes over 
20%!), because there are other ways in which it saves time; I am quite happy 
with that.

In the code I needed functions _Py_bit_length64 and _Py_bit_count64.
I thought these could better move to the bitutils, but I am not sure about a 
good name to use, since there are probably other places where these are used, 
too (I know of at least one in hashtable.c).
The 32 bits versions in bitutils are called _Py_bit_length and _Py_popcount32 
(not the most logical names).
So then it would also be more logical to give all four of these consistent 
names, everywhere. But that's probably better at a later time, right?

--

___
Python tracker 

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



[issue41824] Docs for typing.ForwardRef don't state that it was added in 3.7

2021-01-15 Thread Ken Jin


Change by Ken Jin :


--
keywords: +patch
nosy: +kj
nosy_count: 2.0 -> 3.0
pull_requests: +23048
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/24224

___
Python tracker 

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



[issue42936] Decimal module performs wrong floor division with negative numbers

2021-01-15 Thread Mark Dickinson


Mark Dickinson  added the comment:

Thanks for the report. I'm going to close here, since this isn't a bug.

If you want to advocate for a behaviour change, by all means go ahead, but be 
aware that it would likely be a hard sell. The main challenge would be finding 
a way to change the behaviour that doesn't abruptly break existing code that 
depends on the current semantics.

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



[issue42929] On Windows, shutil.move doesn't raise FileExistsError if dst exists like os.rename

2021-01-15 Thread Eryk Sun


Eryk Sun  added the comment:

I can help, but in this case there isn't much to do. Just replace os.rename() 
with os.replace(), make a minor doc change, and maybe add a test that ensures a 
junction can be moved over an existing file on the same filesystem. For example:

>>> os.mkdir('temp')
>>> _winapi.CreateJunction('temp', 'src')
>>> os.lstat('src').st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT
True
>>> open('dst', 'w').close()

The current implementation tries copytree() on the junction mountpoint and 
fails to create a new directory named "dst":

>>> try: shutil.move('src', 'dst')
... except FileExistsError as e: e
...
FileExistsError(17, 'Cannot create a file when that file already exists')

But move() should simply replace "dst" with the junction via os.replace():

>>> os.replace('src', 'dst')
>>> os.lstat('dst').st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT
True

--

___
Python tracker 

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



[issue42934] use TracebackException's new compact param in unittest.TestResult

2021-01-15 Thread Guido van Rossum


Guido van Rossum  added the comment:


New changeset ba876c44a8d06668e622fb580fdcde45c7a36d48 by Irit Katriel in 
branch 'master':
bpo-42934: use TracebackException(compact=True) in unittest.TestResult 
(GH-24221)
https://github.com/python/cpython/commit/ba876c44a8d06668e622fb580fdcde45c7a36d48


--
nosy: +gvanrossum

___
Python tracker 

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



[issue42934] use TracebackException's new compact param in unittest.TestResult

2021-01-15 Thread Guido van Rossum


Change by Guido van Rossum :


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



[issue42936] Decimal module performs wrong floor division with negative numbers

2021-01-15 Thread Mark Dickinson


Mark Dickinson  added the comment:

The behaviour is deliberate, if unfortunate: it's covered in the documentation 
here: https://docs.python.org/3/library/decimal.html#decimal-objects - see the 
paragraph starting

> There are some small differences between arithmetic on Decimal objects
> and arithmetic on integers and floats. When the remainder operator % is
> applied to Decimal objects

The issue is that the decimal spec specifies "divide-integer" and "remainder" 
operations. We've chosen to map those operations to "%" and "//" for 
convenience, even though there's a difference between float and Decimal here.

--
nosy: +mark.dickinson

___
Python tracker 

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



[issue42936] Decimal module performs wrong floor division with negative numbers

2021-01-15 Thread Jens


New submission from Jens :

from decimal import Decimal

print(-0.9//0.123)
# prints -8.0
print(Decimal('-0.9')//Decimal('0.123'))
# prints -7
print(-10//4.2)
# prints -3.0
print(Decimal('-10')//Decimal('4.2'))
# prints -2

--
messages: 385113
nosy: multiks2200
priority: normal
severity: normal
status: open
title: Decimal module performs wrong floor division with negative numbers
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



[issue42930] xml.parsers.expat results differ buffer_text and / or buffer_size

2021-01-15 Thread Michael XU


Michael XU  added the comment:

Thank you so much Walter. I think that might be it - it fixed this particular 
instance, and it makes sense given what you have said. I'll proceed to close 
this up but will follow up if I encounter this issue when the data has changed.

Thanks again!

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



[issue42693] "if 0:" lines are traced; they didn't use to be

2021-01-15 Thread Mark Shannon


Change by Mark Shannon :


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



[issue42917] Block stack size for frame objects should be dynamically sizable

2021-01-15 Thread Mark Shannon


Mark Shannon  added the comment:

Reducing the size of the frame object seems like a worthwhile goal, but what's 
the point in increasing the maximum block stack?

--
nosy: +Mark.Shannon

___
Python tracker 

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



[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2021-01-15 Thread gaborjbernat


Change by gaborjbernat :


--
nosy: +gaborjbernat

___
Python tracker 

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



[issue42925] Error trace of else inside class

2021-01-15 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue42935] Pickle can't import builtins at exit

2021-01-15 Thread Pete Wicken


New submission from Pete Wicken :

Originally found as an issue in Lib/shelve.py; if we attempt to pickle a 
builtin as the program is exiting then Modules/_pickle.c will fail at the point 
of the PyImport_Import in save_global. In CPython3.8 this causes a segfault, in 
CPython3.9 a PicklingError is raised.

This is especially problematic in shelve.py as object pickling is attempted by 
the __del__ method's call stack when writeback=True. Therefore if the program 
exits before an explicit sync is called; in 3.8 the data will not be written to 
disk and a segfault occurs; in 3.9 the data is written to disk, but with an 
uncaught exception being raised.


Exception demonstrated via shelve on 3.9.1 on MacOS with Clang:

Python 3.9.1 (default, Dec 10 2020, 11:11:14)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import shelve
>>> s = shelve.open('testing', writeback=True)
>>> s['a'] = Exception
>>> exit()
Exception ignored in: 
Traceback (most recent call last):
  File ".../3.9/lib/python3.9/shelve.py", line 162, in __del__
  File ".../3.9/lib/python3.9/shelve.py", line 144, in close
  File ".../3.9/lib/python3.9/shelve.py", line 168, in sync
  File ".../3.9/lib/python3.9/shelve.py", line 124, in __setitem__
_pickle.PicklingError: Can't pickle : import of module 
'builtins' failed


Segfault demonstrated via shelve on 3.8.5 on MacOS with Clang (different system 
from above):

Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27)
[Clang 6.0 (clang-600.0.57)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import shelve
>>> s = shelve.open('testing', writeback=True)
>>> s['a'] = Exception
>>> exit()
[1]10040 segmentation fault  python3.8


Exception demonstrated via shelve on 3.9.1 on RHEL with GCC:

Python 3.9.1 (default, Dec  8 2020, 00:00:00) 
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import shelve
>>> s = shelve.open("thing", writeback=True)
>>> s['a'] = Exception
>>> 
Exception ignored in: 
Traceback (most recent call last):
  File "/usr/lib64/python3.9/shelve.py", line 162, in __del__
  File "/usr/lib64/python3.9/shelve.py", line 144, in close
  File "/usr/lib64/python3.9/shelve.py", line 168, in sync
  File "/usr/lib64/python3.9/shelve.py", line 124, in __setitem__
_pickle.PicklingError: Can't pickle : import of module 
'builtins' failed


Code example to reproduce using Pickle in the class __del__, demonstrated on a 
RHEL system:

Python 3.9.1 (default, Dec  8 2020, 00:00:00) 
[GCC 10.2.1 20201125 (Red Hat 10.2.1-9)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from pickle import DEFAULT_PROTOCOL, Pickler
>>> from io import BytesIO
>>> class T:
...   def __del__(self):
... f = BytesIO()
... p = Pickler(f, DEFAULT_PROTOCOL)
... p.dump(sum)
... 
>>> t = T()
>>> exit()
Exception ignored in: 
Traceback (most recent call last):
  File "", line 5, in __del__
_pickle.PicklingError: Can't pickle : import of module 
'builtins' failed


Have not tested on 3.6, 3.7 or 3.10.

--
components: Library (Lib)
messages: 385110
nosy: Wicken
priority: normal
severity: normal
status: open
title: Pickle can't import builtins at exit
type: crash
versions: 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



[issue42934] use TracebackException's new compact param in unittest.TestResult

2021-01-15 Thread Irit Katriel


Change by Irit Katriel :


--
nosy: +ezio.melotti, michael.foord, rbcollins

___
Python tracker 

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



[issue42934] use TracebackException's new compact param in unittest.TestResult

2021-01-15 Thread Irit Katriel


Change by Irit Katriel :


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

___
Python tracker 

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



[issue7946] Convoy effect with I/O bound threads and New GIL

2021-01-15 Thread Maarten Breddels


Maarten Breddels  added the comment:

In case someone finds it useful, I've written a blog post on how to visualize 
the GIL:
https://www.maartenbreddels.com/perf/jupyter/python/tracing/gil/2021/01/14/Tracing-the-Python-GIL.html

In the comments (or at 
https://github.com/maartenbreddels/fastblog/issues/3#issuecomment-760891430 )
I looked specifically at the iotest.py example (no solutions though).

--
nosy: +maartenbreddels

___
Python tracker 

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



[issue33809] Expose `capture_locals` parameter in `traceback` convenience functions

2021-01-15 Thread Irit Katriel


Irit Katriel  added the comment:

Generally speaking, I don't think it's a good idea to create redundant APIs. If 
we copy all the params from TracebackException (and it will be all params, why 
only this one?) that means more code, more tests, more documentation and a 
higher cognitive load for someone reading the documentation to learn the API.  
And the users don't really get anything tangible in return - they can do 
exactly the same things, maybe with a slightly smaller number of characters.  A 
good standard library API has a small number of buttons that can be used in 
combination to get a lot of functionality.

In this particular case, I think it's nice that print_exception() gives novices 
a simple way to get some basic functionality, and more sophisticated users can 
go to TracebackException for more options. I agree with you that at the moment 
it's a bit clumsy, and a print() method would make it more usable. Note that a 
programmer who understands the different parts of a traceback and wants to 
tweak its representation is not a novice and should be able to use that with 
ease.

--
versions: +Python 3.10 -Python 3.8

___
Python tracker 

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



[issue42929] On Windows, shutil.move doesn't raise FileExistsError if dst exists like os.rename

2021-01-15 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

Eryk Sun, do you mind to create a PR?

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue33809] Expose `capture_locals` parameter in `traceback` convenience functions

2021-01-15 Thread Ulrich Petri


Ulrich Petri  added the comment:

That would make it slightly better, but I still think it's a pretty arcane 
incantation (esp. for newer people).

What makes you hesitant to adding the parameter to the convenience functions?

--

___
Python tracker 

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



[issue42934] use TracebackException's new compact param in unittest.TestResult

2021-01-15 Thread Irit Katriel


New submission from Irit Katriel :

The TracebackException instance created here
https://github.com/python/cpython/blob/63298930fb531ba2bb4f23bc3b915dbf1e17e9e1/Lib/unittest/result.py#L185
is only used for format(), so it can benefit from the compact param added in 
issue42877.

--
components: Library (Lib)
messages: 385105
nosy: iritkatriel
priority: normal
severity: normal
status: open
title: use TracebackException's new compact param in unittest.TestResult
type: performance
versions: Python 3.10

___
Python tracker 

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



[issue42930] xml.parsers.expat results differ buffer_text and / or buffer_size

2021-01-15 Thread Walter Dörwald

Walter Dörwald  added the comment:

Just a guess, but the buffer size might be so small that the text that you 
expect gets passed via **two** calls to _char_data(). You should refactor your 
code the simply collect all the text in _char_data() and act on it in the 
_end_element() handler.

So this probably isn't a bug in xml.parsers.expat.

--
nosy: +doerwalter

___
Python tracker 

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



[issue42927] Inline cache for slots

2021-01-15 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> What is the next step?

I would say just finishing the PR (making sure that we do not miss some arcane 
edge case) and updating the what's new for 3.10 :)

--

___
Python tracker 

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



[issue41837] Upgrade installers to OpenSSL 1.1.1i

2021-01-15 Thread Christian Heimes


Christian Heimes  added the comment:

I got bad news. OpenSSL 1.1.1i introduced a regression in cert validation. This 
affects some cases that involve self-signed certificates. Cert validation fails 
if a self-signed certificate is used as both a trust anchor (root CA) and EE 
cert. This may affect Python.

Would it be possible to rebuild our OpenSSL binaries with patch 
https://github.com/openssl/openssl/pull/13749 ?

--
resolution: fixed -> 
stage: resolved -> patch review
status: closed -> open
type:  -> behavior

___
Python tracker 

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



[issue42933] OUTPUT WRONG

2021-01-15 Thread Christian Heimes


Christian Heimes  added the comment:

"No" is the correct output for your code example. Your code does not raise an 
exception, therefore the else block is executed.

Please don't use the bug tracker to get assistance with learning Python. There 
are community resources like chat and forums dedicated to that, 
https://www.python.org/community/

--
nosy: +christian.heimes
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed
type: security -> behavior

___
Python tracker 

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



[issue42933] OUTPUT WRONG

2021-01-15 Thread Kkshitish


New submission from Kkshitish :

try:
  
  a = 10
  
  if a == 11:

print ("Yes")

except:
  
  print ("Out")
  
else:
  
  print ("No")


Output: No

The output should be "Out" but it print "No", The else statement should be 
print when try condition is execute. But the try condition is not execute on 
program. But still it print else statement. 

This is not ideal output. If you are disagree with me. So, kindly provide very 
strong argument over this.

--
files: main.py
messages: 385100
nosy: Kkshitish
priority: normal
severity: normal
status: open
title: OUTPUT WRONG
type: security
versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9
Added file: https://bugs.python.org/file49745/main.py

___
Python tracker 

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



[issue42931] Include randbytes in random.__all__

2021-01-15 Thread Serhiy Storchaka


Change by Serhiy Storchaka :


--
nosy: +vstinner

___
Python tracker 

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