[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
[issue2931] optparse: various problems with unicode and gettext
Sean Wang added the comment: This bug still exists in Python 2.7.10 with optparse version 1.5.3. When the default_value is not ASCII encoded, it would raise `UnicodeEncodeError: 'ascii' codec can't encode characters` this error is due to the `str` usage in `expand_default` method: def expand_default(self, option): if self.parser is None or not self.default_tag: return option.help default_value = self.parser.defaults.get(option.dest) if default_value is NO_DEFAULT or default_value is None: default_value = self.NO_DEFAULT_VALUE return option.help.replace(self.default_tag, str(default_value)) -- nosy: +Sean.Wang ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue2931> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2931] optparse: various problems with unicode and gettext
Sean Wang added the comment: Sorry, missed one condition: I used `unicode_literals` in Python 2.7.10, example below: >>> from __future__ import unicode_literals >>> str('api名称') Traceback (most recent call last): File "", line 1, in UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-4: ordinal not in range(128) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue2931> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2931] optparse: various problems with unicode and gettext
Sean Wang added the comment: when an unicode option.default_value could not be ascii encoded, it would throw exception, detailed logs below: File "/Users/seanwang/Documents/dev/foo/bar.py", line 119, in main parser.print_help() File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 1670, in print_help file.write(self.format_help().encode(encoding, "replace")) File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 1650, in format_help result.append(self.format_option_help(formatter)) File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 1630, in format_option_help result.append(OptionContainer.format_option_help(self, formatter)) File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 1074, in format_option_help result.append(formatter.format_option(option)) File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 316, in format_option help_text = self.expand_default(option) File "/usr/local/Cellar/python/2.7.10_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/optparse.py", line 288, in expand_default return option.help.replace(self.default_tag, str(default_value)) UnicodeEncodeError: 'ascii' codec can't encode characters in position 3-4: ordinal not in range(128) -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue2931> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25534] SimpleHTTPServer throwed an exception due to negtive st_mtime attr in file
New submission from Sean Wang: I transfered a file from remote Debian host to my local Windows 10 host using SecureFX. I found that the file's last modifed date was 1900/1/1,0:00:00 on Windows. I tried to serve this file to be downloaded, and it crashed as follows: Exception happened during processing of request from ('192.168.1.102', 50978) Traceback (most recent call last): File "C:\Python27\lib\SocketServer.py", line 295, in _handle_request_noblock self.process_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 321, in process_request self.finish_request(request, client_address) File "C:\Python27\lib\SocketServer.py", line 334, in finish_request self.RequestHandlerClass(request, client_address, self) File "C:\Python27\lib\SocketServer.py", line 655, in __init__ self.handle() File "C:\Python27\lib\BaseHTTPServer.py", line 340, in handle self.handle_one_request() File "C:\Python27\lib\BaseHTTPServer.py", line 328, in handle_one_request method() File "C:\Python27\lib\SimpleHTTPServer.py", line 45, in do_GET f = self.send_head() File "C:\Python27\lib\SimpleHTTPServer.py", line 103, in send_head self.send_header("Last-Modified", self.date_time_string(fs.st_mtime)) File "C:\Python27\lib\BaseHTTPServer.py", line 468, in date_time_string year, month, day, hh, mm, ss, wd, y, z = time.gmtime(timestamp) ValueError: (22, 'Invalid argument') I have checked the source code, and found it was because of the last modifed date of the file, I got this in console: >>> os.fstat(f.fileno()) nt.stat_result(st_mode=33206, st_ino=4785074604093500L, st_dev=0L, st_nlink=1, st_uid=0, st_gid=0, st_size=3406L, st_atime=1446477520L, st_mtime=-2209017600L, st_ctime=1446370767L) -2209017600L cannot be handled by "time.gmtime()" method and it throwed error -- components: Library (Lib) messages: 253926 nosy: Sean.Wang priority: normal severity: normal status: open title: SimpleHTTPServer throwed an exception due to negtive st_mtime attr in file type: crash versions: Python 2.7 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25534> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25534] SimpleHTTPServer throwed an exception due to negtive st_mtime attr in file
Sean Wang added the comment: upload a sample test file -- Added file: http://bugs.python.org/file40929/test ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25534> ___ ___ 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 wangxiao8...@gmail.com: 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 rep...@bugs.python.org http://bugs.python.org/issue14311 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com