Code Monkey home page Code Monkey logo

Comments (1)

jamadden avatar jamadden commented on June 12, 2024 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.