Comments (1)
The issue seems to be that the Python version is using None
as the value to mean "no attribute", even though that's a valid value; in C that's spelled NULL
. Using a special marker object solves the issue, to a first approximation:
---------------------------------------------
modified: src/ExtensionClass/__init__.py
---------------------------------------------
@@ -223,14 +223,14 @@ class ExtensionClass(type):
# to care or worry about using super(): it's always object.
def Base_getattro(self, name):
- descr = None
+ descr = marker = object()
for base in type(self).__mro__:
if name in base.__dict__:
descr = base.__dict__[name]
break
- if descr is not None and inspect.isdatadescriptor(descr):
+ if descr is not marker and inspect.isdatadescriptor(descr):
return descr.__get__(self, type(self))
try:
@@ -245,16 +245,17 @@ def Base_getattro(self, name):
if name == '__parent__' or not isinstance(descr, Base):
return descr
- if descr is not None:
- descr_get = getattr(descr, '__get__', None)
- if descr_get is None:
+ if descr is not marker:
+ descr_get = getattr(descr, '__get__', marker)
+ if descr_get is marker:
return descr
return descr_get(self, type(self))
raise AttributeError(
- "'%.50s' object has not attribute '%s'",
- type(self).__name__, name)
+ "'%.50s' object has no attribute '%s'" % (
+ type(self).__name__, name
+ ))
def _slotnames(self):
from extensionclass.
Related Issues (13)
- Review Base_getattro implementation for Python 3.7 compatibility HOT 3
- Py_TPFLAGS_HAVE_CLASS in ExtensionClass.h HOT 3
- 4.2.0 fails C compilation on windows on py27 HOT 3
- Build / publish wheels on Appveyor HOT 1
- Release 4.1? HOT 4
- warning when installing
- Pure-Python ExtensionClass wraps __parent__ but C does not HOT 1
- GHA is not allowed to upload wheels to PyPI HOT 23
- PURE_PYTHON: empty docstring not respected
- PURE_PYTHON: Name check for setting attributes is applied to all classes, not just C classes HOT 3
- Does not build on Python 3.11.0a2 HOT 1
- Port the C extension to Python 3? HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from extensionclass.