Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #10380

PyImport_ImportModule bug in 3.1.2

Path csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!feeder.news-service.com!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!194.109.133.85.MISMATCH!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <wangja@yeahcity.cn>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:bug': 0.04; 'sys': 0.05; 'python': 0.08; 'advice?': 0.09; 'folder,': 0.09; 'null)': 0.09; 'null;': 0.09; '3.1.2.': 0.16; 'null.': 0.16; 'pyobject*': 0.16; 'def': 0.16; 'programming': 0.18; 'int': 0.19; 'seems': 0.20; 'file,': 0.22; 'skip:p 30': 0.28; 'import': 0.29; 'fine.': 0.29; 'skip:( 20': 0.30; 'cmd': 0.30; 'folder.': 0.30; 'imported': 0.30; 'version': 0.30; 'it.': 0.33; 'to:addr:python-list': 0.34; 'test': 0.34; 'try:': 0.35; 'thank': 0.35; 'charset:us-ascii': 0.36; 'response': 0.37; 'some': 0.37; 'but': 0.37; 'could': 0.37; 'except': 0.39; 'skip:s 20': 0.39; 'to:addr:python.org': 0.39; 'give': 0.60; 'you.': 0.62; 'received:58': 0.67
X-Originating-IP [58.246.137.234]
X-Originating-Email [wangja@yeahcity.cn]
From bob.wang <wangja@yeahcity.cn>
To <python-list@python.org>
Subject PyImport_ImportModule bug in 3.1.2
Date Wed, 27 Jul 2011 17:46:16 +0800
MIME-Version 1.0
Content-Type text/plain; charset="us-ascii"
Content-Transfer-Encoding 7bit
X-Mailer Microsoft Office Outlook 12.0
Thread-Index AcxMQgcxBRYWjnEtQnefF7HwqtAU0w==
Content-Language zh-cn
X-OriginalArrivalTime 27 Jul 2011 09:46:19.0384 (UTC) FILETIME=[0942FF80:01CC4C42]
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://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 <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.1531.1311760049.1164.python-list@python.org> (permalink)
Lines 74
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1311760049 news.xs4all.nl 23922 [2001:888:2000:d::a6]:55918
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:10380

Show key headers only | View raw


Hi:
	My Python version is 3.1.2.
	I am programming embedding c with python in windows.
	When I imported urllib.request  in my test py file,
PyImport_ImportModule always return NULL.
	But I imported re or cmd ,they work fine.
	I found urllib is folder, and request seems to be submodule.
	I don't know how to import it. I confirmed myutil.py and application
are in same folder.
	Could you give me some advice?
	Thank you.

myutil.py

import sys
import urllib.request 


CRLF = '\r\n'

def addValue(oper1,oper2):
      return (oper1 + oper2);


def ConnectURL(url):
      try:
            req = urllib.request.urlopen(url)
            response = req.read()
            req.close()
            return (req.getcode(),req.geturl())     
            
      except BaseException as exp:            
            sys.stdout.write(exp)     


native code:



int APIENTRY _tWinMain(HINSTANCE hInstance,
					   HINSTANCE hPrevInstance,
					   LPTSTR    lpCmdLine,
					   int       nCmdShow)
{
	PyObject* pPyUtil	= NULL;
	PyObject* pPypfn	= NULL;
	PyObject* pPyArgs	= NULL;
	PyObject* pPyRet	= NULL;
	int		nRet		= 0;
	int		nValue		= 0;

		
	Py_Initialize();
	PyImport_ImportModule("sys");		// ok
PyImport_ImportModule("csv");		// ok
 
	PyImport_ImportModule("urllib");		// ok

	pPyUtil	= PyImport_ImportModule("myutil"); // failed , 
	if(pPyUtil != NULL)
	{
	
		Py_DECREF(pPyUtil);
	}
	Py_Finalize();



	return 0;
}



Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

PyImport_ImportModule bug in 3.1.2 bob.wang <wangja@yeahcity.cn> - 2011-07-27 17:46 +0800

csiph-web