[issue43954] Possible missing word on unittest doc

2021-04-30 Thread Julien Palard


Julien Palard  added the comment:


New changeset 2abbd8f2add5e80b86a965625b9a77ae94a101cd by Zackery Spytz in 
branch 'master':
bpo-43954: Fix a missing word in the unittest docs (GH-25672)
https://github.com/python/cpython/commit/2abbd8f2add5e80b86a965625b9a77ae94a101cd


--

___
Python tracker 

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



[issue43954] Possible missing word on unittest doc

2021-04-30 Thread miss-islington


Change by miss-islington :


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

___
Python tracker 

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



[issue43954] Possible missing word on unittest doc

2021-04-30 Thread Julien Palard


Julien Palard  added the comment:

As far as this issue is concerned, it's fixed.

The discussion about this feature not working can continue in the appropriate 
issue (23882)

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



[issue43954] Possible missing word on unittest doc

2021-04-30 Thread miss-islington


miss-islington  added the comment:


New changeset a92d7387632de1fc64de51f22f6191acd0c6f5c0 by Miss Islington (bot) 
in branch '3.9':
bpo-43954: Fix a missing word in the unittest docs (GH-25672)
https://github.com/python/cpython/commit/a92d7387632de1fc64de51f22f6191acd0c6f5c0


--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Py_TPFLAGS_IMMUTABLETYPE has been applied to array.array by Erlend in 
https://github.com/python/cpython/pull/25696. Should Py_TPFLAGS_IMMUTABLETYPE 
be applied to other heap types also (the ones that were converted from static 
types)?

--

___
Python tracker 

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



[issue41277] documentation: os.setxattr() errno EEXIST and ENODATA

2021-04-30 Thread Roundup Robot


Change by Roundup Robot :


--
nosy: +python-dev
nosy_count: 3.0 -> 4.0
pull_requests: +24432
pull_request: https://github.com/python/cpython/pull/25742

___
Python tracker 

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



[issue43968] os.path.realpath() unexpected breaking change: resolves subst'd paths to real paths

2021-04-30 Thread sfmc


sfmc  added the comment:

I see the point: the real path may not be accessible from the substitute drive:
 - if symlink (or junction) is used, pointing to path not visible from the 
substitute drive.
 - if different security context is used (e.g. different user or UAC).

But that is the discussion about the _correct_ behavior (which may have 
differing opinions if the exact behavior is not documented).

-

Let's discuss how we can fix the issue caused by the behavior change.

I propose a simple fix: keep old behavior if a special environment variable is 
specified.

E.g. if you specify env. var. PYTHON_NTREALPATH_OLD_BEHAVIOR=1, it doesn't 
resolve symlinks and junctions.

Is this acceptable for Python 3.8.10?

--

___
Python tracker 

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



[issue43976] Introduce mechanism to allow Python distributors to add custom site install schemes

2021-04-30 Thread Miro Hrončok

Miro Hrončok  added the comment:

Cross referencing the discussion: 
https://discuss.python.org/t/mechanism-for-distributors-to-add-site-install-schemes-to-python-installations/8467

--
nosy: +hroncok

___
Python tracker 

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



[issue43984] [security]winreg.SetValueEx shoule check the returned value

2021-04-30 Thread r3pwnx


New submission from r3pwnx :

The library winreg[1] can be used to access registry on windows.  
>reg.SetValueEx(key, 'X', 0, reg.REG_DWORD, -1337)  
`SetValueEx` could store data in the value field of an open registry key, 

In the source file of "PC/winreg.c", `Py2Reg`is called first

```
static PyObject *
winreg_SetValueEx_impl(PyObject *module, HKEY key,
   const Py_UNICODE *value_name, PyObject *reserved,
   DWORD type, PyObject *value)
/*[clinic end generated code: output=811b769a66ae11b7 input=900a9e3990bfb196]*/
{
BYTE *data;
DWORD len;

LONG rc;

if (!Py2Reg(value, type, &data, &len))
...
```

`Py2Reg` is implemented in the same file:

```
Py2Reg(PyObject *value, DWORD typ, BYTE **retDataBuf, DWORD *retDataSize)
{
Py_ssize_t i,j;
switch (typ) {
case REG_DWORD:
if (value != Py_None && !PyLong_Check(value))
return FALSE;
*retDataBuf = (BYTE *)PyMem_NEW(DWORD, 1);
if (*retDataBuf == NULL){
PyErr_NoMemory();
return FALSE;
}
*retDataSize = sizeof(DWORD);
if (value == Py_None) {
DWORD zero = 0;
memcpy(*retDataBuf, &zero, sizeof(DWORD));
}
else {
DWORD d = PyLong_AsUnsignedLong(value);
memcpy(*retDataBuf, &d, sizeof(DWORD));
}
break;
```

When the type is set with reg.REG_DWORD, `PyLong_AsUnsignedLong(value)` will 
change  the value's type, and then memcpy the returned value directly, without 
any check.  

In the Objects/longobject.c, as the comment said:

/* Get a C unsigned long int from an int object.
   Returns -1 and sets an error condition if overflow occurs. */

If PyLong_AsUnsignedLong return -1, the -1 will be stored in the registry 
though the error occured


PoC:


import winreg as reg

key = reg.CreateKey(reg.HKEY_CURRENT_USER, 'SOFTWARE\\Classes\\r3pwn')

try:
print("Set Subkey X: -1337")
reg.SetValueEx(key, 'X', 0, reg.REG_DWORD, -1337)
except Exception as e:
print("Get Subkey: ", reg.QueryValueEx(key, "X")[0])

try:
print("Set Subkey Y: 2**33")
reg.SetValueEx(key, 'Y', 0, reg.REG_DWORD, 2**33)
except Exception as e:
print("Get Subkey: ", reg.QueryValueEx(key, "Y")[0])

The Test Environment
OS: Windows
Python Version: 3.9.0

python winreg_bug.py
Set Subkey X: -1337
Get Subkey:  4294967295
Set Subkey Y: 2**33
Get Subkey:  4294967295

the return value should be checked:

 DWORD d = PyLong_AsUnsignedLong(value);
 +   if (d == (unsigned long)-1 && PyErr_Occurred())
 +   return False;
 memcpy(*retDataBuf, &d, sizeof(DWORD));


[1] https://docs.python.org/3.9/library/winreg.html#winreg.SetValueEx

--
components: Library (Lib)
files: winreg_bug.py
messages: 392392
nosy: r3pwnx
priority: normal
severity: normal
status: open
title: [security]winreg.SetValueEx shoule check the returned value
type: security
versions: Python 3.9
Added file: https://bugs.python.org/file50001/winreg_bug.py

___
Python tracker 

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



[issue43434] sqlite3.Connection(...) bypasses 'sqlite3.connect' audit hooks

2021-04-30 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Steve, is it worth it to improve this?

--

___
Python tracker 

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



[issue43977] Implement the latest semantics for PEP 634 for matching collections

2021-04-30 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 069e81ab3da46c441335ca762c4333b7bd91861d by Mark Shannon in 
branch 'master':
bpo-43977: Use tp_flags for collection matching (GH-25723)
https://github.com/python/cpython/commit/069e81ab3da46c441335ca762c4333b7bd91861d


--

___
Python tracker 

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



[issue43851] Optimise SQLite builds on macOS and Windows

2021-04-30 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

If Berker does not disapprove, I'd like to apply GH-25413 and GH-25414 to the 
installers, Steve & Ned.

--

___
Python tracker 

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



[issue43985] lib2to3 fails on a slash('/') after positional_only paramter in a function signature

2021-04-30 Thread MisterY


New submission from MisterY :

When I try to format a code snippet with yapf, there comes a error.
It seems lib2to3 can't reconised SLASH.

echo "def foo(posonly1, posonly2, /, positional_or_keyword): pass" | yapf 

Traceback (most recent call last):
  File "d:\program 
files\python38\lib\site-packages\yapf\yapflib\pytree_utils.py", line 115, in 
ParseCodeToTree
tree = parser_driver.parse_string(code, debug=False)
  File "d:\program files\python38\lib\lib2to3\pgen2\driver.py", line 103, in 
parse_string
return self.parse_tokens(tokens, debug)
  File "d:\program files\python38\lib\lib2to3\pgen2\driver.py", line 71, in 
parse_tokens
if p.addtoken(type, value, (prefix, start)):
  File "d:\program files\python38\lib\lib2to3\pgen2\parse.py", line 162, in 
