[issue42111] Make the xxlimited module an example of best extension module practices

2020-10-21 Thread Petr Viktorin
New submission from Petr Viktorin : The "xxlimited" module (Modules/xxlimited.c) was added as part of PEP 384 (Defining a Stable ABI), and is undocumented. As far as I can tell, it was added partly to test the stable ABI, and partly as an example of how to write a module (like

[issue40891] Use PEP 573 in functools

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: Here is a PR for _PyType_GetModuleByDef: https://github.com/python/cpython/pull/22835 -- ___ Python tracker <https://bugs.python.org/issue40

[issue1635741] Py_Finalize() doesn't clear all Python objects at exit

2020-10-20 Thread Petr Viktorin
Change by Petr Viktorin : -- nosy: +petr.viktorin nosy_count: 18.0 -> 19.0 pull_requests: +21792 pull_request: https://github.com/python/cpython/pull/22838 ___ Python tracker <https://bugs.python.org/issue1

[issue42100] Add _PyType_GetModuleByDef

2020-10-20 Thread Petr Viktorin
Change by Petr Viktorin : -- keywords: +patch pull_requests: +21789 stage: -> patch review pull_request: https://github.com/python/cpython/pull/22835 ___ Python tracker <https://bugs.python.org/issu

[issue42100] Add _PyType_GetModuleByDef

2020-10-20 Thread Petr Viktorin
Change by Petr Viktorin : -- components: +C API type: -> enhancement versions: +Python 3.10 ___ Python tracker <https://bugs.python.org/issue42100> ___ ___ Py

[issue42100] Add _PyType_GetModuleByDef

2020-10-20 Thread Petr Viktorin
New submission from Petr Viktorin : I would like to add an internal _PyType_GetModuleByDef function to unblock further work on isolating extension modules, as discussed here: https://mail.python.org/archives/list/capi-...@python.org/thread/T3P2QNLNLBRFHWSKYSTPMVEIL2EEKFJU

[issue41726] Update refcounts info of PyType_FromModuleAndSpec in refcounts.dat

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset 38a17d0752781c70fd971f372ddc8d3caf5ded88 by Miss Skeleton (bot) in branch '3.9': bpo-41726: Update the refcounts info of PyType_FromModuleAndSpec in refcounts.dat (GH-22112) (GH-22808) https://github.com/python/cpython/commit

[issue41726] Update refcounts info of PyType_FromModuleAndSpec in refcounts.dat

2020-10-20 Thread Petr Viktorin
Change by Petr Viktorin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue40703] PyType_FromSpec*() overwrites the type's "__module__"

2020-10-20 Thread Petr Viktorin
Change by Petr Viktorin : -- resolution: fixed -> status: closed -> open ___ Python tracker <https://bugs.python.org/issue40703> ___ ___ Python-bugs-list

[issue40703] PyType_FromSpec*() overwrites the type's "__module__"

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: Thank you, Stefan! This should have a test as well. I'm willing to mentor someone who wants to get into the C-API, otherwise this has low priority for me. -- resolution: -> fixed stage: test needed -> resolved status: open -&g

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

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: Also: PyType_GetSlot should return a function pointer, not data. For some slots (Py_tp_doc, Py_tp_methods, Py_tp_members, Py_tp_getset) that ship has sailed, but for new ones, we should honor the distinction between data and function pointers. The C standard

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: Ah, scratch that: PyType_GetSlot returns a function pointer. To be correct, we should to expose a new function like PyType_GetName. It's true that CPython currently doesn't always honor the distinction between data and function pointers, but the C standard

[issue38787] PEP 573: Module State Access from C Extension Methods

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: Thanks Victor, Hai Shi, Pablo, Stefan, Dong-hee Na and Mariatta for reviews! I did not put all the details in the documentation because there are still feature gaps. So, a full write-up is now in the informational PEP 630. -- resolution: -> fi

