How to compare two methods?
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Cần làm rõ
- Mức độ hoạt động
- Đình trệ
- Công nghệ
- javascript, python
- Lĩnh vực
- compilers
Hướng nghiên cứu
No source file or test is named. Start by reproducing the provided ClassA callback-comparison example and inspect the generated JavaScript shown in the issue. Done means determining whether the differing method identity is expected or a compiler bug, then establishing a concrete workaround or regression coverage.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Hi.
I want to check whether a given callback is a specific method in a class. I found that comparing two methods failed. Following is the test code:
class ClassA:
def proc(self, callback=None):
if callback==self.method1:
print('callback==self.method1, callback=', callback)
else:
print('callback!=self.method1')
print('callback.name=', callback.name)
print('callback.__name__=', callback.__name__)
print('callback.__qualname__=', callback.__qualname__)
print('callback=', callback)
print('self.method1=', self.method1)
if self.method1==self.method1:
print('self.method1==self.method1')
else: print('self.method1!=self.method1')
def method1(self):
pass
def main():
a1= ClassA()
a1.proc(a1.method1)
if __name__ == '__main__':
main()
output:
callback!=self.method1
callback.name= None
callback.__name__= None
callback.__qualname__= None
callback= function () {
var args = [] .slice.apply (arguments);
return func.apply (null, [self] .concat (args));
}
self.method1= function () {
var args = [] .slice.apply (arguments);
return func.apply (null, [self] .concat (args));
}
self.method1!=self.method1
What I was surprised was the last line in the output, self.method1!=self.method1, which was a self comparison, but failed. (Is it a bug?)
How can I know a given callback is equal to a specific method? I tried to find a workaround. But as the output above, information about the method (name, _ _ name _ _, and _ _ qualname _ _) is not available. Any idea or workaround is welcome if you have any.
Thanks.
- Ngôn ngữ chính
- Python
- Star
- 2.9k
- Fork
- 218
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
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
- Đọ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 TranscryptOrg/Transcrypt
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
TranscryptOrg/Transcrypt#913 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
TranscryptOrg/Transcrypt#911 · 2 bình luận ·
-
IS: bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
TranscryptOrg/Transcrypt#908 ·
-
SUB: documentation
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
TranscryptOrg/Transcrypt#656 · 7 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 76/100
TranscryptOrg/Transcrypt#914 ·
Tất cả issue của TranscryptOrg/Transcrypt
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
zostera/django-bootstrap4#894 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
use-agent-os/agent-os#3276 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 88/100
NousResearch/hermes-agent#117848 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
zilliztech/memsearch#759 ·