addtoken
raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=17, value='/', context=(' ', 
(1, 28))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "d:\program files\python38\lib\runpy.py", line 194, in 
_run_module_as_main
return _run_code(code, main_globals, None,
  File "d:\program files\python38\lib\runpy.py", line 87, in _run_code
exec(code, run_globals)
  File "D:\Program Files\Python38\Scripts\yapf.exe\__main__.py", line 7, in 

  File "d:\program files\python38\lib\site-packages\yapf\__init__.py", line 
362, in run_main
sys.exit(main(sys.argv))
  File "d:\program files\python38\lib\site-packages\yapf\__init__.py", line 
104, in main
reformatted_source, _ = yapf_api.FormatCode(
  File "d:\program files\python38\lib\site-packages\yapf\yapflib\yapf_api.py", 
line 147, in FormatCode
tree = pytree_utils.ParseCodeToTree(unformatted_source)
  File "d:\program 
files\python38\lib\site-packages\yapf\yapflib\pytree_utils.py", line 121, in 
ParseCodeToTree
tree = parser_driver.parse_string(code, debug=False)
  File "d:\program files\python38\lib\lib2to3\pgen2\driver.py", line 103, in 
parse_string
return self.parse_tokens(tokens, debug)
  File "d:\program files\python38\lib\lib2to3\pgen2\driver.py", line 71, in 
parse_tokens
if p.addtoken(type, value, (prefix, start)):
  File "d:\program files\python38\lib\lib2to3\pgen2\parse.py", line 162, in 
addtoken
raise ParseError("bad input", type, value, context)
lib2to3.pgen2.parse.ParseError: bad input: type=17, value='/', context=(' ', 
(1, 28))

--
components: 2to3 (2.x to 3.x conversion tool)
messages: 392396
nosy: cloud-yu
priority: normal
severity: normal
status: open
title: lib2to3 fails on a slash('/') after positional_only paramter in a 
function signature
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



[issue43985] lib2to3 fails on a slash('/') after positional_only paramter in a function signature

2021-04-30 Thread Christian Heimes

Christian Heimes  added the comment:

The slash syntax was introduced in 3.8. I guess the grammar of lib2to3 was not 
updated to support new syntax elements.

Łukasz, could you please take a look?

--
nosy: +christian.heimes, lukasz.langa

___
Python tracker 

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



[issue43985] lib2to3 fails on a slash('/') after positional_only paramter in a function signature

2021-04-30 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

https://bugs.python.org/issue36541 add support for walrus operator and 
positional arguments. Relevant commit : 
https://github.com/python/cpython/commit/06bfd033e847bedb6e123d131dcf46393a4555df

Relevant yapf issue on python 3.8 support : 
https://github.com/google/yapf/issues/772

Can you please add the exact python version you are using?

--
nosy: +xtreak

___
Python tracker 

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



[issue43985] lib2to3 fails on a slash('/') after positional_only paramter in a function signature

2021-04-30 Thread MisterY


MisterY  added the comment:

python 3.8.3

--

___
Python tracker 

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



[issue43985] lib2to3 fails on a slash('/') after positional_only paramter in a function signature

2021-04-30 Thread Karthikeyan Singaravelan


Karthikeyan Singaravelan  added the comment:

Thanks, the change was merged in December 14, 2020 just missing 3.8.7 . Can you 
please upgrade to 3.8.8 or 3.8.9 and try? If the issue still persists I guess 
it's then an issue with yapf since Python 3.8.8 has the code merged with tests.

--

___
Python tracker 

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



[issue43951] Two minor fixes for C module object

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

commit 175a54b2d8f967605f1d46b5cadccdcf2b54842f
Author: larryhastings 
Date:   Thu Apr 29 20:13:25 2021 -0700

Two minor fixes for accessing a module's name. (#25658)

While working on another issue, I noticed two minor nits in the C 
implementation of the module object.  Both are related to getting a module's 
name.

First, the C function module_dir() (module.__dir__) starts by ensuring the 
module dict is valid.  If the module dict is invalid, it wants to format an 
exception using the name of the module, which it gets from PyModule_GetName().  
However, PyModule_GetName() gets the name of the module from the dict.  So 
getting the name in this circumstance will never succeed.

When module_dir() wants to format the error but can't get the name, it 
knows that PyModule_GetName() must have already raised an exception.  So it 
leaves that exception alone and returns an error.  The end result is that the 
exception raised here is kind of useless and misleading: dir(module) on a 
module with no __dict__ raises SystemError("nameless module").  I changed the 
code to actually raise the exception it wanted to raise, just without a real 
module name: TypeError(".__dict__ is not a dictionary").  This seems 
more useful, and would do a better job putting the programmer who encountered 
this on the right track of figuring out what was going on.

Second, the C API function PyModule_GetNameObject() checks to see if the 
module has a dict.  If m->md_dict is not NULL, it calls 
_PyDict_GetItemIdWithError().  However, it's possible for m->md_dict to be 
None.  And if you call _PyDict_GetItemIdWithError(Py_None, ...) it will *crash*.

Unfortunately, this crash was due to my own bug in the other branch.  
Fixing my code made the crash go away.  I assert that this is still possible at 
the API level.

The fix is easy: add a PyDict_Check() to PyModule_GetNameObject().

Unfortunately, I don't know how to add a unit test for this.  Having 
changed module_dir() above, I can't find any other interfaces callable from 
Python that eventually call PyModule_GetNameObject().  So I don't know how to 
trick the runtime into reproducing this error.

Since both these changes are minor--each entails only a small edit to only 
one line--I didn't bother with a news item.

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Victor:
> check_set_special_type_attr() is used to prevent setting the following 
> attributes:
> [...]
> Right now, I cannot set the attribues on array.array type:
> [...]
> I guess that type_setattro() is used and it checks for 
> Py_TPFLAGS_IMMUTABLETYPE flag early.

Is this always the case? If so, can we turn the check in 
check_set_special_type_attr() into an assert? In any case, 
Py_TPFLAGS_IMMUTABLETYPE should be used, not !Py_TPFLAGS_HEAPTYPE.

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

> Is this always the case? If so, can we turn the check in 
> check_set_special_type_attr() into an assert? In any case, 
> Py_TPFLAGS_IMMUTABLETYPE should be used, not !Py_TPFLAGS_HEAPTYPE.

I don't know. In case of doubt, I suggest to only replace !Py_TPFLAGS_HEAPTYPE 
with Py_TPFLAGS_IMMUTABLETYPE.

--

___
Python tracker 

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



[issue43973] Use Py_TPFLAGS_IMMUTABLETYPE in __class__ assignments check

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset b73b5fb9ea08156991a065c1696e8d8cf7622482 by Erlend Egeberg 
Aasland in branch 'master':
 bpo-43973: object_set_class() checks Py_TPFLAGS_IMMUTABLETYPE (GH-25714)
https://github.com/python/cpython/commit/b73b5fb9ea08156991a065c1696e8d8cf7622482


--

___
Python tracker 

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



[issue43973] Use Py_TPFLAGS_IMMUTABLETYPE in __class__ assignments check

2021-04-30 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Ok! Did you see bpo-24912 regarding the ModuleType check?

--

___
Python tracker 

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



[issue43973] Use Py_TPFLAGS_IMMUTABLETYPE in __class__ assignments check

2021-04-30 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


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



[issue12883] xml.sax.xmlreader.AttributesImpl allows empty string as attribute names

2021-04-30 Thread Irit Katriel


Irit Katriel  added the comment:

I don't think the proposed patch is an acceptable solution. It silently skips 
invalid attributes.  

It would be ok to either raise an exception or to leave it as it is 
(junk-in-junk-out).  I'm not sure which is better.

--
nosy: +iritkatriel
versions: +Python 3.11 -Python 2.6

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Yep, I agree. From my coverage output, it seems that this branch is never 
executed. BUT, that may of course be because there's no test that exercises 
this branch.

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +24433
pull_request: https://github.com/python/cpython/pull/25743

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

Hum, another function should be updated. Do you want to propose a fix Erlend?

static int
type_set_annotations(PyTypeObject *type, PyObject *value, void *context)
{
if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) {
PyErr_Format(PyExc_TypeError, "can't set attributes of 
built-in/extension type '%s'", type->tp_name);
return -1;
}

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

I just found it myself :) pushing out the PR now!

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Included in GH-25743

--

___
Python tracker 

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



[issue24912] The type of cached objects is mutable

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

Update: a new Py_TPFLAGS_IMMUTABLETYPE flag was added in bpo-43908, and it's 
now checked rather than relying on Py_TPFLAGS_HEAPTYPE to decide if a type is 
"mutable" or not.

--
nosy: +ned.deily

___
Python tracker 

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



[issue43973] Use Py_TPFLAGS_IMMUTABLETYPE in __class__ assignments check

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

> Ok! Did you see bpo-24912 regarding the ModuleType check?

No, I didn't. Sorry, there are too many things to look at, and too little bit. 
Do you think that something should be changed? If yes, please open a new 
separated issue.

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

See also bpo-24912 "The type of cached objects is mutable".

--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 3bb09947ec4837de75532e21dd4bd25db0a1f1b7 by Victor Stinner in 
branch 'master':
bpo-43916: Add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag (GH-25721)
https://github.com/python/cpython/commit/3bb09947ec4837de75532e21dd4bd25db0a1f1b7


--

___
Python tracker 

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



[issue43916] Check that new heap types cannot be created uninitialised: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


Change by STINNER Victor :


--
title: Check that new heap types cannot be created uninitialised -> Check that 
new heap types cannot be created uninitialised: add 
Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


Change by STINNER Victor :


--
title: Check that new heap types cannot be created uninitialised: add 
Py_TPFLAGS_DISALLOW_INSTANTIATION type flag -> Mark static types newly 
converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION 
type flag

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


Change by STINNER Victor :


--
components: +C API

___
Python tracker 

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



[issue43973] Use Py_TPFLAGS_IMMUTABLETYPE in __class__ assignments check

2021-04-30 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

> Do you think that something should be changed? If yes, please open a new 
> separated issue.

No, my comment was just for information :)

--

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24434
pull_request: https://github.com/python/cpython/pull/25745

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

PyStdPrinter_Type implements tp_new, but tp_init always fail:

static int
stdprinter_init(PyObject *self, PyObject *args, PyObject *kwds)
{
PyErr_SetString(PyExc_TypeError,
"cannot create 'stderrprinter' instances");
return -1;
}

Maybe it should use the Py_TPFLAGS_IMMUTABLETYPE flag instead?

Instances must be created with PyFile_NewStdPrinter() which doesn't use tp_new 
nor tp_init.

Erlend: do you want to propose a PR?

--

___
Python tracker 

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



[issue43986] ipaddress: increment/decrement on IPv*Interface disregards bitmask prefix

2021-04-30 Thread Kat Hoessel


New submission from Kat Hoessel :

IPv4 and IPv6 interface objects of the `ipaddress` library show unexpected 
behaviour when arithmetic operators like + (increment) and - (decrement) are 
run on them.


`ipaddress` interfaces can be incremented/decremented, similar to IP addresses.
Currently, there are two problems with how these operations are implemented for 
interfaces within this library.
This applies to both IPv4 and IPv6, and may yield incorrect and inconsistent 
results.


1. Increment/decrement on an interface overrides subnet prefix length

The resulting interface will always have a prefix length of /32 for IPv4, /128 
for IPv6, regardless of the original interface prefix. (See iPython code 
examples below.)
This behaviour is incomprehensible and unexpected.


2. Increment/decrement on an interface does not respect subnet arithmetic

For example,

ipaddress.ip_interface('10.0.0.1/24') + 255

has no valid result under subnet arithmetic.
`ipaddress` however, incorrectly returns

IPv4Interface('10.0.1.0/32')


It is likely that the behaviour seen in 2) logically follows after 1).
Both are assumedly related to the fact that IPv*Interface is a subclass of 
IPv*Address with inherited properties.