[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: Also note that the capsule generally needs to hold references to the objects in exposes, and not rely on the module object to keep things alive. (Module objects with multi-phase init are not unique nor immortal.) _ctypes is an exception, since it doesn't have

[issue41726] Update refcounts info of PyType_FromModuleAndSpec in refcounts.dat

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: Definitely. Sorry for the delay -- I missed the notification here. -- ___ Python tracker <https://bugs.python.org/issue41

[issue42035] [C API] PyType_GetSlot cannot get tp_name

2020-10-20 Thread Petr Viktorin
Petr Viktorin added the comment: The slots are originally intended for defining types (PyType_FromSpec); PyType_GetSlot is not as useful as it could be. tp_name can be exposed, but it needs to also be handled properly PyType_FromSpec -- e.g. raise an error

[issue41798] [C API] Revisit usage of the PyCapsule C API with multi-phase initialization API

2020-09-16 Thread Petr Viktorin
Change by Petr Viktorin : -- nosy: +petr.viktorin ___ Python tracker <https://bugs.python.org/issue41798> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue41797] PyModule_GetState doesn't work with LazyLoader

2020-09-16 Thread Petr Viktorin
New submission from Petr Viktorin : One underlying issue from bpo-41631 is that importlib.util.LazyLoader produces modules that are only fully loaded after an attribute is accessed (through __getattribute__). C-API functions like PyModule_GetState, PyModule_GetDict and such do not get

[issue41796] _ast module state should be made per interpreter

2020-09-16 Thread Petr Viktorin
Petr Viktorin added the comment: I started this here: https://github.com/python/cpython/commit/60960cba606573450e76934c954787419524147d Feel free to take that code. -- nosy: +petr.viktorin ___ Python tracker <https://bugs.python.org/issue41

[issue41726] Update refcounts info of PyType_FromModuleAndSpec in refcounts.dat

2020-09-09 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset 1e2f051a6127904cfee5f9e4021dd6e4a4d51c0f by Hai Shi in branch 'master': bpo-41726: Update the refcounts info of PyType_FromModuleAndSpec in refcounts.dat (GH-22112) https://github.com/python/cpython/commit

[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-09-08 Thread Petr Viktorin
Petr Viktorin added the comment: That is interesting. The original post here doesn't mention that the problem occurs in Mercurial's "make all", specifically when building documentation, in the command: /usr/bin/python3.9 gendoc.py "hgrc.5" > hgrc.5.txt.tmp Coul

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

2020-09-08 Thread Petr Viktorin
Petr Viktorin added the comment: IMO, a slot should be exposed if there is some reason for exposing it. bpo-41073 talks about tp_dealloc, which is already exposed as Py_tp_dealloc. Recently, Py_bf_* slots were exposed (but not as part of the limited API), in bpo-40724 which links

[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-09-08 Thread Petr Viktorin
Petr Viktorin added the comment: We need this bug solved for 3.9.0 rc2. Łukasz, you're the one to make the call about the approach; how can we make your job easier? My view is: - Victor's PR 21961 is going in the right direction. But, as far as I know (correct me if I'm wrong), Victor

[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-09-08 Thread Petr Viktorin
Petr Viktorin added the comment: I also looked into Mercurial. They have a large list of modules [0] that don't work with the lazy-loading scheme. I don't think adding one more should be a big problem for them; but we'll reach out to them and confirm that. [0] https://www.mercurial

[issue38787] PEP 573: Module State Access from C Extension Methods

2020-08-27 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset d9a966ae08258da2ce2a432c943d8194760f09c4 by Petr Viktorin in branch 'master': bpo-38787: Clarify docs for PyType_GetModule and warn against common mistake (GH-20215) https://github.com/python/cpython/commit

[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Petr Viktorin
Change by Petr Viktorin : -- pull_requests: +21082 pull_request: https://github.com/python/cpython/pull/21973 ___ Python tracker <https://bugs.python.org/issue41

[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Petr Viktorin
Petr Viktorin added the comment: > Also, option 1 is virtually equivalent to the state of the _ast module prior > to the recent changes except that the symbols are in a shared object instead > of the binary or libpython. The advantage here is not moving them out of the > s

[issue41631] _ast module: get_global_ast_state() doesn't work with Mercurial lazy import

2020-08-26 Thread Petr Viktorin
Petr Viktorin added the comment: Regarding ac46eb4ad6662cf6d771b20d8963658b2186c48c: Module states come and go with the modules that contain them; if a "get_global_ast_state" or "astmodulestate_global" needs to be accessed from outside the module, it shouldn't be modul

[issue41168] Lack of proper checking in PyObject_SetAttr leads to segmentation fault

2020-08-11 Thread Petr Viktorin
Petr Viktorin added the comment: Closing; please re-open if you have more info. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Petr Viktorin
Change by Petr Viktorin : -- pull_requests: +20632 pull_request: https://github.com/python/cpython/pull/21489 ___ Python tracker <https://bugs.python.org/issue39

[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Petr Viktorin
Petr Viktorin added the comment: Larry and Ned, do you want this fix in the security-only releases you manage? PRs for 3.6 ad 3.7 are ready, should you wish to merge them. -- nosy: +larry, ned.deily -miss-islington ___ Python tracker <ht

[issue39017] Infinite loop in the tarfile module

2020-07-15 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset 5a8d121a1f3ef5ad7c105ee378cc79a3eac0c7d4 by Rishi in branch 'master': bpo-39017: Avoid infinite loop in the tarfile module (GH-21454) https://github.com/python/cpython/commit/5a8d121a1f3ef5ad7c105ee378cc79a3eac0c7d4 -- nosy

[issue41191] PyType_FromModuleAndSpec is not mentioned in 3.9 What's new

2020-07-07 Thread Petr Viktorin
Change by Petr Viktorin : -- keywords: +patch pull_requests: +20518 stage: -> patch review pull_request: https://github.com/python/cpython/pull/21374 ___ Python tracker <https://bugs.python.org/issu

[issue41043] Escape the literal part of the path for glob()

2020-07-01 Thread Petr Viktorin
Petr Viktorin added the comment: Would it be worth it to add a "base" keyword argument to glob.glob? -- nosy: +petr.viktorin ___ Python tracker <https://bugs.python.o

[issue41168] Lack of proper checking in PyObject_SetAttr leads to segmentation fault

2020-07-01 Thread Petr Viktorin
Petr Viktorin added the comment: What kind of security-related issues do you mean? A .pyc file is code; it can do anything. Never run untrusted code, be it .py or .pyc. See also: Lib/test/crashers/bogus_code_obj.py -- nosy: +petr.viktorin

[issue41073] [C API] PyType_GetSlot() should accept static types

2020-07-01 Thread Petr Viktorin
Petr Viktorin added the comment: > If we extend PyType_GetSlot() to accept non-heaptype, we need find a way to > judge the max slot of non-heaptype. Static types can have some sub-slots structs but not others. A "max slot" will not help for types that have tp_as_mapping but

[issue40971] Documentation still mentions 'u' string formatting option

2020-06-30 Thread Petr Viktorin
Petr Viktorin added the comment: I'm closing the issue. Please comment or reopen if I missed something. -- resolution: -> not a bug stage: needs patch -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue40971] Documentation still mentions 'u' string formatting option

2020-06-30 Thread Petr Viktorin
Petr Viktorin added the comment: AFAICS, Python 3 suports '%u' for printf-style formatting: Python 3.8.3 (default, May 29 2020, 00:00:00) [GCC 10.1.1 20200507 (Red Hat 10.1.1-1)] on linux Type "help", "copyright", "credits" or "license" for more i

[issue39960] Using typename.__setattr__ in extension type with Py_TPFLAGS_HEAPTYPE is broken (hackcheck too eager?)

2020-06-23 Thread Petr Viktorin
Petr Viktorin added the comment: > do we still only support single inheritance at the C level? Not any more. Heap types may have multiple bases, and they can be created at the C level (since Python 3.2, PEP 384). > So, I think we should do something like walking up the hierarchy t

[issue40891] Use pep573 in functools

2020-06-09 Thread Petr Viktorin
Petr Viktorin added the comment: I wrote about the _PyType_GetModuleByDef idea on the capi-sig mailing list: https://mail.python.org/archives/list/capi-...@python.org/thread/T3P2QNLNLBRFHWSKYSTPMVEIL2EEKFJU/ -- ___ Python tracker <ht

[issue39372] The header files in Include/ have many declarations with no definition

2020-06-09 Thread Petr Viktorin
Petr Viktorin added the comment: Since the removal of PyNoArgsFunction breaks user code, does it deserve a mention in What's New – Porting to Python 3.9? -- nosy: +petr.viktorin ___ Python tracker <https://bugs.python.org/issue39

[issue15577] Real argc and argv in embedded interpreter

2020-06-08 Thread Petr Viktorin
Petr Viktorin added the comment: FWIW, another project that needs Py_GetArgcArgv is "setproctitle": https://bugzilla.redhat.com/show_bug.cgi?id=1792059 See also: https://github.com/cherrypy/cherrypy/issues/1506 -- nosy: +petr.viktorin

[issue40217] The garbage collector doesn't take in account that objects of heap allocated types hold a strong reference to their type

2020-06-01 Thread Petr Viktorin
Change by Petr Viktorin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue40777] _datetimemodule.c:3328:16: error: initializer element is not constant

2020-05-28 Thread Petr Viktorin
Change by Petr Viktorin : -- keywords: +patch nosy: +petr.viktorin nosy_count: 1.0 -> 2.0 pull_requests: +19742 stage: -> patch review pull_request: https://github.com/python/cpython/pull/20493 ___ Python tracker <https://bugs.p

[issue24416] Have date.isocalendar() return a structseq instance

2020-05-28 Thread Petr Viktorin
Petr Viktorin added the comment: This broke compilation with mingw; see https://bugs.python.org/issue40777 -- nosy: +petr.viktorin ___ Python tracker <https://bugs.python.org/issue24

[issue40724] Support buffer protocol with type specs

2020-05-28 Thread Petr Viktorin
Petr Viktorin added the comment: Yes, it should be possible to wrap them in #if so they aren't part of the stable ABI. -- ___ Python tracker <https://bugs.python.org/issue40

[issue40802] AbstractEventLoop.shutdown_default_executor breaks backwards compatibility

2020-05-28 Thread Petr Viktorin
New submission from Petr Viktorin : In bpo-34037, AbstractEventLoop gained a new abstract method, shutdown_default_executor: https://docs.python.org/dev/library/asyncio-eventloop.html#asyncio.loop.shutdown_default_executor All AbstractEventLoop subclasses need to define this method, otherwise

[issue23897] Update Python 3 extension module porting guide

2020-05-28 Thread Petr Viktorin
Petr Viktorin added the comment: py3c has an open issue to check that Barry's notes on C extensions are included: https://github.com/encukou/py3c/issues/1 However, C extensions are only a small part of the wiki page. -- ___ Python tracker <ht

[issue40784] test_sqlite: CheckFuncDeterministic() fails with SQLite 3.32

2020-05-27 Thread Petr Viktorin
Petr Viktorin added the comment: Indeed. The SQLite documentation talks about the limitations that non-deterministic functions have, not about deterministic functions being memoized: https://www.sqlite.org/deterministic.html The flag would be better tested e.g. with a CHECK constraint

[issue40217] The garbage collector doesn't take in account that objects of heap allocated types hold a strong reference to their type

2020-05-26 Thread Petr Viktorin
Change by Petr Viktorin : -- pull_requests: +19690 stage: resolved -> patch review pull_request: https://github.com/python/cpython/pull/20433 ___ Python tracker <https://bugs.python.org/issu

[issue40217] The garbage collector doesn't take in account that objects of heap allocated types hold a strong reference to their type

2020-05-23 Thread Petr Viktorin
Petr Viktorin added the comment: Thank you for responding so quickly! > Petr, do you mind reviewing it? Yes, but I'll only get to it next week. -- ___ Python tracker <https://bugs.python.org/issu

[issue40217] The garbage collector doesn't take in account that objects of heap allocated types hold a strong reference to their type

2020-05-22 Thread Petr Viktorin
Change by Petr Viktorin : Added file: https://bugs.python.org/file49182/reproducer.c ___ Python tracker <https://bugs.python.org/issue40217> ___ ___ Python-bugs-list m

[issue40217] The garbage collector doesn't take in account that objects of heap allocated types hold a strong reference to their type

2020-05-22 Thread Petr Viktorin
Petr Viktorin added the comment: Ha! I think I found the issue in PySide now. It's different, but it's still a CPython issue. It's actually a variant of the "defining class" problem from PEP 573. It's legal to get the value of a slot, using PyType_GetSlot. It's reasonable

[issue40217] The garbage collector doesn't take in account that objects of heap allocated types hold a strong reference to their type

2020-05-22 Thread Petr Viktorin
Petr Viktorin added the comment: Indeed, it seems my initial analysis was incorrect. I can't reproduce this outside of PySide. I'll close this bug and invesatigate more. Sorry for the noise. -- resolution: -> fixed stage: patch review -> resolved status: open -&g

[issue40217] The garbage collector doesn't take in account that objects of heap allocated types hold a strong reference to their type

2020-05-20 Thread Petr Viktorin
Petr Viktorin added the comment: It looks like the fix breaks types that override Py_tp_alloc but not Py_tp_traverse (as some types in PySide do.) I'll investigate more and work on fixing that if someone doesn't beat me to it. -- nosy: +petr.viktorin

[issue38787] PEP 573: Module State Access from C Extension Methods

2020-05-19 Thread Petr Viktorin
Change by Petr Viktorin : -- pull_requests: +19510 pull_request: https://github.com/python/cpython/pull/20215 ___ Python tracker <https://bugs.python.org/issue38

[issue38787] PEP 573: Module State Access from C Extension Methods

2020-05-13 Thread Petr Viktorin
Petr Viktorin added the comment: I guess I'll need to clarify the documentation here. Call `PyType_GetModule` on the *defining class*, not on type(self). See the PEP for details. The associated module is not inherited; each class in the MRO can be defined in a different module

[issue40601] [C API] Hide static types from the limited C API

2020-05-12 Thread Petr Viktorin
Petr Viktorin added the comment: > For example, Objects/longobject.c defines "PyTypeObject PyLong_Type = > {...};". This type is exposed in the limited C API (!) Technically, it is not, see https://www.python.org/dev/peps/pep-0384/#structures Structures like PyLong_Typ

[issue40574] segfault causing regression from PEP 573 implementation (PyQt5)

2020-05-12 Thread Petr Viktorin
Petr Viktorin added the comment: So, the failure is expected. Python's ABI can change until the 3.9.0 final release, so wheels built for different commits can be incompatible. This applies to alphas/betas as well, as you say. There is the PEP 384 stable ABI, which is much stricter (and more

[issue40584] PyType_FromModuleAndSpec function should add the process of tp_vectorcall_offset

2020-05-11 Thread Petr Viktorin
Petr Viktorin added the comment: That seems reasonable. See the discussion around https://bugs.python.org/issue38140 for context. Note that __dictoffset__ and __weaklistoffset__ are also exposed as members (in PyMemberDef type_members) and documented (Doc/c-api/structures.rst). A new

[issue38787] PEP 573: Module State Access from C Extension Methods

2020-05-05 Thread Petr Viktorin
Change by Petr Viktorin : -- pull_requests: +19251 pull_request: https://github.com/python/cpython/pull/19936 ___ Python tracker <https://bugs.python.org/issue38

[issue40246] Different error messages for same error - invalid string prefixes

2020-04-29 Thread Petr Viktorin
Petr Viktorin added the comment: reportlab reported failures on code like: norm=lambda m: m+(m and(m[-1]!='\n'and'\n'or'')or'\n') Note that `or` has a `r` in it. -- nosy: +petr.viktorin ___ Python tracker <https://bugs.python.org/issue40

[issue38787] PEP 573: Module State Access from C Extension Methods

2020-04-29 Thread Petr Viktorin
Petr Viktorin added the comment: I'm working on the implementation as my time allows, here: https://github.com/encukou/cpython/pull/3 . Would it help to create a proper PR for CPython now? That would mean I could no longer do rebases/force-pushes, so the commits would be less readable

[issue34037] asyncio: BaseEventLoop.close() shutdowns the executor without waiting causing leak of dangling threads

2020-04-20 Thread Petr Viktorin
Petr Viktorin added the comment: I got a report from a library that ties together asyncio and some other async libraries, getting errors like this: tests/test_taskgroups.py:60: in test_run_natively module.run(testfunc()) /usr/lib64/python3.9/asyncio/runners.py:48: in run

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-04-07 Thread Petr Viktorin
Change by Petr Viktorin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue37207] Use PEP 590 vectorcall to speed up calls to range(), list() and dict()

2020-04-07 Thread Petr Viktorin
Petr Viktorin added the comment: As discussed briefly in Mark's PR, benchmarks like this are now slower: ret = dict(**{'a': 2, 'b': 4, 'c': 6, 'd': 8}) Python 3.8: Mean +- std dev: 281 ns +- 9 ns master: Mean +- std dev: 456 ns +- 14 ns

[issue37207] Use PEP 590 vectorcall to speed up calls to range(), list() and dict()

2020-04-01 Thread Petr Viktorin
Petr Viktorin added the comment: > Can I submit the patch? Yes! If you think a patch is ready for review, just submit it. There's not much we can comment on before we see the code :) (I hope that doesn't contradict what your mentor s

[issue37207] Use PEP 590 vectorcall to speed up calls to range(), list() and dict()

2020-04-01 Thread Petr Viktorin
Petr Viktorin added the comment: Definitely! -- ___ Python tracker <https://bugs.python.org/issue37207> ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue37207] Use PEP 590 vectorcall to speed up calls to range(), list() and dict()

2020-03-31 Thread Petr Viktorin
Petr Viktorin added the comment: The change to dict() was not covered by the smaller PRs. That one will need more thought, but AFAIK it wasn't yet rejected. -- status: closed -> open ___ Python tracker <https://bugs.python.org/issu

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-03-24 Thread Petr Viktorin
Petr Viktorin added the comment: Moved to Discourse, IMO that's a better place for maintainers of other PEP-3118-compatible libraries to chime in: https://discuss.python.org/t/behavior-of-struct-format-native-bool/3774 -- ___ Python tracker

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-03-24 Thread Petr Viktorin
Petr Viktorin added the comment: I see. Thanks for your patience explaining this to me! I will merge and continue in a different issue. -- ___ Python tracker <https://bugs.python.org/issue39

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-03-18 Thread Petr Viktorin
Petr Viktorin added the comment: I think we are speaking past each other. In my (current) view, the semantics are spelled out in the documentation: "any non-zero value will be True when unpacking". There's also a mention that this corresponds to the _Bool type in C. While this wa

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-03-17 Thread Petr Viktorin
Petr Viktorin added the comment: > You are the one who wanted to *introduce* a hack by dereferencing as char and then cast to _Bool. :-) Yes, I did change my mind after reading the documentation. The docs say two contradicting things: 1. The '?' conversion code corresponds to the _Bool t

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-03-12 Thread Petr Viktorin
Petr Viktorin added the comment: > The docs for native mode (we now always assume C99): > > "The '?' conversion code corresponds to the _Bool type defined by C99." But, nowhere is it suggested that conversion is "do memcpy and then interpret the bit pattern&qu

[issue39761] Python 3.9.0a4 fails to build when configured with --with-dtrace

2020-03-12 Thread Petr Viktorin
Change by Petr Viktorin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-03-12 Thread Petr Viktorin
Petr Viktorin added the comment: > So I vote for not handling incorrectly packed values and removing "and any non-zero value will be True when unpacking" from the docs, which does not seem to make any sense for _Bool. I disagree. I don't think struct module's job is to be fait

[issue38076] Make struct module PEP-384 compatible

2020-03-11 Thread Petr Viktorin
Change by Petr Viktorin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-03-11 Thread Petr Viktorin
Petr Viktorin added the comment: Oh! I just reead the docs more carefully; they say: For the '?' format character, the return value is either True or False. When packing, the truth value of the argument object is used. Either 0 or 1 in the native or standard bool representation

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-03-11 Thread Petr Viktorin
Petr Viktorin added the comment: > > > maybe we should be raising an error if the bytes are not a valid platform > > > _Bool pattern? > > > > That's quite hard to test for. > > How so? We just make the same assumption you're making that true

[issue39689] struct and memoryview tests rely on undefined behavior (as revealed by clang 9)

2020-03-11 Thread Petr Viktorin
Petr Viktorin added the comment: The memoryview module does the same thing as struct, and its tests expect the same behavior as with struct. So, whatever we do in struct should be also done in memoryview. -- title: test_struct failure on s390x Fedora Clang buildbot -> str

[issue37207] Use PEP 590 vectorcall to speed up calls to range(), list() and dict()

2020-03-11 Thread Petr Viktorin
Change by Petr Viktorin : -- nosy: +petr.viktorin nosy_count: 4.0 -> 5.0 pull_requests: +18280 pull_request: https://github.com/python/cpython/pull/18928 ___ Python tracker <https://bugs.python.org/issu

[issue39689] test_struct failure on s390x Fedora Clang buildbot

2020-03-11 Thread Petr Viktorin
Change by Petr Viktorin : -- keywords: +patch pull_requests: +18277 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/18925 ___ Python tracker <https://bugs.python.org/issu

[issue39689] test_struct failure on s390x Fedora Clang buildbot

2020-03-11 Thread Petr Viktorin
Petr Viktorin added the comment: > our unittest assuming that b'\xf0' should be true when interpreted as a bool > is wrong. > just get rid of that value from the loop in the test? That could be the proper thing to do, but it does make it easy to invoke C undefined behavior from Py

[issue38960] DTrace FreeBSD build fix

2020-03-11 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset 3c97e1e457033bbb8bbe0b7198bd13fc794a12b0 by Petr Viktorin in branch 'master': bpo-39761: Fix dtrace build with empty $DFLAGS (GH-18766) https://github.com/python/cpython/commit/3c97e1e457033bbb8bbe0b7198bd13fc794a12b0

[issue39761] Python 3.9.0a4 fails to build when configured with --with-dtrace

2020-03-11 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset 3c97e1e457033bbb8bbe0b7198bd13fc794a12b0 by Petr Viktorin in branch 'master': bpo-39761: Fix dtrace build with empty $DFLAGS (GH-18766) https://github.com/python/cpython/commit/3c97e1e457033bbb8bbe0b7198bd13fc794a12b0

[issue39824] Multi-phase extension module (PEP 489): don't call m_traverse, m_clear nor m_free before the module state is allocated

2020-03-11 Thread Petr Viktorin
Petr Viktorin added the comment: If you use a module subclass that needs some additional C-level infrastructure, it would be more appropriate to override tp_clear/tp_free directly. IMO limiting m_clear/m_free to work just with the module state won't hurt. But it is an API change

[issue39762] PyLong_AS_LONG missing from longobject.h

2020-03-04 Thread Petr Viktorin
Petr Viktorin added the comment: No, in Python 2 the PyInt object (`int` in Python 2) always did fit into a C long -- that was the underlying storage. If it didn't fit, a PyLong object (`long` in Python 2) was used. Python 3 doesn't have PyInt, it only has PyLong (`int` in Python 3

[issue39689] test_struct failure on s390x Fedora Clang buildbot

2020-03-03 Thread Petr Viktorin
Petr Viktorin added the comment: Viewing the oss-fuzz bug requires login. Is there any interesting public info in it? -- ___ Python tracker <https://bugs.python.org/issue39

[issue39546] argparse: allow_abbrev=False is ignored for alternative prefix characters

2020-03-03 Thread Petr Viktorin
Change by Petr Viktorin : -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

[issue39689] test_struct failure on s390x Fedora Clang buildbot

2020-03-03 Thread Petr Viktorin
Petr Viktorin added the comment: IMO: - The "native" format should use native _Bool, and we should only test unpacking 0 and 1 - The "standard" format should use portable char semantics: continue to treat any non-zero value as true - The docs should grow a warning that f

[issue39773] Export symbols for vectorcall

2020-03-03 Thread Petr Viktorin
Petr Viktorin added the comment: Yes. Can you use PyObject_Call instead (or one of the non-Vectorcall variants listed in https://docs.python.org/3.9/c-api/call.html#object-calling-api ) Vectorcall is mainly a speed optimization over PyObject_Call. We want to allow the C compiler to inline

[issue38960] DTrace FreeBSD build fix

2020-03-03 Thread Petr Viktorin
Petr Viktorin added the comment: The fix introduced a regression, see bpo-39761 -- ___ Python tracker <https://bugs.python.org/issue38960> ___ ___ Python-bug

[issue38960] DTrace FreeBSD build fix

2020-03-03 Thread Petr Viktorin
Change by Petr Viktorin : -- pull_requests: +18123 pull_request: https://github.com/python/cpython/pull/18766 ___ Python tracker <https://bugs.python.org/issue38

[issue39761] Python 3.9.0a4 fails to build when configured with --with-dtrace

2020-03-03 Thread Petr Viktorin
Change by Petr Viktorin : -- pull_requests: +18122 pull_request: https://github.com/python/cpython/pull/18766 ___ Python tracker <https://bugs.python.org/issue39

[issue39689] test_struct failure on s390x Fedora Clang buildbot

2020-02-27 Thread Petr Viktorin
Petr Viktorin added the comment: C compiler dev that it's indeed undefined behavior. > Quick and obvious fix: > > static PyObject * > nu_bool(const char *p, const formatdef *f) > { > char x; > memcpy((char *), p, sizeof x

[issue39689] test_struct failure on s390x Fedora Clang buildbot

2020-02-27 Thread Petr Viktorin
Petr Viktorin added the comment: The call: struct.unpack('>?', b'\xf0') means to unpack a "native bool", i.e. native size and alignment. Internally, this does: static PyObject * nu_bool(const char *p, const formatdef *f) { _Bool x; memcpy((char *)

[issue1294959] Problems with /usr/lib64 builds.

2020-02-20 Thread Petr Viktorin
Petr Viktorin added the comment: Why "sys.python_libdir"? Isn't that too public? A lot of similar path-related info is in sysconfig; why shouldn't it be there? How does "sys.python_libdir" work on other platforms? -- ___ Py

[issue39676] test_shutil fails with OSError: [Errno 28] No space left on device on "PPC64LE Fedora Stable LTO + PGO 3.x" buildbot

2020-02-19 Thread Petr Viktorin
Petr Viktorin added the comment: Indeed, builds are green: https://buildbot.python.org/all/#/builders/449 Thanks Victor for reporting and Harris for fixing this. -- nosy: +petr.viktorin resolution: -> fixed stage: -> resolved status: open -&g

[issue39555] test_distutils fails for Windows debug build

2020-02-18 Thread Petr Viktorin
Petr Viktorin added the comment: New changeset d77e77116fa7a9fc85be1d9f417c7e9e33fe1296 by Miss Islington (bot) in branch '3.8': bpo-39555: Fix distutils test to handle _d suffix on Windows debug build (GH-18357) (GH-18548) https://github.com/python/cpython/commit

[issue39611] PyVectorcall_NARGS(): change return type to Py_ssize_t

2020-02-18 Thread Petr Viktorin
Petr Viktorin added the comment: Closing; please reopen if we're somehow misunderstanding each other :) -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.or

<    1   2   3   4   5   6   7   8   9   10   >