[issue40354] problem when using yield
New submission from xie : --version1:-- def func1(): a=0 b=10 for i in range(4): result = yield a+100 if b>100 else (yield a) print(result) f1 = func1() print("value:%s" % next(f1)) print("--") print("value:%s" % next(f1)) print("--") --version2-- def func1(): a=0 b=10 for i in range(4): result = (yield a+100) if b>100 else (yield a) print(result) f1 = func1() print("value:%s" % next(f1)) print("--") print("value:%s" % next(f1)) print("--") --problem I think two version should behave same,but it did not.Do this will be treated as a bug ? -- messages: 366931 nosy: xsmyqf priority: normal severity: normal status: open title: problem when using yield type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue40354> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40354] problem when using yield
xie added the comment: Okay,I agree with you.I did not get the priority. -- stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue40354> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40475] json.JSONEncoder override default method
New submission from xie : I see an example from here:https://docs.python.org/3/library/json.html --It is about custom method from python object to json string:- import json class ComplexEncoder(json.JSONEncoder): def default(self, obj): print("hi") if isinstance(obj, complex): return [obj.real, obj.imag] # Let the base class default method raise the TypeError return json.JSONEncoder.default(self, obj) s2=json.dumps(2 + 1j, cls=ComplexEncoder) print(s2) ---I wrote an program like it,but not the result I want:--- class MyEncoder(json.JSONEncoder): def default(self,obj): print("hi") if isinstance(obj,dict): print("it is dict!") return obj["name"] return json.JSONEncoder.default(self,obj) print(MyEncoder().encode({"name":"sun","age":40})) jsonStr=json.dumps({"name":"wang","age":30},cls=MyEncoder) print(jsonStr) the result of the program is:- {"name": "sun", "age": 40} {"name": "wang", "age": 30} I think it should be:- sun wang what I missed?I am very confused. -- messages: 367912 nosy: xsmyqf priority: normal severity: normal status: open title: json.JSONEncoder override default method type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue40475> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40475] json.JSONEncoder override default method
xie added the comment: I got it,Thank you! -- resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue40475> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2206] critical memory leak in hashlib.md5
Changes by Xie Bengui: -- files: md5.txt nosy: agateriver severity: normal status: open title: critical memory leak in hashlib.md5 type: resource usage versions: Python 2.6 Added file: http://bugs.python.org/file9569/md5.txt __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2206> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2206] critical memory leak in hashlib.md5
New submission from Xie Bengui: I write a pieces of code below to find my lost password: import hashlib for i in range(,): m=hashlib.md5(str(i)).hexdigest() if m=="21e83200cfd4845fd5e07ee151d70caf": print "password is: ", i break when I run it serval minutes, all memory use up. __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2206> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2206] critical memory leak in hashlib.md5
Changes by Xie Bengui: -- nosy: -agateriver __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2206> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2206] critical memory leak in hashlib.md5
Xie Bengui added the comment: I am sorry for submitting this fake issue! Thank Benjamin Peterson! -- nosy: +agateriver __ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2206> __ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38575] Child process deadlock in subprocess.Popen
New submission from Zhipeng Xie <775350...@qq.com>: Hi, we had a child process deadlock on _disabling_gc_lock in subprocess.Popen. It seems that after https://github.com/python/cpython/commit/5e8e371364ee58dadb9a4e4e51c7e9cf6bedbfae, subprocess.Popen no longer support to be called in preexec_fn. Steps to reproduce: [root@localhost ~]# python2 --version Python 2.7.15 [root@localhost ~]# python2 mtfork.py wait for a while and the child process deadlock Here is the gdb stack: (gdb) py-bt Traceback (most recent call first): Waiting for the GIL File "/usr/local/lib/python2.7/subprocess.py", line 931, in _execute_child with self._disabling_gc_lock: File "/usr/local/lib/python2.7/subprocess.py", line 394, in __init__ errread, errwrite) File "mtfork.py", line 36, in run_cmd stderr=subprocess.PIPE) File "/usr/local/lib/python2.7/subprocess.py", line 989, in _execute_child preexec_fn() File "/usr/local/lib/python2.7/subprocess.py", line 394, in __init__ errread, errwrite) File "mtfork.py", line 15, in run_command stdout=arg_stdout, stderr=arg_stderr, shell=True) File "mtfork.py", line 51, in _readerthread3 status = run_command("/root/exe",preexec_fn=preexec_fn_no_args) File "/usr/local/lib/python2.7/threading.py", line 754, in run self.__target(*self.__args, **self.__kwargs) File "/usr/local/lib/python2.7/threading.py", line 801, in __bootstrap_inner self.run() File "/usr/local/lib/python2.7/threading.py", line 774, in __bootstrap self.__bootstrap_inner() (gdb) py-list 926# The first char specifies the exception type: 0 means 927# OSError, 1 means some other error. 928errpipe_read, errpipe_write = self.pipe_cloexec() 929try: 930try: >931with self._disabling_gc_lock: 932gc_was_enabled = gc.isenabled() 933# Disable gc to avoid bug where gc -> file_dealloc -> 934# write to stderr -> hang. 935# https://bugs.python.org/issue1336 936 gc.disable() -- components: Library (Lib) files: mtfork.py messages: 355290 nosy: Zhipeng Xie priority: normal severity: normal status: open title: Child process deadlock in subprocess.Popen type: behavior versions: Python 2.7 Added file: https://bugs.python.org/file48675/mtfork.py ___ Python tracker <https://bugs.python.org/issue38575> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37788] fix for bpo-36402 (threading._shutdown() race condition) causes reference leak
Zhipeng Xie <775350...@qq.com> added the comment: ping I also encountered this problem. Is there a fix now? -- nosy: +Zhipeng Xie ___ Python tracker <https://bugs.python.org/issue37788> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39146] too much memory consumption in re.compile unicode
Change by Zhipeng Xie <775350...@qq.com>: -- title: to much memory consumption in re.compile unicode -> too much memory consumption in re.compile unicode ___ Python tracker <https://bugs.python.org/issue39146> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39146] to much memory consumption in re.compile unicode
New submission from Zhipeng Xie <775350...@qq.com>: when running the following script, we found python2 comsume a lot memory while python3 does not have the issue. import re import time NON_PRINTABLE = re.compile(u'[^\U0001-\U0010]') time.sleep( 30 ) python2: PID USER PR NIVIRTRESSHR S %CPU %MEM TIME+ COMMAND 6943 root 20 0 109956 93436 3956 S 0.0 1.2 0:00.30 python python3: PID USER PR NIVIRTRESSHR S %CPU %MEM TIME+ COMMAND 6952 root 20 0 28032 8880 4868 S 0.0 0.1 0:00.02 python3 -- components: Library (Lib) messages: 358936 nosy: Zhipeng Xie priority: normal severity: normal status: open title: to much memory consumption in re.compile unicode type: resource usage versions: Python 2.7 ___ Python tracker <https://bugs.python.org/issue39146> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39146] too much memory consumption in re.compile unicode
Zhipeng Xie <775350...@qq.com> added the comment: Hi, I tracked it down and found that this problem was introduced in python2.7.9 by following commit: https://hg.python.org/cpython/rev/ebd48b4f650d -- nosy: +serhiy.storchaka ___ Python tracker <https://bugs.python.org/issue39146> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39146] too much memory consumption in re.compile unicode
Zhipeng Xie <775350...@qq.com> added the comment: > but range() was here before ebd48b4f650d. before ebd48b4f650d, _optimize_unicode use xrange. So python2.7.8 is ok and python2.7.9 consume much memory in my test case. > Obviously there are other causes of the difference between 2.7 and 3.x. Maybe it is because my python was compiled with --enable-unicode=ucs4. -- ___ Python tracker <https://bugs.python.org/issue39146> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43163] code.interact() unexpected raises exception when there may be more code
Change by Xie Jingyi : -- nosy: hsfzxjy priority: normal severity: normal status: open title: code.interact() unexpected raises exception when there may be more code type: behavior versions: Python 3.10 ___ Python tracker <https://bugs.python.org/issue43163> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43163] code.interact() unexpected raises exception when there may be more code
New submission from Xie Jingyi : In Python3.10.0a5, `code.interact()` will raise unexpected SyntaxError even if there should be more code. ``` Python 3.10.0a5 (default, Feb 7 2021, 20:14:10) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import code >>> code.interact() Python 3.10.0a5 (default, Feb 7 2021, 20:14:10) [GCC 9.3.0] on linux Type "help", "copyright", "credits" or "license" for more information. (InteractiveConsole) >>> print([1, ... 2, File "", line 1 print([1, ^ SyntaxError: '[' was never closed >>> ``` Similar things also happen in IDLE. -- ___ Python tracker <https://bugs.python.org/issue43163> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43163] code.interact() unexpected raises exception when there may be more code
Change by Xie Jingyi : -- assignee: -> terry.reedy components: +IDLE, Library (Lib) nosy: +terry.reedy ___ Python tracker <https://bugs.python.org/issue43163> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43163] code.interact() unexpectedly raises exception when there may be more code
Change by Xie Jingyi : -- title: code.interact() unexpected raises exception when there may be more code -> code.interact() unexpectedly raises exception when there may be more code ___ Python tracker <https://bugs.python.org/issue43163> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37297] function changed when pickle bound method object
New submission from George Xie : if we create a bound method object `f` with function object `A.f` and instance object `B()`, when pickling this bound method object: import pickle class A(): def f(self): pass class B(): def f(self): pass o = B() f = A.f.__get__(o) pf = pickle.loads(pickle.dumps(f)) print(f) print(pf) we get: > > the underlaying function are lost, changed from `A.f` to `B.f`. as pickle calls `__reduce__` method of `method object`, IMO [its implementation][1] simply ignored the real function, whcih is not right. I have tried a [wordaround][2]: import types import copyreg def my_reduce(obj): return (obj.__func__.__get__, (obj.__self__,)) copyreg.pickle(types.MethodType, my_reduce) [1]: https://github.com/python/cpython/blob/v3.7.3/Objects/classobject.c#L75-L89 [2]: https://stackoverflow.com/a/56614748/4201810 -- components: Library (Lib) messages: 345721 nosy: georgexsh priority: normal severity: normal status: open title: function changed when pickle bound method object type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue37297> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37297] function changed when pickle bound method object
Change by George Xie : -- keywords: +patch Added file: https://bugs.python.org/file48424/0001-fix-bound-method-__reduce__-bug.patch ___ Python tracker <https://bugs.python.org/issue37297> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com