[issue26657] Directory traversal with http.server and SimpleHTTPServer on windows

2016-03-28 Thread Philipp Hagemeister
Philipp Hagemeister added the comment: Update testcase, and call split before splitdrive -- Added file: http://bugs.python.org/file42319/fix-path-traversal-26657.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue26657] Directory traversal with http.server and SimpleHTTPServer on windows

2016-03-28 Thread Philipp Hagemeister
Philipp Hagemeister added the comment: Please find attached a patch which adds a testcase for Windows (on all platforms) as well as code to fix the problem. Since os.path.split returns everything after the final slash/backslash, it only needs to be called once. Note that the usage

Re: Download all youtube favorites with youtube-dl script

2013-09-26 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi Bill, the best way to ask for features or file bugs on youtube-dl is asking us at http://github.com/rg3/youtube-dl/issues . Luckily, I this list from time to time ;) Simply use youtube-dl --username u...@gmail.com --password secret :ytfav

Re: Issues a longer xpath expression

2013-02-22 Thread Philipp Hagemeister
Hi anonymous, your code is working perfectly right. It's just that the only time that you find anything matching //div[@class=col f-cb] is this one: div class=col f-cb div class=name s-fc3 f-fl名称/div div class=down s-fc3 f-fl视频下载/div div class=desc s-fc3 f-fl课程简介/div /div And

Re: pypi changelog api

2013-02-21 Thread Philipp Hagemeister
Hi Gregg, to get a smaller response, you can simply pass in a timestamp, like this: client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi') import time client.changelog(int(time.time() - 600)) [['vs.bootstrap.plonetheme', '1.0.1', 1361451748, 'update description, classifiers'],

Re: pypi changelog api

