Re: Decoding bytes to text strings in Python 2
In article , r...@zedat.fu- berlin.de says... > > I didn't really do a super thorough deep dive on this, > but I'm just giving the initial impression without > actually being familiar with Tkinter under Python 2, > so I might be wrong! > > The Text widget typically expects text in Tcl encoding, > which is usually UTF-8. > > This is independent of the result returned by sys.get- > defaultencoding()! > > If a UTF-8 string is inserted directly as a bytes object, > its code points will be displayed correctly by the Text > widget as long as they are in the BMP (Basic Multilingual > Plane), as you already found out yourself. Many thanks, you've helped me greatly in understanding what's happening. When I tried running my example code on a different system (Python 2.7.18 on Linux, with Tcl/Tk 8.5), I got the error: _tkinter.TclError: character U+1f40d is above the range (U+-U+) allowed by Tcl So, as your reply suggests, the problem is ultimately a limitation of Tcl/Tk itself. Perhaps I should have spent more time studying the docs for that instead of puzzling over the details of character encodings in Python! I'm not sure why it doesn't give the same error on Windows, but at least now I know where the root of the issue is. I am now much better informed about how to migrate the code I'm working on, so I am very grateful for your help. Thanks, Rayner -- https://mail.python.org/mailman/listinfo/python-list
Re: Decoding bytes to text strings in Python 2
In article , ros...@gmail.com says... > > If you switch to a Linux system, it should work correctly, and you'll > be able to migrate the rest of the way onto Python 3. Once you achieve > that, you'll be able to operate on Windows or Linux equivalently, > since Python 3 solved this problem. At least, I *think* it will; my > current system has a Python 2 installed, but doesn't have tkinter > (because I never bothered to install it), and it's no longer available > from the upstream Debian repos, so I only tested it in the console. > But the decoding certainly worked. Thank you for the idea of trying it on a Linux system. I did so, and my example code generated the error: _tkinter.TclError: character U+1f40d is above the range (U+-U+) allowed by Tcl So it looks like the problem is ultimately due to a limitation of Tcl/Tk. I'm still not sure why it doesn't give an error on Windows and instead either works (when UTF-8 encoding is specified) or converts the out-of-range characters to ones it can display (when the encoding isn't specified). But now I know what the root of the problem is, I can deal with it appropriately (and my curiosity is at least partly satisfied). This has given me a much better understanding of what I need to do in order to migrate to Python 3 and add proper support for non-ASCII characters, so I'm very grateful for your help! Thanks, Rayner -- https://mail.python.org/mailman/listinfo/python-list
Decoding bytes to text strings in Python 2
I'm curious about something I've encountered while updating a very old Tk app (originally written in Python 1, but I've ported it to Python 2 as a first step towards getting it running on modern systems). The app downloads emails from a POP server and displays them. At the moment, the code is completely unaware of character encodings (which is something I plan to fix), and I have found that I don't understand what Python is doing when no character encoding is specified. To demonstrate, I have written this short example program that displays a variety of UTF-8 characters to check whether they are decoded properly: Example Code import Tkinter as tk window = tk.Tk() mytext = """ \xc3\xa9 LATIN SMALL LETTER E WITH ACUTE \xc5\x99 LATIN SMALL LETTER R WITH CARON \xc4\xb1 LATIN SMALL LETTER DOTLESS I \xef\xac\x84 LATIN SMALL LIGATURE FFL \xe2\x84\x9a DOUBLE-STRUCK CAPITAL Q \xc2\xbd VULGAR FRACTION ONE HALF \xe2\x82\xac EURO SIGN \xc2\xa5 YEN SIGN \xd0\x96 CYRILLIC CAPITAL LETTER ZHE \xea\xb8\x80 HANGUL SYLLABLE GEUL \xe0\xa4\x93 DEVANAGARI LETTER O \xe5\xad\x97 CJK UNIFIED IDEOGRAPH-5B57 \xe2\x99\xa9 QUARTER NOTE \xf0\x9f\x90\x8d SNAKE \xf0\x9f\x92\x96 SPARKLING HEART """ mytext = mytext.decode(encoding="utf-8") greeting = tk.Label(text=mytext) greeting.pack() window.mainloop() End Example Code This works exactly as expected, with all the characters displaying correctly. However, if I comment out the line 'mytext = mytext.decode (encoding="utf-8")', the program still displays *almost* everything correctly. All of the characters appear correctly apart from the two four-byte emoji characters at the end, which instead display as four characters. For example, the "SNAKE" character actually displays as: U+00F0 LATIN SMALL LETTER ETH U+FF9F HALFWIDTH KATAKANA SEMI-VOICED SOUND MARK U+FF90 HALFWIDTH KATAKANA LETTER MI U+FF8D HALFWIDTH KATAKANA LETTER HE What's Python 2 doing here? sys.getdefaultencoding() returns 'ascii', but it's clearly not attempting to display the bytes as ASCII (or cp1252, or ISO-8859-1). How is it deciding on some sort of almost-but- not-quite UTF-8 decoding? I am using Python 2.7.18 on a Windows 10 system. If there's any other relevant information I should provide please let me know. Many thanks, Rayner -- https://mail.python.org/mailman/listinfo/python-list
[issue46101] argparse: using parents & subcommands, options can be ignored
Lucas Cimon added the comment: The GitHub PR is ready for reviewing. -- ___ Python tracker <https://bugs.python.org/issue46101> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38584] argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help
Lucas Cimon added the comment: This was resolved by https://github.com/python/cpython/pull/28050 -- message_count: 4.0 -> 5.0 pull_requests: +28366 status: open -> closed pull_request: https://github.com/python/cpython/pull/28050 ___ Python tracker <https://bugs.python.org/issue38584> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46101] argparse: using parents & subcommands, options can be ignored
Change by Lucas Cimon : -- keywords: +patch pull_requests: +28364 stage: -> patch review pull_request: https://github.com/python/cpython/pull/30146 ___ Python tracker <https://bugs.python.org/issue46101> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue46101] argparse: using parents & subcommands, options can be ignored
New submission from Lucas Cimon : Hi! Here is some minimal code reproducing the issue: import argparse common_opts_parser = argparse.ArgumentParser(add_help=False) common_opts_parser.add_argument("--endpoint", choices=("prod", "dev"), default="dev") parser = argparse.ArgumentParser(parents=[common_opts_parser]) subparsers = parser.add_subparsers(required=True) subcmd_cmd = subparsers.add_parser("subcmd", parents=[common_opts_parser]) subcmd_cmd.add_argument("--debug", action="store_true") print(parser.parse_args()) Everything works fine / as expected when specifying the common optional arg last: $ ./bug_repro.py subcmd --endpoint=dev Namespace(endpoint='dev', debug=False) However when specifying the --endpoint between the program and the subcommand, the value provided is ignored: $ ./bug_repro.py --endpoint=dev subcmd Namespace(endpoint=None, debug=False) I have a PR ready to fix that. -- components: Library (Lib) messages: 408711 nosy: Lucas Cimon priority: normal severity: normal status: open title: argparse: using parents & subcommands, options can be ignored type: behavior versions: Python 3.11 ___ Python tracker <https://bugs.python.org/issue46101> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: ast.parse, ast.dump, but with comment preservation?
Hi ! Maybe RedBaron may help you ? https://github.com/PyCQA/redbaron IIRC, it aims to conserve the exact same representation of the source code, including comments and empty lines. --lucas On 16/12/2021 04:37, samue...@gmail.com wrote: I wrote a little open-source tool to expose internal constructs in OpenAPI. Along the way, I added related functionality to: - Generate/update a function prototype to/from a class - JSON schema - Automatically add type annotations to all function arguments, class attributes, declarations, and assignments alongside a bunch of other features. All implemented using just the builtin modules (plus astor on Python < 3.9; and optionally black). Now I'm almost at the point where I can run it—without issue—against, e.g., the entire TensorFlow codebase. Unfortunately this is causing huge `diff`s because the comments aren't preserved (and there are some whitespace issues… but I should be able to resolve the latter). Is the only viable solution available to rewrite around redbaron | libcst? - I don't need to parse the comments just dump them out unedited whence they're found… Thanks for any suggestions PS: Library is https://github.com/SamuelMarks/cdd-python (might relicense with CC0… anyway too early for others to use; wait for the 0.1.0 release ;]) -- https://mail.python.org/mailman/listinfo/python-list
Re: import question
ok. all good advice. thank you for that. and with all that I've decided what to do. I'm going to close off any server-side python access so that I don't expose my server or the file system to vulnerabilities and/or wonton attacks. I am building a site for education and what I will configure is allow students to setup and save their projects on the server but only direct them to program in client-side Brython, which is a javascript translation of python for browsers, hence "Brython" or "browser python". my server will provide the javascript files for Brython and its standard libraries and any processing of the student's projects will be directly on the client-side. this way there is no access to the server or cpu or memory management problems. the server will simply server html and Brython-based text, i.e., static pages, to the client browser and the browser will process and interact with the Brython directly. overall, the server will stay secure and the students can learn python through Brython. sound, right? Lucas -- https://mail.python.org/mailman/listinfo/python-list
import question
hello one and all, are there any other ways to import a module or package other then the "import" or "from...import..." statements? i ask because i'm allowing programming on my web2py website and i don't want any accessing packages like os or sys. thank you in advance and have a great day, lucas -- https://mail.python.org/mailman/listinfo/python-list
Re: on writing a while loop for rolling two dice
def how_many_times(): x, y = 0, 1 c = 0 while x != y: c = c + 1 x, y = roll() return c, (x, y) Since I haven't seen it used in answers yet, here's another option using our new walrus operator def how_many_times(): roll_count = 1 while (rolls := roll())[0] != rolls[1]: roll_count += 1 return (roll_count, rolls) I would go even further, saying there is no need to «roll dices»: def how_many_times(): nb_times = random.choice([n for n in range(50) for _ in range(round(1*(1/6)*(5/6)**(n-1)))]) return nb_times, (random.randint(1, 6),) * 2 If i had more time on my hands, i would do something with bissect to get nb_times with more precision, as i have (mis)calculated that the probability of having nb_times = N is N = (1/6) * (5/6) ** (N-1) Something like this may work: nb_times = [random.random() < (1/6) * (5/6) ** (N-1) for N in range(1, 50)].index(True)+1 -- https://mail.python.org/mailman/listinfo/python-list
Re: argparse support of/by argparse
Mmmh, that may work just fine ! Thanks for that idea, ChrisA, i'm looking forward to implement that. Best wishes, --lucas On 12/07/2021 21:33, Chris Angelico wrote: On Tue, Jul 13, 2021 at 5:22 AM lucas wrote: Hello everyone, Let us consider this patch of code: import argparse def parse_cli() -> argparse.Namespace: parser = argparse.ArgumentParser() parser.add_argument('n', type=int) return parser.parse_args() args = parse_cli() print(args.n + ' ') # type error Running CPython on it will raise a TypeError, and running Mypy on it will indicate that no issues were found. I was wondering if there is any way for me to have mypy detecting the args.n type, based on the type keyword of the parser.add_argument function ? It appears that some type annotations were added to tierce party modules, provided by mypy itself. Is there a technical issue preventing such work to be made for argparse (or other CLI ; i didn't find anything for others either) Seems complicated, since it depends on a lot of run-time information. What if you flip the problem on its head? Instead of creating the argparser and letting that govern the types, maybe create a dataclass, and then programmatically build the parser. from dataclasses import dataclass import argparse @dataclass class Args: n: int def parse_cli() -> Args: parser = argparse.ArgumentParser() for field, typ in Args.__dataclass_fields__.items(): if hasattr(typ, "type"): typ = typ.type # Python 3.10 changed things a bit parser.add_argument(field, type=typ) return Args(**vars(parser.parse_args())) args = parse_cli() print(args.n + ' ') Only barely tested it and didn't try MyPy, but that's the basic idea. You'd have to figure out the tidiest way to define all the other attributes of your arguments (help text, etc), but ideally, all the info should be able to be coded in the dataclass. Incidentally, you could choose to make parse_cli into a classmethod of Args. Might be cleaner. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
argparse support of/by argparse
Hello everyone, Let us consider this patch of code: import argparse def parse_cli() -> argparse.Namespace: parser = argparse.ArgumentParser() parser.add_argument('n', type=int) return parser.parse_args() args = parse_cli() print(args.n + ' ') # type error Running CPython on it will raise a TypeError, and running Mypy on it will indicate that no issues were found. I was wondering if there is any way for me to have mypy detecting the args.n type, based on the type keyword of the parser.add_argument function ? It appears that some type annotations were added to tierce party modules, provided by mypy itself. Is there a technical issue preventing such work to be made for argparse (or other CLI ; i didn't find anything for others either) Thank you for reading, --lucas -- https://mail.python.org/mailman/listinfo/python-list
[issue33109] argparse: make new 'required' argument to add_subparsers default to False instead of True
Lucas Cimon added the comment: Sorry, the fix was by Mathias Ettinger: elif isinstance(argument, _SubParsersAction): return '{%s}' % ','.join(map(str, argument.choices)) I submitted a PR with this patch and a corresponding unit test: https://github.com/python/cpython/pull/26278 -- ___ Python tracker <https://bugs.python.org/issue33109> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29298] argparse fails with required subparsers, un-named dest, and empty argv
Change by Lucas Cimon : -- nosy: +Lucas Cimon nosy_count: 7.0 -> 8.0 pull_requests: +24884 pull_request: https://github.com/python/cpython/pull/26278 ___ Python tracker <https://bugs.python.org/issue29298> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33109] argparse: make new 'required' argument to add_subparsers default to False instead of True
Lucas Cimon added the comment: Reporting a duplicate / superseder with the following bug: parser = argparse.ArgumentParser() subparsers = parser.add_subparsers(required=True) subparsers.add_parser('foo') parser.parse_args() Raising: TypeError: sequence item 0: expected str instance, NoneType found It has already been reported in https://bugs.python.org/issue29298 with an interesting solution by Greg Minshall. -- nosy: +Lucas Cimon ___ Python tracker <https://bugs.python.org/issue33109> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: XML RPC changes between 3.7 and 3.9 yield 401 http error
Thank you ChrisA ! I hope it will solve it too. Do i need to do anything ? Thank you for your time and help. Best wishes, --lucas On 27/03/2021 22:49, Chris Angelico wrote: On Sun, Mar 28, 2021 at 5:00 AM lucas wrote: I finally took time (thanks to Florian R.) to get a reproducible example of my problem, as asked previously by ChrisA. Thanks! With this in hand, I can play around with it. On debian, Python 3.7, i got: 127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user=password HTTP/1.1" 404 - On Arch, python 3.9, i got: aluriak@arch❯ python3.9 p.py server 127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 - On Debian, with both versions having been built from source, the same occurs. Furthermore, Python 3.8 behaves as 3.7 does. This definitely changed in 3.9. Note that the two outputs differs in two ways: 127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user=password HTTP/1.1" 404 - 127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 - The first contains the arguments, and the second contains the path. Sounds like there is something wrong with both modules. One point of note is that the request as given actually doesn't have a slash. I think that's technically wrong, but a lot of systems will just implicitly add the slash. That, coupled with commit 9c4c45, is why you're seeing "/RPC2" in there. That distinction vanishes if you change your client thusly: url = 'http://' + URL + '/?' + urlencode({'u': USER, 'p': PASSWD}) Actually, it looks like all the changes came in with that commit. The old way used some internal functions from urllib.parse, and the new way uses the public function urllib.parse.urlparse(), and there are some subtle differences. For one thing, the old way would implicitly readd the missing slash, thus hiding the above issue; the new way leaves the path empty (thus triggering the "/RPC2" replacement). But perhaps more significantly, the old way left query parameters in the "path" portion, where the new way has a separate "query" portion that is being lost. Here's the relevant BPO: https://bugs.python.org/issue38038 It seems to have been intended as a pure refactor, so I'd call this a regression. Fortunately, it's not difficult to fix; but I'm not sure if there are any other subtle changes. The regression's already been reported so I'm adding to this issue: https://bugs.python.org/issue43433 Hopefully that solves the problem! ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: XML RPC changes between 3.7 and 3.9 yield 401 http error
And, in my outputs, a key part is missing: the received arguments as parsed by Flask: Python 3.7: REQUEST: ImmutableMultiDict([('u', 'user'), ('p', 'password')]) Python 3.9: REQUEST: ImmutableMultiDict([]) Have a good day everyone, --lucas On 27/03/2021 18:53, lucas wrote: Following our previous discussion: https://www.talkend.net/post/287193.html I finally took time (thanks to Florian R.) to get a reproducible example of my problem, as asked previously by ChrisA. The following code is implementing a webserver with Flask, and a client with the XMLRPC client: import sys from xmlrpc import server, client from urllib.parse import urlencode from flask import Flask, request PORT = 23456 USER, PASSWD = 'user', 'password' URL = '127.0.0.1:' + str(PORT) if len(sys.argv) > 1 and sys.argv[1] == 'server': app = Flask(__name__) @app.route('/', methods=['POST']) @app.route('/RPC2', methods=['POST']) def login(): print('REQUEST:', request.args) return 'ok' app.run(debug=True, host='localhost', port=PORT) else: url = 'http://' + URL + '?' + urlencode({'u': USER, 'p': PASSWD}) print(url) proxy = client.ServerProxy(url) print(proxy, dir(proxy)) print(proxy.add(2, 3)) You can run the client with `python3 p.py`, and the server with `python3 p.py server`. On debian, Python 3.7, i got: lucas@debianserver:~$ python3.7 p.py server * Serving Flask app "p" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: on * Running on http://localhost:23456/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: 249-992-288 127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user=password HTTP/1.1" 404 - On Arch, python 3.9, i got: aluriak@arch❯ python3.9 p.py server * Serving Flask app "p" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: on * Running on http://localhost:23456/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: 821-276-100 127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 - Both systems return the same output on command `pip3 freeze | grep Flask`, which is `Flask==1.1.2`. Note that the two outputs differs in two ways: 127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user=password HTTP/1.1" 404 - 127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 - The first contains the arguments, and the second contains the path. Sounds like there is something wrong with both modules. This should be a reproducible example ; plus i'm not the only one to encounter that problem: https://github.com/kynan/dokuwikixmlrpc/issues/8#issuecomment-808755244 Best regards, --lucas -- https://mail.python.org/mailman/listinfo/python-list
Re: XML RPC changes between 3.7 and 3.9 yield 401 http error
Following our previous discussion: https://www.talkend.net/post/287193.html I finally took time (thanks to Florian R.) to get a reproducible example of my problem, as asked previously by ChrisA. The following code is implementing a webserver with Flask, and a client with the XMLRPC client: import sys from xmlrpc import server, client from urllib.parse import urlencode from flask import Flask, request PORT = 23456 USER, PASSWD = 'user', 'password' URL = '127.0.0.1:' + str(PORT) if len(sys.argv) > 1 and sys.argv[1] == 'server': app = Flask(__name__) @app.route('/', methods=['POST']) @app.route('/RPC2', methods=['POST']) def login(): print('REQUEST:', request.args) return 'ok' app.run(debug=True, host='localhost', port=PORT) else: url = 'http://' + URL + '?' + urlencode({'u': USER, 'p': PASSWD}) print(url) proxy = client.ServerProxy(url) print(proxy, dir(proxy)) print(proxy.add(2, 3)) You can run the client with `python3 p.py`, and the server with `python3 p.py server`. On debian, Python 3.7, i got: lucas@debianserver:~$ python3.7 p.py server * Serving Flask app "p" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: on * Running on http://localhost:23456/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: 249-992-288 127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user=password HTTP/1.1" 404 - On Arch, python 3.9, i got: aluriak@arch❯ python3.9 p.py server * Serving Flask app "p" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: on * Running on http://localhost:23456/ (Press CTRL+C to quit) * Restarting with stat * Debugger is active! * Debugger PIN: 821-276-100 127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 - Both systems return the same output on command `pip3 freeze | grep Flask`, which is `Flask==1.1.2`. Note that the two outputs differs in two ways: 127.0.0.1 - - [27/Mar/2021 18:31:13] "POST /?u=user=password HTTP/1.1" 404 - 127.0.0.1 - - [27/Mar/2021 18:35:45] "POST /RPC2 HTTP/1.1" 200 - The first contains the arguments, and the second contains the path. Sounds like there is something wrong with both modules. This should be a reproducible example ; plus i'm not the only one to encounter that problem: https://github.com/kynan/dokuwikixmlrpc/issues/8#issuecomment-808755244 Best regards, --lucas -- https://mail.python.org/mailman/listinfo/python-list
Re: XML RPC changes between 3.7 and 3.9 yield 401 http error
On 24/02/2021 20:21, Chris Angelico wrote: On Thu, Feb 25, 2021 at 6:14 AM lucas wrote: I tested from the windows computer (Python 3.8, it appears, not 3.7 as i thought), and got the following nginx log: [LAPTOP IP] - - [24/Feb/2021:20:06:42 +0100] "POST /lib/exe/xmlrpc.php?u=[user]=[password] HTTP/1.1" 200 209 "-" "DokuWikiXMLRPC 1.0 for testing windows" That other laptop also had an ubuntu installed, with python 3.6.9, so i ran the program and got the expected output, and the following nginx log: [LAPTOP IP] - - [24/Feb/2021:20:04:04 +0100] "POST /lib/exe/xmlrpc.php?u=[user]=[password] HTTP/1.1" 200 209 "-" "DokuWikiXMLRPC 1.0 for testing ubuntu" Both accessed correctly the dokuwiki version. Unless this is a platform specific problem, it seems to narrow it to 3.9. Curious. I think, at this point, we need a repeatable test case. Wonder how hard it would be to make a single Python script that has a tiny server and a tiny client, and tries to connect them. ChrisA I will work on that tomorrow. Thanks for your guidance, i will come back with a repeatable test case. Best regards, --lucas -- https://mail.python.org/mailman/listinfo/python-list
Re: XML RPC changes between 3.7 and 3.9 yield 401 http error
On 24/02/2021 19:22, Chris Angelico wrote: On Thu, Feb 25, 2021 at 5:12 AM lucas wrote: On 24/02/2021 18:48, Chris Angelico wrote: I added socket.gethostbyname("wiki.example.net") (i removed the https:// since it, obviously now i think about it, led to a socket error) in the program, so i could verify both the URL and IP are equivalent. I got the exact same URL and IP. To be sure, i let python run the comparison instead of only relying on my eyes. >>> 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user=password' == 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user=password' True >>> 'xx.xxx.xxx.197' == 'xx.xxx.xxx.197' True Those URLs were printed out from each script, just before attempting the call? Yes. The program is that one : import socket import xmlrpc.client as xmlrpclib from xml.parsers.expat import ExpatError from urllib.parse import urlencode URL = 'https://wiki.example.net' USER_AGENT = 'DokuWikiXMLRPC 1.0 for testing' script = '/lib/exe/xmlrpc.php' url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD}) print(url) print(socket.gethostbyname('wiki.example.net')) # xmlrpclib.Transport.user_agent = USER_AGENT # xmlrpclib.SafeTransport.user_agent = USER_AGENT proxy = xmlrpclib.ServerProxy(url) v = proxy.dokuwiki.getVersion() print(v) You gave me an idea: i checked the nginx log of the server hosting the dokuwiki instance, and got something of interest : [SERVER IP] - - [24/Feb/2021:19:08:31 +0100] "POST /lib/exe/xmlrpc.php?u=[USER]=[PASSWORD] HTTP/1.1" 200 209 "-" "Python-xmlrpc/3.7" [LAPTOP IP] - - [24/Feb/2021:19:08:35 +0100] "POST /lib/exe/xmlrpc.php HTTP/1.1" 401 433 "-" "Python-xmlrpc/3.9" It seems that the laptop is not sending the arguments, despite them being fed in the python code ? Fascinating! Well, that does at least simplify things somewhat - instead of "why is this coming back 401", it's "why is this not sending credentials". Yes, we are going forward :) More data is always good. ChrisA I tested from the windows computer (Python 3.8, it appears, not 3.7 as i thought), and got the following nginx log: [LAPTOP IP] - - [24/Feb/2021:20:06:42 +0100] "POST /lib/exe/xmlrpc.php?u=[user]=[password] HTTP/1.1" 200 209 "-" "DokuWikiXMLRPC 1.0 for testing windows" That other laptop also had an ubuntu installed, with python 3.6.9, so i ran the program and got the expected output, and the following nginx log: [LAPTOP IP] - - [24/Feb/2021:20:04:04 +0100] "POST /lib/exe/xmlrpc.php?u=[user]=[password] HTTP/1.1" 200 209 "-" "DokuWikiXMLRPC 1.0 for testing ubuntu" Both accessed correctly the dokuwiki version. Unless this is a platform specific problem, it seems to narrow it to 3.9. --lucas -- https://mail.python.org/mailman/listinfo/python-list
Re: XML RPC changes between 3.7 and 3.9 yield 401 http error
On 24/02/2021 18:48, Chris Angelico wrote: On Thu, Feb 25, 2021 at 4:36 AM lucas wrote: A properly-formed URL will start with a protocol. I don't know specifically what changed, but it's looking like something started rejecting malformed URLs. Try adding "http://; or "https://; to your URL (whichever is appropriate) and see if both versions will accept it. ChrisA I did that, obtaining the following URL https://wiki.[…]/lib/exe/xmlrpc.php?u=[…]=[…] on my two currently available computer (laptop on 3.9, remote on 3.7), and the results is the same. For information, i'm uploading the same python program to my remote server (debian, 3.7), and running it with the same parameters as my laptop (manjaro, 3.9). My laptop is getting the 401, my server is getting the expected dokuwiki version. (I'm aware that you have some other actual domain, but I'll continue using "wiki.example.net" as per your original post.) Is it possible that there's some kind of server-based restriction? What happens if you call socket.gethostbyname("wiki.example.net") on both the laptop and the server - do you get back the same IP address? (Or use gethostbyname_ex, or possibly getaddrinfo if ipv6 support matters.) Also, just to make sure there's nothing stupid happening, try printing out the URL on both machines. Obviously censor the password before sharing it here, but mainly, make sure that the two are generating the exact same URL, just in case. Both are running 3.7+, so dict iteration order shouldn't be getting in your way, but I've seen crazier things before :) ChrisA Thanks for taking time to help me ! I added socket.gethostbyname("wiki.example.net") (i removed the https:// since it, obviously now i think about it, led to a socket error) in the program, so i could verify both the URL and IP are equivalent. I got the exact same URL and IP. To be sure, i let python run the comparison instead of only relying on my eyes. >>> 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user=password' == 'https://wiki.example.net/lib/exe/xmlrpc.php?u=user=password' True >>> 'xx.xxx.xxx.197' == 'xx.xxx.xxx.197' True You gave me an idea: i checked the nginx log of the server hosting the dokuwiki instance, and got something of interest : [SERVER IP] - - [24/Feb/2021:19:08:31 +0100] "POST /lib/exe/xmlrpc.php?u=[USER]=[PASSWORD] HTTP/1.1" 200 209 "-" "Python-xmlrpc/3.7" [LAPTOP IP] - - [24/Feb/2021:19:08:35 +0100] "POST /lib/exe/xmlrpc.php HTTP/1.1" 401 433 "-" "Python-xmlrpc/3.9" It seems that the laptop is not sending the arguments, despite them being fed in the python code ? Now i think about it, my remote server host both the python program into 3.7, and the dokuwiki. One may think it could be the source of the problem. To prove it's not, i will test with another laptop (the one under windows, python 3.7, which successfully accessed the wiki while i was discovering the error on my manjaro laptop) as soon as possible. --lucas -- https://mail.python.org/mailman/listinfo/python-list
Re: XML RPC changes between 3.7 and 3.9 yield 401 http error
On 24/02/2021 18:00, Chris Angelico wrote: On Thu, Feb 25, 2021 at 2:02 AM lucas wrote: Hi everyone, (Sorry for the double-send if any, i'm not sure the first send was performed, maybe because of bounce errors according to mailman.) I'm currently trying to understand an error when using the dokuwikixmlrpc python module, allowing to easily work with DokuWiki RPC interface. Another description of the problem : https://github.com/kynan/dokuwikixmlrpc/issues/8 Here is the code, tailored to work with the DokuWiki RPC interface: from urllib.parse import urlencode import xmlrpc.client as xmlrpclib URL = 'wiki.example.net' USER = 'user' PASSWD = 'password' USER_AGENT = 'DokuWikiXMLRPC 1.0 for testing' script = '/lib/exe/xmlrpc.php' url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD}) xmlrpclib.Transport.user_agent = USER_AGENT xmlrpclib.SafeTransport.user_agent = USER_AGENT proxy = xmlrpclib.ServerProxy(url) v = proxy.dokuwiki.getVersion() print(v) When ran with Python 3.7 (a personnal debian server, or a personal windows computer), i obtain the expected 'Release 2018-04-22a "Greebo"' as ouput. When ran with Python 3.9 (my personnal, manjaro machine), i obtain the following stacktrace: Traceback (most recent call last): File "/home/project/read.py", line 32, in v = proxy.dokuwiki.getVersion() File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__ return self.__send(self.__name, args) File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request response = self.__transport.request( File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in single_request raise ProtocolError( xmlrpc.client.ProtocolError: A properly-formed URL will start with a protocol. I don't know specifically what changed, but it's looking like something started rejecting malformed URLs. Try adding "http://; or "https://; to your URL (whichever is appropriate) and see if both versions will accept it. ChrisA I did that, obtaining the following URL https://wiki.[…]/lib/exe/xmlrpc.php?u=[…]=[…] on my two currently available computer (laptop on 3.9, remote on 3.7), and the results is the same. For information, i'm uploading the same python program to my remote server (debian, 3.7), and running it with the same parameters as my laptop (manjaro, 3.9). My laptop is getting the 401, my server is getting the expected dokuwiki version. --lucas -- https://mail.python.org/mailman/listinfo/python-list
Re: XML RPC changes between 3.7 and 3.9 yield 401 http error
Hi, thanks for your answer ! I updated everything, including certificates, while upgrading to python 3.9, and retried today (no new certificates to install). I am the administrator of the wiki i try to access, and didn't do black magic in the configuration.. The error really seems to came from 3.8 or 3.9, since i can still reach the wiki nominally with my (some being non-updated) machines using python 3.7. This didn't evolve since i discovered the problem few days ago. --lucas On 24/02/2021 16:20, 2qdxy4rzwzuui...@potatochowder.com wrote: On 2021-02-24 at 15:29:58 +0100, lucas wrote: I'm currently trying to understand an error when using the dokuwikixmlrpc python module, allowing to easily work with DokuWiki RPC interface. Another description of the problem : https://github.com/kynan/dokuwikixmlrpc/issues/8 Here is the code, tailored to work with the DokuWiki RPC interface: from urllib.parse import urlencode import xmlrpc.client as xmlrpclib URL = 'wiki.example.net' USER = 'user' PASSWD = 'password' USER_AGENT = 'DokuWikiXMLRPC 1.0 for testing' script = '/lib/exe/xmlrpc.php' url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD}) xmlrpclib.Transport.user_agent = USER_AGENT xmlrpclib.SafeTransport.user_agent = USER_AGENT proxy = xmlrpclib.ServerProxy(url) v = proxy.dokuwiki.getVersion() print(v) When ran with Python 3.7 (a personnal debian server, or a personal windows computer), i obtain the expected 'Release 2018-04-22a "Greebo"' as ouput. When ran with Python 3.9 (my personnal, manjaro machine), i obtain the following stacktrace: Traceback (most recent call last): File "/home/project/read.py", line 32, in v = proxy.dokuwiki.getVersion() File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__ return self.__send(self.__name, args) File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request response = self.__transport.request( File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in single_request raise ProtocolError( xmlrpc.client.ProtocolError: At the risk of stating the obvious, it might actually be an authentication problem. In addition to double checking the password: (1) make sure all of your certificates (under Arch Linux, on which Manjaro is based), that's the ca-certificates package) are up to date; and (2) check with whoever owns the wiki about any other certificates they require. After that, all I know about XML RPC is to avoid it. :-) I don't have the possibility to test this on python 3.8 specifically, but since the XML and XMLRPC modules have been updated in 3.8, and since 3.9 doesn't seems to introduce any change for them, i would expect 3.8 to introduce some change that dokuwikixmlrpc has somehow to take into consideration. Can anyone help me with that one ? I don't know anything about RPC and XML, i don't know what i need to do know to fix dokuwikixmlrpc. -- https://mail.python.org/mailman/listinfo/python-list
Re: name for a mutually inclusive relationship
Hi ! In case you didn't though about that, in argparse, MutuallyExclusiveGroup is used for the mutually exclusive logic. You may use the same nomenclature, which happens to be IMHO much clearer than the one you came up with. In GUIs, i guess that such an option would be implemented by a checkbox that, when checked, enables the widgets associated to all the mutually inclusive options. Best regards, --lucas On 24/02/2021 17:12, Ethan Furman wrote: I'm looking for a name for a group of options that, when one is specified, all of them must be specified. For contrast, - radio buttons: a group of options where only one can be specified (mutually exclusive) - check boxes: a group of options that are independent of each other (any number of them may be specified) - ???: a group of options where, if one is specified, all must be specified (mutually inclusive) So far, I have come up with: - the Three Musketeers - clique - club - best friends - tight knit - group Is there a name out there already to describe that concept? -- ~Ethan~ -- https://mail.python.org/mailman/listinfo/python-list
XML RPC changes between 3.7 and 3.9 yield 401 http error
Hi everyone, (Sorry for the double-send if any, i'm not sure the first send was performed, maybe because of bounce errors according to mailman.) I'm currently trying to understand an error when using the dokuwikixmlrpc python module, allowing to easily work with DokuWiki RPC interface. Another description of the problem : https://github.com/kynan/dokuwikixmlrpc/issues/8 Here is the code, tailored to work with the DokuWiki RPC interface: from urllib.parse import urlencode import xmlrpc.client as xmlrpclib URL = 'wiki.example.net' USER = 'user' PASSWD = 'password' USER_AGENT = 'DokuWikiXMLRPC 1.0 for testing' script = '/lib/exe/xmlrpc.php' url = URL + script + '?' + urlencode({'u': USER, 'p': PASSWD}) xmlrpclib.Transport.user_agent = USER_AGENT xmlrpclib.SafeTransport.user_agent = USER_AGENT proxy = xmlrpclib.ServerProxy(url) v = proxy.dokuwiki.getVersion() print(v) When ran with Python 3.7 (a personnal debian server, or a personal windows computer), i obtain the expected 'Release 2018-04-22a "Greebo"' as ouput. When ran with Python 3.9 (my personnal, manjaro machine), i obtain the following stacktrace: Traceback (most recent call last): File "/home/project/read.py", line 32, in v = proxy.dokuwiki.getVersion() File "/usr/lib/python3.9/xmlrpc/client.py", line 1116, in __call__ return self.__send(self.__name, args) File "/usr/lib/python3.9/xmlrpc/client.py", line 1456, in __request response = self.__transport.request( File "/usr/lib/python3.9/xmlrpc/client.py", line 1160, in request return self.single_request(host, handler, request_body, verbose) File "/usr/lib/python3.9/xmlrpc/client.py", line 1190, in single_request raise ProtocolError( xmlrpc.client.ProtocolError: wiki.example.net/lib/exe/xmlrpc.php: 401 Unauthorized> I don't have the possibility to test this on python 3.8 specifically, but since the XML and XMLRPC modules have been updated in 3.8, and since 3.9 doesn't seems to introduce any change for them, i would expect 3.8 to introduce some change that dokuwikixmlrpc has somehow to take into consideration. Can anyone help me with that one ? I don't know anything about RPC and XML, i don't know what i need to do know to fix dokuwikixmlrpc. Best regard, --lucas -- https://mail.python.org/mailman/listinfo/python-list
[issue40787] Mysql + unittest crash
Lucas added the comment: The problem was that I didn't close the 1st connection to the database and then made another request, which had to wait for the 1st to close, to be exact. -- ___ Python tracker <https://bugs.python.org/issue40787> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40787] Mysql + unittest crash
Lucas added the comment: While trying to simplify my program for you, I found that the problem was caused by a very specific interaction of one of the functions that was being tested with the restore command, which did not happen when I tried to rule this problem out in other ways. Anyways, thank you for your time. -- resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker <https://bugs.python.org/issue40787> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue40787] Mysql + unittest crash
New submission from Lucas : environment: win10 cmd, python 3.8 32-bit, mysql, unittest description: When restoring a database through mysql in a unittest function, the command prompt freezes before giving the result of the test, and I am forced to close it to quit. steps to replicate: Have mysql installed, create a database with some content, dump the latter in a file, create a unit test using python's unittest with at least two test functions, and restore the file in one of them. -- components: Library (Lib) messages: 370039 nosy: lgerosa priority: normal severity: normal status: open title: Mysql + unittest crash type: crash versions: Python 3.8 ___ Python tracker <https://bugs.python.org/issue40787> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38584] argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help
Lucas Cimon added the comment: Thanks for the feedbacks paul.j3 ! I totally agree it would be best to test all formatter classes. I modified the new test to do so. I think I should probably place this test somewhere else in test_argparse.py, but I'm having trouble figuring out where exactly... I just updated the PR and moved the new test to the TestOptionalsHelpVersionActions class. About the best fix, I think a fix to _split_lines() would be more complex. It needs to return a list, so we would make it return [''] in that case ? That would be a bit strange. What do you think ? :) -- ___ Python tracker <https://bugs.python.org/issue38584> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38586] logging: handlers names are not set when using fileConfig
Change by Lucas Cimon : -- keywords: +patch pull_requests: +16450 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16918 ___ Python tracker <https://bugs.python.org/issue38586> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38586] logging: handlers names are not set when using fileConfig
New submission from Lucas Cimon : The logging.Handler .name property is not set when the logging configuration is loaded with logging.fileConfig -- components: Library (Lib) messages: 355338 nosy: Lucas Cimon priority: normal severity: normal status: open title: logging: handlers names are not set when using fileConfig versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue38586> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38584] argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help
Change by Lucas Cimon : -- keywords: +patch pull_requests: +16448 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16917 ___ Python tracker <https://bugs.python.org/issue38584> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38584] argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help
New submission from Lucas Cimon : The test I am going to add to test_argparse.py: def test_whitespace_help(self): parser = self._get_parser() parser.add_argument( '--foo2', action='store_true', help=' ') parser.add_argument( 'bar2', type=float, help=' ') parser.format_help() # raises an IndexError -- components: Library (Lib) messages: 355336 nosy: Lucas Cimon priority: normal severity: normal status: open title: argparse: Specifying a whitespace-only help message to a positional arg triggers an IndexError when displaying --help versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue38584> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue36647] TextTestRunner doesn't honour "buffer" argument
New submission from José Luis Segura Lucas : When using "buffer = True" in a TextTestRunner, the test result behaviour doesn't change at all. This is because TextTestRunner.stream is initialised using a decorator (_WritelnDecorator). When "buffer" is passed, the TestResult base class will try to redirect the stdout and stderr to 2 different io.StringIO objects. As the TextTestRunner.stream is initialised before that "redirection", all the "self.stream.write" calls will end using the original stream (stderr by default), and resulting in not buffering at all. -- components: Tests messages: 340398 nosy: José Luis Segura Lucas priority: normal severity: normal status: open title: TextTestRunner doesn't honour "buffer" argument type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue36647> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35720] Memory leak in Modules/main.c:pymain_parse_cmdline_impl when using the CLI flag
New submission from Lucas Cimon : Hi. I think I have found a minor memory leak in Modules/main.c:pymain_parse_cmdline_impl. When the loop in the pymain_read_conf function in this same file calls pymain_init_cmdline_argv a 2nd time, the pymain->command buffer of wchar_t is overriden and the previously allocated memory is never freed. I haven't written any code test to reproduce this, but it can be tested easily with gdb: ``` gdb -- bin/python3 -c pass start b Modules/main.c:587 b pymain_clear_pymain c c ``` You'll see that PyMem_RawMalloc is called twice without pymain->command ever being freed in pymain_clear_pymain. I have a patch coming as PR on GitHub I'd be glad to have your feedback on this issue and my proposal for a fix. Regards. -- messages: 333499 nosy: Lucas Cimon priority: normal severity: normal status: open title: Memory leak in Modules/main.c:pymain_parse_cmdline_impl when using the CLI flag ___ Python tracker <https://bugs.python.org/issue35720> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34016] Bug in sort()
Lucas Sampaio added the comment: ok, I got it lista4 = input().split() print(lista4) lista4.sort() print(lista4) print(type(lista4[2])) 6 8 10['6', '8', '10'] ['10', '6', '8'] ok, I got it 2018-07-01 18:05 GMT-03:00 Tim Peters : > > Tim Peters added the comment: > > Lucas, as Mark said you're sorting _strings_ here, not sorting integers. > Please study his reply. As strings, "10" is less than "9", because "1" is > less than "9". > > >>> "10" < "9" > True > >>> 10 < 9 > False > > -- > nosy: +tim.peters > > ___ > Python tracker > <https://bugs.python.org/issue34016> > ___ > -- ___ Python tracker <https://bugs.python.org/issue34016> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34016] Bug in sort()
Lucas Sampaio added the comment: same code with another input type is list lista4 = input().split() print(lista4) lista4.sort() print(lista4) 6 8 9 ['6', '8', '9'] ['6', '8', '9'] lista4 = input().split() print(lista4) lista4.sort() print(lista4) 10 11 12 ['10', '11', '12'] ['10', '11', '12'] but if you put a 9 <https://bugs.python.org/issue34016> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34016] Bug in sort()
New submission from Lucas Sampaio : lista4 = input().split() print(lista4) lista4.sort() print(lista4) Input = 6 8 10 Output: 6 8 10 ['6', '8', '10'] ['10', '6', '8'] a bug occurs when setting the 10 -- messages: 320843 nosy: lucassdssampaio priority: normal severity: normal status: open title: Bug in sort() type: behavior versions: Python 3.6 ___ Python tracker <https://bugs.python.org/issue34016> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31952] Weird behavior on tupple item assignment
Change by Lucas Bertoldo <lvcas.berto...@gmail.com>: -- versions: +Python 2.7, Python 3.5 ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31952> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31952] Weird behavior on tupple item assignment
New submission from Lucas Bertoldo <lvcas.berto...@gmail.com>: Basically, I typed: >>> m = (list(), list()) then I got, this, as expected: >>> m[0] += [1] Traceback (most recent call last): File "<pyshell#8>", line 1, in m[0] += [1] TypeError: 'tuple' object does not support item assignment but, when I checked the variable... >>> m ([1], []) - Saying the least, one can kind of assing a value to a tuple of lists and get the expected result, but with the trackback still showing up. -- components: Interpreter Core files: python bug.png messages: 305613 nosy: Lucas Bertoldo priority: normal severity: normal status: open title: Weird behavior on tupple item assignment type: behavior versions: Python 3.6 Added file: https://bugs.python.org/file47252/python bug.png ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31952> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29430] zipfile: invalid link
New submission from Lucas Moeskops: The ZipFile documentation shows a link to the PKZip Application Node. This link, with address "https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT; goes to a "Page Not Found" document. -- messages: 286847 nosy: lucasmus priority: normal severity: normal status: open title: zipfile: invalid link versions: Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue29430> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10109] itertools.product with infinite iterator cause MemoryError.
Lucas Wiman added the comment: It is quite thrifty with memory compared to the size of the search space O(n*k) memory for a search space of size O(n**k). I think a reasonable expectation for itertools.product is that it should _eventually_ reach any element in the search space. The only way to maintain that expectation for infinite iterators would be be to use a Cantor-style zig-zag enumeration. Even for your example of searching over a single infinite iterator, you could end up exploring dates in the order (2010, 0), (2011, 0), (2012, 0), ... by switching the ordering of inputs. You'd never hit the rare date unless it happened on the first day of a year. There's no way to have special behavior _only_ for infinite iterators, since an infinite iterator is indistinguishable from a long-finite one due to the halting problem, so this would require changing the behavior for finite iterators too. While the output ordering is not explicitly documented, the current search order is probably depended on by plenty of existing programs, and has less surprise than a Cantor enumeration. So the only use case where the lazy enumeration matters is if: 1. You have one or more _very_ large iterators. 2. You _do not care_ what order they are searched in, or even if all possible tuples appear in the output. 3. Despite not caring about the output ordering, you still only want a few examples. I'm struggling to think of cases where that would come up. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10109> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14376] sys.exit documents argument as "integer" but actually requires "subtype of int"
Changes by Lucas Hoffmann <l-...@web.de>: -- nosy: +luc ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue14376> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27808] os.waitpid does not return (0, 0) when child has not exited (FreeBSD)
New submission from Casey Lucas: I'm not sure if this a Python issue or a FreeBSD issue but the return value from os.waitpid is not reliably (0,0) on FreeBSD when the WNOHANG is used and the child process has not yet exited. Python docs say that the return value will be (0,0) but this is not the case. I believe it is because the FreeBSD implementation of waitpid writes an uninitialized value to the status field when a child process is not available. See also: http://stackoverflow.com/questions/38984449/is-status-value-from-os-waitpid-unreliable-when-os-wnohang-is-used-under-freebsd Maybe this is just a documentation issue? Or does the C code in the Python library need to handle this case? -- components: FreeBSD, Library (Lib) files: waitpid_test.py messages: 273167 nosy: Casey Lucas, koobs priority: normal severity: normal status: open title: os.waitpid does not return (0,0) when child has not exited (FreeBSD) versions: Python 2.7, Python 3.4 Added file: http://bugs.python.org/file44161/waitpid_test.py ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27808> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27623] int.to_bytes() and int.from_bytes(): raise ValueError when bytes count is zero
Lucas Morales added the comment: This is actually a problem in Objects/longobject.c, in the _PyLong_AsByteArray function. It should have given an overflow error, because -1 cannot be encoded in 0 bytes. -- nosy: +lucasem ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue27623> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue10109] itertools.product with infinite iterator cause MemoryError.
Lucas Wiman added the comment: I realize this is an old (and closed!) thread, but here are a few notes from running into this issue recently, working on a search problem with infinite iterators. First, note that yegle's recursive solution is not correct, since it exhausts the iterators: >>> def product(*args): ... if len(args) == 1: ... for i in args[0]: ... yield [i] ... else: ... for i in args[0]: ... for j in product(*args[1:]): ... j.append(i) ... yield j ... >>> >>> assert len(list(itertools.product(*[iter(range(2)) for _ in range(10)]))) >>> == 2 ** 10 >>> assert len(list(product(*[iter(range(2)) for _ in range(10)]))) == 2 ** 10 Traceback (most recent call last): File "", line 1, in AssertionError This is fairly tricky to get right, and even a correct fully-lazy solution requires each iterator to eventually be fully stored in memory. For that reason, Sumudu's MemoryError is not something that can be easily escaped, though it can be delayed. For infinite iterators, the naive "lexicographic" solution to product(count(0), count(0)) would never get to 1 on the first iterator, yielding (0, 0), (0, 1), (0, 2), ... To fully explore the space, the user needs to think about how to iterate over that space, so IMO keeping infinite iterators as invalid arguments to itertools.product makes sense. -- nosy: +Lucas Wiman ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue10109> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Drag and Drop Images in Python (NEED HELP!)
Hi at all user! I used Tkinter and canvas to make a window and i added 2 transparent .png images. So when i start my programm it just shows the 2 images. I want to drag one image above the other image and than it will disappear. So I need help with drag and drop images heres my code if you want to have a look, its basically just displaying 2 images but i want to drag 1 image above the other one.. #pythonprogramm feed from tkinter import * #importing tkinter f = Tk() f.title('Give the boy his apple.') f.geometry('500x500') c = Canvas(master=f,width=500,height=500,bg='white') c.place(x=0,y=0) p = PhotoImage(file='sadsmiley.png') #sad smiley image i = c.create_image(250,320,image=p) #genaue position p2 = PhotoImage(file='food.png') #food image (should be dropped on sadsmiley) i2 = c.create_image(70,100,image=p2) f.geometry('500x500') f.mainloop() -- https://mail.python.org/mailman/listinfo/python-list
Re: Yet Another Switch-Case Syntax Proposal
On 6 April 2014 20:07, Chris Angelico rosuav-at-gmail.com |python-list@python.org| d7v3zta...@sneakemail.com wrote: Here's a simpler form of the proposal, which might cover what you need. It's basically a short-hand if/elif tree. case expression comp_op expression: suite case [comp_op] expression: suite else: suite I like this solution, but I tought about a simpler one. Basically it's my first proposal with two modifications: 1. case / elcase instead of continue, as before 2. if the case expression is a *tuple* (and not any one iterable), case suite is executed if the switched expression is an element of the tuple. If you want to match exactly a tuple, you have simply to put it into another tuple of length 1. Tricky but too much rare to care about. To recap: switch_stmt ::= switch expression case expression_list : suite (case | elcase expression_list : suite)* [else : suite] 1. if expression_list is a tuple, the case suite will be executed if the switch expression is a member of the tuple. 2. if expression_list is not a tuple, the case suite will be executed if the switch expression is equal Example: briefing_days = (Tue, Thu) normal_days = (Mon, Wed, Fri) switch day normal_days + briefing_days: go_to_work = True day_type = weekday case normal_days: lunch_time = datetime.time(12) meeting_time = datetime.time(14) elcase briefing_days: lunch_time = datetime.time(11, 30) meeting_time = datetime.time(12, 30) else: go_to_work = False day_type = festive lunch_time = None meeting_time =None Another example: switch tarot case 0: card = Fool case 1: card = Alan Moore case 2: card = High Priestess etc. -- https://mail.python.org/mailman/listinfo/python-list
Re: Yet Another Switch-Case Syntax Proposal
Thank you for reading and commenting my proposal. Here are my replies: In reply to Chris Angelico: I don't like the iterable vs non-iterable distinction. Compare: [...] case Test: # And there's your problem. Yes, I had already thought after I posted that testing against string it's a problem. But I think that the more practical and unambiguous solution is to introduce also casein as a new keyword. So if you want to test a string: switch mystring case -h: print_usage() case --version print_version() If you want to test against membership: switch mychar casein aeiou: mychar.vocal = True I prefer casein instead of case in for the same reason Python uses elif instead of else if. In reply to Ian Kelly: A more suitable place to propose this would be the python-ideas mailing list. You're right. I posted here because this list was linked by PEP 1. But now that I read more there's also python-ideas listed. Let me know if I have to continue there instead. Why just just an identifier after the switch keyword instead of an expression? Because I wronged, it can be an expression_list as well. An expression_list is one or more independent expressions separated by commas that don't create a tuple. Well, py docs state An expression list containing at least one comma yields a tuple. __contains__ is not part of the interface for iterables For what I know there's not an Iterable interface. For example List simply extends Object. I hope that an ABC Iterable class will be introduced in a future. Anyway, I think that switch x casein y should simply raise a TypeError if y doesn't implement __contains__, like x in y do. If we overload the continue keyword in this way, then a continue can't be used within the switch to control a loop that the switch is nested within. Well, this is the same problem for, say, a for loop nested inside another for loop, and you can solve it with the same methods. Instead of disabling fallthrough by default, why not disable it all together? I was tempted but there are cases in which it's useful. An example switch day casein (Monday, Thursday, Wednesday, Tuesday, Friday): gotowork = True continue casein (Monday, Thursday, Wednesday, Tuesday, Friday): daytype = ferial casein (Saturday, Sunday) daytype = festive -- https://mail.python.org/mailman/listinfo/python-list
Yet Another Switch-Case Syntax Proposal
Hi all. I would proposeto you all a switch-case syntax for Python. I already read PEP 3103 and I'm not completely satisfied by any of the proposed solutions. This is my proposal: switch_stmt ::= switch identifier case expression_list : suite (case expression_list : suite)* [else : suite] or, more simply: switch x case var1: case var2: ... case var3: ... else: ... Expression list should yield an iterable. The case suite will be executed if the variable of the identifier is a member of the iterable. For example, in a switch x statement, the code case iterable: is identical to if x in iterable: (or elif etc). So if you want to perform the same case block for more than one value, you have only to specify a tuple, a range etc. I would suggest to add an exception for non-iterable variables, so that you don't have to write case var, : but simply case var: and it will be identical to if x == var: . It's a bit tricky but the alternative is ugly. Fallthrough is disabled by default. The continue keyword cause to skip all the remaining current case suite. The next case will be checked. You can't use the continue keyword in the else clause. Some random remarks: 1. switch is on the same line of the first case. This will avoid any unpythonic syntaxes like: switch x case var1: ... or switch x: case var1: ... 2. Fallthrough is disabled by default because IMHO it's what non-programmers expect and that's what programmer usually needs more. I don't think a switch with such a syntax needs a break statement. 3. As an alternative, the continue statement could be written only at the end of a case suite; it will be less powerful and not consistent with the other compound statements, but it will improve readability. 4. I decided to not use already existing keyword like if or in, since it will be misleading and problematic for syntax highlighters. Tell me what you think about. -- https://mail.python.org/mailman/listinfo/python-list
[issue11416] netrc module does not handle multiple entries for a single host
Lucas Hoffmann added the comment: What is the status of this issue? On version 3.3 I still can not get more than one entry per host. The stopping issue #12009 seems to be closed. (Sorry, if I violate some etiquette by bumping this, just tell me.) -- nosy: +luc ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11416 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17946] base64 encoding result should be str, not bytes
New submission from Lucas Clemente Vella: As stated in RFC 3548: Base encoding of data is used in many situations to store or transfer data in environments that, perhaps for legacy reasons, are restricted to only US-ASCII [9] data. thus, I was surprised to see, when I used base64 for the first time in python 3, that the encodig result was bytes, not str. Well, if I am encoding something to base64, I am most certainly needing it as a printable ASCII string, not as an binary byte array. Thus, I suggest that the output of: base64.b64encode(data) to be, instead, the output of: base64.b64encode(data).decode('ascii') -- components: Library (Lib) messages: 188786 nosy: Lucas.Vella priority: normal severity: normal status: open title: base64 encoding result should be str, not bytes type: enhancement versions: Python 3.3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17946 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: Sorry for the little glitches you had to fix, I wonder why I didn't catch them. Anyways, thanks Petri! -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: As per Ezio's comment, changed l1 to utf-8 in the example of the doc. -- Added file: http://bugs.python.org/file28195/filetype11175.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: OK, I'll give it a try. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: Added some documentation for the patch. Let me know what you think. -- Added file: http://bugs.python.org/file28139/filetype11175.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: Is there something I can do something to move this forward? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: Alright, here's a version with more tests (unittest.mock is awesome!). I think it tests exactly what it should (and no more), i.e. that the arguments are correctly passed to `open`. -- Added file: http://bugs.python.org/file27729/filetype11175.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: Here's an attempt at implementing this (my first contribution). Some notes: - I tried to keep `__repr__()` backwards compatible. It would have been easier to inherit from `_AttributeHolder`, but maybe this might break some things... - I added some test cases for `__repr__()`, but that's it. I don't think there's any other sensible test to do, as we're really just passing stuff to `open()` - not sure about the style, especially line breaks... -- keywords: +patch nosy: +lum Added file: http://bugs.python.org/file27674/filetype11175.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11175] allow argparse FileType to accept encoding and errors arguments
Lucas Maystre added the comment: OK, as discussed offline with Petri I'll put some tests to ensure that open() is called the right way (using unittest.mock.patch). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11175 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13241] llvm-gcc-4.2 miscompiles Python (XCode 4.1 on Mac OS 10.7)
Lucas Sinclair added the comment: I agree to close the issue. I tried following the steps proposed here: http://docs.python.org/devguide/ And typed these two commands on a OS X 10.8.1 with XCode and command line tools installed. $ hg clone http://hg.python.org/cpython. $ run ./configure --with-pydebug make -j2 Python built perfectly. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13241 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
get return or locals from exec str in environment
ok, i am stuck. i tried some test code attempts and i am stuck. so here is some sample code: xx2 = def lucas53(): harry = (4+16)/2 rtn = dict(harry=harry) return rtn and then i run: env = {} exec xx2 in env lst = env and lst returns a huge dictionary of many types, some excerpts are: {... ...'globals': built-in function globals, ... ...'vars': built-in function vars, ... ...'locals': built-in function locals, ... ...'lucas53': function lucas53 at 0x214348c} and i can see my executed function in there as a type function, and local and global vars, but i can not access or find harry or rtn the variables within the function lucas53. i do not know how to access the local variables within lucas53 or the locals to find harry or rtn. i really just want the return dictionary. make sense? anyway, python impresses me with its graceful and concise code, but i really have not found the solution to this mess. please advise and thank you in advance. lucas -- http://mail.python.org/mailman/listinfo/python-list
Re: get return or locals from exec str in environment
Far as I can see, you never actually called that function anywhere. ChrisA doesn't the exec command call the function? -- http://mail.python.org/mailman/listinfo/python-list
Re: get return or locals from exec str in environment
oh, yeah that was perfect. got it working and it is graceful too. sorry about the double post, i thought i was only posting to this one. one final concern, if this code is running under a function in a multi-threaded, multi-session kind of environment, does exec cross threads or sessions? like, i am afraid that i will get cross-over or bleeding into other threads or sessions. does exec do that kind of common memory space wherein i have to be very very careful about executing such code and my daemon crashing or security holes and the like. lucas -- http://mail.python.org/mailman/listinfo/python-list
Re: get return or locals from exec str in environment
also, does that environment space, what i am assigning as env, have any such common memory space or cross thread problem with simultaneous threads or sessions? -- http://mail.python.org/mailman/listinfo/python-list
Make never ends when compiling from source
I'm trying to install Python 2.7 from source on Centos 6.0. When running make after first running ./configure successfully on the source directory, it performs the checks done by the configure step again in a loop, i.e: the checks are done infinitely many times, so the compiling process never starts. Does anyone know the cause of this behaviour and how to solve it? - Lucas -- http://mail.python.org/mailman/listinfo/python-list
Re: Make never ends when compiling from source
Just found that the issue was that the clock was not set properly on the server. 2012/1/19 Lucas Moauro lage...@gmail.com I'm trying to install Python 2.7 from source on Centos 6.0. When running make after first running ./configure successfully on the source directory, it performs the checks done by the configure step again in a loop, i.e: the checks are done infinitely many times, so the compiling process never starts. Does anyone know the cause of this behaviour and how to solve it? - Lucas -- http://mail.python.org/mailman/listinfo/python-list
Typed python comparison / code analysis questions
Hello, I'm relatively new to Python. I come from C/C++ so I love the flexibility but I am slightly irked by the lack of compilation time checking. I've got two questions 1) Are there any tools that do an analysis of code and attempt to catch potential issues such as undefined variables, etc? I use xdebug in php for this purpose and it's a life saver. Currently for Python I use module test cases and simulate situations but this doesn't catch everything and on a larger scale of development becomes difficult. 2) Is there a way to error when comparing variables of different types? I was up late last night coding and caused a few bugs with the below code, which turns out to compare a typestr to a typeint. I know good programming I should know what my variable types are, but it would be even better if I could always abide by a rule of using _ (or something) which would spit an exception when comparing non-equal types/instances. rows = pamss.conn.fetchRows(results) count = rows[0]['cases']// should be int(rows[0]['cases']) return count MAX_CONCURRENT_IVR thanks! Lucas -- http://mail.python.org/mailman/listinfo/python-list
Re: Typed python comparison / code analysis questions
Thank you! At the moment python3 isn't an option. There's a variety of dependencies I'm working around. Is there any type of 2.x add-on? either way thanks for the info L On Wed, Jan 4, 2012 at 3:34 PM, Ian Kelly ian.g.ke...@gmail.com wrote: On Wed, Jan 4, 2012 at 1:09 PM, Lucas Vickers lucasvick...@gmail.com wrote: Hello, I'm relatively new to Python. I come from C/C++ so I love the flexibility but I am slightly irked by the lack of compilation time checking. I've got two questions 1) Are there any tools that do an analysis of code and attempt to catch potential issues such as undefined variables, etc? I use xdebug in php for this purpose and it's a life saver. Currently for Python I use module test cases and simulate situations but this doesn't catch everything and on a larger scale of development becomes difficult. Yes, try pylint, pychecker, or pyflakes. 2) Is there a way to error when comparing variables of different types? I was up late last night coding and caused a few bugs with the below code, which turns out to compare a typestr to a typeint. I know good programming I should know what my variable types are, but it would be even better if I could always abide by a rule of using _ (or something) which would spit an exception when comparing non-equal types/instances. This is a well-known wart in Python 2. The recommended solution would be to upgrade to Python 3, which no longer allows ordered comparisons between unrelated built-in types. Cheers, Ian -- http://mail.python.org/mailman/listinfo/python-list
[issue13583] sqlite3.Row doesn't support slice indexes
New submission from Lucas Sinclair blastoc...@mac.com: When using the sqlite3.Row object as a row factory, one can access the resulting rows by index (such as row[1]) or by name (such as row['b']). However, the slice functionality is lost, as doing row[0:2] raises the error: slices not implemented, yet Here is a patch that fixes this, I implemented it and I added the corresponding unit test. -- files: sqlrowslice.patch keywords: patch messages: 149251 nosy: xapple priority: normal severity: normal status: open title: sqlite3.Row doesn't support slice indexes type: feature request versions: Python 2.6, Python 2.7, Python 3.2, Python 3.3 Added file: http://bugs.python.org/file23919/sqlrowslice.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13583 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9750] sqlite3 iterdump fails on column with reserved name
Lucas Sinclair blastoc...@mac.com added the comment: My patch contains two new dump tests which originally fail, and the fixes to the code that makes them pass. -- Added file: http://bugs.python.org/file23629/issue9750.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9750 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13241] llvm-gcc-4.2 miscompiles Python (XCode 4.1 on Mac OS 10.7)
Lucas Sinclair blastoc...@mac.com added the comment: Well the configure parameters suggested by Michael Foord worked. I was able to build cpython on a mac. But I could not have guessed how to make it work. Shouldn't these instructions be added here http://docs.python.org/devguide/ ? Shouldn't the latest version of OS X be included in the list of *nix systems that cpython is checked to build on ? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13241 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13241] llvm-gcc-4.2 miscompiles Python (XCode 4.1 on Mac OS 10.7)
Lucas Sinclair blastoc...@mac.com added the comment: I'm on 10.7.2, with XCode is 4.2 and the problem is still present. The command ggc -v produces the following output: gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00) The command ./configure --with-pydebug make -j2 fails with the following output: Assertion failed: (compact-utf8_length == 0), function _PyUnicode_CheckConsistency, file Objects/unicodeobject.c, line 381. make: *** [sysconfig] Abort trap: 6 The only solution seems to be to install macports and use it to get a more recent gcc like Oleg Plakhotnyuk suggested. -- nosy: +xapple ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13241 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13241] llvm-gcc-4.2 miscompiles Python (XCode 4.1 on Mac OS 10.7)
Lucas Sinclair blastoc...@mac.com added the comment: I just cloned cpython today. The output of hg summary is: parent: 73351:2bec7c452b39 tip Fix C89 incompatibility. branch: default commit: (clean) update: (current) -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue13241 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9750] sqlite3 iterdump fails on column with reserved name
Lucas Sinclair blastoc...@mac.com added the comment: Sure, I can have a try at it and address the issues you pointed out. The URL to the guidelines you provided gives a 404. In what form exactly would you like the patch to be ? I wouldn't mind either adding to the test suite, but I'm not sure how to do that. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9750 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9750] sqlite3 iterdump fails on column with reserved name
Lucas Sinclair blastoc...@mac.com added the comment: I just encountered this issue today. So, it's been several months, will the patch be merged into the master branch ? Or will this never be fixed ? -- nosy: +xapple ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9750 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9634] Add timeout parameter to Queue.join()
New submission from Kelly Lucas kdlu...@gmail.com: I've seen quite a few people requesting to add a timeout value to the Queue.join() method, as it seems like a nice feature to have when waiting for queue's to finish. Please add a feature so that Queue.join() will issue a self.all_tasks_done.release() when the timeout value is reached. -- components: Library (Lib) messages: 114257 nosy: kdlucas priority: normal severity: normal status: open title: Add timeout parameter to Queue.join() versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9634 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9634] Add timeout parameter to Queue.join()
Changes by Kelly Lucas kdlu...@gmail.com: -- versions: +Python 3.1 -Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9634 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9634] Add timeout parameter to Queue.join()
Kelly Lucas kdlu...@gmail.com added the comment: Here are a few that I saw: http://stackoverflow.com/questions/1564501/add-timeout-argument-to-pythons-queue-join http://www.eggheadcafe.com/software/aspnet/36145181/max-time-threads.aspx http://efreedom.com/Question/1-1564501/Add-timeout-argument-to-python-s-Queue-join -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9634 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue9634] Add timeout parameter to Queue.join()
Kelly Lucas kdlu...@gmail.com added the comment: This is easy enough to implement by subclassing the Queue class and overriding join(), so it's not a big deal. Just seems like it would be a nice thing to have. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9634 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Python source checkout problem
I am trying to check-out the python source using subversion. The documentation says that svn co http://svn.python.org/projects/python/trunk; should do the trick. When I do this I get the following response: svn: REPORT of '/projects/!svn/vcc/default': 200 OK (http:// svn.python.org) There is now a hidden .svn folder in my directory, but I can't find any source anywhere, all subdirectories are empty. When I try to update via svn update I get the following response. svn: Server sent unexpected return value (307 Proxy Redirect) in response to OPTIONS request for 'http://svn.python.org/projects/python/ trunk' Any ideas what I am doing wrong? Thanks, Andrew -- http://mail.python.org/mailman/listinfo/python-list
For...in statement and generators
Is there a way to send() information back to a generator while using the for...in statement? Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
Re: File Handling Problem
On Fri, Sep 4, 2009 at 9:50 AM, joy99 subhakolkata1...@gmail.com wrote: Dear Group, I have a file. The file has multiple lines. I want to get the line number of any one of the strings. Once I get that I like to increment the line number and see the string of the immediate next line or any following line as output. The problem as I see is nicely handled in list, You could just grab each line and associate that line's content with its line numbers, like this: f = open(my_file.txt, r) line2pos = {} for line_num, line in enumerate(f.readlines()): if line not in line2pos: line2pos[line] = [] line2pos[line].append(line_num) (...) This approach would be nice when you don't know which string to look for beforehand. In the case you already know it, there's no need for keeping the line2pos variable, the right approach should be to iterate through the lines of the file and, when you see the string you need, just display the next line and exit: def lookNextLineAfterString(s) f = open(my_file.txt, r) found = False while True: line = f.readline() if line == '': break line = line[:-1] #stripping the newline if line == s: found = True break if found == True: nextString = f.readline() if nextString == '': print String found but there's no next string else: print Next string is , nextString[:-1] else: print String not found -- http://mail.python.org/mailman/listinfo/python-list
Generators through the C API
Hello, I'm a total noob about the C API. Is there any way to create a generator function using the C API? I couldn't find anything like the 'yield' keyword in it. Thanks in advance. -- http://mail.python.org/mailman/listinfo/python-list
[issue6567] Make inf be almost equal to inf
Lucas Prado Melo lucaspradom...@gmail.com added the comment: I would like to ask as a feature request that inf be almost equal to inf. I wrote a program with a timeline class that had a method to tell the time of the last event registered into it such that some events would be positioned at the infinite when they wouldn't occur. I did generic tests that would receive any output from this method and compare to the expected result through unittest.TestCase.assertAlmostEqual(). Notice, though, that I couldn't just pick assertEqual() to do this job because the time of the last event would be defined through a series of calculations. Despite that, I believe that everything which is equal to anything else would definitely be almost equal too. Thus, it would be nice to check for equality before checking for almost-equality to define whether two objects are almost equal. -- status: closed - open title: Isn't inf almost equal to inf? - Make inf be almost equal to inf type: behavior - feature request ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6567 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6567] Isn't inf almost equal to inf?
New submission from Lucas Prado Melo lucaspradom...@gmail.com: When we use TestCase.assertAlmostEqual to compare two float('inf') objects, the result is that float('inf') is not almost equal to float('inf'). I believe this is a bug. I tested against r74195 of Python 3.2 and against Python 2.6.2. -- messages: 90902 nosy: lucaspmelo severity: normal status: open title: Isn't inf almost equal to inf? versions: Python 2.6 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6567 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6567] Isn't inf almost equal to inf?
Changes by Lucas Prado Melo lucaspradom...@gmail.com: -- versions: +Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6567 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6567] Isn't inf almost equal to inf?
Changes by Lucas Prado Melo lucaspradom...@gmail.com: -- components: +Tests ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6567 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6567] Isn't inf almost equal to inf?
Changes by Lucas Prado Melo lucaspradom...@gmail.com: -- type: - behavior ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6567 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
List insertion cost
Hello, I would like to know how much it costs to insert an element into a list using this operation: a[2:2] = [ 1 ] i. e, what is the complexity of the operation above (given that len(a) = n)? Thanks. -- http://mail.python.org/mailman/listinfo/python-list
Re: List insertion cost
Robert Kern wrote: O(n). Python lists are contiguous arrays in memory, and everything after the insertion point needs to be moved. Raymond Hettinger has a good talk about the implementation of Python lists and other container objects. http://www.youtube.com/watch?v=hYUsssClE94 http://www.pycon.it/static/stuff/slides/core-python-containers-under-hood.ppt Thanks. :) -- http://mail.python.org/mailman/listinfo/python-list
Balanced binary tree implementation
Hello, I would like to use a balanced binary tree implementation (preferably within some API). Any hints about where I could find it? I am looking for something that implements insertion, deletion, search and a special search that returns the lesser element bigger than a given key [1]. A nice possibility would be an extensible API that allows me to inherit its classes and to add operations myself. Thanks in advance. [1] Ex: 1 2 3 4 5 6 are elements of the bbt. If I use this operation given 4 as the parameter, the value returned would be 5. -- http://mail.python.org/mailman/listinfo/python-list
[issue6467] raw_input() doesn't work as expected when it gets multiple ^D
New submission from Lucas Prado Melo lucaspradom...@gmail.com: -- $ cat raw_input_test.py s = '' try: while True: c = raw_input() print c s += c except EOFError: pass $ python raw_input_test.py test^D^Dtes ^D $ python --version Python 2.7a0 $ bash --version GNU bash, version 3.2.48(1)-release (i486-pc-linux-gnu) Copyright (C) 2007 Free Software Foundation, Inc. -- Surprisingly, though: -- $ python raw_input_test.py output test^D^D^D $ cat output test -- ^D = Press Ctrl+D I am using Ubuntu 9.04 (Jaunty Jackalope). -- components: IO messages: 90443 nosy: lucaspmelo severity: normal status: open title: raw_input() doesn't work as expected when it gets multiple ^D versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6467 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue5870] subprocess.DEVNULL
Lucas Prado Melo lucaspradom...@gmail.com added the comment: -1 on this one. It is not a portable decision (only *nix OSes do have /dev/null). Also, why would we want it as a default constant? The subprocess module would need to open /dev/null every time. Despite that, I can't see how would someone use the redirection of errors to /dev/null through a python script and, at the same time, make it seem not a bad practice at all. -- nosy: +lucaspmelo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5870 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6447] PATCH: typo (English) in subprocess module
New submission from Lucas Prado Melo lucaspradom...@gmail.com: I am pretty sure this patch is alright. -- nosy: +lucaspmelo ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6447 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Remoting over SSH
Hussein B wrote: Hey, I want to perform commands on a remote server over SSH. What do I need? Thanks. Hi, If you want to use the SSH2 protocol into a python code, you should take a look at this module: paramiko [1]. [1] http://www.lag.net/paramiko/ Regards, Lucas. -- http://mail.python.org/mailman/listinfo/python-list
windows command-line
Hi, I'd like to run a simple windows command-line program from within my python script and agt all the returt it generates. Is this possible? How can I do it? Thank you! Veja quais são os assuntos do momento no Yahoo! +Buscados http://br.maisbuscados.yahoo.com-- http://mail.python.org/mailman/listinfo/python-list
[issue5230] pydoc reports misleading failure if target module raises an ImportError
Lucas Prado Melo lukepada...@gmail.com added the comment: I think this patch is ok. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5230 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6064] Add daemon argument to threading.Thread constructor
Lucas Prado Melo lukepada...@gmail.com added the comment: +1 to the py3k diff. :) Hey, I think this daemon property should be set as a keyword argument of the Thread constructor. -- nosy: +conf ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6064 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com