[issue10106] missing packages
New submission from S S : when trying to install beutifulsoup package on windows xp x86 with python 2.6.6 getting the following error C:\Python26>python C:\temp\BeautifulSoup-3.0.8.1\setup.py install 'import site' failed; use -v for traceback Traceback (most recent call last): File "C:\temp\BeautifulSoup-3.0.8.1\setup.py", line 1, in from distutils.core import setup ImportError: No module named distutils.core installing the same package with python 2.7 gives a different error about site module missing. these errors i am getting with any packages installs actually. -- components: Installation messages: 118685 nosy: S.S priority: normal severity: normal status: open title: missing packages type: compile error versions: Python 2.6 ___ Python tracker <http://bugs.python.org/issue10106> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10106] missing packages
S S added the comment: Brett, the installation did not had any issues. its running on windows xp, i am administrator of the machine so no permission issues. nothing got moved either as it fresh install -- ___ Python tracker <http://bugs.python.org/issue10106> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10106] missing packages
S S added the comment: finally was able to figure it out. i had another product installed, which uses python 2.4 that product during installation put PYTHONHOME into system variable environment. as soon as i either change that PYTHONHOME to my latest python path c:\python26 everything starts working. -- ___ Python tracker <http://bugs.python.org/issue10106> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33611] Fatal Python error: Py_Initialize: unable to load the file system codec
New submission from s : Fatal Python error: Py_Initialize: unable to load the file system codec ModuleNotFoundError: No module named 'encodings' ### Process: Python [1889] Path: /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python Identifier:Python Version: 3.6.5 (3.6.5) Code Type: X86-64 (Native) Parent Process:bash [722] Responsible: Python [1889] User ID: 501 Date/Time: 2018-05-22 23:52:40.997 -0700 OS Version:Mac OS X 10.13.4 (17E202) Report Version:12 Anonymous UUID:F667AFCE-E0F9-BF0F-FB74-372904C44DB5 Time Awake Since Boot: 2000 seconds System Integrity Protection: disabled Crashed Thread:0 Dispatch queue: com.apple.main-thread Exception Type:EXC_CRASH (SIGABRT) Exception Codes: 0x, 0x Exception Note:EXC_CORPSE_NOTIFY Application Specific Information: abort() called Thread 0 Crashed:: Dispatch queue: com.apple.main-thread 0 libsystem_kernel.dylib 0x0001018eeb6e __pthread_kill + 10 1 libsystem_pthread.dylib 0x000101928080 pthread_kill + 333 2 libsystem_c.dylib 0x0001015c51ae abort + 127 3 org.python.python 0x000100877611 Py_FatalError + 65 4 org.python.python 0x0001008793c1 _Py_InitializeEx_Private + 1281 5 org.python.python 0x000100896b40 Py_Main + 1360 6 org.python.python 0x00010dfe 0x1 + 3582 7 org.python.python 0x00010c34 0x1 + 3124 Thread 0 crashed with X86 Thread State (64-bit): rax: 0x rbx: 0x00010192e380 rcx: 0x7fff5bffef58 rdx: 0x rdi: 0x0307 rsi: 0x0006 rbp: 0x7fff5bffef90 rsp: 0x7fff5bffef58 r8: 0x r9: 0x0006 r10: 0x r11: 0x0202 r12: 0x0307 r13: 0x0002 r14: 0x0006 r15: 0x002d rip: 0x0001018eeb6e rfl: 0x0202 cr2: 0x000101bd7020 Logical CPU: 0 Error Code: 0x02000148 Trap Number: 133 Binary Images: 0x1 -0x10ff7 +org.python.python (3.6.5 - 3.6.5) /Library/Frameworks/Python.framework/Versions/3.6/Resources/Python.app/Contents/MacOS/Python 0x13000 -0x10049dff7 com.apple.CoreFoundation (6.9 - 1452.23) <358C547D-E227-3228-8218-62327F4605C8> /System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation 0x10075 -0x100977fef +org.python.python (3.6.5, [c] 2001-2018 Python Software Foundation. - 3.6.5) /Library/Frameworks/Python.framework/Versions/3.6/Python 0x100ac -0x100ac1ffb libSystem.B.dylib (1252.50.4) /usr/lib/libSystem.B.dylib 0x100ac8000 -0x100ac9ff3 libDiagnosticMessagesClient.dylib (104) <9712E980-76EE-3A89-AEA6-DF4BAF5C0574> /usr/lib/libDiagnosticMessagesClient.dylib 0x100acf000 -0x100cf6ffb libicucore.A.dylib (59173.0.1) /usr/lib/libicucore.A.dylib 0x100dc8000 -0x1011b93b7 libobjc.A.dylib (723) /usr/lib/libobjc.A.dylib 0x10136a000 -0x10137cffb libz.1.dylib (70) <48C67CFC-940D-3857-8DAD-857774605352> /usr/lib/libz.1.dylib 0x101382000 -0x101386ff7 libcache.dylib (80) <092479CB-1008-3A83-BECF-E115F24D13C1> /usr/lib/system/libcache.dylib 0x10138c000 -0x101396ff3 libcommonCrypto.dylib (60118.50.1) <029F5985-9B6E-3DCB-9B96-FD007678C6A7> /usr/lib/system/libcommonCrypto.dylib 0x1013a4000 -0x1013abfff libcompiler_rt.dylib (62) <968B8E3F-3681-3230-9D78-BB8732024F6E> /usr/lib/system/libcompiler_rt.dylib 0x1013b9000 -0x1013c2ffb libcopyfile.dylib (146.50.5) <3885083D-50D8-3EEC-B481-B2E605180D7F> /usr/lib/system/libcopyfile.dylib 0x1013c9000 -0x10144efff libcorecrypto.dylib (562.50.17) <67007279-24E1-3F30-802D-A55CD5C27946> /usr/lib/system/libcorecrypto.dylib 0x10146b000 -0x1014a4ff7 libdispatch.dylib (913.50.12) <848EEE57-4235-3A61-9A52-C0097DD2AB5E> /usr/lib/system/libdispatch.dylib 0x1014df000 -0x1014fcff7 libdyld.dylib (551.3) /usr/lib/system/libdyld.dylib 0x101517000 -0x101517ffb libkeymgr.dylib (28) /usr/lib/system/libkeymgr.dylib 0x10151c000 -0x10151cff7 liblaunch.dylib (1205.50.76) <4D52BB64-C568-3A36-8935-2480427EE2A2> /usr/lib/system/liblaunch.dylib 0x101523000 -0x101527ffb libmacho.dylib (906) <1902A611-081A-3452-B11E-EBD1B166E831> /usr/lib/system/libmacho.dylib 0x10152e000 -0x101530ff3 libquarantine.dylib (86)
[issue33611] Fatal Python error: Py_Initialize: unable to load the file system codec
s added the comment: Guys, First of all - thank you for accepting it and trying to fix it. I lost two days attempting to resurrect python3 on my laptop and ended up with uninstalling it and restoring python 2.7.10. I agree (and I think it is separate and well known python's problem) - there are several tools/techniques installing python and paths ARE different between OS. this is what I was observing today comparing Mac OS and CentOS 7. and as it seems to me this "complaint" about "encoding" is exactly about it - as it is such a directory on Linux and there is no such directory on Mac. In any case, whatever way it all this handled, it should not cause python to die and more importantly - something is making changes in configuration of python on the system and user is unable to use python after this error AT ALL. I had to reinstall it completely several times yesterday and today because of this. About shebangs. yes, I do have different ones (and I suspect many of us do, as python's very interesting feature of incompatibility between major versions) And after all these my attempts to fix python 3 on my laptop I ended up with total mess on the system - none of the pythons were working. So, I said - you know... I'll wait for python 3 be more mature... Perhaps that is the reason Apple is not installing more resent version and keeps 2.7.10? :) Regards, Slava On Wed, May 23, 2018 at 6:20 PM, STINNER Victor wrote: > > STINNER Victor added the comment: > > I completed the _PyCoreConfig structure to add home, > module_search_path_env, and many other options. It might help to guess how > the final configuration has been computed. I also reworked the code to > clarify when and how sys.path is computed. sys.path value (not the actual > sys.path Python list) is now computed earlier. > > -- > > ___ > Python tracker > <https://bugs.python.org/issue33611> > ___ > -- ___ Python tracker <https://bugs.python.org/issue33611> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33611] Fatal Python error: Py_Initialize: unable to load the file system codec
s added the comment: :) sure. if you want to close it - it's up to you. if you however, want to fix it, please tell me what information do you need me to provide. I don't think my tone was bad/offensive. ...and it's still a bug, regardless of my tone or anything else. and by the way, I don't like yours tone. I used brew and pip bash --version GNU bash, version 4.4.12(1)-release (x86_64-apple-darwin16.3.0) Copyright (C) 2016 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html > which python /usr/bin/python env _system_type=Darwin OPT=/opt LANG=en_US.UTF-8 XPC_FLAGS=0x0 DISPLAY=/private/tmp/com.apple.launchd.XNIGqOXCBz/org.macosforge.xquartz:0 rvm_bin_path=/Users//.rvm/bin TERM_SESSION_ID=781A3902-E266-48B2-8BDF-0114DE0CAC97 rvm_version=1.26.11 (latest) RUBY_VERSION=ruby-2.2.3 GEM_HOME=/Users//.rvm/gems/ruby-2.2.3 JAVA_HOME=/usr SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.tIfMUtKKFM/Listeners GVM_ROOT=/Users//.gvm STDLIB=/usr/local/lib USER= RBENV_SHELL=bash GOPATH=/Users//working/golang/projects PWD=/Users//working/python/scripts/passman/db _system_version=10.13 HOME=/Users/ GOROOT=/usr/local/go LC_CTYPE=en_US.UTF-8 _system_name=OSX rvm_user_install_flag=1 TERM_PROGRAM=Apple_Terminal TERM_PROGRAM_VERSION=404 Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.zL9jzzDVzY/Render _system_arch=x86_64 GEM_PATH=/Users//.rvm/gems/ruby-2.2.3:/Users//.rvm/gems/ruby-2.2.3@global TMPDIR=/var/folders/g8/xflwp75s5nv0lc4wmhz2t270gn/T/ rvm_stored_umask=0022 rvm_loaded_flag=1 rvm_path=/Users//.rvm XPC_SERVICE_NAME=0 SHELL=/bin/bash TERM=xterm-256color SECURITYSESSIONID=186a7 rvm_prefix=/Users/ SHLVL=2 PYENV_SHELL=bash PYTHONPATH=/usr/local/lib/python2.7/site-packages LOGNAME= LDFLAGS=/usr/local/opt/bison/lib GOBIN=/usr/local/go/bin STDINCLUDE=/usr/local/include MY_RUBY_HOME=/Users//.rvm/rubies/ruby-2.2.3 PATH=/opt/:/usr/local/lib:/usr/local/include:/usr/local/opt/bison/bin:/usr/local/opt/e2fsprogs/sbin:/Users//.pyenv/shims:/Users//.rvm/gems/ruby-2.2.3/bin:/Users//.rvm/gems/ruby-2.2.3@global /bin:/Users//.rvm/rubies/ruby-2.2.3/bin:/Users//.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/go/bin:/opt/X11/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Wireshark.app/Contents/MacOS:/Applications/Postgres.app/Contents/Versions/latest/bin/:/Users//.rvm/bin:/usr/local/go/bin:/Users//working/golang/projects:/usr/local/go/bin:/usr/local/include:/opt:/usr/local/lib:/Users//.rvm/bin:/usr/local/go/bin:/usr/local:/opt IRBRC=/Users//.rvm/rubies/ruby-2.2.3/.irbrc GOROOT_BOOTSTRAP=/usr/local/go _=/usr/bin/env On Thu, May 24, 2018 at 7:27 AM, STINNER Victor wrote: > > STINNER Victor added the comment: > > Slava doesn't seem to want to provide any useful information to debug his > event, whereas Naoki asked multiple times gently. I also dislike Slava's > tone in answers, trolling Python 3 doesn't help to fix your issue... > > There are millions of Python 3 users on Windows, and it's the first time > that I see this bug on Windows. So it's likely something very specific to > your setup. > > It's very unlikely a bug in the Windows installer of Python, so I close > the issue. > > -- > resolution: -> not a bug > stage: -> resolved > status: open -> closed > > ___ > Python tracker > <https://bugs.python.org/issue33611> > ___ > -- ___ Python tracker <https://bugs.python.org/issue33611> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46093] 2D array issue
New submission from Ritvik S : I had a problem running the following code. When I ran through what I thought python was supposed to do, I got a different answer than what python did. I think this is an error. Here is the code: problem_ary = [['a','b','c'],['d','e','f'],['g','h','i']] normal_ary = ['a','b','c'] print(normal_ary[:]) #should print ['a','b','c'] print(problem_ary[:][1]) The second output should be ['b','e','h'] since the print statement tells python to take [0][1],[1][1], and [2][1] from the problem_ary which is 'b','e','h'. It confused me when python instead returned ['d','e','f']. I came across this problem when I was trying to create tic-tac-toe in python. I tried coding this is Python 3.8, 3.9, and using an online interpreter, and I got the same result every time. -- files: 2D-Array-Problem.py messages: 408671 nosy: ritviksetty priority: normal severity: normal status: open title: 2D array issue type: behavior versions: Python 3.8, Python 3.9 Added file: https://bugs.python.org/file50498/2D-Array-Problem.py ___ Python tracker <https://bugs.python.org/issue46093> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46288] Migrating python 2.7 to 3.6 using 2to3 tool
New submission from Karthik S : Greeting of the day to all.. I would like to address few queries as mentioned in the below. python 2.7 code is running fine on RHEL 7.9,we are migrating to python3 from Python2 using 2to3 on RHEL 7.9. After migrating, When we run our products in python 3.6,we are facing some modules are not imported error. Example 1: from IN import AF_INET6 ModuleNotFoundError: No module named 'IN' In 2.7 IN modules coming from python-libs package,but in python3-libs doesnt find the IN module. /usr/lib64/python2.7/plat-linux2/IN.py is avaialbe in python-libs-2.7.5-89.el7.x86_64 ,but it is not avilable in python3-libs. [root@opt]# rpm -ql python-libs | grep -i IN.py /usr/lib64/python2.7/plat-linux2/IN.py /usr/lib64/python2.7/plat-linux2/IN.pyc /usr/lib64/python2.7/plat-linux2/IN.pyo [root@ opt]# rpm -ql python3-libs | grep -i IN.py [root@ opt]# Example2: from yum import YumBase ModuleNotFoundError: No module named 'yum' In RHEL 7.9 python 2.7 /usr/lib/python2.7/site-packages/yum is avaialbe , but in RHEL 7.9 with python3 it is not available.python3 is require python3-dnf but this is avaialbe from RHEL 8,doesnt have in RHEL 7.9. Kindly help, how to overcome this kind of issue, it would be more helpful for us to move forward. We are using 2to3 migration tool for converting py2 to py3. -- components: 2to3 (2.x to 3.x conversion tool) messages: 409950 nosy: mskarthik28 priority: normal severity: normal status: open title: Migrating python 2.7 to 3.6 using 2to3 tool type: compile error versions: Python 3.6 ___ Python tracker <https://bugs.python.org/issue46288> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42548] debugger stops at breakpoint of `pass` that is not actually reached
Andy S added the comment: Can reproduce this on 3.9. Is the fact 3.9 is in `bugfix` status enough to backport any fixing changes from 3.11 (if that's true and the bug was fixed)? -- ___ Python tracker <https://bugs.python.org/issue42548> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42548] debugger stops at breakpoint of `pass` that is not actually reached
Andy S added the comment: Then maybe those RMs (for 3.9 and 3.10) should decide on their own? That should mean the bug should be reopened for them to get assigned to. -- ___ Python tracker <https://bugs.python.org/issue42548> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20779] Add pathlib.chown method
Jaspar S. added the comment: I would love to use chown for a pathlib Path, too. It may not be used often, but if anyone want's to change all the os references from a file, it would be cool to have it on pathlib! -- nosy: +y0urself ___ Python tracker <https://bugs.python.org/issue20779> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue20779] Add pathlib.chown method
Change by Jaspar S. : -- pull_requests: +29382 stage: -> patch review pull_request: https://github.com/python/cpython/pull/31212 ___ Python tracker <https://bugs.python.org/issue20779> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13111] Error 2203 when installing Python/Perl?
New submission from MA S : I can't install Python or Strawberry Perl on the Windows 8 Developer Preview :( I keep getting installer error 2203; the log file's attached. I really don't know what's wrong... -- components: Windows files: python.log messages: 144975 nosy: MA.S priority: normal severity: normal status: open title: Error 2203 when installing Python/Perl? type: crash versions: Python 2.7 Added file: http://bugs.python.org/file23320/python.log ___ Python tracker <http://bugs.python.org/issue13111> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1372770] email.Header should preserve original FWS
Changes by Srikanth S : -- nosy: +srikanths ___ Python tracker <http://bugs.python.org/issue1372770> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11492] email.header.Header doesn't fold headers correctly
Changes by Srikanth S : -- nosy: +srikanths ___ Python tracker <http://bugs.python.org/issue11492> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6942] email.generator.Generator memory consumption
Changes by Srikanth S : -- nosy: +srikanths ___ Python tracker <http://bugs.python.org/issue6942> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1670765] email.Generator: no header wrapping for multipart/signed
Changes by Srikanth S : -- nosy: +srikanths ___ Python tracker <http://bugs.python.org/issue1670765> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue968430] error flattening complex smime signed message
Changes by Srikanth S : -- nosy: +srikanths ___ Python tracker <http://bugs.python.org/issue968430> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10061] ** operator yielding wrong result for negative numbers
New submission from eswar s : -5 ** 4 results as -625. It should be 625 -- components: None messages: 118311 nosy: eswar.s priority: normal severity: normal status: open title: ** operator yielding wrong result for negative numbers type: compile error versions: Python 2.6 ___ Python tracker <http://bugs.python.org/issue10061> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8503] smtpd module does not allow
New submission from mike s : The SMTPServer supplied by the smtpd library allows clients to send mail to any domain. This makes the server attractive to spammers, thinking they have found an open relay. The patch below adds an "accept_domain" method to SMTPServer (documented below) which can be overridden by the user to compare the incoming domain against a list, etc, and return True or False (True=accept address, False=reject). My apologies if this is the wrong place to submit this; I have not submitted a patch like this before and am just hoping to help! :) Mike --- smtpd.py.bak2010-04-23 00:22:39.0 -0700 +++ smtpd.py2010-04-23 00:51:22.0 -0700 @@ -241,6 +241,10 @@ if not address: self.push('501 Syntax: RCPT TO: ') return + address_domain = address.split('@')[1] + if self._SMTPChannel__server.accept_domain(address_domain) is False: + self.push('554 Relay access denied') + return self.__rcpttos.append(address) print >> DEBUGSTREAM, 'recips:', self.__rcpttos self.push('250 Ok') @@ -289,6 +293,15 @@ print >> DEBUGSTREAM, 'Incoming connection from %s' % repr(addr) channel = SMTPChannel(self, conn, addr) +def accept_domain(self,domain): + """domain is a string like domain.com that specifes the domain of + an email address supplied by client's RCPT TO command. + + Override this method to determine whether SMTPServer should + accept mail for a given domain. This is handy for preventing + spammers from thinking you are running an open relay.""" + return True + # API for "doing something useful with the message" def process_message(self, peer, mailfrom, rcpttos, data): """Override this abstract method to handle messages from the client. -- components: Library (Lib) messages: 103993 nosy: mike.s severity: normal status: open title: smtpd module does not allow versions: Python 2.5, Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3 ___ Python tracker <http://bugs.python.org/issue8503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8503] smtpd module does not allow domain filtering
Changes by mike s : -- title: smtpd module does not allow -> smtpd module does not allow domain filtering ___ Python tracker <http://bugs.python.org/issue8503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8503] smtpd SMTPServer does not allow domain filtering
Changes by mike s : -- title: smtpd module does not allow domain filtering -> smtpd SMTPServer does not allow domain filtering ___ Python tracker <http://bugs.python.org/issue8503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue8503] smtpd SMTPServer does not allow domain filtering
mike s added the comment: I don't think that is a suitable solution for this problem, because the expected SMTP behavior is to reject an unsuitable RCPT TO directly after it is proposed by the client. However, I think it would be a great idea to have such a method being called after the end of the DATA segment (immediately before the message is queued - or not). Mike On 2010-04-23, at 12:00 PM, Giampaolo Rodola' wrote: > > Giampaolo Rodola' added the comment: > > Idea: wouldn't it be better to provide a more powerful "accept_mail" method > instead of "accept_domain? > > -- > nosy: +giampaolo.rodola > > ___ > Python tracker > <http://bugs.python.org/issue8503> > ___ -- ___ Python tracker <http://bugs.python.org/issue8503> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4963] mimetypes.guess_extension result changes after mimetypes.init()
New submission from S Arrowsmith : Asking mimetypes to reload mime.types can cause guess_extension() to return a different result if multiple extensions are mapped to that mime type: >>> import mimetypes >>> mimetypes.guess_extension('image/jpeg') '.jpe' >>> mimetypes.init() >>> mimetypes.guess_extension('image/jpeg') '.jpeg' >>> This is because both the forward (extension to type) and inverse (type to extension) type mapping dicts are populated by iterating through the existing forward (extension to type) dict (types_map), then supplemented by reading from mime.types (or any other files given to init()). The fully populated forward dict becomes the new types_map. Initially, types_map is hard-coded, but when the type mapping dicts are repopulated, by explicitly or implicitly calling init() again, it is done by iterating over the types_map created by the first init() call, not the hard-coded one. If the iteration order for a set of extensions with the same type is different in these two versions of the forward dict, the order of extensions appearing for that type in the inverse dict will change. And so the behavior of guess_all_extensions() and hence guess_extension() will change. -- components: Library (Lib) messages: 79955 nosy: siona severity: normal status: open title: mimetypes.guess_extension result changes after mimetypes.init() type: behavior versions: Python 2.4, Python 2.5 ___ Python tracker <http://bugs.python.org/issue4963> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue4963] mimetypes.guess_extension result changes after mimetypes.init()
S Arrowsmith added the comment: Ah, yes, forgot to mention this is on Debian 4.0. I doubt you're going to run into it on a Windows system unless you explicitly give init() a mime.types file, looking at the knownfiles list used by default. ___ Python tracker <http://bugs.python.org/issue4963> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38457] __package__ is None in __init__.py until an import is used
New submission from Yuval S : In Python 2.7, the __package__ variable isn't set when __init__.py is run, until an import is done. In Python 3.5, it is set correctly. e.g. # mkdir x && echo "print(__package__)" | tee x/__init__.py x/test.py # python2 x.test None x # python3 x.test x x # echo -e "import os\n$(cat x/__init__.py)" > x/__init__.py # python2 x.test x x This is very old, as it's there at least since 2010: https://stackoverflow.com/questions/4437394/package-is-none-when-importing-a-python-module I would expect Python 2 and 3 to behave the same. -- components: Library (Lib) messages: 354555 nosy: Yuval S priority: normal severity: normal status: open title: __package__ is None in __init__.py until an import is used versions: Python 2.7 ___ Python tracker <https://bugs.python.org/issue38457> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38457] __package__ is None in __init__.py until an import is used
Yuval S added the comment: * It should be python[23] -m x.test, of course. -- ___ Python tracker <https://bugs.python.org/issue38457> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43430] Exception raised when attempting to create Enum via functional API
Suhail S. added the comment: In my usecase, I wanted to override the behaviour of __getitem__. I was able to accomplish this by subclassing EnumMeta. Having done so, I was able to work around this bug as follows. Instead of trying to access the functional API via Enum (using an enum as the type parameter) and failing, I was able to succeed by accessing the functional API via subclass of Enum. Something like: MyEnum2 = MyEnumBase1(...) -- ___ Python tracker <https://bugs.python.org/issue43430> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43583] make test failures, 2 tests failed: test_embed test_tabnanny
Change by Alexei S : -- components: +Tests type: -> compile error ___ Python tracker <https://bugs.python.org/issue43583> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43001] python3.9.1python3.9.1 test_embed test_tabnanny failed
Change by Alexei S : -- title: python3.9.1 test_embed test_tabnanny failed -> python3.9.1python3.9.1 test_embed test_tabnanny failed ___ Python tracker <https://bugs.python.org/issue43001> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43001] python3.9.1 test_embed test_tabnanny failed
Change by Alexei S : -- resolution: out of date -> status: closed -> open ___ Python tracker <https://bugs.python.org/issue43001> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43001] python3.8.9, python3.9.1 test_embed test_tabnanny failed
Change by Alexei S : -- versions: +Python 3.8 ___ Python tracker <https://bugs.python.org/issue43001> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43001] python3.8.9, python3.9.1 test_embed test_tabnanny failed
Alexei S added the comment: python 3.8.9 also show compile problems my system: Linux Mint 20.1 Cinnamon (Cinnamon 4.8.6) kernel 5.8.0-48-generic $uname -a Linux home 5.8.0-48-generic #54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux I tried to execute problem code from tabnanny in PyCharm - that's ok from test.support import (captured_stderr, captured_stdout, script_helper, findfile, unlink) def validate_cmd(self, *args, stdout="", stderr="", partial=False): """Common function to assert the behaviour of command line interface.""" _, out, err = script_helper.assert_python_ok('-m', 'tabnanny', *args) # Note: The `splitlines()` will solve the problem of CRLF(\r) added # by OS Windows. out = out.decode('ascii') err = err.decode('ascii') if partial: for std, output in ((stdout, out), (stderr, err)): _output = output.splitlines() for _std in std.splitlines(): with self.subTest(std=_std, output=_output): self.assertIn(_std, _output) else: self.assertListEqual(out.splitlines(), stdout.splitlines()) self.assertListEqual(err.splitlines(), stderr.splitlines()) def test_command_usage(self): path = findfile('~/Загрузки/Python-3.8.9/Lib/test/tabnanny.py') stderr = f"Usage: {path} [-v] file_or_directory ..." self.validate_cmd(stderr=stderr) -- title: python3.9.1python3.9.1 test_embed test_tabnanny failed -> python3.8.9, python3.9.1 test_embed test_tabnanny failed Added file: https://bugs.python.org/file50006/make_test_3.8.9.log ___ Python tracker <https://bugs.python.org/issue43001> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43001] python3.8.9, python3.9.1 test_embed test_tabnanny failed
Change by Alexei S : Added file: https://bugs.python.org/file50007/log_make_test 3.9.2.log ___ Python tracker <https://bugs.python.org/issue43001> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43001] python3.8.9, python3.9.2 test_embed test_tabnanny failed
Change by Alexei S : -- title: python3.8.9, python3.9.1 test_embed test_tabnanny failed -> python3.8.9, python3.9.2 test_embed test_tabnanny failed ___ Python tracker <https://bugs.python.org/issue43001> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] python3.8.9, python3.9.2 test_embed test_tabnanny failed
Change by Alexei S : Added file: https://bugs.python.org/file50009/log_make 3.9.2.log ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] python3.8.9, python3.9.2 test_embed test_tabnanny failed
New submission from Alexei S : Python 3.9.2 make test == Tests result: FAILURE then FAILURE == 396 tests OK. 2 tests failed: test_embed test_tabnanny 27 tests skipped: test_bz2 test_curses test_dbm_gnu test_dbm_ndbm test_devpoll test_gdb test_idle test_ioctl test_kqueue test_lzma test_msilib test_ossaudiodev test_readline test_smtpnet test_ssl test_startfile test_tcl test_tix test_tk test_ttk_guionly test_ttk_textonly test_turtle test_winconsoleio test_winreg test_winsound test_zipfile64 test_zoneinfo 2 re-run tests: test_embed test_tabnanny Total duration: 10 min 58 sec Tests result: FAILURE then FAILURE make: *** [Makefile:1199: test] Error 2 python 3.8.9 also show compile problems my system: Linux Mint 20.1 Cinnamon (Cinnamon 4.8.6) kernel 5.8.0-48-generic $uname -a Linux home 5.8.0-48-generic #54~20.04.1-Ubuntu SMP Sat Mar 20 13:40:25 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux I tried to execute problem code from tabnanny in PyCharm - that's ok from test.support import (captured_stderr, captured_stdout, script_helper, findfile, unlink) def validate_cmd(self, *args, stdout="", stderr="", partial=False): """Common function to assert the behaviour of command line interface.""" _, out, err = script_helper.assert_python_ok('-m', 'tabnanny', *args) # Note: The `splitlines()` will solve the problem of CRLF(\r) added # by OS Windows. out = out.decode('ascii') err = err.decode('ascii') if partial: for std, output in ((stdout, out), (stderr, err)): _output = output.splitlines() for _std in std.splitlines(): with self.subTest(std=_std, output=_output): self.assertIn(_std, _output) else: self.assertListEqual(out.splitlines(), stdout.splitlines()) self.assertListEqual(err.splitlines(), stderr.splitlines()) def test_command_usage(self): path = findfile('~/Загрузки/Python-3.8.9/Lib/test/tabnanny.py') stderr = f"Usage: {path} [-v] file_or_directory ..." self.validate_cmd(stderr=stderr) -- components: Tests files: log_configure 3.9.2.log messages: 392880 nosy: asholomitskiy84, terry.reedy, vstinner, wingarmac priority: normal severity: normal status: open title: python3.8.9, python3.9.2 test_embed test_tabnanny failed type: compile error versions: Python 3.8, Python 3.9 Added file: https://bugs.python.org/file50008/log_configure 3.9.2.log ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] python3.8.9, python3.9.2 test_embed test_tabnanny failed
Change by Alexei S : Added file: https://bugs.python.org/file50010/log_make_test 3.9.2.log ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] python3.8.9, python3.9.2 test_embed test_tabnanny failed
Change by Alexei S : Added file: https://bugs.python.org/file50011/log_make_test 3.8.9.log ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] python3.8.9, python3.9.2 test_embed test_tabnanny failed
Alexei S added the comment: this problem was announced also in 43001 https://bugs.python.org/issue43001?@ok_message=%D0%98%D0%B7%D0%BC%D0%B5%D0%BD%D0%B5%D0%BD%D1%8B%20%D0%B0%D1%82%D1%80%D0%B8%D0%B1%D1%83%D1%82%D1%8B%20%D0%B7%D0%B0%D0%B3%D0%BB%D0%B0%D0%B2%D0%B8%D0%B5%20%D0%BE%D0%B1%D1%8A%D0%B5%D0%BA%D1%82%D0%B0%20issue%2043001&@template=item -- ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43001] python3.8.9, python3.9.2 test_embed test_tabnanny failed
Change by Alexei S : -- resolution: -> out of date status: open -> closed ___ Python tracker <https://bugs.python.org/issue43001> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43583] make test failures, 2 tests failed: test_embed test_tabnanny
Change by Alexei S : Added file: https://bugs.python.org/file50012/log_make_test 3.8.9.log ___ Python tracker <https://bugs.python.org/issue43583> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43583] make test failures, 2 tests failed: test_embed test_tabnanny
Change by Alexei S : Added file: https://bugs.python.org/file50013/log_make_test 3.9.2.log ___ Python tracker <https://bugs.python.org/issue43583> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43583] make test failures, 2 tests failed: test_embed test_tabnanny
Alexei S added the comment: I have opened the same issue https://bugs.python.org/issue44031 -- nosy: +asholomitskiy84 ___ Python tracker <https://bugs.python.org/issue43583> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] python3.8.9, python3.9.2 test_embed test_tabnanny failed
Alexei S added the comment: the same issue also in https://bugs.python.org/issue43583 -- ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43583] make test failures, 2 tests failed: test_embed test_tabnanny
Alexei S added the comment: python3 -m ~/Загрузки/Python-3.8.9/Lib/test/test_embed -v /usr/bin/python3: Error while finding module specification for '/home/alexei/Загрузки/Python-3.8.9/Lib/test/test_embed' (ModuleNotFoundError: No module named '/home/alexei/Загрузки/Python-3') it doesn't recognize '-' ?? -- ___ Python tracker <https://bugs.python.org/issue43583> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43583] make test failures, 2 tests failed: test_embed test_tabnanny
Alexei S added the comment: i rename folder and tried python3 -m '~/Загрузки/Python-389/Lib/test/test_embed' -v /usr/bin/python3: No module named ~/Загрузки/Python-389/Lib/test/test_embed ??? -- ___ Python tracker <https://bugs.python.org/issue43583> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] python3.8.9, python3.9.2 test_embed test_tabnanny failed
Alexei S added the comment: make test TESTOPTS="-v test_embed test_tabnanny" CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-DNDEBUG -g -fwrapv -O3 -Wall' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python -E ./setup.py build running build running build_ext The following modules found by detect_modules() in setup.py, have been built by the Makefile instead, as configured by the Setup files: _abc atexitpwd time running build_scripts copying and adjusting /home/alexei/Загрузки/Python-3.9.4/Tools/scripts/pydoc3 -> build/scripts-3.9 copying and adjusting /home/alexei/Загрузки/Python-3.9.4/Tools/scripts/idle3 -> build/scripts-3.9 copying and adjusting /home/alexei/Загрузки/Python-3.9.4/Tools/scripts/2to3 -> build/scripts-3.9 changing mode of build/scripts-3.9/pydoc3 from 664 to 775 changing mode of build/scripts-3.9/idle3 from 664 to 775 changing mode of build/scripts-3.9/2to3 from 664 to 775 renaming build/scripts-3.9/pydoc3 to build/scripts-3.9/pydoc3.9 renaming build/scripts-3.9/idle3 to build/scripts-3.9/idle3.9 renaming build/scripts-3.9/2to3 to build/scripts-3.9/2to3-3.9 ./python -E -c 'import sys ; from sysconfig import get_platform ; print("%s-%d.%d" % (get_platform(), *sys.version_info[:2]))' >platform ./python ./Tools/scripts/run_tests.py -v test_embed test_tabnanny /home/alexei/Загрузки/Python-3.9.4/python -u -W default -bb -E -m test -r -w -j 0 -u all,-largefile,-audio,-gui -v test_embed test_tabnanny == CPython 3.9.4 (default, May 25 2021, 18:48:10) [GCC 9.3.0] == Linux-5.8.0-48-generic-x86_64-with-glibc2.31 little-endian == cwd: /home/alexei/Загрузки/Python-3.9.4/build/test_python_58488æ == CPU count: 4 == encodings: locale=UTF-8, FS=utf-8 Using random seed 464094 0:00:00 load avg: 0.41 Run tests in parallel using 6 child processes 0:00:01 load avg: 0.53 [1/2/1] test_tabnanny failed test_correct_directory (test.test_tabnanny.TestCheck) Directory which contains few error free python source code files. ... ok test_correct_directory_verbose (test.test_tabnanny.TestCheck) Directory containing few error free python source code files. ... ok test_correct_file (test.test_tabnanny.TestCheck) A python source code file without any errors. ... ok test_errored_directory (test.test_tabnanny.TestCheck) Directory containing wrongly indented python source code files. ... ok test_when_nannynag_error (test.test_tabnanny.TestCheck) A python source code file eligible for raising `tabnanny.NannyNag`. ... ok test_when_nannynag_error_verbose (test.test_tabnanny.TestCheck) A python source code file eligible for raising `tabnanny.NannyNag`. ... ok test_when_no_file (test.test_tabnanny.TestCheck) A python file which does not exist actually in system. ... ok test_when_tokenize_tokenerror (test.test_tabnanny.TestCheck) A python source code file eligible for raising 'tokenize.TokenError'. ... ok test_when_wrong_indented (test.test_tabnanny.TestCheck) A python source code file eligible for raising `IndentationError`. ... ok test_command_usage (test.test_tabnanny.TestCommandLine) Should display usage on no arguments. ... ERROR test_double_verbose_mode (test.test_tabnanny.TestCommandLine) Should display detailed error information if double verbose is on. ... ok test_quiet_flag (test.test_tabnanny.TestCommandLine) Should display less when quite mode is on. ... ok test_verbose_mode (test.test_tabnanny.TestCommandLine) Should display more error information if verbose mode is on. ... ok test_with_error_free_file (test.test_tabnanny.TestCommandLine) Should not display anything if python file is correctly indented. ... ok test_with_errored_file (test.test_tabnanny.TestCommandLine) Should displays error when errored python file is given. ... ok test_errprint (test.test_tabnanny.TestErrPrint) Asserting result of `tabnanny.errprint()` by giving sample inputs. ... ok test_format_witnesses (test.test_tabnanny.TestFormatWitnesses) Asserting formatter result by giving various input samples. ... ok test_all_methods (test.test_tabnanny.TestNannyNag) Asserting behaviour of `tabnanny.NannyNag` exception. ... ok test_with_correct_code (test.test_tabnanny.TestProcessTokens) A python source code without any whitespace related problems. ... ok test_with_errored_codes_samples (test.test_tabnanny.TestProcessTokens) A python source code with whitespace related sampled problems. ... ok == ERROR: test_command_usage (test.test_tabnanny.TestCommandLine) Should display usage on no arguments. -- Traceback (most recent call last): File "/home/alexei/Загрузки/Python-3.9.4/Lib/test/test_tabnanny.py", line 324, in test_command_usage self.validate_cmd(stderr=stderr) File
[issue44031] python3.8.9, python3.9.2 test_embed test_tabnanny failed
Alexei S added the comment: I downloaded tar.gz of Python-3.8.9 and Python-3.9.4 into my ~/Downloads folder (~/Загрузки in Russian) extracted them, after that executed: chmod +x configure CXX=/usr/bin/g++ ./configure --enable-optimizations make -j4 problems the same for both Python versions -- ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] test_embed and test_tabnanny fails if the current directory is non-ASCII
Alexei S added the comment: the problem is caused by language?? -- ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] test_embed and test_tabnanny fails if the current directory is non-ASCII
Alexei S added the comment: yes! the problem was in folder caption! -- ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44031] test_embed and test_tabnanny fails if the current directory is non-ASCII
Alexei S added the comment: how we can fix this small problem in next releases of test_embed test_tabnanny? other tests didn't fail -- ___ Python tracker <https://bugs.python.org/issue44031> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44481] Tkinter config() minor documentation bug for shorthand options
New submission from Jeff S : The documentation page https://docs.python.org/3/library/tkinter.html states "Passing the config() method the name of a shorthand option will return a 2-tuple, not 5-tuple." While config() without argument does return a map that yields references like this, if config() is given the shorthand name as an argument, it follows the reference to the long option name and does yield the full 5-tuple. To demonstrate the difference: from tkinter import Tk Tk().config()['bg'] Tk().config('bg') -- components: Tkinter messages: 396301 nosy: spirko priority: normal severity: normal status: open title: Tkinter config() minor documentation bug for shorthand options type: behavior versions: Python 3.6, Python 3.9 ___ Python tracker <https://bugs.python.org/issue44481> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39800] Inconsistent/incomplete disassembly of methods vs method source code
New submission from S Murthy : I am using the dis module to look at source (and logical) lines of code vs corresponding bytecode instructions. I am bit confused by the output of dis.dis when disassembling a given method vs the corresponding source string, e.g. >>> def f(x): return x**2 >>> dis.dis(f) 1 0 LOAD_FAST 0 (x) 2 LOAD_CONST 1 (2) 4 BINARY_POWER 6 RETURN_VALUE This is the bytecode instruction block for the body only (not the method header), but dis.dis('def f(x): return x**2') produces the instructions for the header and body: >>> dis.dis('def f(x): return x**2') 1 0 LOAD_CONST 0 (", line 1>) 2 LOAD_CONST 1 ('f') 4 MAKE_FUNCTION0 6 STORE_NAME 0 (f) 8 LOAD_CONST 2 (None) 10 RETURN_VALUE Disassembly of ", line 1>: 1 0 LOAD_FAST 0 (x) 2 LOAD_CONST 1 (2) 4 BINARY_POWER 6 RETURN_VALUE I have traced this difference to the different behaviour of dis.dis for methods vs source code strings: def dis(x=None, *, file=None, depth=None): ... ... if hasattr(x, '__code__'): x = x.__code__ ... # Perform the disassembly ... elif hasattr(x, 'co_code'): # Code object _disassemble_recursive(x, file=file, depth=depth) ... elif isinstance(x, str):# Source code _disassemble_str(x, file=file, depth=depth) ... It appears as if the method body is contained in the code object produced from compiling the source (_try_compile(source, '', ...)) but not if the code object was obtained from f.__code__. Why is this the case, and would it not be better to for dis.dis to behave consistently for methods and source strings of methods, and to generate/produce the complete instruction set, including for any headers? The current behaviour of dis.dis means that Bytecode(x) is also affected, as iterating over the instructions gives you different instructions depending on whether x is a method or a source string of x: >>> for instr in dis.Bytecode(f): ... print(instr) ... Instruction(opname='LOAD_FAST', opcode=124, arg=0, argval='x', argrepr='x', offset=0, starts_line=1, is_jump_target=False) Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval=2, argrepr='2', offset=2, starts_line=None, is_jump_target=False) Instruction(opname='BINARY_POWER', opcode=19, arg=None, argval=None, argrepr='', offset=4, starts_line=None, is_jump_target=False) Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=6, starts_line=None, is_jump_target=False >>> for instr in dis.Bytecode(inspect.getsource(f)): ... print(instr) ... Instruction(opname='LOAD_CONST', opcode=100, arg=0, argval=", line 1>, argrepr='", line 1>', offset=0, starts_line=1, is_jump_target=False) Instruction(opname='LOAD_CONST', opcode=100, arg=1, argval='f', argrepr="'f'", offset=2, starts_line=None, is_jump_target=False) Instruction(opname='MAKE_FUNCTION', opcode=132, arg=0, argval=0, argrepr='', offset=4, starts_line=None, is_jump_target=False) Instruction(opname='STORE_NAME', opcode=90, arg=0, argval='f', argrepr='f', offset=6, starts_line=None, is_jump_target=False) Instruction(opname='LOAD_CONST', opcode=100, arg=2, argval=None, argrepr='None', offset=8, starts_line=None, is_jump_target=False) Instruction(opname='RETURN_VALUE', opcode=83, arg=None, argval=None, argrepr='', offset=10, starts_line=None, is_jump_target=False) -- components: Library (Lib) messages: 362985 nosy: smurthy priority: normal severity: normal status: open title: Inconsistent/incomplete disassembly of methods vs method source code type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue39800> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39800] Inconsistent/incomplete disassembly of methods vs method source code
S Murthy added the comment: @steven.daprano In this case, the method f was created by via def. And calling dis.dis(s) where s is the source code of f (say s = inspect.getsource(f)) shows the bytecode both for the header and the body, as is clear enough from the example I first posted. >>> dis.dis('def f(x): return x**2') 1 0 LOAD_CONST 0 (", line 1>) 2 LOAD_CONST 1 ('f') 4 MAKE_FUNCTION0 6 STORE_NAME 0 (f) 8 LOAD_CONST 2 (None) 10 RETURN_VALUE Disassembly of ", line 1>: 1 0 LOAD_FAST 0 (x) 2 LOAD_CONST 1 (2) 4 BINARY_POWER 6 RETURN_VALUE The first block of instructions here are for the def statement, and the second block for the return statement. -- ___ Python tracker <https://bugs.python.org/issue39800> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39800] Inconsistent/incomplete disassembly of methods vs method source code
S Murthy added the comment: BTW how else are methods/functions are created in Python except via def? -- ___ Python tracker <https://bugs.python.org/issue39800> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39800] Inconsistent/incomplete disassembly of methods vs method source code
S Murthy added the comment: Yes, I know that a method body may contain more than just the return statement - I was referrring to the byte code for the method def f(x): return x**2. I don't think the output of dis.dis is correct here for the source string of f - it doesn't make sense for example to iterate over Bytecode(f) and get only the instruction for the return statement, but then iterate over Bytecode(inspect.getsource(f)) to get only the byte code for the def - the documentation for dis.dis and Bytecode indicate that all the bytecode for a piece of code, whether specified as a method, callable, generator, async. generator, coroutine, class, or a source string, will be generated. -- ___ Python tracker <https://bugs.python.org/issue39800> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39823] Disassembly - improve documentation for bytecode instruction class and set source line no. attribute for every instruction
New submission from S Murthy : I note that on disassembling a piece of source code (via source strings or code objects) the corresponding sequence of bytecode instruction objects (https://docs.python.org/3/library/dis.html#dis.Instruction) do not always have the `starts_line` attribute set - the storage and display of this line no. seems to be based on whether a given instruction is the first in a block of instructions which implement a given source line. I think it would be better, for mapping source and logical lines of code to bytecode instruction blocks, to set `starts_line` for every instruction, and amend the bytecode printing method (`dis._disassemble_bytes`) to keep the existing behaviour by detecting whether an instruction is the first line of an instruction block. ATM `Instruction` objects are created and generated within this loop in `dis._get_bytecode_instructions`: def _get_instructions_bytes(code, varnames=None, names=None, constants=None, cells=None, linestarts=None, line_offset=0): """Iterate over the instructions in a bytecode string. Generates a sequence of Instruction namedtuples giving the details of each opcode. Additional information about the code's runtime environment (e.g. variable names, constants) can be specified using optional arguments. """ labels = findlabels(code) starts_line = None for offset, op, arg in _unpack_opargs(code): if linestarts is not None: starts_line = linestarts.get(offset, None) ... ... So it's this line starts_line = linestarts.get(offset, None) which currently causes `starts_line` to be to set to `None` for every instruction which isn't the first in an instruction block - linestarts is a dict of source line numbers and offsets of the first instructions starting the corresponding instruction blocks. My idea is to (1) change that line above to starts_line = linestarts.get(offset, starts_line) which ensures every instruction will have the corresponding source line no. set, (2) amend `Instruction._disassemble` to add a new optional argument `print_start_line` with default of `True` to determine whether to print the source line no., and (3) amend `dis._disassemble_bytes` to accept a new optional argument `start_line_by_block` with a default of `True` which can be used to preserve existing behaviour of printing source line numbers by instruction block. I was wondering whether this sounds OK, if so, I am happy to submit a PR. -- components: Library (Lib) messages: 363140 nosy: smurthy priority: normal severity: normal status: open title: Disassembly - improve documentation for bytecode instruction class and set source line no. attribute for every instruction type: enhancement versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue39823> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39823] Disassembly - improve documentation for bytecode instruction class and set source line no. attribute for every instruction
S Murthy added the comment: Docstring for `Instruction` should be more precise. ATM the description of `starts_line` is line started by this opcode (if any), otherwise None I think "source line started ..." would be a bit more precise and accurate. -- ___ Python tracker <https://bugs.python.org/issue39823> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39993] Language Reference - Function definition parameter_list item definition not equivalent to implementation.
New submission from Michael S : I just read https://docs.python.org/3/reference/compound_stmts.html#function-definitions The item parameter_list is defined as: parameter_list::= defparameter ("," defparameter)* "," "/" ["," [parameter_list_no_posonly]] | parameter_list_no_posonly This definition states that the "," "/" after ("," defparameter)* are mandatory. But this is not true in Python 3.8, because you can define a function as def f(a): pass Did I miss something? -- assignee: docs@python components: Documentation messages: 364425 nosy: Michael S2, docs@python priority: normal severity: normal status: open title: Language Reference - Function definition parameter_list item definition not equivalent to implementation. type: enhancement versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue39993> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39993] Language Reference - Function definition parameter_list item definition not equivalent to implementation.
Michael S added the comment: Thanks Pablo, sorry, I was just stupid. > Do you think that adding these explicit parentheses would help with help > making this more clear? Maybe. I read the BNF documentation the first time today, but since it's not intended for beginners, I think it's clear enough. How should we continue with this issue? I don't really see any closing button or the like. -- ___ Python tracker <https://bugs.python.org/issue39993> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9253] argparse: optional subparsers
Change by brent s. : -- nosy: +bsaner ___ Python tracker <https://bugs.python.org/issue9253> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue39010] ProactorEventLoop raises unhandled ConnectionResetError
Rustam S. added the comment: Please take a look at this as well: (ipython #12049 'Unhandled exception in event loop' (WinError 995)) https://github.com/ipython/ipython/issues/12049#issuecomment-586544339 and below -- nosy: +Rustam S. ___ Python tracker <https://bugs.python.org/issue39010> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results
New submission from Yuval S : The following code gives different results on each run, even though "``random.seed()``" is used: >>> import random >>> random.seed(6) >>> x = set(str(i) for i in range(500)) >>> print(random.sample(x, 1)) presumably because of string hash randomization (see also #27706), unless "``PYTHONHASHSEED``" is set. However, this is non-intuitive, especially as this random aspect of Python is not mentioned in `Notes on Reproducability <https://docs.python.org/3/library/random.html#notes-on-reproducibility>`_. I would suggest this is either fixed (using the provided seed for string hash randomization as well) or documented. -- assignee: docs@python components: Documentation, Library (Lib) files: test.py messages: 366741 nosy: Yuval S, docs@python priority: normal severity: normal status: open title: Random.seed does not affect string hash randomization leading to non-intuitive results versions: Python 3.7, Python 3.8 Added file: https://bugs.python.org/file49075/test.py ___ Python tracker <https://bugs.python.org/issue40325> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results
Yuval S added the comment: Thank you for the attention and the quick fix. However, the current documentation for "Notes on Reproducibility" should still address this issue of hash randomization. Not only `sample` is affected by this, but any code that combines strings (or bytes or datetime) with hash and random, e.g. >>> import random >>> random.seed(6) >>> a = list(set(str(i) for i in range(500))) >>> print(a[int(random.random() * 500)]) or, this >>> import random >>> import datetime >>> random.seed(6) >>> print(random.choice(range(hash(datetime.datetime(2000,1,1)) % 100))) will still produce non-reproducible results even after the fix. Here is my suggestion for documentation: > Hash randomization, which is enabled by default since version 3.3, is not > affected by `random.seed()`. For this reason, code that relies on string > hashes, such as code that relies on the ordering of `set` or `dict`, might be > non-reproducible, unless string hash randomization is disabled or seeded > (see: https://docs.python.org/3/using/cmdline.html#envvar-PYTHONHASHSEED). My vote would be to keep hash randomization ties to `random.seed()`, and this would make all use cases more predictable, as well as allow `random.sample()` to support `set`. -- ___ Python tracker <https://bugs.python.org/issue40325> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40325] Random.seed does not affect string hash randomization leading to non-intuitive results
Change by Yuval S : -- pull_requests: +18932 pull_request: https://github.com/python/cpython/pull/19596 ___ Python tracker <https://bugs.python.org/issue40325> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35907] [security][CVE-2019-9948] Unnecessary URL scheme exists to allow local_file:// reading file in urllib
Petter S added the comment: We should whitelist the protocols. The current solution with `getattr` is really fragile. For example, this crashes with a `TypeError`: `URLopener().open("unknown_proxy://test")` -- nosy: +Petter S ___ Python tracker <https://bugs.python.org/issue35907> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35907] [security][CVE-2019-9948] Unnecessary URL scheme exists to allow local_file:// reading file in urllib
Petter S added the comment: The solution is incomplete because it fixes just this single security issue, not the inherent fragility of this file. If, in the future someone happens to add another method starting with open to this class, we are at risk of having the same problem again. As for the error message, it is of course a minor issue, but I don't think it is expected that "unknown_proxy://" and "something_else://" raise different exceptions, right? -- ___ Python tracker <https://bugs.python.org/issue35907> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40673] UrlOpener raises different exceptions based on implementation detail
New submission from Petter S : The following code crashes with TypeError: URLopener().open("unknown_proxy://test") the expected behavior is an OSError, which is normally raised for unknown protocols. This implementation of directly calling a method called "unknown_proxy" is fragile and was recently the subject of a security issue: https://bugs.python.org/issue35907 (CVE-2019-9948) Would be good to make this more robust. -- components: Library (Lib) messages: 369291 nosy: Petter S priority: normal severity: normal status: open title: UrlOpener raises different exceptions based on implementation detail type: enhancement versions: Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue40673> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40673] urllib.request.URLopener raises different exceptions based on implementation detail
Change by Petter S : -- title: UrlOpener raises different exceptions based on implementation detail -> urllib.request.URLopener raises different exceptions based on implementation detail ___ Python tracker <https://bugs.python.org/issue40673> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35907] [security][CVE-2019-9948] Unnecessary URL scheme exists to allow local_file:// reading file in urllib
Petter S added the comment: OK: https://bugs.python.org/issue40673 -- ___ Python tracker <https://bugs.python.org/issue35907> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40673] urllib.request.URLopener raises different exceptions based on implementation detail
Petter S added the comment: I can fix this, but it does not have high priority. -- ___ Python tracker <https://bugs.python.org/issue40673> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40673] urllib.request.URLopener raises different exceptions based on implementation detail
Petter S added the comment: I see. Perhaps that is the resolution then. -- ___ Python tracker <https://bugs.python.org/issue40673> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue42548] debugger stops at breakpoint of `pass` that is not actually reached
New submission from Andy S : The python (3.6) doc states (https://docs.python.org/3/reference/simple_stmts.html#the-pass-statement): pass is a null operation... So since this is still an operation one could expect that it can be used as an op to breakpoint on while debugging some scripts. Nevertheless: $ pdb3.7 ./debug_bug.py > /...play/debug_bug.py(1)() -> a = None (Pdb) list 1 -> a = None 2 3 4 def fun(): 5 b = False 6 if a is None: 7 b = True 8 pass 9 else: 10 pass 11 (Pdb) 12 13 fun() 14 pass [EOF] (Pdb) b 10 Breakpoint 1 at /...play/debug_bug.py:10 (Pdb) run Restarting ./debug_bug.py with arguments: ./debug_bug.py > /...play/debug_bug.py(1)() -> a = None (Pdb) continue > /...play/debug_bug.py(10)fun() -> pass (Pdb) bt /usr/lib/python3.7/bdb.py(585)run() -> exec(cmd, globals, locals) (1)() /...play/debug_bug.py(13)() -> fun() > /...play/debug_bug.py(10)fun() -> pass (Pdb) p b True (Pdb) -- components: Interpreter Core, Library (Lib) files: debug_bug.py messages: 382351 nosy: gatekeeper.mail priority: normal severity: normal status: open title: debugger stops at breakpoint of `pass` that is not actually reached type: behavior versions: Python 3.7 Added file: https://bugs.python.org/file49649/debug_bug.py ___ Python tracker <https://bugs.python.org/issue42548> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43001] python3.9.1 test_embed test_tabnanny failed
New submission from Alexei S : == Tests result: FAILURE then FAILURE == 396 tests OK. 2 tests failed: test_embed test_tabnanny 27 tests skipped: test_bz2 test_curses test_dbm_gnu test_dbm_ndbm test_devpoll test_gdb test_idle test_ioctl test_kqueue test_lzma test_msilib test_ossaudiodev test_readline test_smtpnet test_ssl test_startfile test_tcl test_tix test_tk test_ttk_guionly test_ttk_textonly test_turtle test_winconsoleio test_winreg test_winsound test_zipfile64 test_zoneinfo 2 re-run tests: test_embed test_tabnanny Total duration: 10 min 58 sec Tests result: FAILURE then FAILURE make: *** [Makefile:1199: test] Error 2 -- components: Tests messages: 385490 nosy: asholomitskiy84 priority: normal severity: normal status: open title: python3.9.1 test_embed test_tabnanny failed type: compile error versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue43001> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43328] make test errors
New submission from Alexei S : this commands are successful: CXX=/usr/bin/g++ ./configure --enable-optimizations >> log_configure.log make -j4 >> log_make.log errors on make test: make -j4 test >> log_make_test.log my system: uname -a Linux home 5.8.0-43-generic #49~20.04.1-Ubuntu SMP Fri Feb 5 09:57:56 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux Linux Mint 20.1 x64 Cinnamon -- files: PythonCompileLogs.tar.gz messages: 387723 nosy: asholomitskiy84 priority: normal severity: normal status: open title: make test errors type: compile error versions: Python 3.9 Added file: https://bugs.python.org/file49838/PythonCompileLogs.tar.gz ___ Python tracker <https://bugs.python.org/issue43328> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43328] make test errors
Alexei S added the comment: == Tests result: FAILURE == 403 tests OK. 3 tests failed: test_embed test_ssl test_tabnanny -- stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue43328> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43430] Exception raised when attempting to create Enum via functional API
New submission from Suhail S. : It is possible to create custom Enum classes with a metaclass that is a subtype of EnumMeta. It is also possible to inherit from such an enumeration to create another enumeration. However, attempting to do so via the functional API raises an exception. See attached file that highlights minimal failing test case. -- components: Library (Lib) files: test.py messages: 388255 nosy: suhailsingh247 priority: normal severity: normal status: open title: Exception raised when attempting to create Enum via functional API type: crash versions: Python 3.7, Python 3.8, Python 3.9 Added file: https://bugs.python.org/file49855/test.py ___ Python tracker <https://bugs.python.org/issue43430> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue43430] Exception raised when attempting to create Enum via functional API
Change by Suhail S. : -- nosy: +barry, eli.bendersky, ethan.furman ___ Python tracker <https://bugs.python.org/issue43430> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41555] re.sub replaces twice
New submission from S. Zhang : The following command produced "name.tsvtsv" with version 3.7.1 and 3.8.5 instead of the expected "name.tsv" from version 2.7.5, 3.5.6, and 3.6.7. Changing * to + produced expected "name.tsv". python -c 'import re; v="name.txt";v = re.sub("[^\.]*$", "tsv", v);print(v)' -- messages: 375436 nosy: spz1st priority: normal severity: normal status: open title: re.sub replaces twice type: behavior versions: Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue41555> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41555] re.sub replaces twice
S. Zhang added the comment: Thanks. But if talking about empty matches, there would be endless empty matches at the end in such cases. So in my opinion, [^\.]*$ should match txt plus the empty match because the greedy rule applies here. On Fri, Aug 14, 2020 at 10:37 PM Ma Lin wrote: > > Ma Lin added the comment: > > The re.sub() doc said: > Changed in version 3.7: Empty matches for the pattern are replaced when > adjacent to a previous non-empty match. > > IMO 3.7+ behavior is more reasonable, and it fixed a bug, see issue25054. > > -- > nosy: +malin > > ___ > Python tracker > <https://bugs.python.org/issue41555> > ___ > -- ___ Python tracker <https://bugs.python.org/issue41555> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41555] re.sub replaces twice
S. Zhang added the comment: Okay. Thanks. On Sat, Aug 15, 2020 at 9:07 AM Ma Lin wrote: > > Ma Lin added the comment: > > There can be at most one empty match at a position. IIRC, Perl's regex > engine has very similar behavior. > If don't want empty match, use + is fine. > > -- > > ___ > Python tracker > <https://bugs.python.org/issue41555> > ___ > -- ___ Python tracker <https://bugs.python.org/issue41555> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41555] re.sub replaces twice
S. Zhang added the comment: Thanks. On Mon, Aug 17, 2020 at 7:40 PM Pablo Galindo Salgado < rep...@bugs.python.org> wrote: > > Change by Pablo Galindo Salgado : > > > -- > resolution: -> not a bug > stage: -> resolved > status: open -> closed > > ___ > Python tracker > <https://bugs.python.org/issue41555> > ___ > -- ___ Python tracker <https://bugs.python.org/issue41555> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35047] Better error messages in unittest.mock
Change by Petter S : -- pull_requests: +13628 pull_request: https://github.com/python/cpython/pull/13746 ___ Python tracker <https://bugs.python.org/issue35047> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error
Change by Petter S : -- pull_requests: +13630 pull_request: https://github.com/python/cpython/pull/13748 ___ Python tracker <https://bugs.python.org/issue27682> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37594] re does not honor matching trailing multiple periods
New submission from brent s. : (Sorry for the title; not quite sure how to summarize this) SO! Have I got an interesting one for you. ISSUE: In release 3.7.3 (and possibly later), the re module, if one has a string e.g. 'a.b.', a pattern such as '\.*$' will successfully *match* any number of multiple trailing periods. HOWEVER, when attempting to substitute those with actual character(s), it chokes. See attached poc.py NOTES: - This *is a regression* from 2.6.6, 2.7.16, and 3.6.7 (other releases were not tested). This behaviour does not occur on those versions. -- components: Library (Lib) files: example.py messages: 347933 nosy: bsaner priority: normal severity: normal status: open title: re does not honor matching trailing multiple periods versions: Python 3.7 Added file: https://bugs.python.org/file48481/example.py ___ Python tracker <https://bugs.python.org/issue37594> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37594] re does not honor matching trailing multiple periods
brent s. added the comment: Sorry- by "chokes", I mean "substitutes in multiple replacements". -- ___ Python tracker <https://bugs.python.org/issue37594> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37594] re does not honor matching trailing multiple periods
brent s. added the comment: WORKAROUND: Obviously, str.rstrip('.') still works, but this is of course quite inflexible compared to a regex pattern. -- ___ Python tracker <https://bugs.python.org/issue37594> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37594] re does not honor matching trailing multiple periods
brent s. added the comment: "'\.' is an invalid escape sequence. Could you try it with a raw string?" Well, a valid regex escape, but right. Point taken. I am under the impression, however, that given the value in ptrn (in example.py) is already a string, it should be interpreted as a raw string in the re.compile(), no? Because otherwise it'd be a dickens of a time getting a regex pattern that's dynamic/programmatically assigned to a name, since there's no raw(), str.raw(), or str.encode('raw'). They both evaluate to the same, for what it's worth: >>> repr('\.+$') "'.+$'" >>> repr(r'\.+$') "'.+$'" >>> ptrn = '\.+$' >>> repr(ptrn) "'.+$'" So. "Also, it's not really clear to me what you're seeing, vs. what you expect to see. For one example that you think is incorrect, could you show what you get vs. what you expect to get? And, if that's different on different python versions, could you show what each version does?" The comment from Serhiy clarifies that this was indeed something that was changed. You can see the difference pretty easily by just calling the example.py between python2 and python3. -- "This change was intentional and documented. It fixed old bug in the Python implementation of RE and removed the discrepancy with other RE engines." Okay, so I'm not going insane. That's good. Do you have the bug ID it fixes and where it's documented? Do you know which other RE engines were doing this? Because GNU sed, for instance, does not behave like this - it behaves as the "pre-bugfix" behaviour did: $ echo 'a.b.' | sed -e 's/\.*$/./g' a.b. $ echo 'a.b...' | sed -e 's/\.*$/./g' a.b. $ echo 'a.b' | sed -e 's/\.*$/./g' a.b. "The pattern r'\.*$' matches not only a sequence of dots at the of the line, but also an empty string at the end of line. If this is not what you want, use r'\.+$'." Right; it's to guarantee there is one and only one period at the end of a line, whether there is no period, one period, or many periods in the original string (think e.g. enforcing RFC1025-compatible FQDNs, for instance). -- ___ Python tracker <https://bugs.python.org/issue37594> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue37594] re does not honor matching trailing multiple periods
brent s. added the comment: Oh for pete's sake. I wish I could edit comments. Eric- To make it clear: * VERSION: 2.7.16 (default, Mar 11 2019, 18:59:25) [GCC 8.2.1 20181127] PATTERN: \.*$ BEFORE: a.b WITHOUT: a.b DUMMY: a.bX AFTER: a.b. RSTRIP: a.b == BEFORE: a.b. WITHOUT: a.b DUMMY: a.bX AFTER: a.b. RSTRIP: a.b == BEFORE: a.b.. WITHOUT: a.b DUMMY: a.bX AFTER: a.b. RSTRIP: a.b == BEFORE: a.b... WITHOUT: a.b DUMMY: a.bX AFTER: a.b. RSTRIP: a.b == * VERSION: 3.7.3 (default, Jun 24 2019, 04:54:02) [GCC 9.1.0] PATTERN: \.*$ BEFORE: a.b WITHOUT: a.b DUMMY: a.bX AFTER: a.b. RSTRIP: a.b == BEFORE: a.b. WITHOUT: a.b DUMMY: a.bXX AFTER: a.b.. RSTRIP: a.b == BEFORE: a.b.. WITHOUT: a.b DUMMY: a.bXX AFTER: a.b.. RSTRIP: a.b == BEFORE: a.b... WITHOUT: a.b DUMMY: a.bXX AFTER: a.b.. RSTRIP: a.b == Note the differences between versions for cases a.b., a.b.., and a.b... ("BEFORE: ..." lines). Compare their "AFTER" and "DUMMY" lines between python2 and python3. Serhiy- Apologies; I meant RFC1035; I typo'd that. But as shown above, the difference is pretty distinct (and inconsistent with GNU sed behaviour). -- ___ Python tracker <https://bugs.python.org/issue37594> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error
Petter S added the comment: The following message can still appear in the log when running the Django development server: Exception happened during processing of request from ('127.0.0.1', 50713) Traceback (most recent call last): File "d:\python37\Lib\socketserver.py", line 650, in process_request_thread self.finish_request(request, client_address) File "d:\python37\Lib\socketserver.py", line 360, in finish_request self.RequestHandlerClass(request, client_address, self) File "d:\python37\Lib\socketserver.py", line 720, in __init__ self.handle() File "D:\Virtualenvs\***\lib\site-packages\django\core\servers\basehttp.py", line 171, in handle self.handle_one_request() File "D:\Virtualenvs\***\lib\site-packages\django\core\servers\basehttp.py", line 179, in handle_one_request self.raw_requestline = self.rfile.readline(65537) File "d:\python37\Lib\socket.py", line 589, in readinto return self._sock.recv_into(b) ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine This is much better than before but even this message is completely uninteresting as web browsers disconnect from servers all the time. However, this could be better to fix in Django. -- ___ Python tracker <https://bugs.python.org/issue27682> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error
Petter S added the comment: Could potentially already be fixed in Django: https://github.com/django/django/commit/7785e03ba89aafbd949191f126361fb9103cb980#diff-f6d1c75ec606389da5af6558bf57f171L51 -- ___ Python tracker <https://bugs.python.org/issue27682> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27682] wsgiref BaseHandler / SimpleHandler can raise additional errors when handling an error
Petter S added the comment: No it is not fixed in Django, but I verified that adding ConnectionAbortedError on this line https://github.com/django/django/blob/c6581a40be3bb4c1e13861f0adbb3fe01f09107f/django/core/servers/basehttp.py#L55 fixes the error. -- ___ Python tracker <https://bugs.python.org/issue27682> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28053] parameterize what serialization is used in multiprocessing
Will S added the comment: Documentation would be appreciated. I have a project that uses BaseManager, Client, and Listener to create some servers and clients. I would like to update the project to work with Python 3 and would prefer to update the clients and the servers separately (i.e. switch the client to Python 3 while the server is run with Python 2.7). However, BaseManager uses connection.Client which uses connection._ConnectionBase which uses reduction.ForkingPickler without a protocol argument. It seems the default protocol is 3 on Python 3.6 and 2 on Python 2.7 (contrary to the comment above about v2 being used). I just want to set the protocol version to 2 in Python 3.6. Can I do that with the changes added by this patch? I tried creating pickle2reducer.py like this: from multiprocessing.reduction import ForkingPickler, AbstractReducer class ForkingPickler2(ForkingPickler): def __init__(self, *args): if len(args) > 1: args[1] = 2 else: args.append(2) super().__init__(*args) @classmethod def dumps(cls, obj, protocol=2): return ForkingPickler.dumps(obj, protocol) def dump(obj, file, protocol=2): ForkingPickler2(file, protocol).dump(obj) class Pickle2Reducer(AbstractReducer): ForkingPickler = ForkingPickler2 register = ForkingPickler2.register dump = dump and then putting import pickle2reducer multiprocessing.reducer = pickle2reducer.Pickle2Reducer() at the top of my module before import multiprocessing.connection but I still see "ValueError: unsupported pickle protocol: 3" on the server when I connect with a Python 3.6 client. -- nosy: +Will S ___ Python tracker <http://bugs.python.org/issue28053> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28053] parameterize what serialization is used in multiprocessing
Will S added the comment: Just to follow up in case anyone comes across my last message later: I just had to change the last line from multiprocessing.reducer = pickle2reducer.Pickle2Reducer() to multiprocessing.context._default_context.reducer = pickle2reducer.Pickle2Reducer() -- ___ Python tracker <http://bugs.python.org/issue28053> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31555] Windows pyd slower when not loaded via load_dynamic
New submission from S Safihre: I have a Python 2.7 C-extension that was made for performance, however, I noticed something strange on Windows: When I run locally python setup.py install and it installs it the "egg" way, the performance of calling the function in the module 500x in a loop is: yEnc C New took 579 ms yEnc C New took 580 ms yEnc C New took 580 ms But when I install it as a wheel locally or via pip without a single change to the C-code, this is the result: yEnc C New took 702 ms yEnc C New took 694 ms yEnc C New took 691 ms That's a 10-15% difference. I also checked macOS and Ubuntu, here it does not seem to be the case. By investigating (https://github.com/pypa/setuptools/issues/1154) I found that the difference is only that the "egg" way the module gets loaded via imp.load_dynamic I cannot test under Python 3, since the module is (not yet) converted to Python 3-style. To reproduce run and look at the yEnc C New score between the 2 ways (on Windows only of course): git clone https://github.com/sabnzbd/sabyenc.git cd sabyenc python setup.py install python .\tests\speed_compare.py; python .\tests\speed_compare.py;python .\tests\speed_compare.py; pip uninstall sabyenc -y pip install sabyenc # Or this: # python setup.py install bdist_wheel # pip install .\dist\sabyenc-3.3.1-cp27-cp27m-win_amd64.whl python .\tests\speed_compare.py; python .\tests\speed_compare.py;python .\tests\speed_compare.py; -- components: Extension Modules, Windows messages: 302768 nosy: S Safihre, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Windows pyd slower when not loaded via load_dynamic type: performance versions: Python 2.7 ___ Python tracker <https://bugs.python.org/issue31555> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35335] msgfmt should be able to merge more than one po file
New submission from s-ball : GNU gettext msgfmt can merge several po files into one single mo file. The current version of msgfmt can only compile one po file to one mo file. After looking at the code, the enhancement should be simple to implement. Command line: if one output file is given (option -o) and several input files, then all the input files should be combined. Implementation: - main should pass all the parameters to make (*args) - make should accept one single string for compatibility or an iterable of string. In that latter case, the current processing should be repeated on all input files. I could propose a patch (but I am afraid it ends being rather large) or a pull request. As a new user here, I do not know what is the best way... -- components: Demos and Tools messages: 330575 nosy: s-ball priority: normal severity: normal status: open title: msgfmt should be able to merge more than one po file type: enhancement versions: Python 2.7, Python 3.4, Python 3.5, Python 3.6, Python 3.7, Python 3.8 ___ Python tracker <https://bugs.python.org/issue35335> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35335] msgfmt should be able to merge more than one po file
s-ball added the comment: Ok, I have created a fork, and started coding on a local branch. But it will take some time, because I assume that I am supposed to write tests for the msgfmt module... -- ___ Python tracker <https://bugs.python.org/issue35335> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35335] msgfmt should be able to merge more than one po file
s-ball added the comment: I have followed SilentGhost's advice and begun by thoroughly testing the current behaviour. I then realized that I was wrong, and that (probably by chance) msgfmt.py partially followed my requirements, but pybabel did not and GNU gettext msgfmt did not really. I wrote 2 tiny po files (joined) and played with them, meaning I tried to combine them with pybabel, msgfmt.py and GNU gettext msg. Current behaviour (Windows shell syntax): > pybabel compile -o .\file12-fr.mo -l fr -i file1-fr.po -i file2-fr.po only uses second file (file2-fr.po) > msgfmt -o file12-fr.mo --no-hash file1-fr.po file2-fr.po chokes on a repeated key on file2 (the header has "" for key...). It works fine anyway after commenting out the header in any of the files > python "path\to\Tools\i18n\msgfmt.py" -o file12py-fr.mo file1-fr.po > file2-fr.po unexpectedly produces the expected result and successfully combines both po files into one single mo file BUT: > python "path\to\Tools\i18n\msgfmt.py" file1-fr.po file2-fr.po Produces file1-fr.mo which is the compiled version of file1-fr.po and file2-fr.mo which combines both input files. Definitely not an expected result! This is caused by the problem identified in issue 9741 (https://bugs.python.org/issue9741) My initial goal was to be able to use the make function from msgfmt.py in an external script. I then realize that combining multiple po files is not a good idea because the resulting mo file can only contain one single header and the best behaviour is GNU gettext msgfmt one. I now wonder whether this issue should not be closed because the requirement is not relevant, and it would probably better to propose a fix (including tests and code improvement) for issue 9741. -- Added file: https://bugs.python.org/file47966/files.zip ___ Python tracker <https://bugs.python.org/issue35335> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35335] msgfmt should be able to merge more than one po file
s-ball added the comment: After some more thinking about it, my opinion is that the proposed path for issue 9741 does not address at all my requirements. So I will try to propose a pull request addressing both issues here. -- ___ Python tracker <https://bugs.python.org/issue35335> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com