To achieve consistent behaviour for interfaces under +/-, I would suggest to 
either

  a) make sure that +/- operators on interfaces preserve the prefix and respect 
subnet arithmetic, or
  b) forbid +/- operators on interfaces.

My preferred solution would be a). I would be interested in providing a patch, 
given that the observed behaviour is confirmed as a bug.



### IPv4

In [1]: import ipaddress

In [2]: iff = ipaddress.ip_interface('10.0.0.1/24')

In [3]: iff
Out[3]: IPv4Interface('10.0.0.1/24')

In [4]: iff1 = iff + 1

In [5]: iff1
Out[5]: IPv4Interface('10.0.0.2/32')

In [6]: iff.network.prefixlen
Out[6]: 24

In [7]: iff1.network.prefixlen
Out[7]: 32

### overflow

In [8]: iff + 255  # this should not work
Out[8]: IPv4Interface('10.0.1.0/32')

### IPv6

In [9]: iff = ipaddress.ip_interface('1:1:1:2::1/64')

In [10]: iff
Out[10]: IPv6Interface('1:1:1:2::1/64')

In [11]: iff + 1
Out[11]: IPv6Interface('1:1:1:2::2/128')

### version information

In [12]: import sys

In [13]: sys.version
Out[13]: '3.8.3 (default, Aug 31 2020, 16:03:14) \n[GCC 8.3.1 20191121 (Red Hat 
8.3.1-5)]'

--
components: Library (Lib)
messages: 392417
nosy: katsel
priority: normal
severity: normal
status: open
title: ipaddress: increment/decrement on IPv*Interface disregards bitmask prefix
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



[issue15443] datetime module has no support for nanoseconds

2021-04-30 Thread Mark Dickinson


Mark Dickinson  added the comment:

[Alexander]

> Is there high enough demand for nanoseconds in datetime and time instances?

One need that we've encountered in real code is simply for compatibility. We 
have Python code that interacts with a logging web service whose timestamps 
include nanosecond information. Whether or not nanosecond resolution makes 
sense for those timestamps is a moot point: that's out of our control.

When representing information retrieved from that web service in Python-land, 
we have a problem. If datetime.datetime had nanosecond precision, then using 
datetime.datetime to represent the retrieved values would be a no-brainer. As 
it is, we face a choice between:

- truncating or rounding to microsecond precision, and losing information as a 
result (which is particularly problematic if we want to write records back at 
any point)
- representing in some indirect form (as a str, an integer number of 
nanoseconds, a (datetime, nanoseconds) tuple, ...) and requiring the user to 
convert values for plotting or other analysis
- writing our own non-standard ns-supporting datetime class, or looking for a 
3rd party library with that support

None of those choices are terrible, but none of them are particularly palatable 
compared with using a standard library solution. (FWIW, we went with option 2, 
returning nanoseconds since the Unix epoch as an int.)

--

___
Python tracker 

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



[issue43987] Add "Annotations Best Practices" to HOWTO

2021-04-30 Thread Larry Hastings


New submission from Larry Hastings :

Dealing with annotations is complicated.  I think there should be a section of 
the Python documentation describing best practices for working
with annotations.  So, here goes.

The best spot I found for it was as a new HOWTO.  I added links to that HOWTO 
to a couple relevant glossary definitions, and one in the documentation for 
inspect.get_annotations().  I'm not sure if it makes sense to add any other 
links; I considered adding links to the HOWTO to where the __annotations__ 
attribute is defined on functions, modules, and classes, in 
reference/datamodel.rst, but it just didn't seem like a good idea.

--
assignee: larry
components: Documentation
messages: 392419
nosy: larry
priority: normal
severity: normal
stage: needs patch
status: open
title: Add "Annotations Best Practices" to HOWTO
type: enhancement
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