2013-02-21 Thread Philipp Hagemeister
:33 AM, Philipp Hagemeister phi...@phihag.dewrote: Hi Gregg, to get a smaller response, you can simply pass in a timestamp, like this: client = xmlrpclib.ServerProxy('http://pypi.python.org/pypi') import time client.changelog(int(time.time() - 600)) [['vs.bootstrap.plonetheme', '1.0.1

Re: pypi changelog api

2013-02-21 Thread Philipp Hagemeister
On 02/21/2013 02:58 PM, Michael Herman wrote: Oh - and I haven't tried this site, but you may be able to set something up on there to email when the changelog is updated. http://www.changedetection.com/ They just query the whole page - I could do that myself, easily. But the problem is that

Re: ** Please Rank These Learning Sources **

2013-02-21 Thread Philipp Hagemeister
http://learnpythonthehardway.org/book/ I have never used that myself, but I have seeen plenty of stackoverflow and student questions about it. In short, it's horrible. The book mostly consists of basic Python programs, and beginners often fail to grasp even the most basic structures

Re: any chance for contracts and invariants in Python?

2013-02-14 Thread Philipp Hagemeister
I don't know anything about the status of this PEP or why it hasn't been implemented, but here's what strikes me as obviously complex: Doesn't one need to traverse the entire class hierarchy on every function call? So if I have class A: def foo(self): return 1 class B(A): inv: True

Re: what’s the difference between socket.send() and socket.sendall() ?

2013-01-08 Thread Philipp Hagemeister
socket.socket.send is a low-level method and basically just the C/syscall method send(3) / send(2). It can send less bytes than you requested. socket.socket.sendall is a high-level Python-only method that sends the entire buffer you pass or throws an exception. It does that by calling send until

[issue16465] dict creation performance regression

2012-11-13 Thread Philipp Hagemeister
New submission from Philipp Hagemeister: On my system, {} has become significantly slower in 3.3: $ python3.2 -m timeit -n 100 '{}' 100 loops, best of 3: 0.0314 usec per loop $ python3.3 -m timeit -n 100 '{}' 100 loops, best of 3: 0.0892 usec per loop $ hg id -i ee7b713fec71

Re: Blue Screen Python

2012-10-09 Thread Philipp Hagemeister
On 10/09/2012 09:37 AM, mikcec82 wrote: In my script I open and close an html (in a FOR cycle); could be this the problem? Unless you're running your Python script as a kernel driver (and you can't do that accidentally), there is no way that your user-space program should cause a bluescreen.

Re: consistent input() for Python 2 and 3

2012-08-02 Thread Philipp Hagemeister
On 08/02/2012 11:49 AM, Ulrich Eckhardt wrote: try: # redirect input() to raw_input() like Python 3 input = raw_input except NameError: # no raw input, probably running Python 3 already pass What do you think? Any better alternatives? That's the generic

Re: Error help

2012-08-02 Thread Philipp Hagemeister
Let's go thorugh this program: On 08/02/2012 12:58 PM, danielashi...@googlemail.com wrote: import cPickle, pickle you probably want to transparently fall back to pickle if cPickle is not available. print 'WELLCOME TO THE LIBET CLOCK EXPERIMENT DATA ANALYSIST' file=raw_input('\nPLEASE ENTER

[issue15538] Avoid nonstandard s6_addr8

2012-08-02 Thread Philipp Hagemeister
New submission from Philipp Hagemeister: The s6_addr8 field of in6_addr structs is nonstandard, and therefore not supported on all platforms (android in my example). cpython's socket module should use the standard s6_addr field instead. -- components: IO hgrepos: 144 messages: 167233

[issue15538] Avoid nonstandard s6_addr8

2012-08-02 Thread Philipp Hagemeister
Changes by Philipp Hagemeister phi...@phihag.de: -- keywords: +patch Added file: http://bugs.python.org/file26664/issue15538.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15538

Re: Linux shell to python

2012-07-30 Thread Philipp Hagemeister
On 07/30/2012 09:05 AM, Vikas Kumar Choudhary wrote: `lspci | grep Q | grep $isp_str1 | grep $isp_str2 | cut -c1-7' The rough Python equivalent would be import subprocess [ l.partition(' ')[0] # or l[:7], if you want to copy it verbatim for l in

Re: Linux shell to python

2012-07-30 Thread Philipp Hagemeister
On 07/30/2012 01:31 PM, Jürgen A. Erhard wrote: On Mon, Jul 30, 2012 at 12:35:38PM +0200, Philipp Hagemeister wrote: import subprocess [ l.partition(' ')[0] # or l[:7], if you want to copy it verbatim for l in subprocess.check_output(['lspci']).splitlines() if 'Q' in l and isp_str1

Re: catch UnicodeDecodeError

2012-07-26 Thread Philipp Hagemeister
On 07/26/2012 01:15 PM, Stefan Behnel wrote: exits with a UnicodeDecodeError. ... that tells you the exact code line where the error occurred. Which property of a UnicodeDecodeError does include that information? On cPython 2.7 and 3.2, I see only start and end, both of which refer to the

Re: catch UnicodeDecodeError

2012-07-26 Thread Philipp Hagemeister
On 07/26/2012 02:24 PM, Stefan Behnel wrote: Read again: *code* line. The OP was apparently failing to see that the error did not originate in the source code lines that he had wrapped with a try-except statement but somewhere else, thus leading to the misguided impression that the exception

Re: from future import pass_function

2012-07-25 Thread Philipp Hagemeister
Unlike the print statement, pass has no overboarding complexity (like , printing tuples, etc.) - it just serves as a marker (and practicality beats purity). And you don't ever want to use pass as a value (say, for map() or the right side of an assignment). In fact, if pass were a function, users

Re: catch UnicodeDecodeError

2012-07-25 Thread Philipp Hagemeister
Hi Jaroslav, you can catch a UnicodeDecodeError just like any other exception. Can you provide a full example program that shows your problem? This works fine on my system: import sys open('tmp', 'wb').write(b'\xff\xff') try: buf = open('tmp', 'rb').read() buf.decode('utf-8') except

Re: dict: keys() and values() order guaranteed to be same?

2012-07-23 Thread Philipp Hagemeister
On 07/23/2012 01:23 PM, Henrik Faber wrote: With an arbitrary dictionaty d, are d.keys() and d.values() guaraneed to be in the same order? Yes. From the documentation[1]: If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are called with no intervening modifications to the

Re: Initial nose experience

2012-07-16 Thread Philipp Hagemeister
On 07/15/2012 08:58 PM, Roy Smith wrote: What motivated you to migrate from unittest to nose? Mostly I was just looking for a better way to run our existing tests. We've got a bunch of tests written in standard unittest, but no good way to start at the top of the tree and run them all with

unittest: Improve discoverability of discover (Was: Initial nose experience)

2012-07-16 Thread Philipp Hagemeister
On 07/16/2012 01:47 PM, Peter Otten wrote: http://docs.python.org/library/unittest#test-discovery That's precisely it. Can we improve the discoverability of the discover option, for example by making it the default action, or including a message use discover to find test files automatically if

Re: unittest: Improve discoverability of discover (Was: Initial nose experience)

2012-07-16 Thread Philipp Hagemeister
On 07/16/2012 02:37 PM, Philipp Hagemeister wrote: Can we improve the discoverability of the discover option, for example by making it the default action, or including a message use discover to find test files automatically if there are no arguments? Oops, already implemented as of Python 3.2

Re: multiprocessing: excepthook not getting called

2012-06-13 Thread Philipp Hagemeister
multiprocessing just mimicks the threading module here, see http://bugs.python.org/issue1230540 . Why do you need excepthook in the first place? You can perfectly simulate it by wrapping the root method (target in your example) in a try .. catch: import multiprocessing import sys def

Re: multiprocessing: excepthook not getting called

2012-06-13 Thread Philipp Hagemeister
On 06/13/2012 11:00 AM, Dave Cook wrote: Originally, I was trying to send formatted tracebacks back to the main process on a queue. You can still do that: import multiprocessing import sys def queueErrors(q): def decorator(func): def wrapped(*args, **kwargs): try:

Re: Any Advice Would Be Greatly Appreciated

2012-02-29 Thread Philipp Hagemeister
If you're looking for skilled developers, the best way to find them is probably to search their current work. http://careers.stackoverflow.com/ and the more experimental http://githire.com/ are two excellent developer-friendly solutions for that. - Philipp On 03/01/2012 12:08 AM, Greg Harezlak

codecs in a chroot / without fs access

2012-01-09 Thread Philipp Hagemeister
I want to forbid my application to access the filesystem. The easiest way seems to be chrooting and droping privileges. However, surprisingly, python loads the codecs from the filesystem on-demand, which makes my program crash: import os os.getuid() 0 os.chroot('/tmp')

Re: youtube-dl: way to deal with the size cap issue + new errors + issues ...

2011-11-21 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 As a general rule, feel free to contact youtube-dl developers and users at https://github.com/rg3/youtube-dl/issues/ . youtube-dl is just one application, which happens to be written in Python. l...@mail.python.org wrote: I did find my way

Re: python-based downloader (youtube-dl) missing critical feature ...

2011-11-04 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 As already said, you should file your request at https://github.com/rg3/youtube-dl/issue , not here. A few things to note: * Not all sites necessarily send the Content-Length header. * RTMP URLs would have to be treated differently * Sending a

Re: Code Review

2011-09-17 Thread Philipp Hagemeister
Instead of comments, you can often use docstrings (http://www.python.org/dev/peps/pep-0257/ ): This is hard to read due to the indentation, and cannot be accessed programmatically: #Update the GUI def update_gui(self, new_word): Instead, use this: def update_gui(self, new_word):

Re: From Python on Solaris to Python on LINUX

2011-09-15 Thread Philipp Hagemeister
What are the traps to be avoided? Assuming you're not using any OS features (scan the code for /dev and /proc), the transition from Solaris to Linux will be seamless. Your main problem will be the transition from the archaic Python 2.3 to a modern one. Luckily, all 2.x Pythons should be

Python3: hex() on arbitrary classes

2009-09-01 Thread Philipp Hagemeister
the hex string? Regards, Philipp Hagemeister signature.asc Description: OpenPGP digital signature -- http://mail.python.org/mailman/listinfo/python-list

Re: Python3: hex() on arbitrary classes

2009-09-01 Thread Philipp Hagemeister
Mark Dickinson wrote: (...) If you want to be able to interpret instances of X as integers in the various Python contexts that expect integers (e.g., hex(), but also things like list indexing), you should implement the __index__ method: Thanks. Somehow forgot this magic method and deleted it

[issue6098] xml.dom.minidom incorrectly claims DOM Level 3 conformance

2009-05-24 Thread Philipp Hagemeister
New submission from Philipp Hagemeister phi...@phihag.de: From DOM Level 3[1]: An implementation conforms to a DOM Level 3 module if it supports all the interfaces for that module and the associated semantics.. minidom supports only some Level 3 functions such as Node.renameNode

Re: identifying live hosts on a network

2009-05-20 Thread Philipp Hagemeister
We acknowledge your problems with a network script idenifying live hosts on your network. Seriously, you have to tell us a little bit more so that we can help you. How about you actually post the script, and actually post the trouble (What exactly do you expect? What exactly do you see? What

Re: issue: Permissions in odfpy

2009-05-19 Thread Philipp Hagemeister
Hi Shruti, your message is kind of hard to read. Please note the following: · Do not put useless junk(issue) in title. · Multiple exclamation marks convey a sure sign of a diseased mind, especially syntactically interesting constructions such as ??.. · You didn't purchase your keyboard in August

.pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Philipp Hagemeister
Where is the fault in my reasoning here? 1) According to http://docs.python.org/dev/install/, The most convenient way is to add a path configuration file to a directory that’s already on Python’s path, (...). 2) Path configuration files have an extension of .pth, (...) 12 = 3) A file test.pth

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Philipp Hagemeister
David Lyon wrote: (...) 12 = 3) A file test.pth with the content /example/ should result in sys.path containing /example/. No. Python, once finding the .pth will process it. Yes, but that processing will add /example/ to sys.path, right? 4) (the current directory) is the first element

Re: .pth in current directory: Why doesn't it work as the documentation says?

2009-05-18 Thread Philipp Hagemeister
David Lyon wrote: On Mon, 18 May 2009 14:34:33 +0200, Philipp Hagemeister phi...@phihag.de wrote: Yes, but that processing will add /example/ to sys.path, right? It actually works the other way around. The directories listed in sys.path are scanned for .pth files. No, they are not. That's

[issue6036] test_posixpath.py

2009-05-16 Thread Philipp Hagemeister
New submission from Philipp Hagemeister phi...@phihag.de: At line 300 (version 72674) there is the following interesting construction: if hasattr(os, symlink): if hasattr(os, symlink): (...) (...) hasattr is idempotent. Additionally, test_posixpath.py is missing

[issue6036] Clean up test_posixpath.py

2009-05-16 Thread Philipp Hagemeister
Changes by Philipp Hagemeister phi...@phihag.de: -- title: test_posixpath.py - Clean up test_posixpath.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6036

[issue6025] documentation of xml.dom.minidom.parse signature is wrong

2009-05-16 Thread Philipp Hagemeister
Philipp Hagemeister phi...@phihag.de added the comment: The patch has been applied to trunk, but not branches/py3k. Sorry for that, I should really get into the habit of providing patches for both branches. -- status: closed - open ___ Python tracker

[issue6025] documentation of xml.dom.minidom.parse signature is wrong

2009-05-14 Thread Philipp Hagemeister
New submission from Philipp Hagemeister phi...@phihag.de: In the documentation, the signature is given as parse(filename_or_file, parser), although the next paragraph reads (...) *parser*, if given, (...). The latter is correct, and there is a new bufsize parameter, too. -- assignee

[issue5379] Multicast example mcast.py is outdated and ugly

2009-05-03 Thread Philipp Hagemeister
Philipp Hagemeister phi...@phihag.de added the comment: Updated patch to use the new ipaddr module instead of the platform-specific socket.inet_pton (unavailable on some platforms, including Windows XP) Updated formatting -- Added file: http://bugs.python.org/file13851/mcast

[issue5379] Multicast example mcast.py is outdated and ugly

2009-05-03 Thread Philipp Hagemeister
Changes by Philipp Hagemeister phi...@phihag.de: Removed file: http://bugs.python.org/file13198/mcast-example.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue5379

[issue5916] Wrong function referenced in documentation of socket.inet_aton

2009-05-03 Thread Philipp Hagemeister
New submission from Philipp Hagemeister phi...@phihag.de: From the documentation of socket.inet_aton (and socket.inet_ntoa): inet_aton() does not support IPv6, and getnameinfo() should be used instead for IPv4/v6 dual stack support. socket.getnameinfo can not replace inet_aton/inet_ntoa at all

[issue5917] Reference platform-independent alternative in socket.inet_ntop documentation

2009-05-03 Thread Philipp Hagemeister
New submission from Philipp Hagemeister phi...@phihag.de: socket.inet_ntop is only available on some UNIX platforms, although for example Windows users may want to use it. The new ipaddr module provides a platform-independent conversion to the packed format on all platforms and should therefore

Re: Binary IP address representation

2009-04-22 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 Hi Dave, I've solved this now using ipaddr. ipaddr will be in the stdlib as soon as its developers realize there are actually not one, but two proposals to fix the remaining issues waiting for their input. Anyway, since ipaddr:r68, you can do the

Re: how to convert from network to host byte order

2009-03-05 Thread Philipp Hagemeister
and alignment in http://docs.python.org/library/struct.html. Regards, Philipp Hagemeister -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAkmv2JkACgkQ9eq1gvr7CFymKACghFXMZb9D6pkWZQdapvwTsKJ5 b0UAn0Uvbcguv/rdxjFKXhMQz22+Notn =ZiKx -END PGP SIGNATURE- -- http

[issue5424] Packed IPaddr conversion tests should be extended

2009-03-05 Thread Philipp Hagemeister
New submission from Philipp Hagemeister phi...@phihag.de: Currently, the testStringToIPv6 and testIPv6ToStrings tests in Lib/test/test_socket.py only check for variants 1 and 2 (but not 3) from RFC 4291 2.2. Furthermore, there are no assertions that check wrong inputs are appropriately refused

Convert IPv6 address to binary representation on 2.x/Windows

2009-03-04 Thread Philipp Hagemeister
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 socket.inet_pton which does exactly what I want is not available on 2.x on Windows. Strangely, the documentation of socket.inet_aton (IPv4 only) reads: inet_aton() does not support IPv6, and getnameinfo() should be used instead for IPv4/v6 dual

Re: Convert IPv6 address to binary representation on 2.x/Windows

2009-03-04 Thread Philipp Hagemeister
? netaddr[3] has the function I'm looking for Addr('::1').packed(), but it's way over the top for this purpose; an assembler implementation would be more readable. Kind regards, Philipp Hagemeister [1] http://bugs.python.org/issue5379 [2] http://ipaddr-py.googlecode.com [3] http://code.google.com/p

[issue5379] Multicast example mcast.py is outdated and ugly

2009-02-26 Thread Philipp Hagemeister
New submission from Philipp Hagemeister phi...@phihag.de: The multicast example Demo/sockets/mcast.py 1. mentions that multicast is only implemented on SGI (and optional on other systems). That is not the case anymore. 2. Includes completely unrelated code for broadcast transmission