Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

Wernher von Braun settled for a V-2 when he coulda had a V-8.


devel / comp.lang.python / Re: Help on ImportError('Error: Reinit is forbidden')

SubjectAuthor
o Re: Help on ImportError('Error: Reinit is forbidden')Barry

1
Re: Help on ImportError('Error: Reinit is forbidden')

<mailman.95.1684419486.13552.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=27692&group=comp.lang.python#27692

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: barry@barrys-emacs.org (Barry)
Newsgroups: comp.lang.python
Subject: Re: Help on ImportError('Error: Reinit is forbidden')
Date: Thu, 18 May 2023 15:17:49 +0100
Lines: 84
Message-ID: <mailman.95.1684419486.13552.python-list@python.org>
References: <CAGxzrjaZ0XFJRhx_CXfawFXU7PupDSAvWFp=8LBExHqAV9LJdQ@mail.gmail.com>
<6AD2027C-6EBE-4C08-AAE7-93663CE484AA@barrys-emacs.org>
Mime-Version: 1.0
Content-Type: text/plain; charset="utf-8"
X-Trace: news.uni-berlin.de sjSJdf29p9xSmcYQ4qpc/QL8J2f8snOYI1gZjVjpIDUg==
Return-Path: <barry@barrys-emacs.org>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=none reason="no signature";
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.000
X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; '2023': 0.07; 'libraries.':
0.07; '18,': 0.09; 'cc:addr:python-list': 0.09; 'const': 0.09;
'from:addr:barry': 0.09; 'instances': 0.09; 'int': 0.09;
'received:217.70': 0.09; 'received:gandi.net': 0.09;
'received:mail.gandi.net': 0.09; '&gt;': 0.14; 'import': 0.15;
'url:mailman': 0.15; '"error': 0.16; '***': 0.16; 'barry': 0.16;
'cc:name:python list': 0.16; 'char': 0.16; 'from:addr:barrys-
emacs.org': 0.16; 'hunt': 0.16; 'message-id:@barrys-emacs.org':
0.16; 'pyobject*': 0.16; 'skip:{ 30': 0.16; "subject:')": 0.16;
"subject:('": 0.16; 'subject:ImportError': 0.16; 'void': 0.16;
'wrote:': 0.16; 'python': 0.16; 'subject:Help': 0.17; 'thu,':
0.19; 'cc:addr:python.org': 0.20; 'code': 0.23; 'skip:p 30': 0.23;
'run': 0.23; 'url-ip:188.166.95.178/32': 0.25; 'url-
ip:188.166.95/24': 0.25; 'help.': 0.25; 'url:listinfo': 0.25;
'cc:2**0': 0.25; 'url-ip:188.166/16': 0.25; 'jun': 0.26; 'bit':
0.27; 'email addr:python.org&gt;': 0.28; 'error': 0.29; 'seem':
0.31; 'url-ip:188/8': 0.31; 'assume': 0.32; 'python-list': 0.32;
'but': 0.32; 'printing': 0.34; 'skip:" 20': 0.34; 'header:In-
Reply-To:1': 0.34; 'following': 0.35; 'errors': 0.36; 'file':
0.38; 'means': 0.38; 'thanks': 0.38; 'break': 0.39; 'skip:h 10':
0.61; 'skip:i 20': 0.62; 'skip:* 20': 0.62; '2018,': 0.64; 'your':
0.64; 'top': 0.65; 'received:217': 0.67; 'time,': 0.67; 'points':
0.84; 'email name:&lt;python-list': 0.84; 'null)': 0.84; 'null;':
0.84; 'receives': 0.91
In-Reply-To: <CAGxzrjaZ0XFJRhx_CXfawFXU7PupDSAvWFp=8LBExHqAV9LJdQ@mail.gmail.com>
X-Mailer: iPad Mail (20E252)
X-Content-Filtered-By: Mailman/MimeDel 2.1.39
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <6AD2027C-6EBE-4C08-AAE7-93663CE484AA@barrys-emacs.org>
X-Mailman-Original-References: <CAGxzrjaZ0XFJRhx_CXfawFXU7PupDSAvWFp=8LBExHqAV9LJdQ@mail.gmail.com>
 by: Barry - Thu, 18 May 2023 14:17 UTC

On 18 May 2023, at 13:56, Jason Qian <jqian@tibco.com> wrote:


Hi Barry,
void handleError(const char* msg)
{
...
PyErr_Fetch(&pyExcType, &pyExcValue, &pyExcTraceback);
PyErr_NormalizeException(&pyExcType, &pyExcValue, &pyExcTraceback);

PyObject* str_value = PyObject_Repr(pyExcValue);
PyObject* pyExcValueStr = PyUnicode_AsEncodedString(str_value, "utf-8",
"Error ~");
const char *strErrValue = PyBytes_AS_STRING(pyExcValueStr);
//where   strErrValue   = "ImportError('Error: Reinit is forbidden')"
...
}
What we imported is a Python file which import some pyd libraries.

Please do not top post replies.
Ok so assume the error is correct and hunt for the code that does the
reimport.
You may need to set break points in you C code to find tnw caller.
Barry

Thanks 
Jason 
On Thu, May 18, 2023 at 3:53 AM Barry <[1]barry@barrys-emacs.org> wrote:

> On 17 May 2023, at 20:35, Jason Qian via Python-list
<[2]python-list@python.org> wrote:
>
>  Hi,
>
>   I Need some of your help.
>
> I have the following C code to import *Import python.*   It works
99% of
> the time, but sometimes  receives  "*ImportError('Error: Reinit is
> forbidden')*". error.
> **We run multiple instances of the app parallelly.
>
> *** Python version(3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51)
[MSC
> v.1914 64 bit (AMD64)]
>
> PyObject * importPythonModule(const char* pmodName)
> {
>    const char* errors = NULL;
>     int nlen = strlen(pmodName);
>     PyObject *pName = PyUnicode_DecodeUTF8(pmodName, nlen, errors);
>     PyObject *pModule = *PyImport_Import*(pName);
>     Py_DECREF(pName);
>     if (pModule == NULL) {
>     if (*PyErr_Occurred*()) {
>            handleError("PyImport_Import()");
>      }
>   }
> }
> void handleError(const char* msg)
> {
>  ...
>  "PyImport_Import() - ImportError('Error: Reinit is forbidden')"
> }

You do not seem to printing out msg, you have assumed it means reinit
it seems.
What does msg contain when it fails?

Barry
>
>
> Thanks
> Jason
> --
> [3]https://mail.python.org/mailman/listinfo/python-list
>

References

Visible links
1. mailto:barry@barrys-emacs.org
2. mailto:python-list@python.org
3. https://mail.python.org/mailman/listinfo/python-list


devel / comp.lang.python / Re: Help on ImportError('Error: Reinit is forbidden')

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor