Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit46df79f

Browse files
committed
Discuss metaclass conflicts in test module docstring
1 parent02c2f00 commit46df79f

File tree

1 file changed

+25
-2
lines changed

1 file changed

+25
-2
lines changed

‎test/deprecation/test_cmd_git.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,11 @@
55
including deprecation warnings, while others verify that other aspects of attribute
66
access are not inadvertently broken by mechanisms introduced to issue the warnings.
77
8-
A note on multiprocessing: Because USE_SHELL has no instance state, this module does not
9-
include tests of pickling and multiprocessing.
8+
A note on multiprocessing
9+
=========================
10+
11+
Because USE_SHELL has no instance state, this module does not include tests of pickling
12+
and multiprocessing:
1013
1114
- Just as with a simple class attribute, when a class attribute with custom logic is
1215
later set to a new value, it may have either its initial value or the new value when
@@ -28,6 +31,26 @@
2831
2932
- That USE_SHELL cannot be set on instances, and that when retrieved on instances it
3033
always gives the same value as on the class, is covered in the tests here.
34+
35+
A note on metaclass conflicts
36+
=============================
37+
38+
The most important DeprecationWarning is for the code ``Git.USE_SHELL = True``, which is
39+
a security risk. But this warning may not be possible to implement without a custom
40+
metaclass. This is because a descriptor in a class can customize all forms of attribute
41+
access on its instances, but can only customize getting an attribute on the class.
42+
Retrieving a descriptor from a class calls its ``__get__`` method (if defined), but
43+
replacing or deleting it does not call its ``__set__`` or ``__delete__`` methods.
44+
45+
Adding a metaclass is a potentially breaking change. This is because derived classes
46+
that use an unrelated metaclass, whether directly or by inheriting from a class such as
47+
abc.ABC that uses one, will raise TypeError when defined. These would have to be
48+
modified to use a newly introduced metaclass that is a lower bound of both. Subclasses
49+
remain unbroken in the far more typical case that they use no custom metaclass.
50+
51+
The tests in this module do not establish whether the danger of setting Git.USE_SHELL to
52+
True is high enough, and applications of deriving from Git and using an unrelated custom
53+
metaclass marginal enough, to justify introducing a metaclass to issue the warnings.
3154
"""
3255

3356
importcontextlib

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp