[issue36457] functools.singledispatchmethod interacts poorly with subclasses

2022-03-17 Thread Tim Mitchell


Change by Tim Mitchell :


Added file: https://bugs.python.org/file50689/test_sdm.py

___
Python tracker 
<https://bugs.python.org/issue36457>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36457] functools.singledispatchmethod interacts poorly with subclasses

2022-03-17 Thread Tim Mitchell


Tim Mitchell  added the comment:

I've come up with a version that does not require a base class.

Seems a bit hacky as the descriptor __get__ method now modifies the class to 
put the dispatch table in place the first time the method is accessed.

--
Added file: https://bugs.python.org/file50688/singledispatchmethod.py

___
Python tracker 
<https://bugs.python.org/issue36457>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36744] functools.singledispatch: Shouldn't require a positional argument if there is only one keyword argument

2022-03-17 Thread Tim Mitchell


Tim Mitchell  added the comment:

I would really prefer the dispatch logic remains simple and fast, rather than 
handle single keyword arguments.

--
nosy: +Tim Mitchell2

___
Python tracker 
<https://bugs.python.org/issue36744>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36457] functools.singledispatchmethod interacts poorly with subclasses

2019-04-11 Thread Tim Mitchell


Tim Mitchell  added the comment:

Attached is an improved implementation that does not use a module level 
register() function.  
It makes the code in the original post work as expected: The 
`@BaseVisitor.visit.register()` decorator on the `AVisitor` class does not 
modify the base class dispatch table.  This works by constructing the dispatch 
registry in the `__init_subclass__` method instead.

--
Added file: https://bugs.python.org/file48261/singledispatchmethod.py

___
Python tracker 
<https://bugs.python.org/issue36457>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue36457] functools.singledispatchmethod interacts poorly with subclasses

2019-03-27 Thread Tim Mitchell


New submission from Tim Mitchell :

The new functools.singledispatchmethod (issue32380) class interacts poorly with 
subclasses.
There is no way for a sub-class to override or extend the dispatch registry.
E.g.

class BaseVistor:
   @singledispatchmethod
   def visit(self, obj):
  raise ValueError('Explict vistor implementation missing)

class AVisitor(BaseVisitor):
   # problem: here we can only register against base class method
   @BaseVistor.visit.reister(int)
   def visit_int(self, obj):
   print ('integer')

The AVistor class has now changed the dispatch registry for BaseVistor class 
which is bad.

To fix this the dispatch registry needs to be copied for each subclass and an 
alternate register mechanism provided for subclasses to register against a 
subclass method.
See attached file and pypi methoddispatch for details :)

--
components: Library (Lib)
files: methoddispatch36.py
messages: 339008
nosy: Tim Mitchell2, inada.naoki
priority: normal
severity: normal
status: open
title: functools.singledispatchmethod interacts poorly with subclasses
type: behavior
versions: Python 3.8
Added file: https://bugs.python.org/file48235/methoddispatch36.py

___
Python tracker 
<https://bugs.python.org/issue36457>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26240] Docstring of the subprocess module should be cleaned up

2016-10-20 Thread Tim Mitchell

Tim Mitchell added the comment:

Changes as per Martins review.

--
Added file: http://bugs.python.org/file45159/subprocess3.patch

___
Python tracker 
<http://bugs.python.org/issue26240>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26240] Docstring of the subprocess module should be cleaned up

2016-10-18 Thread Tim Mitchell

Tim Mitchell added the comment:

Am now working from tip of default in mercurial (Python 3.6).

* Removed all changes to subprocess.rst.

subprocess.__doc__
* Trimmed down even further - removed function signatures.
* added note to see Python docs for complete description.

Exception docs
* just list attributes rather than describing them - they are pretty 
self-explanatory.

Popen.__doc__ 
* Trimmed down to just list arguments with 1 or 2 liner descriptions. 
* Added note to see Python docs for complete description.
* added encoding and errors arguments

--
Added file: http://bugs.python.org/file45140/subprocess2.patch

___
Python tracker 
<http://bugs.python.org/issue26240>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26240] Docstring of the subprocess module should be cleaned up

2016-10-18 Thread Tim Mitchell

Tim Mitchell added the comment:

hg patch with changes forthcoming

--

___
Python tracker 
<http://bugs.python.org/issue26240>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue26240] Docstring of the subprocess module should be cleaned up

2016-10-17 Thread Tim Mitchell

Tim Mitchell added the comment:

Have stripped down the module __doc__ to a list of contents.
I chose to indent the descriptions of each argument to Popen. I know this is 
non-standard but it is such a long ramble otherwise.

Changed true -> :const:`True` in subprocess.rst.

--
keywords: +patch
nosy: +tim.mitchell
Added file: http://bugs.python.org/file45126/subprocess-docs.patch

___
Python tracker 
<http://bugs.python.org/issue26240>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27946] issues in elementtree and elsewhere due to PyDict_GetItem

2016-09-12 Thread Tim Mitchell

Tim Mitchell added the comment:

Added test to patch

--

___
Python tracker 
<http://bugs.python.org/issue27946>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27946] issues in elementtree and elsewhere due to PyDict_GetItem

2016-09-12 Thread Tim Mitchell

Changes by Tim Mitchell :


Removed file: 
http://bugs.python.org/file44605/0001-issue27946-Hold-reference-to-dict-in-PyDict_GetItem.patch

___
Python tracker 
<http://bugs.python.org/issue27946>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27946] issues in elementtree and elsewhere due to PyDict_GetItem

2016-09-12 Thread Tim Mitchell

Changes by Tim Mitchell :


Added file: 
http://bugs.python.org/file44611/0001-issue27946-Hold-reference-to-dict-in-PyDict_GetItem.patch

___
Python tracker 
<http://bugs.python.org/issue27946>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27946] issues in elementtree and elsewhere due to PyDict_GetItem

2016-09-12 Thread Tim Mitchell

Tim Mitchell added the comment:

see also similar dict issue 27945

--

___
Python tracker 
<http://bugs.python.org/issue27946>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27946] issues in elementtree and elsewhere due to PyDict_GetItem

2016-09-12 Thread Tim Mitchell

Tim Mitchell added the comment:

see also similar dict issue 27945

--

___
Python tracker 
<http://bugs.python.org/issue27946>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27946] issues in elementtree and elsewhere due to PyDict_GetItem

2016-09-12 Thread Tim Mitchell

Tim Mitchell added the comment:

Verified problem.  Added patch to keep reference to dict in PyDict_GetItem.

--
keywords: +patch
nosy: +Tim Mitchell
Added file: 
http://bugs.python.org/file44605/0001-issue27946-Hold-reference-to-dict-in-PyDict_GetItem.patch

___
Python tracker 
<http://bugs.python.org/issue27946>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue27945] Various segfaults with dict

2016-09-11 Thread Tim Mitchell

Tim Mitchell added the comment:

Here is my patch for parts 3 and 4.
Core issue for part 4 appears to be dk_lookup calling arbitrary python code may 
free the key.
dk_lookup is also used in _PyDict_LoadGlobal not sure if this bug can occur 
here.

--
nosy: +Tim Mitchell
Added file: 
http://bugs.python.org/file44587/0001-Issue-27945-Fixed-segfaults-in-dict.fromkeys-when-it.patch

___
Python tracker 
<http://bugs.python.org/issue27945>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com