Skip to content

Commit ae570c5

Browse files
authored
Merge pull request #341 from python-greenlet/issue302
Stop using 'const PyObject*', per @vstinner
2 parents 880825b + 616df60 commit ae570c5

File tree

4 files changed

+34
-10
lines changed

4 files changed

+34
-10
lines changed

Diff for: .github/workflows/tests.yml

+14-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ jobs:
4242
run: |
4343
python -m pip install -U pip setuptools wheel
4444
python -m pip install -U twine
45-
- name: Install greenlet
45+
- name: Install greenlet (non-Mac)
46+
if: ${{ ! startsWith(runner.os, 'Mac') }}
4647
run: |
4748
python setup.py bdist_wheel
4849
python -m pip install -U -e ".[test,docs]"
@@ -53,6 +54,18 @@ jobs:
5354
# process-wide effects), we test with Ofast here, because we
5455
# expect that some people will compile it themselves with that setting.
5556
CPPFLAGS: "-Ofast -UNDEBUG"
57+
- name: Install greenlet (Mac)
58+
if: startsWith(runner.os, 'Mac')
59+
run: |
60+
python setup.py bdist_wheel
61+
python -m pip install -U -e ".[test,docs]"
62+
env:
63+
# Unlike the above, we are actually distributing these
64+
# wheels, so they need to be built for production use.
65+
CPPFLAGS: "-O3"
66+
# Build for both architectures
67+
ARCHFLAGS: "-arch x86_64 -arch arm64"
68+
5669
- name: Check greenlet build
5770
run: |
5871
ls -l dist

Diff for: CHANGES.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@
88
- Fix calling ``greenlet.settrace()`` with the same tracer object that
99
was currently active. See `issue 332
1010
<https://github.com/python-greenlet/greenlet/issues/332>`_.
11-
- Various compilation and standards conformance fixes. See #335, #336, #300.
11+
- Various compilation and standards conformance fixes. See #335, #336,
12+
#300, #302.
13+
1214

1315

1416
2.0.1 (2022-11-07)

Diff for: src/greenlet/greenlet_refs.hpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ namespace greenlet {
225225
inline OwnedObject PyRequireAttr(const ImmortalObject& name) const;
226226
inline OwnedObject PyCall(const BorrowedObject& arg) const;
227227
inline OwnedObject PyCall(PyGreenlet* arg) const ;
228-
inline OwnedObject PyCall(const PyObject* arg) const ;
228+
inline OwnedObject PyCall(PyObject* arg) const ;
229229
// PyObject_Call(this, args, kwargs);
230230
inline OwnedObject PyCall(const BorrowedObject args,
231231
const BorrowedObject kwargs) const;
@@ -714,11 +714,11 @@ namespace greenlet {
714714
template<typename T, TypeChecker TC>
715715
inline OwnedObject PyObjectPointer<T, TC>::PyCall(PyGreenlet* arg) const
716716
{
717-
return this->PyCall(reinterpret_cast<const PyObject*>(arg));
717+
return this->PyCall(reinterpret_cast<PyObject*>(arg));
718718
}
719719

720720
template<typename T, TypeChecker TC>
721-
inline OwnedObject PyObjectPointer<T, TC>::PyCall(const PyObject* arg) const
721+
inline OwnedObject PyObjectPointer<T, TC>::PyCall(PyObject* arg) const
722722
{
723723
assert(this->p);
724724
return OwnedObject::consuming(PyObject_CallFunctionObjArgs(this->p, arg, NULL));
@@ -845,16 +845,16 @@ namespace greenlet {
845845
this->PyAddObject(name, new_object.borrow());
846846
}
847847

848-
void PyAddObject(const char* name, const PyTypeObject& type)
848+
void PyAddObject(const char* name, PyTypeObject& type)
849849
{
850-
this->PyAddObject(name, reinterpret_cast<const PyObject*>(&type));
850+
this->PyAddObject(name, reinterpret_cast<PyObject*>(&type));
851851
}
852852

853-
void PyAddObject(const char* name, const PyObject* new_object)
853+
void PyAddObject(const char* name, PyObject* new_object)
854854
{
855855
Py_INCREF(new_object);
856856
try {
857-
Require(PyModule_AddObject(this->p, name, const_cast<PyObject*>(new_object)));
857+
Require(PyModule_AddObject(this->p, name, new_object));
858858
}
859859
catch (const PyErrOccurred&) {
860860
Py_DECREF(p);

Diff for: src/greenlet/platform/switch_aarch64_gcc.h

+10-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ slp_switch(void)
2626
{
2727
int err;
2828
void *fp;
29-
register long *stackref, stsizediff;
29+
long *stackref, stsizediff;
3030
__asm__ volatile ("" : : : REGS_TO_SAVE);
3131
__asm__ volatile ("str x29, %0" : "=m"(fp) : : );
3232
__asm__ ("mov %0, sp" : "=r" (stackref));
@@ -59,6 +59,15 @@ slp_switch(void)
5959
stack space), and the simplest is to call a function
6060
that returns an unknown value (which happens to be zero),
6161
so the saved/restored value is unused. */
62+
/* XXX: This line produces warnings:
63+
64+
value size does not match register size specified by the
65+
constraint and modifier
66+
67+
The suggested fix is to change %0 to %w0.
68+
69+
TODO: Validate and change that.
70+
*/
6271
__asm__ volatile ("mov %0, #0" : "=r" (err));
6372
}
6473
__asm__ volatile ("ldr x29, %0" : : "m" (fp) :);

0 commit comments

Comments
 (0)