Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

test/upcast.cpp does not compile since python 3.10

Đang mở
#479 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
48/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
cpp, python
Lĩnh vực
testing-qa

Hướng nghiên cứu

Bắt đầu bằng cách đọc test/upcast.cpp ở các dòng 16-17 và tái hiện quá trình biên dịch được báo cáo với các header của Python 3.10 hoặc 3.13. So sánh việc sử dụng Py_REFCNT với Python C API đã thay đổi, sau đó xác minh rằng test/upcast.cpp biên dịch thành công với các phiên bản Python mới hơn.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

revision: 3e7be69e1e405e1d5ddd232c69c024ee441592c5

Since Python 3.10, compilation of test/upcast.cpp fails.

https://github.com/boostorg/python/blob/3e7be69e1e405e1d5ddd232c69c024ee441592c5/test/upcast.cpp#L16-L17

$ g++ -Iinclude -I/opt/miniconda3/envs/py310/include/python3.10 test/upcast.cpp
In file included from /usr/include/boost/detail/lightweight_test.hpp:15,
                 from ./test/upcast.cpp:7:
./test/upcast.cpp: In function 'int main()':
/opt/miniconda3/envs/py310/include/python3.10/object.h:133:33: error: lvalue required as unary '&' operand
  133 | #define Py_REFCNT(ob) _Py_REFCNT(_PyObject_CAST_CONST(ob))
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
./test/upcast.cpp:16:17: note: in expansion of macro 'Py_REFCNT'
   16 |     BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&o)) == &Py_REFCNT(&o));
      |                 ^~~~~~~~~
/opt/miniconda3/envs/py310/include/python3.10/object.h:133:33: error: lvalue required as unary '&' operand
  133 | #define Py_REFCNT(ob) _Py_REFCNT(_PyObject_CAST_CONST(ob))
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
./test/upcast.cpp:16:68: note: in expansion of macro 'Py_REFCNT'
   16 |     BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&o)) == &Py_REFCNT(&o));
      |                                                                    ^~~~~~~~~
/opt/miniconda3/envs/py310/include/python3.10/object.h:133:33: error: lvalue required as unary '&' operand
  133 | #define Py_REFCNT(ob) _Py_REFCNT(_PyObject_CAST_CONST(ob))
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
./test/upcast.cpp:17:17: note: in expansion of macro 'Py_REFCNT'
   17 |     BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&y)) == &Py_REFCNT(&y));
      |                 ^~~~~~~~~
/opt/miniconda3/envs/py310/include/python3.10/object.h:133:33: error: lvalue required as unary '&' operand
  133 | #define Py_REFCNT(ob) _Py_REFCNT(_PyObject_CAST_CONST(ob))
      |                       ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
./test/upcast.cpp:17:68: note: in expansion of macro 'Py_REFCNT'
   17 |     BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&y)) == &Py_REFCNT(&y));
      |                                                                    ^~~~~~~~~
$ g++ -Iinclude -I/usr/include/python3.13 test/upcast.cpp
In file included from /usr/include/boost/detail/lightweight_test.hpp:15,
                 from test/upcast.cpp:7:
test/upcast.cpp: In function 'int main()':
/usr/include/python3.13/object.h:330:34: error: lvalue required as unary '&' operand
  330 | #  define Py_REFCNT(ob) Py_REFCNT(_PyObject_CAST(ob))
      |                         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
test/upcast.cpp:16:17: note: in expansion of macro 'Py_REFCNT'
   16 |     BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&o)) == &Py_REFCNT(&o));
      |                 ^~~~~~~~~
/usr/include/python3.13/object.h:330:34: error: lvalue required as unary '&' operand
  330 | #  define Py_REFCNT(ob) Py_REFCNT(_PyObject_CAST(ob))
      |                         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
test/upcast.cpp:16:68: note: in expansion of macro 'Py_REFCNT'
   16 |     BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&o)) == &Py_REFCNT(&o));
      |                                                                    ^~~~~~~~~
/usr/include/python3.13/object.h:330:34: error: lvalue required as unary '&' operand
  330 | #  define Py_REFCNT(ob) Py_REFCNT(_PyObject_CAST(ob))
      |                         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
test/upcast.cpp:17:17: note: in expansion of macro 'Py_REFCNT'
   17 |     BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&y)) == &Py_REFCNT(&y));
      |                 ^~~~~~~~~
/usr/include/python3.13/object.h:330:34: error: lvalue required as unary '&' operand
  330 | #  define Py_REFCNT(ob) Py_REFCNT(_PyObject_CAST(ob))
      |                         ~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
test/upcast.cpp:17:68: note: in expansion of macro 'Py_REFCNT'
   17 |     BOOST_TEST(&Py_REFCNT(boost::python::upcast<PyObject>(&y)) == &Py_REFCNT(&y));
      |                                                                    ^~~~~~~~~

This is because Py_REFCNT() is changed to the inline static function.

Unfortunately, the CI images use python upto 3.8, so the issue has not been found.

Ngôn ngữ chính
C++
Star
537
Fork
223
Merge trung bình
11 giờ 22 phút
Pull request đã merge (30 ngày)
2

Hướng dẫn đóng góp

Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của boostorg/python

Tất cả issue của boostorg/python

Issue tương tự

Thêm issue về C++

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.