[Pyobjc-dev] TypeError: cannot change a method
Brought to you by:
ronaldoussoren
From: Daniel M. <mil...@gm...> - 2009-07-16 02:30:21
|
My testing framework for the app I've been developing (previously with PyObjC 1.4, now attempting to migrate to PyObjC 2) is giving lots of errors due to a restriction in PyObjC 2 that methods cannot be overwritten [0]. My testing framework mocks Cocoa API calls to verify that the calls are being made as expected without actually hitting Cocoa (which would cause all sorts of unwanted side-affects). My first question is about circumventing this read-only method restriction for my tests. Is it possible to (temporarily?) make PyObjC methods writable? Maybe through some hack that would only be activated as a pre-test setup task, allowing me to overwrite methods just during the testing phase? My second question is why such a restriction has been added? I'm not trying to start a flame war here, so please don't get that idea. Python is generally very liberal in what it allows one to do, even potentially damaging things such as shooting ones self in the foot: "Python culture tends towards "we're all consenting adults here". If you attempt to shoot yourself in the foot, you should get some kind of warning that perhaps it is not what you really want to do, but if you insist, hey, go ahead, it's your foot!" [1] "...this is Python, where we vigorously defend the right to shoot ourselves in the foot." [2] Is there any particular technical reason why PyObjC tries harder- than-normal-for-Python to protect me from doing things that most people probably do not want to do? Thanks in advance for taking time to answer my questions. ~ Daniel [0] http://www.mail-archive.com/mat...@li.../msg05035.html [1] http://mail.python.org/pipermail/tutor/2006-December/051569.html [2] http://www.gossamer-threads.com/lists/python/python/753888#753888 |