bpo-29847: Path subclasses raise TypeError given kwargs - #13399
bpo-29847: Path subclasses raise TypeError given kwargs#13399jsaporta wants to merge 443 commits into
Conversation
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| if kwargs: | ||
| raise TypeError("keyword arguments provided but ignored") |
There was a problem hiding this comment.
What about start the raise with uppercase?
There was a problem hiding this comment.
Other errors I've seen start with lowercase letters.
>>> 3 + 'string'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unsupported operand type(s) for +: 'int' and 'str'| __slots__ = () | ||
|
|
||
| def __new__(cls, *args, **kwargs): | ||
| if kwargs: |
There was a problem hiding this comment.
This weird for me because if you don't have kwargs on __new__(cls, *args, **kwargs)
because this will raise a exception, what are you sending on super().__new__(cls, *args, **kwargs)
There was a problem hiding this comment.
Not sure I understand you clearly, but if kwargs is an empty dictionary, then it will act as a falsy value in the if statement, and the exception will not be raised.
|
I would suggest adding a NEWS entry and perhaps a versionchanged section to doc since someone could have been passing kwargs though it was silently ignored and undocumented in the past that now raises a TypeError. |
|
What about a test to see if a new subclass of import pathlib
class MyPath(type(pathlib.Path())):
def __init__(self, *args, foo):
self.foo = foo
path = MyPath('bar', foo=42)
assert path.foo == 42 |
…H-8096) There is no need to clear these immutable objects during shutdown.
Fix DeprecationWarning introduced in aee19f5 https://bugs.python.org/issue37099
This reverts commit 71dc7c5. Turns out you must have write access for CODEOWNERS to work.
As per the PEP and the [audit event raised](https://github.com/python/cpython/blob/13d4e6a4a090031f8214e058ed3c8fd47767e05f/Lib/urllib/request.py#L524) in urllib.request this should be `urllib.Request` cc: @zooba
when platform lacks a functioning sem_open implementation https://bugs.python.org/issue36342
Bump the removal to 3.9, indicate collections.abc available since 3.3, replace version-changed directive to deprecated-removed. https://bugs.python.org/issue36953
…yping (GH-13685) This is an old feature request that appears from time to time. After a year of experimenting with various introspection capabilities in `typing_inspect` on PyPI, I propose to add these two most commonly used functions: `get_origin()` and `get_args()`. These are essentially thin public wrappers around private APIs: `__origin__` and `__args__`. As discussed in the issue and on the typing tracker, exposing some public helpers instead of `__origin__` and `__args__` directly will give us more flexibility if we will decide to update the internal representation, while still maintaining backwards compatibility. The implementation is very simple an is essentially a copy from `typing_inspect` with one exception: `ClassVar` was special-cased in `typing_inspect`, but I think this special-casing doesn't really help and only makes things more complicated.
…async (GH-13464) Automatically replace tp_print -> tp_vectorcall_offset tp_compare -> tp_as_async tp_reserved -> tp_as_async
It seems to be the only widget label not capitalized.
… 2. (GH-11859) Escape ``\r``, ``\0`` and ``\x1a`` (end-of-file on Windows) in Unicode strings.
The ssl module now can dump key material to a keylog file and trace TLS protocol messages with a tracing callback. The default and stdlib contexts also support SSLKEYLOGFILE env var. The msg_callback and related enums are private members. The feature is designed for internal debugging and not for end users. Signed-off-by: Christian Heimes <christian@python.org>
If a type's __ipow__ method was implemented in C, attempting to use the *modulo* parameter would cause crashes. https://bugs.python.org/issue36379
|
It's not cool to spam the entire team with code review requests. |
|
I synced my fork with master then rebased the issue branch on top of it before updating it. Looks like that may have been a mistake? |
|
Please use merge instead of rebase next time. |

TypeError raised in the subclasses as per the discussion on bugs.python.org.
https://bugs.python.org/issue29847