[issue24912] The type of cached objects is mutable

2021-04-30 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
nosy: +erlendaasland
nosy_count: 17.0 -> 18.0
pull_requests: +24435
pull_request: https://github.com/python/cpython/pull/25714

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

https://docs.python.org/dev/c-api/typeobj.html#Py_TPFLAGS_IMMUTABLETYPE says:
"This bit is set for type objects that are immutable: type attributes cannot be 
set nor deleted."

Is it possible that a metatype (type subtype) overrides tp_setattro and ignores 
the Py_TPFLAGS_IMMUTABLETYPE flag? Should we suggest that metatypes implemented 
in C and overridding tp_setattro should take the Py_TPFLAGS_IMMUTABLETYPE flag 
in account?

When a type overrides tp_setattro, I understand that it's fine since it's only 
used to set attributes of its instances, not on the type itself.

--

See also bpo-43770 "Rework C types initialization": some types explicitly sets 
explicitly tp_setattro to PyObject_GenericSetAttr. But it's unrelated since 
it's used to set attributes of type instances.

--

___
Python tracker 

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



[issue43987] Add "Annotations Best Practices" to HOWTO

2021-04-30 Thread Larry Hastings


Change by Larry Hastings :


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

___
Python tracker 

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



[issue43987] Add "Annotations Best Practices" to HOWTO

2021-04-30 Thread Larry Hastings


Change by Larry Hastings :


--
nosy: +Jelle Zijlstra

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

Erlend: would you mind to document the new Py_TPFLAGS_IMMUTABLETYPE flag in the 
C API section of What's New in Python 3.10?
https://docs.python.org/dev/whatsnew/3.10.html#c-api-changes

In "New Features", something like:

* Add a new :c:data:`Py_TPFLAGS_IMMUTABLETYPE` type flag to (...).
  (Contributed by xxx in :issue:`43908`.)

And in the "Porting to Python 3.10", I don't know if we should suggest 
reviewing metatypes implemented in C which overrides tp_setattro, to take the 
new flag in account.

Maybe explain that Py_TPFLAGS_IMMUTABLETYPE should now be checked to decide if 
a type is mutable or not, rather than relying on Py_TPFLAGS_HEAPTYPE.

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Erlend Egeberg Aasland

Erlend Egeberg Aasland  added the comment:

Yes, I’ll have a look at it this afternoon. (On mobile now.)

--

___
Python tracker 

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



[issue36384] [security] CVE-2021-29921: ipaddress Should not reject IPv4 addresses with leading zeroes as ambiguously octal

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

The CVE-2021-29921 was assigned to this vulnerability.

--
title: ipaddress Should not reject IPv4 addresses with leading zeroes as 
ambiguously octal -> [security] CVE-2021-29921: ipaddress Should not reject 
IPv4 addresses with leading zeroes as ambiguously octal

___
Python tracker 

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



[issue43981] test_idle is leaking references

2021-04-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I will try to investigate today or tomorrow but notice that is very possible 
that the leak is somewhere else in the interpreter and is just showing in the 
IDLE tests.

--

___
Python tracker 

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



[issue37387] test_compileall fails randomly on Windows when tests are run in parallel

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

I proposed a way to fix the issue:

"Maybe the test should copy all .py files of the stdlib into a temporary 
directory and work there, to not impact other tests run in parallel."


Shreyan Avigyan:
> Though I've never been able to reproduce this test failure. Maybe it's fixed 
> (maybe it was a side effect of another test)?

It's a race condition. It's hard to reproduce in a reliable way, but I'm sure 
that it has not been fixed.

The bug happens when one process tries to recreate the .pyc, whereas another 
process has the old .pyc file open. You can maybe make the issue more likely by 
adding a sleep in the code reading pyc content.

For example, in the FileLoader.get_data() method of 
importlib._bootstrap_external. Hacking importlib is non trivial, since the 
Python code is compiled as a frozen module.

--

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 0cad068ec174bbe33fb80460da56eb413f3b9359 by Victor Stinner in 
branch 'master':
bpo-43916: Remove _disabled_new() function (GH-25745)
https://github.com/python/cpython/commit/0cad068ec174bbe33fb80460da56eb413f3b9359


--

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +24437
pull_request: https://github.com/python/cpython/pull/25748

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24438
pull_request: https://github.com/python/cpython/pull/25749

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 4908fae3d57f68694cf006e89fd7761f45003447 by Victor Stinner in 
branch 'master':
bpo-43916: PyStdPrinter_Type uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25749)
https://github.com/python/cpython/commit/4908fae3d57f68694cf006e89fd7761f45003447


--

___
Python tracker 

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



[issue43922] Double dots in quopri transported emails

2021-04-30 Thread Julien Castiaux


Julien Castiaux  added the comment:

Fix deployed in the third party

--
resolution:  -> third party
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



[issue43667] Solaris: Fix broken Unicode encoding in non-UTF locales

2021-04-30 Thread STINNER Victor

STINNER Victor  added the comment:


New changeset 9032cf5cb1e33c0349089cfb0f6bf11ed3c30e86 by Jakub Kulík in branch 
'master':
bpo-43667: Fix broken Unicode encoding in non-UTF locales on Solaris (GH-25096)
https://github.com/python/cpython/commit/9032cf5cb1e33c0349089cfb0f6bf11ed3c30e86


--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 64141382ecbad665d5738ff26d15505f3427c724 by Erlend Egeberg 
Aasland in branch 'master':
bpo-43908: check_set_special_type_attr() checks Py_TPFLAGS_IMMUTABLETYPE 
(GH-25743)
https://github.com/python/cpython/commit/64141382ecbad665d5738ff26d15505f3427c724


--

___
Python tracker 

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



[issue40222] "Zero cost" exception handling

2021-04-30 Thread Mark Shannon


Change by Mark Shannon :


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

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
pull_requests: +24439
pull_request: https://github.com/python/cpython/pull/25750

___
Python tracker 

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-04-30 Thread Mark Shannon


