Re: Mark built-in module as deprecated

2010-06-15 Thread Thomas Jollans
On 2010-06-15 02:29, moerchendiser2k3 wrote:
 Hi, yes, that was my first idea when I just create an
 external module. I forgot something to say:

 In my case the initfoo() function is called on startup
 in my embedding environment, that means I call that
 on startup of my main app.
   
ah. In that case, I don't think it's possible to do anything on import -
AFAIK, if the module foo is already loaded/initialized, import foo
is equivalent to foo = sys.modules['foo'] and doesn't invoke any
module-specific code...

You could issue a warning on each and every method call in your module,
so that when it's used, the user gets warned. Then you could cache
whether a warning has been issued already in a global static variable or
in module state to be able to only warn once.

Thomas
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mark built-in module as deprecated

2010-06-14 Thread Thomas Jollans
On 06/14/2010 02:30 AM, moerchendiser2k3 wrote:
 PyErr_WarnEx(PyExc_DeprecationWarning, foo deprecated. use fuzz,
 1);
 
 But where can I write this? With Py_InitModule4 I can just
 pass a list of functions but no real execution part which
 is executed when a module is imported.

This is Python 2.x, right? I'm only familiar with Python 3 extension
writing, but there shouldn't have been that much change...

Where do you call the Py_InitModule4? I would have expected you call it
in your initfoo function - which is also a good place to issue a
warning. - the initfoo (or PyInit_foo) function is called when the
module is first imported.

-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mark built-in module as deprecated

2010-06-14 Thread moerchendiser2k3
Hi, yes, that was my first idea when I just create an
external module. I forgot something to say:

In my case the initfoo() function is called on startup
in my embedding environment, that means I call that
on startup of my main app.

Bye,
moerchendiser2k3
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mark built-in module as deprecated

2010-06-13 Thread Thomas Jollans
On 06/13/2010 03:54 PM, moerchendiser2k3 wrote:
 Hi,
 
 can anyone give me a hint how to mark a built-in module as deprecated?
 So mark via warnings... I create a module with Py_InitModule4.

How are modules ever marked as deprecated? I think all there is to it is
issuing a DeprecationWarning... something  like

PyErr_WarnEx(PyExc_DeprecationWarning, foo deprecated. use fuzz, 1);

maybe.
-- 
http://mail.python.org/mailman/listinfo/python-list


Re: Mark built-in module as deprecated

2010-06-13 Thread moerchendiser2k3
PyErr_WarnEx(PyExc_DeprecationWarning, foo deprecated. use fuzz,
1);

But where can I write this? With Py_InitModule4 I can just
pass a list of functions but no real execution part which
is executed when a module is imported.
-- 
http://mail.python.org/mailman/listinfo/python-list