[issue46174] Feature Request for Python Interfaces
New submission from Or : Most object oriented languages provide interfaces as part of the core language, this helps bring better design principles to a team's workflows. Today Python provides the ABC module for abstract base classes and the Protocol class from typing module as something that might resemble an interface. Creating abstract classes to simulate interface behavior is pretty tedious and the Protocol class is not supported by IDEs for type hints, completions, bug findings, etc. I think the Python community would really benefit if we have an interface keyword built into the core language and enforced by the interpreter, similar to how it's implemented in Java and C#. -- messages: 409149 nosy: Orie priority: normal severity: normal status: open title: Feature Request for Python Interfaces type: enhancement versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue46174> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12480] urllib2 doesn't use proxy (fieddler2), configed the proxy with ProxyHandler
New submission from Or : I have fieddler2 listening on 0.0.0.0:. this code is suppose to use the proxy on my localhost. try: data = '' proxy = urllib2.ProxyHandler({'http': '127.0.0.1:'}) //also tried {'http': 'http://127.0.0.1:/'} opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) req = urllib2.Request('http://www.google.com') response = urllib2.urlopen(req) the_page = response.read() print the_page except Exception, detail: print "Err ", detail I have fieddler2 listening on 0.0.0.0:. try: proxy = urllib2.ProxyHandler({'http': '127.0.0.1:'}) //also tried {'http': 'http://127.0.0.1:/'} opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) req = urllib2.Request('http://www.google.com') response = urllib2.urlopen(req) the_page = response.read() print the_page except Exception, detail: print "Err ", detail I don't see the GET or any request to google in fieddler (but I can see other requests) is there a way to debug it? is seems like python bypasses fieddler or ignores the proxy. the code is working, but it's not using the proxy to fetch google, it bypasses the proxy. I also configured win7 to work with fieddler - C:\Windows\system32>netsh winhttp set proxy 127.0.0.1: Current WinHTTP proxy settings: Proxy Server(s) : 127.0.0.1: Bypass List : (none) In order to check if the code is using the porxy I've changed fieddler to require proxy authentication and I had to use a user\pass on my browser when browsing, run the python code again and it worked, so it defiantly doesn't use the proxy. -- components: Extension Modules, Library (Lib), Windows messages: 139688 nosy: Or.Wilder priority: normal severity: normal status: open title: urllib2 doesn't use proxy (fieddler2), configed the proxy with ProxyHandler versions: Python 2.7 ___ Python tracker <http://bugs.python.org/issue12480> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue12480] urllib2 doesn't use proxy (fieddler2), configed the proxy with ProxyHandler
Or added the comment: I have fieddler2 listening on 0.0.0.0:. this code is suppose to use the proxy on my localhost. try: proxy = urllib2.ProxyHandler({'http': '127.0.0.1:'}) //also tried {'http': 'http://127.0.0.1:/'} opener = urllib2.build_opener(proxy) urllib2.install_opener(opener) req = urllib2.Request('http://www.google.com') response = urllib2.urlopen(req) the_page = response.read() print the_page except Exception, detail: print "Err ", detail I don't see the GET or any request to google in fieddler (but I can see other requests) is there a way to debug it? is seems like python bypasses fieddler or ignores the proxy. the code is working, but it's not using the proxy to fetch google, it bypasses the proxy. I also configured win7 to work with fieddler - C:\Windows\system32>netsh winhttp set proxy 127.0.0.1: Current WinHTTP proxy settings: Proxy Server(s) : 127.0.0.1: Bypass List : (none) In order to check if the code is using the porxy I've changed fieddler to require proxy authentication and I had to use a user\pass on my browser when browsing, run the python code again and it worked, so it defiantly doesn't use the proxy. -- ___ Python tracker <http://bugs.python.org/issue12480> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35464] json.dumps very unclear exception
New submission from Or : when dumping a value coming from numpy.random.choice([True,False]) the exception raised is very unclear. json.dumps(result) File "/usr/local/Cellar/python@2/2.7.15/Frameworks/Python.framework/Versions/2.7/lib/python2.7/json/encoder.py", line 184, in default raise TypeError(repr(o) + " is not JSON serializable") which prints "True is not JSON serializable" - but it should actually print " is not JSON serializable". -- components: Library (Lib) messages: 331632 nosy: orshemy priority: normal severity: normal status: open title: json.dumps very unclear exception type: behavior versions: Python 2.7 ___ Python tracker <https://bugs.python.org/issue35464> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40316] Add zero function to time, datetime, which acts as the use case of replace to limit resolution
New submission from Or Toledano : I propose the zero(time_unit) function, which replaces all time units with greater equal resolution than time_unit by 0. E.g. >>> datetime.datetime(2020, 4, 18, 12, 27, 30, 500).zero("second") datetime.datetime(2020, 4, 18, 12, 27) I purpose it for the datetime, time classes. I also added unit tests for the function in those classes. GitHub PR: -- components: Library (Lib) messages: 366696 nosy: Or Toledano, belopolsky, lemburg, p-ganssle priority: normal severity: normal status: open title: Add zero function to time, datetime, which acts as the use case of replace to limit resolution type: enhancement versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue40316> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40316] Add zero function to time, datetime, which acts as the use case of replace to limit resolution
Change by Or Toledano : -- keywords: +patch pull_requests: +18918 stage: -> patch review pull_request: https://github.com/python/cpython/pull/19580 ___ Python tracker <https://bugs.python.org/issue40316> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40316] Add zero function to time, datetime, which acts as the use case of replace to limit resolution
Or Toledano added the comment: https://github.com/python/cpython/pull/19580 -- ___ Python tracker <https://bugs.python.org/issue40316> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40316] Add zero function to time, datetime, which acts as the use case of replace to limit resolution
Or Toledano added the comment: The use-case for this method is to "limit" the resolution of a time object. I encountered the need for it when I needed to reduce the resolution of some timestamps, to compare them with timestamps of lesser resolution. I found the following SOF post: https://stackoverflow.com/questions/13838394/can-i-easily-get-datetime-with-less-resolution-in-python which made me think that a zero function can be nice for that use case of datetime.replace -- ___ Python tracker <https://bugs.python.org/issue40316> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41588] Potential Memory leak with concurrent.futures.ThreadPoolExecutor's map
New submission from Or Yahalom : I've been debugging a high memory consumption in one of my scripts and traced it back to the `concurrent.futures.ThreadPoolExecutor`. When further investigating and playing around, I found out that when using `concurrent.futures.ThreadPoolExecutor` with the map function, and passing a dictionary to the map's function as an argument, the memory used by the pool won't be freed and as a result the total memory consumption will continue to rise. (Seems like it also happens when passing a list and maybe even other types). Here is an example of a code to recreate this issue: ``` #!/usr/bin/env python3 import os import time import psutil import random import concurrent.futures from memory_profiler import profile as mem_profile p = psutil.Process(os.getpid()) def do_magic(values): return None @mem_profile def foo(): a = {i: chr(i) for i in range(1024)} with concurrent.futures.ThreadPoolExecutor(max_workers=10) as pool: proccessed_data = pool.map(do_magic, a) def fooer(): while True: foo() time.sleep(1) fooer() ``` -- components: Extension Modules messages: 375647 nosy: or12 priority: normal severity: normal status: open title: Potential Memory leak with concurrent.futures.ThreadPoolExecutor's map type: resource usage versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue41588> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6135] subprocess seems to use local 8-bit encoding and gives no choice
Changes by Shahar Or : -- nosy: +DawnLight ___ Python tracker <http://bugs.python.org/issue6135> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1759845] subprocess.call fails with unicode strings in command line
Changes by Shahar Or : -- nosy: +DawnLight ___ Python tracker <http://bugs.python.org/issue1759845> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1759845] subprocess.call fails with unicode strings in command line
Changes by Shahar Or : -- nosy: -DawnLight ___ Python tracker <http://bugs.python.org/issue1759845> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com