[Patches] Making modules callable when they have the attribute "__call__"

Pekka Pessi Pekka.Pessi@nokia.com
Fri, 14 Apr 2000 18:07:03 +0300 (EEST)


	Hello,

	Attached you find patches that make modules callable when they have
	an attribute "__call__".  I think that this makes Python mode
	orthogonal. YMMV.

					Pekka Pessi
	
-----8<-------------8<-------------8<-------------8<-------------8<-----
*** Objects/object.c-virgin	Mon Apr 10 16:42:33 2000
--- Objects/object.c	Fri Apr 14 17:56:20 2000
***************
*** 601,607 ****
  	    PyCFunction_Check(x) ||
  	    PyClass_Check(x))
  		return 1;
! 	if (PyInstance_Check(x)) {
  		PyObject *call = PyObject_GetAttrString(x, "__call__");
  		if (call == NULL) {
  			PyErr_Clear();
--- 601,608 ----
  	    PyCFunction_Check(x) ||
  	    PyClass_Check(x))
  		return 1;
! 	if (PyInstance_Check(x) ||
! 	    PyModule_Check(x)) {
  		PyObject *call = PyObject_GetAttrString(x, "__call__");
  		if (call == NULL) {
  			PyErr_Clear();
*** Python/ceval.c-virgin	Mon Apr 10 15:45:10 2000
--- Python/ceval.c	Fri Apr 14 17:56:16 2000
***************
*** 2430,2436 ****
  	if (PyClass_Check(func)) {
  		return PyInstance_New(func, arg, kw);
  	}
! 	if (PyInstance_Check(func)) {
  	        PyObject *res, *call = PyObject_GetAttrString(func,"__call__");
  		if (call == NULL) {
  			PyErr_Clear();
--- 2430,2437 ----
  	if (PyClass_Check(func)) {
  		return PyInstance_New(func, arg, kw);
  	}
! 	if (PyInstance_Check(func) ||
! 	    PyModule_Check(func)) {
  	        PyObject *res, *call = PyObject_GetAttrString(func,"__call__");
  		if (call == NULL) {
  			PyErr_Clear();
-----8<-------------8<-------------8<-------------8<-------------8<-----



--
	I confirm that, to the best of my knowledge and belief, this
        contribution is free of any claims of third parties under
        copyright, patent or other rights or interests ("claims").  To
        the extent that I have any such claims, I hereby grant to CNRI a
        nonexclusive, irrevocable, royalty-free, worldwide license to
        reproduce, distribute, perform and/or display publicly, prepare
        derivative versions, and otherwise use this contribution as part
        of the Python software and its related documentation, or any
        derivative versions thereof, at no cost to CNRI or its licensed
        users, and to authorize others to do so.
	
        I acknowledge that CNRI may, at its sole discretion, decide
        whether or not to incorporate this contribution in the Python
        software and its related documentation.  I further grant CNRI
        permission to use my name and other identifying information
        provided to CNRI by me for use in connection with the Python
        software and its related documentation.