Error when calling to_pydict on a message having a repeated timestamp field
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 35/100
Hướng nghiên cứu
Tái hiện vấn đề với định nghĩa Msg và giá trị datetime được cung cấp, sau đó truy vết đường dẫn chuyển đổi to_pydict xử lý repeated fields và các giá trị google.protobuf.Timestamp. Được coi là hoàn tất khi to_pydict hoàn thành mà không có AttributeError và trả về biểu diễn repeated timestamp như mong đợi, khớp với hành vi hoạt động của to_dict.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When calling the to_pydict method on a message which has a repeated timestamp field, an AttributeError is raised.
Reproduction Steps
Compile the following message :
message Msg {
repeated google.protobuf.Timestamp ts = 1;
}
Then, execute the following code:
from datetime import datetime
msg = Msg(ts=[datetime(2015, 3, 5)])
print(msg.to_dict())
print(msg.to_pydict())
Expected Results
In this situation, it is expected for the two calls to work without error.
Actual Results
The call to to_dict works as expected: it prints {'ts': ['2015-03-05T00:00:00Z']}. However, the call to to_pydict fails with the error: AttributeError: 'datetime.datetime' object has no attribute 'to_pydict'.
It is possible to simply fix this bug (and the related bugs) by patching the to_pydict function, but it might be easier with a bit of refactoring first. I will probably be able to work on this once my other PRs are approved.
System Information
libprotoc 3.12.4
Python 3.12.5
Name: betterproto
Version: 2.0.0b7
Summary: A better Protobuf / gRPC generator & library
Home-page: https://github.com/danielgtaylor/python-betterproto
Author: Daniel G. Taylor
Author-email: [email protected]
License: MIT
Location: XXX/.venv/lib/python3.12/site-packages
Requires: grpclib, python-dateutil, typing-extensions
Required-by: pygrpc-poc
Checklist
- I have searched the issues for duplicates.
- I have shown the entire traceback, if possible.
- I have verified this issue occurs on the latest prelease of betterproto which can be installed using
pip install -U --pre betterproto, if possible.
- Ngôn ngữ chính
- Python
- Star
- 1.8k
- Fork
- 235
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của danielgtaylor/python-betterproto
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 15/100
-
bug investigation needed
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 42/100
-
bug investigation needed
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
-
bug investigation needed
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
danielgtaylor/python-betterproto#676 · 3 bình luận ·
Tất cả issue của danielgtaylor/python-betterproto
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 67/100
MISP/misp-workbench#496 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
fossasia/visdom-dev#69 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
[Bug] Parameters named like a property break to_xcal()Có thể đã có người làm @atharvasalunke1267 đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
collective/icalendar#2018 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Maintainer thường phản hồi trong vòng 1 ngày