Mark Shannon  added the comment:


New changeset 5979e81a212949c62c2490167c9137d233d7de64 by Mark Shannon in 
branch 'master':
bpo-43933:  Set frame.f_lineno during call to __exit__ (GH-25719)
https://github.com/python/cpython/commit/5979e81a212949c62c2490167c9137d233d7de64


--

___
Python tracker 

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-04-30 Thread Mark Shannon


Mark Shannon  added the comment:

I'm claiming that this is fixed.

Feel free to reopen if the additional line in tracing causes a problem.

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 387397f8a4244c983f4568c16a28842e3268fe5d by Erlend Egeberg 
Aasland in branch 'master':
bpo-43916: select.poll uses Py_TPFLAGS_DISALLOW_INSTANTIATION (GH-25750)
https://github.com/python/cpython/commit/387397f8a4244c983f4568c16a28842e3268fe5d


--

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:


New changeset 9746cda705decebc0ba572d95612796afd06dcd4 by Erlend Egeberg 
Aasland in branch 'master':
bpo-43916: Apply Py_TPFLAGS_DISALLOW_INSTANTIATION to selected types (GH-25748)
https://github.com/python/cpython/commit/9746cda705decebc0ba572d95612796afd06dcd4


--

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread Erlend Egeberg Aasland


Erlend Egeberg Aasland  added the comment:

Pablo & Serhiy, can we close this issue now?

--

___
Python tracker 

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



[issue4130] Intel icc 9.1 does not support __int128_t used by ctypes

2021-04-30 Thread Irit Katriel


Change by Irit Katriel :


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



[issue43988] Add test.support.assert_dissallow_instantiation

2021-04-30 Thread Erlend Egeberg Aasland


New submission from Erlend Egeberg Aasland :

See https://github.com/python/cpython/pull/25748#discussion_r623849521:
"What do you think of adding support.assert_disallow_instanciation(type, *args) 
function which would check for TypeError but also check the error message? 
TypeError is quite generic and it might hide a bug."


Ref. bpo-43916.

--
components: Tests
messages: 392436
nosy: erlendaasland, vstinner
priority: normal
severity: normal
status: open
title: Add test.support.assert_dissallow_instantiation

___
Python tracker 

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



[issue43988] Add test.support.assert_dissallow_instantiation

2021-04-30 Thread Erlend Egeberg Aasland


Change by Erlend Egeberg Aasland :


--
type:  -> enhancement

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

Currently, 33 types explicitly set the Py_TPFLAGS_DISALLOW_INSTANTIATION flag:

* PyStdPrinter_Type
* _curses.ncurses_version type
* _curses_panel.panel
* _dbm.dbm
* _gdbm.gdbm
* _hashlib.HASH
* _hashlib.HASHXOF
* _hashlib.HMAC
* _multibytecodec.MultibyteCodec
* _sre..SRE_Scanner
* _thread._localdummy
* _thread.lock
* _tkinter.Tcl_Obj
* _tkinter.tkapp
* _tkinter.tktimertoken
* _winapi.Overlapped
* _xxsubinterpretersmodule.ChannelID
* array.arrayiterator
* functools.KeyWrapper
* functools._lru_list_elem
* os.DirEntry
* os.ScandirIterator
* pyexpat.xmlparser
* re.Match
* re.Pattern
* select.poll
* sys.flags type
* sys.getwindowsversion() type
* sys.version_info type
* unicodedata.UCD
* zlib.Compress
* zlib.Decompress
* _xxsubinterpreters.ChannelID

---

Static types with tp_base=NULL (or tp_base=&PyBaseObject_Type) and tp_new=NULL 
get Py_TPFLAGS_DISALLOW_INSTANTIATION flag automatically. Example of 70 static 
types which gets this flag automatically:

* CArgObject
* EncodingMap
* Generic
* GenericAlias
* PyCapsule
* TaskStepMethWrapper
* Token.MISSING
* _RunningLoopHolder
* _asyncio.FutureIter
* _ctypes.CThunkObject
* _ctypes.StructParam_Type
* _ctypes._CData
* _elementtree._element_iterator
* _io._BytesIOBuffer
* _pickle.Pdata
* _pickle.PicklerMemoProxy
* _pickle.UnpicklerMemoProxy
* _xxsubinterpreters.ChannelID
* anext_awaitable
* async_generator
* async_generator_asend
* async_generator_athrow
* async_generator_wrapped_value
* builtin_function_or_method
* bytearray_iterator
* bytes_iterator
* callable_iterator
* classmethod_descriptor
* coroutine
* coroutine_wrapper
* decimal.ContextManager
* dict_itemiterator
* dict_items
* dict_keyiterator
* dict_keys
* dict_reverseitemiterator
* dict_reversekeyiterator
* dict_reversevalueiterator
* dict_valueiterator
* dict_values
* fieldnameiterator
* formatteriterator
* frame
* generator
* getset_descriptor
* hamt_array_node
* hamt_bitmap_node
* hamt_collision_node
* items
* iterator
* keys
* list_iterator
* list_reverseiterator
* longrange_iterator
* managedbuffer
* member_descriptor
* method-wrapper
* method_descriptor
* moduledef
* odict_iterator
* range_iterator
* set_iterator
* str_iterator
* symtable entry
* tuple_iterator
* types.Union
* values
* weakcallableproxy
* weakproxy
* wrapper_descriptor

--

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

I remove the release blocker priority of this issue, since the main issue has 
been fixed.

--
priority: release blocker -> 

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

Currently, 4 types are declared with Py_TPFLAGS_IMMUTABLETYPE explicitly:

* array.array
* re.Pattern
* re.Match
* _sre.SRE_Scanner

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

Moreover, all static types get the Py_TPFLAGS_IMMUTABLETYPE flag automatically. 
For example, "./python -c pass" initializes 196 immutable static types:

