This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author abarry
Recipients abarry, ncoghlan, rhettinger, vstinner, xiang.zhang
Date 2016-05-28.03:19:52
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1464405594.78.0.630294477297.issue27137@psf.upfronthosting.co.za>
In-reply-to
Content
Attached patch turns the Python implementation of functools.partial into a class. The implementation is as close to the C version as possible, except __repr__ where I went for a different, more Pythonic approach (output is identical).

I haven't yet added tests for this, and I had to fix something (because some errors occur if _functools is not present and that's the only way I know to make the tests run against the Python implementation). One test fails with the patch (and sys.modules["_functools"] = None):

...........................................................E....................
....................................................................
======================================================================
ERROR: test_pickle (test.test_functools.TestPartialC)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "E:\GitHub\cpython\lib\test\test_functools.py", line 224, in test_pickle
    f_copy = pickle.loads(pickle.dumps(f, proto))
_pickle.PicklingError: Can't pickle <class 'functools.partial'>: it's not the sa
me object as functools.partial

----------------------------------------------------------------------
Ran 148 tests in 0.216s

FAILED (errors=1)

I'll try to see what kind of tests I can add to this to reliably test both 'partial' implementations. I'll also see what I can do about that one failing test. Oddly enough, there seems to be a test for subclassing '_functools.partial', which I might extend.

Raymond, what do you think?
History
Date User Action Args
2016-05-28 03:19:54abarrysetrecipients: + abarry, rhettinger, ncoghlan, vstinner, xiang.zhang
2016-05-28 03:19:54abarrysetmessageid: <1464405594.78.0.630294477297.issue27137@psf.upfronthosting.co.za>
2016-05-28 03:19:54abarrylinkissue27137 messages
2016-05-28 03:19:54abarrycreate