Comments (6)
from cython.
Have tested latest version - 3.0.7. Problem still occurs.
Not sure how to provide the traceback. The problem is reported in the GUI/Web page when I attempt to make changes to a field in my application.
I have attached a sample application to demonstrate the problem. Use username="sam" and password="Secret_123" to login to the admin screen ( /admin ). You can start the dev server using "python manage.py runserver 0:8000" from the pixel directory.
Further testing shows that the issue arrises when I create a custom save for my model. It does not occur if I don't have a custom save mode. The issue also only occurs only when I compile using Cython.
django_cython_error.tar.gz
The tar archive contains the Django project but you will likely need to install the requirements ( assume you will use a python venv).
The specific part of the code that causes the issue is in admin.py.
# sample save_model - note indentation not shown
def save_model(self, request, obj, form, change):
obj.save()
print(change)
if change:
print("change", change, obj.id)
if not os.path.isdir(f'/tmp/{obj.id}'):
os.mkdir(f'/tmp/{obj.id}')
Again - this code only creates the issue when the project is compiled with Cython. There is a setup.py file in the pixel directory that I used to compile the project with command "python setup.py build_ext --inplace"
Please let me know if there is anything else you need.
from cython.
Looking through Django's code a bit, there seems to be a metaclass involved for this class: MediaDefiningClass
. It doesn't touch this specific method, but at least, it changes the way the class is instantiated. The method itself seems to be very ordinary and overriding it shouldn't harm. Also, the fact that it says "3 arguments given" instead of 5 seems odd. If anything goes wrong with a method, it's usually off by one due to self
, not off by two. Difficult to say what's going wrong here.
from cython.
Not a Cython bug - this is a choice that django-mass-edit has made:
for (varname, var) in self.get_overrided_properties().items():
if not varname.startswith('_') and not isinstance(var, types.FunctionType):
self.__dict__[varname] = var
Cython functions don't pass the check isinstance(var, types.FunctionType)
, which checks for an regular Python function. Therefore your CustomerAdmin.save_model
gets inappropriately copied over to overwrite MassAdmin.save_model
and you end up in some sort of mess.
Cython functions are not regular Python functions by necessity. We made them look as much like Python functions as possible, but we can never pass an isinstance
type check.
from cython.
If you want a reproducible example that doesn't use Cython then change your CustomerAdmin
class to be:
class CustomerAdmin(...): # put in the correct base class
class Callable:
def __call__(self, request, obj, form, change):
... # implementation of save_model goes here
save_model = Callable()
This'll demonstrate the (roughly) same issue you see here.
from cython.
from cython.
Related Issues (20)
- [ENH] Cast a C pointer to a contiguous memoryview without the GIL HOT 1
- [BUG] Incorrect code generation for += on complex arrays
- [BUG] Getting "performance hint: ..." HOT 8
- [BUG] Incompatibility of Integers for Arithmetic Operations with Floating-Point Numbers in Class Instance Methods HOT 2
- [BUG] Cython compiler crashes with `AttributeError: 'NoneType' object has no attribute 'type'`
- [BUG] definitions of global constants HOT 1
- [ENH] got pandas warning after cythonize HOT 3
- [BUG] '-Wundef' warning when compiling cythonized file with `from cpython cimport bool`
- [ENH] Recompile based on file hash, not timestamp HOT 3
- [ENH] Allow using scan-build/clang static analyzer with `__cinit__`
- [BUG] "isolated_limited_api_tests" crashes in Py3.13a4 HOT 1
- C-API for signalling monitoring events
- [BUG] Segfault when __dealloc__ calls a non-existent method. HOT 2
- [BUG] Segfault when passing None to `cdef` method.
- [BUG] Cython inserts a call to PyMemoryView_CheckExact() which is not present in CPython API HOT 1
- Notes on "tuple table" HOT 4
- [BUG] Incompatible pointer in inlined method of derived class HOT 2
- Document and improve generation of C lines in traceback HOT 9
- [BUG] Fused type in init yields broken C program
- [BUG] `.so` file size too large? HOT 10
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 cython.