[issue13662] os.listdir bug
New submission from wang : when I use os.list the return value is like this: ['some.xml', '\ufeff9158.xml'] but the file name have not the '\ufeff'. because this problem the script can't runing. -- messages: 150252 nosy: guxianminer priority: normal severity: normal status: open title: os.listdir bug versions: Python 3.1 ___ Python tracker <http://bugs.python.org/issue13662> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13662] os.listdir bug
wang added the comment: only I double click the script file generate this problem. in IDE not this problem. -- ___ Python tracker <http://bugs.python.org/issue13662> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13662] os.listdir bug
wang added the comment: I mean in IDLE can run ok. the '\ufeff' is still have. -- ___ Python tracker <http://bugs.python.org/issue13662> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13662] os.listdir bug
wang added the comment: I mean in IDLE can run ok. the '\ufeff' is still have. -- ___ Python tracker <http://bugs.python.org/issue13662> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13662] os.listdir bug
Changes by wang : -- components: +Windows ___ Python tracker <http://bugs.python.org/issue13662> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5090] import tkinter library Visual C++ Concepts:C Run-Time Error R6034 when embeded python in c++
New submission from wang : import tkinter library Visual C++ Concepts:C Run-Time Error R6034 when embeded python in c++ -- components: Tkinter messages: 80710 nosy: guxianminer severity: normal status: open title: import tkinter library Visual C++ Concepts:C Run-Time Error R6034 when embeded python in c++ versions: Python 3.0 ___ Python tracker <http://bugs.python.org/issue5090> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5090] import tkinter library Visual C++ Concepts:C Run-Time Error R6034 when embeded python in c++
wang added the comment: my compile is gcc 4.2.1 system is windows xp some other library can be import. such as:sys os c++ code line: Py_Initialize(); Py_SetProgramName(L"MyProgram"); module=PyImport_ImportModule("__main__"); moduledict=PyModule_GetDict(dodule); PySys_SetArgv(1,wxargv); PyRun_StringFlags("\ import tkinter\n\ ",Py_file_input,moduledict,moduledict,NULL); Py_finalize(); the urllib.request also can not import. -- type: -> crash ___ Python tracker <http://bugs.python.org/issue5090> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14096] Python 3.1 IDLE has a bug.Can fix it?
New submission from wang : paltform is windows. generate this bug: within IDLE edtor. first select some text. second press down the shift key. third press the end key. fourth press the home key. last IDLE quit with no message and document with no save. -- components: IDLE messages: 154037 nosy: guxianminer priority: normal severity: normal status: open title: Python 3.1 IDLE has a bug.Can fix it? type: crash versions: Python 3.1 ___ Python tracker <http://bugs.python.org/issue14096> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14096] IDLE quits unexpectedly when some keys are pressed
wang added the comment: thanks. new version 3.2.2 have not this problem. -- resolution: -> fixed status: open -> closed ___ Python tracker <http://bugs.python.org/issue14096> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43079] wrong IP address range given for ipv4_mapped
Change by jiahua wang : -- keywords: +patch nosy: +wangjiahua nosy_count: 2.0 -> 3.0 pull_requests: +28885 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30687 ___ Python tracker <https://bugs.python.org/issue43079> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34875] Change .js mime to "text/javascript"
Change by jiahua wang : -- nosy: +wangjiahua nosy_count: 3.0 -> 4.0 pull_requests: +28927 stage: resolved -> patch review pull_request: https://github.com/python/cpython/pull/30740 ___ Python tracker <https://bugs.python.org/issue34875> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46456] Add mime type "image/avif"
New submission from jiahua wang : https://www.iana.org/assignments/media-types/image/avif -- components: Library (Lib) messages: 411134 nosy: wangjiahua priority: normal severity: normal status: open title: Add mime type "image/avif" versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue46456> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46456] Add mime type "image/avif"
Change by jiahua wang : -- keywords: +patch pull_requests: +29010 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30823 ___ Python tracker <https://bugs.python.org/issue46456> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46484] Add test for Calendar().iterweekdays()
New submission from jiahua wang : Apparently there is no test for Calendar().iterweekdays(). wangdeMacBook-Pro :: ~/cpython » grep -R iterweekdays Lib/test/ * Binary file Lib/test//__pycache__/test_calendar.cpython-311.pyc matches Doc/library/calendar.rst: .. method:: iterweekdays() Binary file Lib/test/__pycache__/test_calendar.cpython-311.pyc matches Binary file Lib/__pycache__/calendar.cpython-311.pyc matches Lib/calendar.py:def iterweekdays(self): Lib/calendar.py:return ' '.join(self.formatweekday(i, width) for i in self.iterweekdays()) Lib/calendar.py:s = ''.join(self.formatweekday(i) for i in self.iterweekdays()) -- components: Tests messages: 411359 nosy: wangjiahua priority: normal severity: normal status: open title: Add test for Calendar().iterweekdays() versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue46484> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46484] Add test for Calendar().iterweekdays()
Change by jiahua wang : -- keywords: +patch pull_requests: +29012 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30825 ___ Python tracker <https://bugs.python.org/issue46484> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46157] Typo in JSON documentation
Change by jiahua wang : -- nosy: +wangjiahua nosy_count: 5.0 -> 6.0 pull_requests: +29028 pull_request: https://github.com/python/cpython/pull/30846 ___ Python tracker <https://bugs.python.org/issue46157> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46498] Add new triplets for loongarch64
New submission from WANG Xuerui : First of all I think the changes should probably go in main branch first, then backported to the older branches if possible; although IMO you'd be much better off just backporting and carrying the patch yourselves. Secondly the suggested patch is not consistent with the LoongArch toolchain spec, in that it didn't use the multiarch identifiers in the spec document (https://github.com/loongson/LoongArch-Documentation/blob/a8a004148734445480659a5e25ef985817881341/docs/LoongArch-toolchain-conventions-EN.adoc, Table 12), but rather the old-world one; see the discussion at https://github.com/loongarch64/cpython/pull/1 (in Chinese) too. -- nosy: +xen0n ___ Python tracker <https://bugs.python.org/issue46498> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25948] Invalid MIME encoding generated by email.mime (line too long)
Change by jiahua wang : -- keywords: +patch nosy: +wangjiahua nosy_count: 3.0 -> 4.0 pull_requests: +29159 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30980 ___ Python tracker <https://bugs.python.org/issue25948> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10754] os.path.isfile doesn't work with some greek characters
New submission from Wang Yanjin : There is a file named "µTorrent.lnk" in the folder. Here is the code: #encoding=utf-8 import os for i in os.listdir('.'): print os.path.isfile(i), '\t', i a = input() and the output: True3.py False aμ汉字.txt TrueuTorrent.lnk False μTorrent.lnk False μTorrent1.lnk False μ汉字.txt False μ汉字.txt.lnk Trueαγβδο Trueφχ.txt Trueφχ.txt.lnk the function just doesn't work with the character "μ" -- components: Unicode, Windows messages: 124473 nosy: wyj1046 priority: normal severity: normal status: open title: os.path.isfile doesn't work with some greek characters type: behavior versions: Python 2.6 ___ Python tracker <http://bugs.python.org/issue10754> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10754] os.path.isfile doesn't work with some greek characters
Wang Yanjin added the comment: I encoutered this problem on Winxp sp3. I have retested it on the win7, and it could return the correct value as it did on linux. -- ___ Python tracker <http://bugs.python.org/issue10754> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10905] zipfile: fix arcname with leading '///' or '..'
New submission from Zhigang Wang : We only support arcname with one leading '/', but not more. This patch fixes it. We don't support arcname with '..' well. The default behavior of unzip and 7z is to ignore all '..'. This patch does the same. Also updated the doc. If there are other security related issues exist, we should revise the doc. Please review. -- components: Library (Lib) files: python-zipfile-fix-arcname.patch keywords: patch messages: 126254 nosy: zhigang priority: normal severity: normal status: open title: zipfile: fix arcname with leading '///' or '..' type: security versions: Python 3.3 Added file: http://bugs.python.org/file20404/python-zipfile-fix-arcname.patch ___ Python tracker <http://bugs.python.org/issue10905> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10905] zipfile: fix arcname with leading '///' or '..'
Zhigang Wang added the comment: $ unzip -l t.zip Archive: t.zip Length DateTimeName - -- - 3 01-14-2011 21:11 ../foo 3 01-14-2011 21:11 foo - --- 6 2 files [zhigang@localhost tmp]$ unzip -d aa t.zip Archive: t.zip warning: skipped "../" path component(s) in ../foo extracting: aa/foo replace aa/foo? [y]es, [n]o, [A]ll, [N]one, [r]ename: A extracting: aa/foo $ 7za x -oaa t.zip 7-Zip (A) 9.13 beta Copyright (c) 1999-2010 Igor Pavlov 2010-04-15 p7zip Version 9.13 (locale=en_US.UTF-8,Utf16=on,HugeFiles=on,1 CPU) Processing archive: t.zip file aa/foo already exists. Overwrite with ../foo? (Y)es / (N)o / (A)lways / (S)kip all / A(u)to rename all / (Q)uit? A Extracting ../foo Extracting foo Everything is Ok Files: 2 Size: 6 Compressed: 198 -- ___ Python tracker <http://bugs.python.org/issue10905> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10905] zipfile: fix arcname with leading '///' or '..'
Zhigang Wang added the comment: Yes, in zipfile, we just overwrite it. Actually, ZipFile.extract() overwrite existing files already. If we want it more powerful, we can add a 'overwrite' parameter. But turning zipfile a full featured zip/unzip tool needs much more extra work... -- ___ Python tracker <http://bugs.python.org/issue10905> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue3058] Let SimpleXMLRPCServer pass client_address to called functions.
New submission from Kunshan Wang <[EMAIL PROTECTED]>: I recently wrote a program making use of SimpleXMLRPCServer. It has a function that responds to the caller according to the caller's IP address. However the current SimpleXMLRPCServer does not allow me to do this (directly). For example: def whoami(): # blah blah blah return the_caller_s_ip_address svr.register_function(whoami) The problem is that only SimpleXMLRPCRequestHandler knows the client's IP address. I googled and searched the google group. Many people recommends subclassing the SimpleXMLRPCRequestHandler. I did this, but found that it is not very easy, although possible. I managed to make the RequestHandler pass its member client_address to function _dispatch by subclassing SimpleXMLRPCRequestHandler, copy-and-paste the code from the library, and then add an extra argument to _dispatch. Now _dispatch function looks like this: _dispatch(self, method, params, client_address) By default _dispatch assumes that the first parameter of 'method' is client_address, and then followed by other parameters from the (remote) caller. So if the XMLRPC client calls: s=xmlrpclib.Server("http://localhost:";) s.whoami() the server actually calls whoami(client_address), where whoami is defined as: def whoami(client_address): return client_address The attachment contains a subclassed version of SimpleXMLRPCServer, named AddressRevealingXMLRPCServer. The code is ugly (because most codes are copied, and is vulnerable to future library changes), but it just works now. However this leads to more problems: Now that client_address can be passed to the called function, it may be needed that more informations could be passed to the called function, such as the HTTP headers, the response time, etc.. My code may not be the best solution. I suggest there may be some mechanism (such as overridable methods) to be added to SimpleXMLRPCServer so that user can specify *what* to pass to the called function. -- components: Library (Lib) files: AddressRevealingXMLRPCServer.py messages: 67811 nosy: cloverprince severity: normal status: open title: Let SimpleXMLRPCServer pass client_address to called functions. type: feature request versions: Python 2.5 Added file: http://bugs.python.org/file10545/AddressRevealingXMLRPCServer.py ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue3058> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4027] wrong page index number in reference book of python documentation
New submission from Ray Wang <[EMAIL PROTECTED]>: the Glossary's index number is 3, which should be 75, so people could not navigate "Glossary" by clicking the title showed in Table of Content, or index link which is beside the content in Evince. -- assignee: georg.brandl components: Documentation files: ref.png messages: 74233 nosy: georg.brandl, ray severity: normal status: open title: wrong page index number in reference book of python documentation type: behavior versions: Python 2.6 Added file: http://bugs.python.org/file11689/ref.png ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4027> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4027] wrong page index number in reference book of python documentation
Ray Wang <[EMAIL PROTECTED]> added the comment: hi, sorry for didn't present very clear. > Which version of the Ref Manual is this supposed to be? the newest python documentations, Release 2.6, October 2, 2008 > By Evince do you mean the Gnome document viewer? > http://www.gnome.org/projects/evince/ Yes > If so, are you trying to view a .pdf downloaded from python.org? Yes, from the official site. download the docs from http://docs.python.org/ftp/python/doc/2.6/python-docs-pdf-a4.tar.bz2 > If so, did you try viewing it with acrobat or some other .pdf viewer? Yes, the same. I tested in acrobat. both has this problem. > This would indicate whether the fault is with the Evince or Python's > .pdf generation or index support. I guess the problem is index support. > The screenshot shows two other major problems with the TOC. > Data model should not be indented; it is not part of lexical analysis. > Three chapters between Data Model and Compound Statements are missing. exactly, the index may be messed up. ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4027> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7852] [PATCH] Drop "Computer" from "Apple Computer" in plistlib
New submission from Wang Chun : Apple's official utilities had been dropped the word "Computer". We should follow them. imac:~$ cat test.py __import__('plistlib').writePlist({}, 'test.plist') imac:~$ python test.py imac:~$ cat test.py __import__('plistlib').writePlist({}, 'test.plist') imac:~$ python test.py imac:~$ cat test.plist http://www.apple.com/DTDs/PropertyList-1.0.dtd";> imac:~$ plutil -convert xml1 test.plist imac:~$ cat test.plist http://www.apple.com/DTDs/PropertyList-1.0.dtd";> imac:~$ -- components: Library (Lib) files: plistlib.diff keywords: patch messages: 98815 nosy: wangchun severity: normal status: open title: [PATCH] Drop "Computer" from "Apple Computer" in plistlib type: behavior versions: Python 2.7 Added file: http://bugs.python.org/file16123/plistlib.diff ___ Python tracker <http://bugs.python.org/issue7852> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7852] [PATCH] Drop "Computer" from "Apple Computer" in plistlib
Wang Chun added the comment: plutil is a command shipped with every Mac. See the example in my original post. -- ___ Python tracker <http://bugs.python.org/issue7852> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4027] wrong page index number in reference book of python documentation
Ray Wang <[EMAIL PROTECTED]> added the comment: any feedback here? ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4027> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4027] wrong page index number in reference book of python documentation
Ray Wang <[EMAIL PROTECTED]> added the comment: > We are all volunteers here, and I see three replies. > This may or may not be trivial to fix, and may take some time. > Python docs are written in rst format and translated by Sphinx to > various formats. The main translation is to html, as viewed on the > site. Translation to .pdf is indirect via translation to latex and then > from latex to .pdf. Since the .html index appears flawless, and since a > different .pdf has problems, I suspect that the .pdf index problem is in > one of the two translation steps. Hence the change of component. > In the meanwhile, either ignore the index or use the html version. Thanks a lot for you reply. I just intend to raise somebody's attention to this problem in order to improve reader's experience. It might or might not be a trivial to fix though. ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4027> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4027] wrong page index number in reference book of python documentation
Ray Wang <[EMAIL PROTECTED]> added the comment: ah, thanks goodness, what a fortune that you are not ignoring this problem. I expect the fix could be happen in the near future. :) ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4027> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4027] wrong page index number in reference book of python documentation
Ray Wang <[EMAIL PROTECTED]> added the comment: Woohoo, you are awesome, thanks a lot! ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4027> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4027] wrong page index number in reference book of python documentation
Ray Wang <[EMAIL PROTECTED]> added the comment: Thanks for your big efforts! ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4027> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1982] Feature: extend strftime to accept milliseconds
Wang Chun <[EMAIL PROTECTED]> added the comment: Ruby recently added support of millisecond and nanosecond to strftime. This is their changeset: http://redmine.ruby-lang.org/repositories/revision/ruby-19?rev=18731 To use the extended strftime, one can do: >> Time.now.strftime('%Y-%m-%dT%H:%M:%S.%L%z') .. "2008-10-29T17:46:03.895+0800" In the current implementation of Python, both datetime and time modules have strftime. Like in Ruby, the strftime in datetime module is a method. But the strftime in time module is a function, which takes time value to be formatted from argument, and which must be a 9-tuple returned by gmtime or localtime. No microsecond data in the tuple, unfortunately. I think as the first step we can make datetime.datetime.strftime do microsecond. I prefer microsecond to milli- or micro- second because it is something from the the system. The current Ruby implementation use %L or %3N for millisecond, %6N for microsecond, and %N or %9N for nanosecond. I am not sure where they came from. Hope there can be some widely accepted standard. -- nosy: +wangchun ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue1982> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4227] unicode_literals and print_function do not work together.
New submission from Wang Chun <[EMAIL PROTECTED]>: If "from __future__ import unicode_literals, print_function", unicode_literals works, but not print_function; If "from __future__ import print_function, unicode_literals", print_function works, but not unicode_literals. -- components: Interpreter Core messages: 75314 nosy: wangchun severity: normal status: open title: unicode_literals and print_function do not work together. type: behavior versions: Python 2.6 ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4227> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2173] Python fails silently on bad locale
Wang Chun <[EMAIL PROTECTED]> added the comment: This issue remains unsolved in the latest python 3.0rc2+ subversion repository as of 2008-11-13. -- nosy: +wangchun ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2173> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4515] Formatting error in "What's New in Python 3.0"
New submission from Peter Wang <[EMAIL PROTECTED]>: In the section "Removed Syntax", there is some ReST markup that leaked through into the output: "The only acceptable syntax for relative imports is from .``[*module*] :keyword:`import` *name*; :keyword:`import` forms not starting with ``. are always interpreted as absolute imports. (PEP 0328)" -- assignee: georg.brandl components: Documentation messages: 76865 nosy: georg.brandl, pwang severity: normal status: open title: Formatting error in "What's New in Python 3.0" versions: Python 3.0 ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4515> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4516] Another formatting error in "What's New in Python 3.0"
New submission from Peter Wang <[EMAIL PROTECTED]>: In the "Library Changes" section, the next to last bullet point about string.letters has leaked through some ReST markup into the final output: ":data:string.letters`" -- assignee: georg.brandl components: Documentation messages: 76866 nosy: georg.brandl, pwang severity: normal status: open title: Another formatting error in "What's New in Python 3.0" versions: Python 3.0 ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4516> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4629] getopt should not accept no_argument that ends with '='
New submission from Wang Chun <[EMAIL PROTECTED]>: Consider the following program tmp.py: import sys, getopt print(getopt.getopt(sys.argv[1:], '', ['help'])) The program accept "--help" without a value: python helloworld.py --help But if someone invoke the program like: python helloworld.py --help= Python should raise an error. "--help=" is not considered as no_argument in libc's getopt implementation (tested on Mac OS X Leopard): #include static struct option longopts[] = { { "help", no_argument, NULL, "h" }, }; #include static struct option longopts[] = { { "help", no_argument, NULL, 'h' }, }; int main(int argc, char **argv) { while (getopt_long(argc, argv, "h", longopts, NULL) != -1); return 0; } macbook:~/tmp$ gcc -o tmp tmp.c macbook:~/tmp$ ./tmp --help= tmp: option `--help' doesn't allow an argument macbook:~/tmp$ -- components: Library (Lib) messages: 77597 nosy: wangchun severity: normal status: open title: getopt should not accept no_argument that ends with '=' type: behavior versions: Python 2.1.1, Python 2.1.2, Python 2.2, Python 2.2.1, Python 2.2.2, Python 2.2.3, Python 2.3, Python 2.4, Python 2.5, Python 2.5.3, Python 2.6, Python 2.7, Python 3.0, Python 3.1 ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4629> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4629] getopt should not accept no_argument that ends with '='
Changes by Wang Chun <[EMAIL PROTECTED]>: -- keywords: +patch Added file: http://bugs.python.org/file12325/getopt.py.diff ___ Python tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue4629> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4650] getopt need re-factor...
New submission from Wang Chun : I created #4629 a couple of days ago. And besides that issue, for Python 3.x, I guess we can remove getopt.error since Python 3.x does not have to backward compatible with Python 2.x. And another issue is, GetoptError does not render right error message with unicode_literals enabled in Python 2.6. -- components: Library (Lib) messages: 77715 nosy: wangchun severity: normal status: open title: getopt need re-factor... versions: Python 3.0, Python 3.1 ___ Python tracker <http://bugs.python.org/issue4650> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4651] getopt need re-factor...
New submission from Wang Chun : I created #4629 a couple of days ago. And besides that issue, for Python 3.x, I guess we can remove getopt.error since Python 3.x does not have to backward compatible with Python 2.x. And another issue is, GetoptError does not render right error message with unicode_literals enabled in Python 2.6. -- components: Library (Lib) messages: 77716 nosy: wangchun severity: normal status: open title: getopt need re-factor... versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1 ___ Python tracker <http://bugs.python.org/issue4651> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
New submission from Javen Wang : I encountered a very strange issue in file flush operation in Windows. Here's the scenario of my application: 1. The main thread of my application will create makefiles sequentially. 2. Once a makefile is generated, launch a separate process calling nmake.exe to run it in parallell. The main thread then create another makefile until no more makefiles to create. 3. The number of new processes is limited by command line options. My application has been running for almost a year without any problem. But, after I made some changes recently to the content of makefile generated, "nmake.exe" in separate process sometimes complains that the makefile was not found. But when I went into the directory, the makefile was there. Because I didn't change any thing related to file creation and the new makefiles are a little bit less than before, I guessed that the makefile just created hasn't been flushed to disk because of size change so the new process could not see it in a short time. So I decided add code to force flush file buffer after writing the file content (I didn't flush the file explicitly before). I did it like below: Fd = open(File, "w") Fd.write(Content) Fd.flush() os.fsync(Fd.fileno()) Fd.close() The strangest thing happened. The "makefile" missing happened more frequently than no flush operation. I searched the web but no answer there. Finally I tried to use Windows file API to create the file via pywin32 extension. The problem's gone. import win32file Fd = win32file.CreateFile( File, win32file.GENERIC_WRITE, 0, None, win32file.CREATE_ALWAYS, win32file.FILE_ATTRIBUTE_NORMAL, None ) win32file.WriteFile(Fd, str(Content), None) win32file.FlushFileBuffers(Fd) win32file.CloseHandle(Fd) I tried writing small python extension in C to make use Windows API to create file like above. It also works well, even I removed the FlushFileBuffers() calling. I think that there's a bug in Python file buffer mechanism. -- components: Windows messages: 79829 nosy: javen72 severity: normal status: open title: os.fsync() doesn't work as expect in Windows type: behavior versions: Python 2.5 ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: gagenellina, My application is a little bit different from your test code. It won't wait for the exit of new process and there're file writing operations during makefile running. I changed the test code to be real multi-process and tried many file sizes. But I cannot reproduce it. Maybe my application is more complicated situation. ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: The created files are on local drive. I saw the problem on the laptop (XP-SP2), desktop(XP-SP3) and server (Win2003). But there's no such problem on the Linux and Mac boxes. I tried to use fopen/fwrite in my extension according to your suggestion. The problem wasn't be reproduced. It seems the bug is more alike in Python part. My application is a build system and is also an open source project. Is it possible for you to download it and try it in your box? I created temporary user (py123, password: 123py123) for you (just in case) and here's steps of how to reproduce it. 1. Checkout the build system source code in, for example, c:\test C:\test> svn co --username py123 --password 123py123 https://buildtools.tianocore.org/svn/buildtools/trunk/BaseTools tools 2. Checkout the source code to be built against in c:\test C:\test> svn co --username py123 --password 123py123 https://edk2.tianocore.org/svn/edk2/trunk/edk2 edk2 3. Change the source code between line 222 and line 229 of c:\test\tools\Source\Python\Common\Misc.py (SaveFileOnChange function) like below: Fd = open(File, "wb") Fd.write(Content) Fd.flush() os.fsync(Fd.fileno()) Fd.close() 4. In c:\test\edk2, run C:\test\edk2> edksetup.bat C:\test\edk2> set PYTHONPATH=C:\test\tools\Source\Python C:\test\edk2> python.exe C:\test\tools\Source\Python\build\build.py -n 2 -p MdeModulePkg\MdeModulePkg.dsc -a IA32 -s 5. If the application stops with message like "makefile not found" or "AutoGen.h not found" message, that means the problem happened. Visual Studio 2005 is needed to reproduce it. ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: There would be more chances to see the problem by doing this: C:\test\edk2> python.exe C:\test\tools\Source\Python\build\build.py -n 2 -p IntelFrameworkModulePkg\IntelFrameworkModulePkg.dsc -a IA32 -s ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: Thank you very much for the trying. You might miss the step 4 in my previous message. The step is: C:\test\edk2> edksetup.bat C:\test\edk2> set PYTHONPATH=C:\test\tools\Source\Python C:\test\edk2> python.exe C:\test\tools\Source\Python\build\build.py -n 2 -p IntelFrameworkModulePkg\IntelFrameworkModulePkg.dsc -a IA32 -s The Visual Studio 2005 must be in the standard installation directory. Otherwise the C:\test\edk2\Conf\tools_def.txt needs to be changed to reflect the real path. And I tried to disabled all antivirus services and the problem is still there. Don't worry about the binary version of build in edk2\BaseTools\Bin\Win32 (linked against Python 2.5.2). The step I told you is to execute my application from Python script directly. And I tried to execute from script source against Python 2.5.4 and the problem is the same. And no matter running the build from script source or the freeze-ed binary, the results are the same either. If it's hard or inconvenient for you to reproduce it, could you please give me any advice or suggestion on how to debug it (in the interpreter) and where's most possible place the root cause would be in the Python interpreter's code? I can try to change something in the Python interpreter's code, rebuild it and try it on my machine. Although I have work around for this problem, I'd like to root cause it to avoid further possible build break of our project. ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: I agree multithread programming is kind of difficult and tricky. But I don't think there's a race condition in _MultiThreadBuildPlatform method, because I do have only one producer. And the consumer consumes the product only when it's done (i.e. the file is created and closed). The only race condition, I think, it's in the Python or Windows file system, in which the file created might not be seen by other process due to the file buffer mechanism. I think the flush() method of file object and os.fsync() are to remove the race condition. But it seems that they are not working as they're supposed to be. What I know is that os.fsync() calls the _commit() which calls FlushFileBuffers(). Why no problem if I call the FlushFileBuffers() directly? That's why I think the most possible race condition is in Python file buffer operation which is out of the control of my Python code. I'm sorry that I didn't realize there's 150M code to checkout. Thanks for your patience. Actually they are not code of my application itself. They are the code used to test my application because my application is a build system which needs source code to build. The real code of my application is in the, for my example, directory of C:\test\tools\Source\Python with just about 3M source files :-) And I think I have narrowed down the issue in the file creation in SaveFileOnChange function in C:\test\tools\Source\Python\Common\Misc.py. I know it's very hard to reproduce issue in multi-thread context. And I cannot say absolutely there's no bug in my code. It's OK for you to close this tracker. But it would be better to let it open for a few days so that I can do more investigation then. Anyway, thanks for the trying again. ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: I narrowed down the root cause in the GIL of Python. I read the source code of implementing os.fsync and found it's using Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS to enclose the calling of _commit() in order to be thread safe. I tried to add them in my C extension and then the issue was reproduced. It looks like the thread state operation or GIL caused a race condition and let os.fsync() not flush the makefile in buffer to disk before it returns. The multi-thread scenario in my application is a. the main thread produces makefile b. once a makefile is generated, the main thread launches a new thread in which a separated process is launched to run the makefile until it exits. I think there's no issue in this multi-thread scenario. And the Python 2.5.2 Maunal, Python/C API Ch8.1, says GIL must be taken care when doing some blocking I/O operations, but it caused thread unsafe. So I still think there's a bug in the Python. ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: I'm quite certain that the makefile is generated before the "make" program is launched in separated process. Follow is the original code where the makefile is created (line 14) and a task is put in queue (line 19). It's executed in the main thread (no parallel execution here). There's no way that the process is launched before the makefile generation. 01for Module in Pa.Platform.Modules: 02Ma = ModuleAutoGen(Wa, Module, BuildTarget, ToolChain, Arch, self.PlatformFile) 03if Ma == None: 04continue 05# generate AutoGen files and Makefile here 06if self.Target not in ['clean', 'cleanlib', 'cleanall', 'run', 'fds']: 07# for target which must generate AutoGen code and makefile 08if not self.SkipAutoGen or self.Target == 'genc': 09Ma.CreateCodeFile(True) 10if self.Target == "genc": 11continue 12 13if not self.SkipAutoGen or self.Target == 'genmake': 14Ma.CreateMakeFile(True) 15if self.Target == "genmake": 16continue 17 18# Generate build task for the module which will be launched separately 19Bt = BuildTask.New(ModuleMakeUnit(Ma, self.Target)) I think the Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS should not be used for fsync in the Python core code (in posixmodule.c, right?). Because fsync is mostly used to solve file operation issue in parallel execution context, it should not give out CPU time to other threads or processes when it's running. ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: I did trace the order of file creation and process launch. It shows the file is indeed created before the process launch. I did another investigation. I added a new process, "cmd.exe /c copy Makefile NewMakefile", to copy the the Makefile created, just before launching the "nmake.exe" process. The strangest thing happened again: each makefile was copied successful but there's still "makefile not found" reported by "nmake.exe" process. I tried standalone copy application "xcopy.exe" and the result was the same. So I guess that "cmd.exe", "xcopy.exe" and "nmake.exe" might use different families of API or different mode (sync vs async) to access file. I decided to try the code you provided. In checkfile.c, fopen is used to test the file existence. I changed it to the Windows native API CreateFile and I also added a file write operation in order to make it more similar to the real case. Eventually, the problem was reproduced in your code. Following are the successful number of creating 1000 files 5 times in different file sizes: Create file in 403 bytes, 985, 992, 984, 989, 992 (no flush after creation) 883, 886, 907, 909, 915 (flush after creation) Create file in 4061 bytes 983, 976, 982, 977, 983 (no flush after creation) 654, 672, 684, 686, 648 (flush after creation) Create file in 16461 bytes: 970, 967, 963, 963, 971 (no flush after creation) 598, 664, 711, 653, 623 (flush after creation) In summary: a. Using fopen to test a file existence in check_file.c will never report failure, no matter buffer is flushed or not. b. Using CreateFile (read mode) to test a file existence in check_file.c will always report failure. The bigger the file size will cause more failure reported; the flush operation after file creation in test_file_flush.py will cause more failure reported; the flush operation after new file creation in check_file.c will cause more failure reported; no flush operation in both check_file.c and test_file_flush.py almost cause no failure. I don't know what's root cause: GIL, Python thread state switch, Python file buffer or Windows FileCreate API. I'm just certain there's race condition between Python and Windows. Added file: http://bugs.python.org/file12807/checkfile.c ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: The test code and script which can reproduce the problem has been uploaded. Added file: http://bugs.python.org/file12808/test_file_flush.py ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: I'm using Python2.5 in which close_fds is not available in Windows. And I cannot use Python2.6 because I need to redirect the stdout and stderr and there's performance concern. I have questions on the root cause: a. why doesn't fopen() has sharing issue? b. why don't os.close() and FileObject.close() really close the file? ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4944] os.fsync() doesn't work as expect in Windows
Javen Wang added the comment: I don't have Python2.6 installed. I just have ever read a bench article comparing the performance between different version of Python, including 2.5, 2.6 and 3.0. That article shows, for the same script, Python2.6 has longer running time than Python2.5. My application is a build system and the users are very care about the time spent in build. That's why I have the performance concern. What concerns me more is the stdout/stderr redirection. Python2.6 manual says they cannot be redirected if close_fds is set to True. My application relies on the I/O redirection to control the screen output from subprocess. Actually I have had a work-around for this issue. It works very well so far. I reported a bug here just because I want the Python to be better. I learned it one year ago but I love this language. I just hope nobody else encounter such problem again. If you guys think it won't be fixed in Python 2.5 or has been fixed in Python 2.6, it's OK to close this tracker. Thanks for your time. ___ Python tracker <http://bugs.python.org/issue4944> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46907] Update Windows and MacOS installer to SQLite 3.38.2
Change by jiahua wang : -- nosy: +wangjiahua nosy_count: 9.0 -> 10.0 pull_requests: +30229 pull_request: https://github.com/python/cpython/pull/32149 ___ Python tracker <https://bugs.python.org/issue46907> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38420] defaultdict does not support parametric lambda
New submission from wang xuancong : A very common use of defaultdict is that if the key exist, use the corresponding mapped target, if the key does not exist, use the key itself. However, current Python 2/3 defaultdict does not support parametric lambda function: >>> from collections import * >>> aa=defaultdict(lambda t:t) >>> aa defaultdict( at 0x10a55c950>, {}) >>> aa[0] Traceback (most recent call last): File "", line 1, in TypeError: () missing 1 required positional argument: 't' >>> I would like to suggest that use the dict's query key as the first argument in the default lambda function. And use the dict itself as the 2nd argument in the default lambda function (e.g., if the key exist, use the mapped target, otherwise, use the size of the current defaultdict). I think that will make Python much more powerful than any other programming language. Anyone can think of any additional information for the default lambda function? Thanks! -- messages: 354255 nosy: xuancong84 priority: normal severity: normal status: open title: defaultdict does not support parametric lambda type: enhancement versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue38420> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38315] Provide defaultdict variant that passes key to default_factory
wang xuancong added the comment: I agree with Mark Amery. The reason why defaultdict still exists given that everything can be achieved by subclassing the built-in dict is because of convenience. I suggest maybe Python developer can put it into low priority instead. -- nosy: +xuancong84 ___ Python tracker <https://bugs.python.org/issue38315> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38503] bug: string search can find \n, but can NEVER find \r
New submission from wang xuancong : If I load a file which contains "\r" and "\n", I can find "\n", but not "\r". This behaviour is inconsistent in Python 3, but consistent in Python 2. >>> open('./3cjkxdnw/accessibilityLog/1570181896323.csv', >>> 'rb').read().count(b'\r') 88 >>> open('./3cjkxdnw/accessibilityLog/1570181896323.csv').read().count('\r') 0 >>> type(open('./3cjkxdnw/accessibilityLog/1570181896323.csv').read()) >>> type('\r') Thanks! -- messages: 354834 nosy: xuancong84 priority: normal severity: normal status: open title: bug: string search can find \n, but can NEVER find \r type: behavior versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue38503> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38568] [3.7.5 x86_64 Linux] f-string parsing results in EOL
New submission from Ying Wang : Hey, I encountered an interesting bug when trying to do string parsing using f-strings. I am currently under the impression that within the curly braces is any expression that can be successfully evaluated in a REPL. Here's the error: ```bash yingw787@yingw787-Oryx-Pro:~/src/gpudb-dev-v6.2.0/kio/kio/tests/regression/_data/csv$ python Python 3.7.5 (default, Oct 15 2019, 21:38:37) [GCC 5.4.0 20160609] on linux Type "help", "copyright", "credits" or "license" for more information. >>> blah = '"hi"' >>> blah '"hi"' >>> f'{blah.strip('"')}' File "", line 1 f'{blah.strip('"')}' ^ SyntaxError: EOL while scanning string literal >>> '{0}'.format(blah.strip('"')) 'hi' >>> ``` I can use '.format()' for now, but it might be nice to align f-string expr behavior w/ .format(). Please let me know if you need more reproduction steps, or if you need a helping hand :) Thanks Ying -- components: Interpreter Core messages: 355254 nosy: yingw787 priority: normal severity: normal status: open title: [3.7.5 x86_64 Linux] f-string parsing results in EOL type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue38568> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38568] [3.7.5 x86_64 Linux] f-string parsing results in EOL
Ying Wang added the comment: Oh cool, I didn't know triple quotes can be used as part of f-strings! Thanks for the explanation! -- ___ Python tracker <https://bugs.python.org/issue38568> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44028] Request for locals().update() to work, it is
New submission from wang xuancong : In general, the ability to update local variables is very important and it simplifies life tremendously. For example, in machine learning, it allows saving/loading arbitrary-format datasets and arbitrary-structure neural networks (NN) using a single line of code. In computer games, no matter how many complex data structures are there, saving and loading can be done in a single line. Imagine you are game developer or a deep neural network (DNN) researcher, if all local variables are serializable, then no matter how complicated your game or your DNN structure is, saving the entire game or DNN (to STDOUT) can be simply put into one line as `print(locals())`, and loading the entire game or DNN (from STDIN) can be simply put into one line as `locals().update(eval(sys.stdin.read()))`. Currently, `globals().update(...)` takes immediate effect but `locals().update(...)` does not work because Python documentation says: > The default locals act as described for function locals() below: > modifications to the default locals dictionary should not be > attempted. Pass an explicit locals dictionary if you need to see > effects of the code on locals after function exec() returns. Why they design Python in such way is because of optimization and conforming the `exec` statement into a function: > To modify the locals of a function on the fly is not possible without > several consequences: normally, function locals are not stored in a > dictionary, but an array, whose indices are determined at compile time > from the known locales. This collides at least with new locals added > by exec. The old exec statement circumvented this, because the > compiler knew that if an exec without globals/locals args occurred in > a function, that namespace would be "unoptimized", i.e. not using the > locals array. Since exec() is now a normal function, the compiler does > not know what "exec" may be bound to, and therefore can not treat is > specially. Since `global().update(...)` works, the following piece of code will work in root namespace (i.e., outside any function) because locals() is the same as globals() in root namespace: ``` locals().update({'a':3, 'b':4}) print(a, b) ``` But this will not work inside a function. I have explored a few ways of hacking updating locals() on Python 3, it seems there is no way so far. The following piece of code seems to works: ``` def f1(): sys._getframe(1).f_locals.update({'a':3, 'b':4}) print(a, b) f1() ``` However, that is because `sys._getframe(1)` is the root namespace, so `sys._getframe(1).f_locals.update()` is essentially `globals().update()`. >From the above Python developer documentation, I understand that in Python 2, >local namespace lookup has 2 modes: optimized mode if there is no `exec` >statement, un-optimized mode if there exists an `exec` statement. But in >Python 3, `exec` becomes a function, so the compiler cannot determine which >namespace optimization mode at compile time (because `exec` can be overridden >or aliased into a different name). Therefore, Python 3 has only optimized >namespace lookup. My suggestion is that whenever this optimized local >namespace lookup fails, perform an un-optimized lookup (which will include >locals()). This should solve the problem. Do you have any other ideas or suggestions for doing this? Thanks! -- components: Interpreter Core messages: 392852 nosy: xuancong84 priority: normal severity: normal status: open title: Request for locals().update() to work, it is type: enhancement versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue44028> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44028] Request for locals().update() to work, it is
wang xuancong added the comment: Of course, I am aware of that. As elite-level Python programmers, we should all be aware of security issues whenever we deal with exec() and eval(). -- ___ Python tracker <https://bugs.python.org/issue44028> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44028] Request for locals().update() to work, it is
wang xuancong added the comment: Thanks @terry.reedy for your expert-level good comments! 1. "In Python 3, the one *implementation*, and its lookup mode, are fixed. The slower implementation was dropped because it was not thought worth the bother." If I remember correctly, the performance penalty due to the slower lookup mode is not quite significant, in most Python benchmarks, Python2 still performs much faster than Python3 because most codes that need speed does not contain exec/eval, so the slow mode won't affect in practice. 2. "When you invoke the save function while playing a game, I am imagine that the save function does not have access to and does not same the locals of whatever function was executing at the time you hit the save key. Rather a game and player states are serialized, and likely not in one line of code." I have personally tried this on one implementation of deep neural network using Tensorflow, it works pretty well, especially on saving the network parameters at every Nth epoch, or resuming training from a particular epoch. The biggest advantage is that it does not scale with network size or complexity, so the Python code size has a O(1) complexity with network size/complexity and that is a small constant O(1) as it does not involve any Python loop. In practice, you can select what to save/load, such as those not starting with '_'. -- ___ Python tracker <https://bugs.python.org/issue44028> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44790] Recursion causes Crash
New submission from Michael Wang : Ultimately it seems that deep recursion after setting the recursion limit actually crashes python -- components: Interpreter Core files: bug.py messages: 398619 nosy: michaeljwang10 priority: normal severity: normal status: open title: Recursion causes Crash type: crash versions: Python 3.7 Added file: https://bugs.python.org/file50193/bug.py ___ Python tracker <https://bugs.python.org/issue44790> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44930] super-Matlab-style ranged list literal initialization
New submission from wang xuancong : Different from Python 2, Python 3 has removed the capability to create a list from a range. In Python 2, we can use range(1,100,2) to create a list [1, 3, 5, ..., 99], but in Python 3, we can only use list(range(1,100,2)) or [*range(1,100,2)] where the latter is even slower. I would like to propose to use something like [1:100:2] to initialize a list, moreover, you can use [1:100:2, 1000:1200:5, 5000:6000, :10] to create a list of multiple segments of ranges, i.e., [1,3,5,...,99,1000,1005,1010,...,1195,5000,5001,5002,...,5999,0,1,2,...,9]. Ranged list creation is quite useful and is often used in multi-thread/multi-processing scheduling or tracked sorting. This is especially useful in deep learning where you want to shuffle the training data but keep track of their corresponding labels. In deep RNN, where every training instance has a different length, after shuffling/sorting, you also need to keep track of their corresponding lengths information and etc. Thanks! -- components: Interpreter Core messages: 399707 nosy: xuancong84 priority: normal severity: normal status: open title: super-Matlab-style ranged list literal initialization type: enhancement ___ Python tracker <https://bugs.python.org/issue44930> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44930] super-Matlab-style ranged list literal initialization
wang xuancong added the comment: Another lazy explanation not wanting to improve anything -- ___ Python tracker <https://bugs.python.org/issue44930> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45230] Something wrong when Calculate "3==3 is not True"
New submission from Wang Bingchao <819576...@qq.com>: I use python3.7 python3.6 python2.7, and run the following code: print(3==3 is not True) print(3==3 is True) print(3==2 is not True) print(3==2 is True) I got the same results as follow: True False False False but I don't think it is a reasonable result, it may be bugs? -- components: Subinterpreters messages: 402010 nosy: ET priority: normal severity: normal status: open title: Something wrong when Calculate "3==3 is not True" type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue45230> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45441] Some links in the document is changed
Change by jiahua wang : -- assignee: docs@python components: Documentation nosy: 180909, docs@python priority: normal pull_requests: 27191 severity: normal status: open title: Some links in the document is changed versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue45441> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45742] python -h can't find -R option
New submission from jiahua wang : I input python -h on the command line, and I can't find any -R option. -- assignee: docs@python components: Documentation messages: 405891 nosy: 180909, docs@python priority: normal severity: normal status: open title: python -h can't find -R option versions: Python 3.10 ___ Python tracker <https://bugs.python.org/issue45742> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45712] Typo in "control flow" documentation
Change by jiahua wang : -- keywords: +patch nosy: +180909 nosy_count: 2.0 -> 3.0 pull_requests: +27714 stage: needs patch -> patch review pull_request: https://github.com/python/cpython/pull/29460 ___ Python tracker <https://bugs.python.org/issue45712> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19460] Add test for MIMENonMultipart
Change by jiahua wang : -- keywords: +patch nosy: +180909 nosy_count: 4.0 -> 5.0 pull_requests: +28049 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29817 ___ Python tracker <https://bugs.python.org/issue19460> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28445] Wrong documentation for GzipFile.peek
Change by jiahua wang : -- keywords: +patch nosy: +180909 nosy_count: 4.0 -> 5.0 pull_requests: +28052 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29820 ___ Python tracker <https://bugs.python.org/issue28445> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue18717] test for request.urlretrieve
Change by jiahua wang : -- nosy: +180909 nosy_count: 2.0 -> 3.0 pull_requests: +28054 pull_request: https://github.com/python/cpython/pull/29822 ___ Python tracker <https://bugs.python.org/issue18717> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19737] Documentation of globals() and locals() should be improved
Change by jiahua wang : -- nosy: +180909 nosy_count: 5.0 -> 6.0 pull_requests: +28055 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29823 ___ Python tracker <https://bugs.python.org/issue19737> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38619] [Doc] UUID.hex is lowercase
Change by jiahua wang : -- keywords: +patch nosy: +wangjiahua nosy_count: 5.0 -> 6.0 pull_requests: +28061 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29830 ___ Python tracker <https://bugs.python.org/issue38619> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue45114] bad example for os.stat
Change by jiahua wang : -- keywords: +patch nosy: +wangjiahua nosy_count: 2.0 -> 3.0 pull_requests: +28074 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29845 ___ Python tracker <https://bugs.python.org/issue45114> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28953] Use `raise from` when raising new IncompleteRead
Change by jiahua wang : -- nosy: +wangjiahua nosy_count: 1.0 -> 2.0 pull_requests: +28088 stage: -> patch review pull_request: https://github.com/python/cpython/pull/29861 ___ Python tracker <https://bugs.python.org/issue28953> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28343] Bad encoding alias cp936 -> gbk: euro sign
Mingye Wang added the comment: b'\x80'.decode('cp936') is still broken on python 3.7. Working on a PR. -- versions: +Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue28343> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39732] plistlib should export UIDs in XML like Apple does
New submission from Mingye Wang : Although there is no native UID type in Apple's XML format, Apple's NSKeyedArchiver still works with it because it converts the UID to a dict of {"CF$UID": int(some_uint64_val)}. Plistlib should do the same. For a sample, see https://github.com/apple/swift-corelibs-foundation/blob/2a5bc4d8a0b073532e60410682f5eb8f00144870/Tests/Foundation/Resources/NSKeyedUnarchiver-ArrayTest.plist. -- components: Library (Lib) messages: 362513 nosy: Artoria2e5 priority: normal severity: normal status: open title: plistlib should export UIDs in XML like Apple does type: behavior versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue39732> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39732] plistlib should export UIDs in XML like Apple does
Change by Mingye Wang : -- keywords: +patch pull_requests: +17987 stage: -> patch review pull_request: https://github.com/python/cpython/pull/18622 ___ Python tracker <https://bugs.python.org/issue39732> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39782] local varible referenced a Exception won't be collected in function
New submission from Wang Jie : I referenced an Exception object in a function and found memory usage will increase constantly in the accident. I think it may be a bug. I wrote a minimal code to reproduce it. ```py from threading import local, Thread from time import sleep l = {} def t0(): b = l.get('e') # memory usage won't increase if I remove this line try: raise Exception('1') except Exception as e: l['e'] = e def target(): while True: sleep(0.0001) t0() target() # t = Thread(target=target) # t.daemon = True # t.start() ``` I tried to execute it in IPython and got the following output: ``` In [1]: run py/ref_exception_causes_oom.py In [2]: import objgraph In [3]: objgraph.show_growth(limit=3) frame78792+78792 Exception78779+78779 traceback78779+78779 In [4]: objgraph.show_growth(limit=3) Exception 100862+22083 traceback 100862+22083 frame 100875+22083 In [5]: objgraph.show_growth(limit=3) Exception 115963+15101 traceback 115963+15101 frame 115976+15101 ``` And I tried to execute this code in python2.7 and pypy. Both of them won't occur this problem. -- components: Interpreter Core messages: 362873 nosy: wangjie priority: normal severity: normal status: open title: local varible referenced a Exception won't be collected in function type: resource usage versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue39782> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39910] os.ftruncate on Windows should be sparse
New submission from Mingye Wang : Consider this interaction: cmd> echo > 1.txt cmd> python -c "__import__('os').truncate('1.txt', 1024 ** 3)" cmd> fsutil sparse queryFlag 1.txt Not only takes a long time as is typical for a zero-write, but also reports non-sparse as an actual write would suggest. This is because internally, _chsize_s and friends enlarges files using a loop.[1] [1]: https://github.com/leelwh/clib/blob/master/c/chsize.c On Unix systems, ftruncate for enlarging is described as "... as if the extra space is zero-filled", but this is not to be taken literally. In practice, sparse files are used whenever available (GNU dd expects that) and people do expect the operation to be very fast without a lot of real writes. A FreeBSD bug exists around how ftruncate is too slow on UFS. The aria2 downloader gives a good example of how to truncate into a sparse file on Windows.[2] First a FSCTL_SET_SPARSE control is issued, and then a seek + SetEndOfFile would finish the job. Of course, a lseek to the end would be required to first determine the size of the file, so we know whether we are enlarging (sparse) or shrinking (don't sparse). [2]: https://github.com/aria2/aria2/blob/master/src/AbstractDiskWriter.cc#L507 -- components: Library (Lib) messages: 363717 nosy: Artoria2e5, steve.dower priority: normal severity: normal status: open title: os.ftruncate on Windows should be sparse versions: Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue39910> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39961] warning: this use of "defined" may not be portable (Mac OS)
New submission from Clem Wang : pyenv install 3.8.2 results in: BUILD FAILED (OS X 10.15.3 using python-build 20180424) Inspect or clean up the working tree at /var/folders/jy/10md97xn3mz_x_b42l1r2r8cgp/T/python-build.20200313154805.37448 Results logged to /var/folders/jy/10md97xn3mz_x_b42l1r2r8cgp/T/python-build.20200313154805.37448.log Last 10 log lines: 331 | #if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT | ^~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h:331:6: warning: this use of "defined" may not be portable [-Wexpansion-to-defined] /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h:540:6: warning: this use of "defined" may not be portable [-Wexpansion-to-defined] 540 | #if !_PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT | ^~ /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h:540:6: warning: this use of "defined" may not be portable [-Wexpansion-to-defined] cc1: some warnings being treated as errors make: *** [Objects/floatobject.o] Error 1 make: *** Waiting for unfinished jobs The real problem is on line 199 of /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/pthread.h /* */ #define _PTHREAD_SWIFT_IMPORTER_NULLABILITY_COMPAT \ defined(SWIFT_CLASS_EXTRA) && (!defined(SWIFT_SDK_OVERLAY_PTHREAD_EPOCH) || (SWIFT_SDK_OVERLAY_PTHREAD_EPOCH < 1)) I'm not sure if this is a problem for Apple to fix or whether the Python build needs to be more tolerant of warnings. -- components: macOS messages: 364125 nosy: clem.wang, ned.deily, ronaldoussoren priority: normal severity: normal status: open title: warning: this use of "defined" may not be portable (Mac OS) type: compile error versions: Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue39961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39961] warning: this use of "defined" may not be portable (Mac OS)
Clem Wang added the comment: Oops: forgot version numbers MacOS Catalina (10.15.13 19D76) 2.6 Ghz 6-Code Intel i7 32 GB RAM Homebrew 2.2.10 Homebrew/homebrew-core (git revision 58c0; last commit 2020-03-13) Homebrew/homebrew-cask (git revision ab52c7; last commit 2020-03-14) Not sure which compiler is being used, but I have these installed: gcc --version gcc (MacPorts gcc9 9.2.0_1) 9.2.0 (3.8-env) C02ZD5VVLVDQ:3.8-env clem.wang$ clang --version clang version 9.0.0 (tags/RELEASE_900/final) Target: x86_64-apple-darwin19.3.0 Thread model: posix InstalledDir: /usr/local/opt/llvm/bin -- ___ Python tracker <https://bugs.python.org/issue39961> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42527] UnicodeEncode error in BaseHttpRequestHandler class when send unicode data.
New submission from Yanfeng Wang : My environment: system: MacOS 10.15.x python: 3.9.0 when I inherit the BaseHTTPRequestHandler class, and call the send_error(error_di, msg) method in my own class's do_GET override function: the msg argument can't accept unicode string, an UnicodeEncodeError of 'latin-1' encoding error with ordinal call failed of out of range(255). I tracked the code, and found in the implementation of this class, the data was sent through a encode call with 'latin-1' hard coded in. in the file: server.py near line 507. BTW, I tried u'my string'.encode('utf-8'), and it didn't work, another TypeError in module html __init__.py line 19. If I commented the original hard code 'latin-1' line and replace with the hard code encoding to 'utf-8', all will be fine. Thanks for your read anyone who cares or takes care of this issue. -- components: Unicode messages: 382268 nosy: ezio.melotti, vstinner, wangyanfeng.p priority: normal severity: normal status: open title: UnicodeEncode error in BaseHttpRequestHandler class when send unicode data. type: behavior versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue42527> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38119] resource tracker destroys shared memory segments when other processes should still have valid access
keven wang added the comment: Agree w/ PR here to remove resource tracker unlinking as a quick fix: https://github.com/python/cpython/pull/15989 This will at least make the unlink behavior more controllable, which is not the case currently (on mac and linux). Would love to have this merged. -- nosy: +keven425 ___ Python tracker <https://bugs.python.org/issue38119> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41352] FileIO.readall() should raise "UnsupportedOperation" when in "w" mode
New submission from Ziyi Wang : Here are the two test cases: the one with FileIO.readall() fails def testReadWithWritingMode(self): r, w = os.pipe() w = os.fdopen(w, "w") w.write("hello") w.close() with io.FileIO(r, mode="w") as f: with self.assertRaises(_io.UnsupportedOperation): f.read() def testReadallWithWritingMode(self): r, w = os.pipe() w = os.fdopen(w, "w") w.write("hello") w.close() with io.FileIO(r, mode="w") as f: with self.assertRaises(_io.UnsupportedOperation): f.readall() With FileIO.read() raises "UnsupportedOperation" in "w" mode, I expect FileIO.readall() do the same. But in fact FileIO.readall() does not check for readable and does not raise "UnsupportedOperation" in "w"mode. I'm happy to write a pull request if you want. -- components: IO, Library (Lib) messages: 374027 nosy: Ziyi Wang priority: normal severity: normal status: open title: FileIO.readall() should raise "UnsupportedOperation" when in "w" mode type: behavior versions: Python 3.10, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue41352> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41437] SIGINT blocked by socket operations like recv on Windows
New submission from Zhiming Wang : I noticed that on Windows, socket operations like recv appear to always block SIGINT until it's done, so if a recv hangs, Ctrl+C cannot interrupt the program. (I'm a *nix developer investigating a behavioral problem of my program on Windows, so please excuse my limited knowledge of Windows.) Consider the following example where I spawn a TCP server that stalls connections by 5 seconds in a separate thread, and use a client to connect to it on the main thread. I then try to interrupt the client with Ctrl+C. import socket import socketserver import time import threading interrupted = threading.Event() class HoneypotServer(socketserver.TCPServer): # Stall each connection for 5 seconds. def get_request(self): start = time.time() while time.time() - start < 5 and not interrupted.is_set(): time.sleep(0.1) return self.socket.accept() class EchoHandler(socketserver.BaseRequestHandler): def handle(self): data = self.request.recv(1024) self.request.sendall(data) class HoneypotServerThread(threading.Thread): def __init__(self): super().__init__() self.server = HoneypotServer(("127.0.0.1", 0), EchoHandler) def run(self): self.server.serve_forever(poll_interval=0.1) def main(): start = time.time() server_thread = HoneypotServerThread() server_thread.start() sock = socket.create_connection(server_thread.server.server_address) try: sock.sendall(b"hello") sock.recv(1024) except KeyboardInterrupt: print(f"processed SIGINT {time.time() - start:.3f}s into the program") interrupted.set() finally: sock.close() server_thread.server.shutdown() server_thread.join() if __name__ == "__main__": main() On *nix systems the KeyboardInterrupt is processed immediately. On Windows, the KeyboardInterrupt is always processed more than 5 seconds into the program, when the recv is finished. I suppose this is a fundamental limitation of Windows? Is there any workaround (other than going asyncio)? Btw, I learned about SIGBREAK, which when unhandled seems to kill the process immediately, but that means no chance of cleanup. I tried to handle SIGBREAK but whenever a signal handler is installed, the behavior reverts to that of SIGINT -- the handler is called only after 5 seconds have passed. (I'm attaching a socket_sigint_sigbreak.py which is a slightly expanded version of my sample program above, showing my attempt at handler SIGBREAK. Both python .\socket_sigint_sigbreak.py --sigbreak-handler interrupt and python .\socket_sigint_sigbreak.py --sigbreak-handler exit stall for 5 seconds.) -- components: Windows files: socket_sigint_sigbreak.py messages: 374580 nosy: paul.moore, steve.dower, tim.golden, zach.ware, zmwangx priority: normal severity: normal status: open title: SIGINT blocked by socket operations like recv on Windows type: behavior versions: Python 3.8 Added file: https://bugs.python.org/file49348/socket_sigint_sigbreak.py ___ Python tracker <https://bugs.python.org/issue41437> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14527] How to link with a non-system libffi?
wang zhao added the comment: We managed to fixed on the server by following and got it sucuessfully compiled: -./configure --with-system-ffi LDFLAGS="-L /home/XXX/installs/libffi-3.3/lib64/" CPPFLAGS="-I /home/XXX/installs/libffi-3.3/include/" -LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/XXX/installs/libffi-3.3/lib64/ -make -- nosy: +zhao.wang.unsw versions: -Python 3.9 ___ Python tracker <https://bugs.python.org/issue14527> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42005] profile/cProfile CLI should catch BrokenPipeError
New submission from Zhiming Wang : Since profile/cProfile CLI interface prints a sorted list of stats, using head to limit output to the most relevant entries should be a fairly natural thing to do. Unfortunately, BrokenPipeError isn't caught, causing quite a bit of pollution to the output: $ python3 -m cProfile -m http.server -h | head usage: http.server [-h] [--cgi] [--bind ADDRESS] [--directory DIRECTORY] [port] positional arguments: port Specify alternate port [default: 8000] optional arguments: -h, --helpshow this help message and exit --cgi Run as CGI Server --bind ADDRESS, -b ADDRESS Traceback (most recent call last): File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/runpy.py", line 87, in _run_code exec(code, run_globals) File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 180, in main() File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 173, in main runctx(code, globs, None, options.outfile, options.sort) File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 19, in runctx return _pyprofile._Utils(Profile).runctx(statement, globals, locals, File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/profile.py", line 66, in runctx self._show(prof, filename, sort) File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/profile.py", line 72, in _show prof.print_stats(sort) File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/cProfile.py", line 42, in print_stats pstats.Stats(self).strip_dirs().sort_stats(sort).print_stats() File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/pstats.py", line 431, in print_stats self.print_line(func) File "/Users/zmwang/.pyenv/versions/3.9.0/lib/python3.9/pstats.py", line 513, in print_line print(f8(tt/nc), end=' ', file=self.stream) BrokenPipeError: [Errno 32] Broken pipe Exception ignored in: <_io.TextIOWrapper name='' mode='w' encoding='utf-8'> BrokenPipeError: [Errno 32] Broken pipe I think the exception should be caught in order to suppress this noise. -- components: Library (Lib) messages: 378421 nosy: zmwangx priority: normal severity: normal status: open title: profile/cProfile CLI should catch BrokenPipeError type: behavior versions: Python 3.10 ___ Python tracker <https://bugs.python.org/issue42005> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42005] profile/cProfile CLI should catch BrokenPipeError
Change by Zhiming Wang : -- keywords: +patch pull_requests: +21617 stage: -> patch review pull_request: https://github.com/python/cpython/pull/22643 ___ Python tracker <https://bugs.python.org/issue42005> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39828] json.tool should catch BrokenPipeError
Change by Zhiming Wang : -- nosy: +zmwangx nosy_count: 5.0 -> 6.0 pull_requests: +21618 pull_request: https://github.com/python/cpython/pull/22643 ___ Python tracker <https://bugs.python.org/issue39828> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14311] ConfigParser does not parse utf-8 files with BOM bytes
New submission from Sean Wang : ConfigParser failed to parse a utf-8 file with BOM bytes('\xef\xbb\xbf'), it would raise ConfigParser.MissingSectionHeaderError. I think that other files with BOM would have the same problem; because the argument "SECTCRE" does not consider the BOM conditions. Now the workaround is like below: cp=ConfigParser.ConfigParser() cfgfile=os.path.join(curpath,'config.cfg') cp.readfp(codecs.open(cfgfile, 'r','utf-8-sig')) -- components: Library (Lib) messages: 155843 nosy: Sean.Wang priority: normal severity: normal status: open title: ConfigParser does not parse utf-8 files with BOM bytes type: behavior versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue14311> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37258] Logging cache not cleared properly when setting level
New submission from David Wang : If you call setLevel() on a subclass of logging.Logger, it does not reset the cache for that logger. This mean that if you make some logging calls, then call setLevel(), the logger still acts like it still has its old level. See the attached python file for a reference. Currently, the user has to call logger._cache.clear() to manually clear the cache after calling setLevel(). To fix this in Python, we would have to change Logger.setLevel() in /logging/__init__.py to have the following code ``` self.level = _checkLevel(level) self.manager._clear_cache() self._cache.clear() ``` Note the following: - I made sure the subclass has a handler attached so setLevel() should work - This bug does not occur if you use logging.getLogger(). This is because logging.getLogger() returns the root logger, and the cache clear specifically targets the root logger's cache to be cleared. It occurs when the logger is specifically subclassed from logging.getLoggerClass() - The cache was added in Python 3.7, so this bug is specific to this version of python. -- components: Library (Lib) files: test.py messages: 345414 nosy: David Wang priority: normal severity: normal status: open title: Logging cache not cleared properly when setting level type: behavior versions: Python 3.7 Added file: https://bugs.python.org/file48416/test.py ___ Python tracker <https://bugs.python.org/issue37258> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37678] Incorrect behaviour for user@password URI pattern in urlparse
New submission from Sean Wang : When an IPV4 URL with 'username:password' in it, and the password contains special characters like #[]?, urlparse would act as unexcepted. example: urlparse('http://user:pass#?[w...@example.com:80/path') -- components: Library (Lib) messages: 348431 nosy: Sean.Wang priority: normal severity: normal status: open title: Incorrect behaviour for user@password URI pattern in urlparse type: behavior versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7 ___ Python tracker <https://bugs.python.org/issue37678> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37780] A strange bug in eval() not present in Python 3
New submission from wang xuancong : We all know that since: [False, True, False].count(True) gives 1 eval('[False, True, False].count(True)') also gives 1. However, in Python 2, eval('[False, True, False].count(True)', {}, Counter()) gives 3, while eval('[False, True, False].count(True)', {}, {}) gives 1. Take note that a Counter is a special kind of defaultdict, which is again a special kind of dict. Thus, this should not alter the behaviour of eval(). This behaviour is correct in Python 3. -- components: Library (Lib) messages: 349146 nosy: xuancong84 priority: normal severity: normal status: open title: A strange bug in eval() not present in Python 3 type: behavior versions: Python 2.7 ___ Python tracker <https://bugs.python.org/issue37780> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36338] urlparse of urllib returns wrong hostname
Xianbo Wang added the comment: Python2 urlparse.urlparse and urllib2.urlparse.urlparse have a similar IPv6 hostname parsing bug. >>> urlparse.urlparse('http://nevil.com[]').hostname >>> 'evil.com[' This is less practical to exploit since the parsed domain contains a '[' in the end. Do I need to create a separate issue for this Python2 bug? I think the way PR 14896 fix the python3 bug can also be applied to this. Also, do we need a CVE ID for the python3 bug? As it may lead to some security issues in some Python apps, e.g., open-redirect. I have found such a case in a private bug bounty program. -- ___ Python tracker <https://bugs.python.org/issue36338> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30802] datetime.datetime.strptime('200722', '%Y%U')
New submission from winton Wang: datetime stiptime error according to "%U" format. Python version: 3.4.3, 2.7.13 ,3.6.0, 3.5.2 from datetime import datetime input: datetime.strptime('201726', '%Y%U') output: datetime.datetime(2007, 1, 1, 0, 0) -- components: Library (Lib) messages: 297265 nosy: winton priority: normal severity: normal status: open title: datetime.datetime.strptime('200722', '%Y%U') type: behavior versions: Python 2.7, Python 3.3, Python 3.4, Python 3.5, Python 3.6 ___ Python tracker <http://bugs.python.org/issue30802> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30802] datetime.datetime.strptime('200722', '%Y%U')
winton Wang added the comment: the output: datetime.datetime(2017, 1, 1, 0, 0) I question about the week format if without the week of the weekday, the datetime should be the fist day of week as the default? -- ___ Python tracker <http://bugs.python.org/issue30802> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30823] os.startfile("") craches Python 2.7, 3.4, 3.5
New submission from morris wang: try... except... won't catch it. import os try: os.startfile("") except: pass crashes python, resulting in error message "python has stopped working" -- messages: 297487 nosy: morris wang priority: normal severity: normal status: open title: os.startfile("") craches Python 2.7, 3.4, 3.5 type: crash versions: Python 3.5 ___ Python tracker <http://bugs.python.org/issue30823> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com