* ArithmeticError
* AssertionError
* AttributeError
* BaseException
* BlockingIOError
* BrokenPipeError
* BufferError
* BytesWarning
* ChildProcessError
* ConnectionAbortedError
* ConnectionError
* ConnectionRefusedError
* ConnectionResetError
* DeprecationWarning
* EOFError
* EncodingMap
* EncodingWarning
* Exception
* FileExistsError
* FileNotFoundError
* FloatingPointError
* FutureWarning
* GeneratorExit
* ImportError
* ImportWarning
* IndentationError
* IndexError
* InterpreterID
* InterruptedError
* IsADirectoryError
* KeyError
* KeyboardInterrupt
* LookupError
* MemoryError
* ModuleNotFoundError
* NameError
* NoneType
* NotADirectoryError
* NotImplementedError
* NotImplementedType
* OSError
* OverflowError
* PendingDeprecationWarning
* PermissionError
* ProcessLookupError
* PyCapsule
* RecursionError
* ReferenceError
* ResourceWarning
* RuntimeError
* RuntimeWarning
* StopAsyncIteration
* StopIteration
* SyntaxError
* SyntaxWarning
* SystemError
* SystemExit
* TabError
* TimeoutError
* Token.MISSING
* TypeError
* UnboundLocalError
* UnicodeDecodeError
* UnicodeEncodeError
* UnicodeError
* UnicodeTranslateError
* UnicodeWarning
* UnraisableHookArgs
* UserWarning
* ValueError
* Warning
* ZeroDivisionError
* _contextvars.Context
* _contextvars.ContextVar
* _contextvars.Token
* _io.BufferedRWPair
* _io.BufferedRandom
* _io.BufferedReader
* _io.BufferedWriter
* _io.BytesIO
* _io.FileIO
* _io.IncrementalNewlineDecoder
* _io.StringIO
* _io.TextIOWrapper
* _io._BufferedIOBase
* _io._BytesIOBuffer
* _io._IOBase
* _io._RawIOBase
* _io._TextIOBase
* _thread._ExceptHookArgs
* anext_awaitable
* async_generator
* async_generator_asend
* async_generator_athrow
* async_generator_wrapped_value
* asyncgen_hooks
* bool
* builtin_function_or_method
* builtin_method
* bytearray
* bytearray_iterator
* bytes
* bytes_iterator
* callable_iterator
* cell
* classmethod
* classmethod_descriptor
* code
* collections.OrderedDict
* complex
* coroutine
* coroutine_wrapper
* dict
* dict_itemiterator
* dict_items
* dict_keyiterator
* dict_keys
* dict_reverseitemiterator
* dict_reversekeyiterator
* dict_reversevalueiterator
* dict_valueiterator
* dict_values
* ellipsis
* enumerate
* fieldnameiterator
* filter
* float
* formatteriterator
* frame
* frozenset
* function
* generator
* getset_descriptor
* hamt
* hamt_array_node
* hamt_bitmap_node
* hamt_collision_node
* instancemethod
* int
* items
* iterator
* keys
* list
* list_iterator
* list_reverseiterator
* longrange_iterator
* managedbuffer
* map
* mappingproxy
* member_descriptor
* memoryview
* method
* method-wrapper
* method_descriptor
* module
* moduledef
* object
* odict_items
* odict_iterator
* odict_keys
* odict_values
* pickle.PickleBuffer
* property
* range
* range_iterator
* reversed
* set
* set_iterator
* signal.struct_siginfo
* slice
* staticmethod
* stderrprinter
* str
* str_iterator
* super
* symtable entry
* sys.flags
* sys.float_info
* sys.hash_info
* sys.int_info
* sys.thread_info
* sys.version_info
* time.struct_time
* traceback
* tuple
* tuple_iterator
* type
* types.GenericAlias
* types.SimpleNamespace
* types.Union
* values
* weakcallableproxy
* weakproxy
* weakref
* wrapper_descriptor
* zip

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Victor, the types, that Py_TPFLAGS_IMMUTABLETYPE flag is yet to be applied to, 
are different for 3.9 and 3.10. Should we proceed with that? (If yes I'd be 
happy to collaborate with Erlend to apply the flag on those types.)

--

___
Python tracker 

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



[issue14243] tempfile.NamedTemporaryFile not particularly useful on Windows

2021-04-30 Thread Zachary Ware


Zachary Ware  added the comment:

> if NamedTemporaryFile is used as a context manager, the file is closed *on 
> context manager exit* and *not* when the file is closed.

+1

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

> Victor, the types, that Py_TPFLAGS_IMMUTABLETYPE flag is yet to be applied 
> to, are different for 3.9 and 3.10. Should we proceed with that? (If yes I'd 
> be happy to collaborate with Erlend to apply the flag on those types.)

Please don't change the behavior in the 3.9 stable branch.

--

___
Python tracker 

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



[issue37387] test_compileall fails randomly on Windows when tests are run in parallel

2021-04-30 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Ok

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Ok

--

___
Python tracker 

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



[issue43908] array.array should remain immutable: add Py_TPFLAGS_IMMUTABLETYPE flag

2021-04-30 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

Ok

--

___
Python tracker 

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



[issue43710] Access violations in C extension modules on Python 3.9.3

2021-04-30 Thread Anjali Singh


Change by Anjali Singh :


Added file: 
https://bugs.python.org/file50002/Screenshot_20210426-104915_Lucknow Public 
School.jpg

___
Python tracker 

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



[issue14243] tempfile.NamedTemporaryFile not particularly useful on Windows

2021-04-30 Thread Paul Moore


Paul Moore  added the comment:

Looking at the various comments, I think we have 5 votes for deleting on CM 
exit when used as a CM, and no change in behaviour otherwise (me, Zachary, 
Ethan, Jason and Steve). Steve also wants O_TEMPORARY to be removed, which 
doesn't seem controversial among this group of people.

Eryk has argued for a delete_on_close flag that would need to be explicitly set 
to False, retaining the use of O_TEMPORARY in the default case, but there 
doesn't seem to be a lot of support for that.

If I've misrepresented anyone's view, please speak up!

I didn't look back at the stuff from 2013 and earlier, I'll admit.

I do think this needs care to implement (and document!) correctly. For example, 
consider the following case:

