[issue44532] multi subinterpreters use _PyStructSequence_InitType failed.

2021-11-14 Thread Hai Shi


Hai Shi  added the comment:

OK,thanks. If it's just only interal calling, I don't think throwing a 
exception would break anything. As your pasted code shows, the modules have 
judeged the tp_name is inited or not.

--

___
Python tracker 

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



[issue44532] multi subinterpreters use _PyStructSequence_InitType failed.

2021-11-09 Thread junyixie


junyixie  added the comment:

Include/internal/pycore_structseq.h:
   10  
   11  
   12: PyAPI_FUNC(int) _PyStructSequence_InitType(
   13  PyTypeObject *type,
   14  PyStructSequence_Desc *desc,

Modules/_cursesmodule.c:
 4794  /* ncurses_version */
 4795  if (NcursesVersionType.tp_name == NULL) {
 4796: if (_PyStructSequence_InitType(,
 4797 _version_desc,
 4798 
Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {

Objects/structseq.c:
  463  
  464  int
  465: _PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc 
*desc,
  466 unsigned long tp_flags)
  467  {
  ...
  527  PyStructSequence_InitType2(PyTypeObject *type, PyStructSequence_Desc 
*desc)
  528  {
  529: return _PyStructSequence_InitType(type, desc, 0);
  530  }
  531  

Python/sysmodule.c:
 2813  /* version_info */
 2814  if (VersionInfoType.tp_name == NULL) {
 2815: if (_PyStructSequence_InitType(,
 2816 _info_desc,
 2817 
Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {
 
 2827  // sys.flags: updated in-place later by _PySys_UpdateConfig()
 2828  if (FlagsType.tp_name == 0) {
 2829: if (_PyStructSequence_InitType(, _desc,
 2830 
Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {
 2831  goto type_init_failed;
 
 2837  /* getwindowsversion */
 2838  if (WindowsVersionType.tp_name == 0) {
 2839: if (_PyStructSequence_InitType(,
 2840 _version_desc,
 2841 
Py_TPFLAGS_DISALLOW_INSTANTIATION) < 0) {

--

___
Python tracker 

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



[issue44532] multi subinterpreters use _PyStructSequence_InitType failed.

2021-10-20 Thread Hai Shi


Hai Shi  added the comment:

> In _PyStructSequence_InitType, it will check type is initialized.
  It's a internal C API :)

> when type already been initialized, should return 0 rather than throw 
> exception.
  The another solution is to check the type status before calling 
_PyStructSequence_InitType().

--
nosy: +shihai1991

___
Python tracker 

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



[issue44532] multi subinterpreters use _PyStructSequence_InitType failed.

2021-06-29 Thread junyixie


Change by junyixie :


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

___
Python tracker 

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



[issue44532] multi subinterpreters use _PyStructSequence_InitType failed.

2021-06-29 Thread junyixie


New submission from junyixie :

In _PyStructSequence_InitType, it will check type is initialized.
but when we have multi subinterpreters, type may be initialized expected.

when type already been initialized, should return 0 rather than throw exception.
```c
/* PyTypeObject has already been initialized */
if (Py_REFCNT(type) != 0) {
return 0;
}
```


```c
int
_PyStructSequence_InitType(PyTypeObject *type, PyStructSequence_Desc *desc,
   unsigned long tp_flags)
{
PyMemberDef *members;
Py_ssize_t n_members, n_unnamed_members;

#ifdef Py_TRACE_REFS
/* if the type object was chained, unchain it first
   before overwriting its storage */
if (type->ob_base.ob_base._ob_next) {
_Py_ForgetReference((PyObject *)type);
}
#endif

/* PyTypeObject has already been initialized */
if (Py_REFCNT(type) != 0) {
PyErr_BadInternalCall();
return -1;
}
```

--
components: Subinterpreters
messages: 396703
nosy: JunyiXie
priority: normal
severity: normal
status: open
title: multi subinterpreters use _PyStructSequence_InitType failed.
type: crash

___
Python tracker 

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