ntf = NamedTemporaryFile()
# Do some stuff (1)
with ntf:
# Do some stuff (2)
# Do some followup stuff

I assume we'd want a close in (1) to delete the file, but a close in (2) to 
leave it open until the CM exit.

Evgeny, would you be willing to update your PR (including adding the docs 
change, and tests to catch as many edge cases as you can think up) to match 
this behaviour?

--

___
Python tracker 

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



[issue43710] Access violations in C extension modules on Python 3.9.3

2021-04-30 Thread Zachary Ware


Change by Zachary Ware :


Removed file: https://bugs.python.org/file49966/logs.gz

___
Python tracker 

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



[issue43710] Access violations in C extension modules on Python 3.9.3

2021-04-30 Thread Zachary Ware


Change by Zachary Ware :


Removed file: 
https://bugs.python.org/file50002/Screenshot_20210426-104915_Lucknow Public 
School.jpg

___
Python tracker 

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



[issue43933] Regression in python3.10 with traceback frame having lineno of -1

2021-04-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Thanks Mark for the quick fix!

Can someone confirm if the pytest issue is fixed?

--

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

Unfortunately commit 2f2b69855d6524e15d12c15ddc0adce629e7de84 has broken the 
buildbots:

==
FAIL: test_annotations_are_created_correctly (test.test_module.ModuleTests)
--
Traceback (most recent call last):
  File 
"D:\buildarea\3.x.ware-win81-release.refleak\build\lib\test\test_module.py", 
line 338, in test_annotations_are_created_correctly
self.assertTrue("__annotations__" in ann_module4.__dict__)
AssertionError: False is not true
--

Example failure:

https://buildbot.python.org/all/#/builders/511/builds/12/steps/4/logs/stdio

--
nosy: +pablogsal
resolution: fixed -> 
status: closed -> open

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
priority: normal -> release blocker

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

I think that test_annotations_are_created_correctly should use the 
import_helper.import_fresh_module helper

--

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24441
pull_request: https://github.com/python/cpython/pull/25751

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Larry Hastings


Larry Hastings  added the comment:

Gee whiz!  Sorry about that.  I swear, it works fine on my machine.

I'll incorporate import_helper.import_fresh_module helper into the test as you 
suggest, and once I get it to work I'll send you a PR.  I don't know how to 
test fixing this failure, though, because again it already works fine on my 
machine.

Why would it fail on Windows?  Are there dramatic differences under the covers 
with respect to the import machinery and caching and such between POSIX and 
Windows?

--

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

According to msg391924, more types should use Py_TPFLAGS_DISALLOW_INSTANTIATION:

* _md5.md5
* _sha1.sha1
* _sha256.sha224
* _sha256.sha256
* _sha512.sha384
* _sha512.sha512

* select.devpoll: I created PR 25751
* select.kevent: it implements a working tp_new method: "{Py_tp_new, 
select_kqueue},"

* sqlite3.Cache
* sqlite3.Connection
* sqlite3.Cursor
* sqlite3.Node
* sqlite3.Row
* sqlite3.Statement

--

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Pablo Galindo Salgado

Pablo Galindo Salgado  added the comment:

Oh, actually is workse because commenting out the test shows refleaks:

𓋹 ./python.exe -m test test_module -R :
0:00:00 load avg: 5.03 Run tests sequentially
0:00:00 load avg: 5.03 [1/1] test_module
beginning 9 repetitions
123456789
.
test_module leaked [47, 47, 47, 47] references, sum=188
test_module leaked [6, 6, 6, 6] memory blocks, sum=24
test_module failed

== Tests result: FAILURE ==

1 test failed:
test_module

Total duration: 2.0 sec

--

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

>> Why would it fail on Windows?

It fails on all refleak buildbots. To reproduce:

% ./configure --with-pydebug -C && make -j -s
% ./python.exe -m test test_module -R :

--

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


Change by STINNER Victor :


--
pull_requests: +24443
pull_request: https://github.com/python/cpython/pull/25753

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Larry Hastings


Change by Larry Hastings :


--
pull_requests: +24442
stage: resolved -> patch review
pull_request: https://github.com/python/cpython/pull/25752

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Larry Hastings


Larry Hastings  added the comment:

Eek!  I swear I did a refleak check and got a clean bill of health.  Again, 
sorry about this!

--

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Pablo Galindo Salgado


Change by Pablo Galindo Salgado :


--
pull_requests: +2
pull_request: https://github.com/python/cpython/pull/25754

___
Python tracker 

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



[issue43916] Mark static types newly converted to heap types as immutable: add Py_TPFLAGS_DISALLOW_INSTANTIATION type flag

2021-04-30 Thread STINNER Victor


STINNER Victor  added the comment:

* _md5.md5
* _sha1.sha1
* _sha256.sha224
* _sha256.sha256
* _sha512.sha384
* _sha512.sha512

I created PR 25753.

--

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Pablo Galindo Salgado


Pablo Galindo Salgado  added the comment:

> Eek!  I swear I did a refleak check and got a clean bill of health.  Again, 
> sorry about this!

No problem at all! I'm sure we can fix this on time :)

Opened https://github.com/python/cpython/pull/25754 for the refleaks

--

___
Python tracker 

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



[issue43901] Lazy-create an empty annotations dict in all unannotated user classes and modules

2021-04-30 Thread Larry Hastings


Larry Hastings  added the comment:

You want a separate PR for the refleak fix, or should I roll them both up into 
one?

--

___
Python tracker 

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



[issue43984] [security]winreg.SetValueEx shoule check the returned value

2021-04-30 Thread Shreyan Avigyan


Shreyan Avigyan  added the comment:

+1 on my side.

--
nosy: +paul.moore, shreyanavigyan, steve.dower, stutzbach, tim.golden, zach.ware

___
Python tracker 

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



[issue29753] [Linux] ctypes packs bitfields Incorrectly

2021-04-30 Thread Filipe Laíns

Filipe Laíns  added the comment:

I forgot to ping here, the patch went in and should be available in 3.10, so 
this can be closed now.

--
nosy: +jaraco

___
Python tracker 

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



  1   2   3   >