[ python-Bugs-1180997 ] lax error-checking in new-in-2.4 marshal stuff
Bugs item #1180997, was opened at 2005-04-11 20:53 Message generated for change (Comment added) made by mwh You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1180997&group_id=5470 Category: Python Interpreter Core Group: Python 2.4 Status: Open Resolution: None Priority: 7 Submitted By: Michael Hudson (mwh) Assigned to: Martin v. Löwis (loewis) Summary: lax error-checking in new-in-2.4 marshal stuff Initial Comment: I realise one of the points of the TYPE_STRINGREF and so on stuff was efficiency, but: >>> marshal.loads('R') # TYPE_STRINGREF == 'R' Segmentation fault -- >Comment By: Michael Hudson (mwh) Date: 2005-04-13 11:05 Message: Logged In: YES user_id=6656 While I have your attention: >>> marshal.loads("", 1) Segmentation fault This is the guilty line: if (!PyArg_ParseTuple(args, "s#|i:loads", &s, &n)) there's no pointer corresponding to the optional integer argument. I'd just fix this, but I have too many local changes to make it easy :( -- Comment By: Martin v. Löwis (loewis) Date: 2005-04-11 22:25 Message: Logged In: YES user_id=21627 I agree, and will try to work on a patch before 2.4.2. -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1180997&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Feature Requests-1182143 ] making builtin exceptions more informative
Feature Requests item #1182143, was opened at 2005-04-13 11:02 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1182143&group_id=5470 Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Submitted By: Sebastien de Menten (sdementen) Assigned to: Nobody/Anonymous (nobody) Summary: making builtin exceptions more informative Initial Comment: Using builtin exception information is tricky as it consists of: a) the type of exception (easily accessible) b) the args attribute = a 1 element tuple with a string 1st example: try: print foo except NameError, e: print e.args symbol = e.args[0][17:-16] print symbols ==> ("NameError: name 'foo' is not defined", ) foo It would be nicer to have: e.args = ("NameError: name 'foo' is not defined", "foo") The first element being the current string for backward compatibilty. = 2nd example: try: (4).foo except NameError, e: print e.args ==> ("'int' object has no attribute 'foo'",) It would be nicer to have: e.args = ("'int' object has no attribute 'foo'", 4, "foo") Again, the first element being the current string for backward compatibilty. = Moreover, in the documentation about Exception, I read """Warning: Messages to exceptions are not part of the Python API. Their contents may change from one version of Python to the next without warning and should not be relied on by code which will run under multiple versions of the interpreter. """ So even args could not be relied upon ! But it also means that there is no need to be backward compatible (I am playing devil's advocate, backward compatibility is important !) Seb ps: There may be problems (that I am not aware) with a) an exception keeping references to other objects b) C API that can throw only exceptions with strings c) a specific advantage of having strings only in builtin exceptions -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=355470&aid=1182143&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1180267 ] expanding platform module and making it work as it should
Bugs item #1180267, was opened at 2005-04-10 19:44 Message generated for change (Comment added) made by nkour You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1180267&group_id=5470 Category: Python Library Group: None Status: Open Resolution: None Priority: 5 Submitted By: Nikos Kouremenos (nkour) Assigned to: Nobody/Anonymous (nobody) Summary: expanding platform module and making it work as it should Initial Comment: platform.release() (which is supposed to return the Name of Windows) also does not work as it should in some versions of windows I tried (xp pro sp1). Luckily to print more than Windows (eg. print Windows XP or Windows 2000 etc) you can have a look at this http://www.brunningonline.net/simon/blog/archives/001168.html of Simon Brunning also only debian, mdk and redhat is scanned for GNU/Linux ?? why even bother then? I think that PSL is good but this module is has hell of limitations. At least dont' make anyone write this: import os distro_info = { 'Arch Linux': '/etc/arch-release', 'Aurox Linux': '/etc/aurox-release', 'Conectiva Linux': '/etc/conectiva-release', 'Debian GNU/Linux': '/etc/debian_release', 'Debian GNU/Linux': '/etc/debian_version', 'Fedora Linux': '/etc/fedora-release', 'Gentoo Linux': '/etc/gentoo-release', 'Mandrake Linux': '/etc/mandrake-release', 'Slackware Linux': '/etc/slackware-release', 'Slackware Linux': '/etc/slackware-version', 'Solaris/Sparc': '/etc/release', 'Sun JDS': '/etc/sun-release', 'Novell SUSE Linux': '/etc/SuSE-release', 'PLD Linux': '/etc/pld-release', 'SUSE Linux': '/etc/SuSE-release', 'Yellow Dog Linux': '/etc/yellowdog-release', # many distros use the /etc/redhat-release for compatibility # so Redhat is the last 'Redhat Linux': '/etc/redhat-release'} def get_os_info(): if os.name =='nt': win_version = { (1, 4, 0): "95",(1, 4, 10): "98", (1, 4, 90): "ME", (2, 4, 0): "NT",(2, 5, 0): "2000", (2, 5, 1): "XP" }[os.sys.getwindowsversion()[3], os.sys.getwindowsversion()[0], os.sys.getwindowsversion()[1]] return 'Windows' + ' ' + win_version elif os.name =='posix': executable = 'lsb_release' params = ' --id --codename --release --short' for path in os.environ['PATH'].split(':'): full_path_to_executable = os.path.join(path, executable) if os.path.exists(full_path_to_executable): command = executable + params child_stdin, child_stdout = os.popen2(command) output = child_stdout.readline().strip() child_stdout.close() child_stdin.close() return output # lsb_release executable not available, so parse files for distro in distro_info: path_to_file = distro_info[distro] if os.path.exists(path_to_file): file = open(path_to_file) text = file.read().strip() file.close() if path_to_file.endswith('version'): text = distro + ' ' + text return text print get_os_info() Thank you -- >Comment By: Nikos Kouremenos (nkour) Date: 2005-04-13 14:12 Message: Logged In: YES user_id=865368 A friend of mine has a french win xp pro. your way says to him WP platform.release() returns "" to him he has used antispam and such "tools" so he must have accidentaly removed the place where release() seems to look. So release() doesn't do for windows what you do. I also noticed that On a windows exploer help --> about will give Microsoft Windows 5.1 (more info) it won't try the magic that release() [that fail] simon's code still works there as charm. so if release() returns "" I try to do that other code. I would like to see that included though [or a better code for release() to detect the correct stuff] along with the more linux distros and the usage of lsb_release Comments? -- Comment By: Nikos Kouremenos (nkour) Date: 2005-04-12 13:56 Message: Logged In: YES user_id=865368 ok I have it again in a friend of mine. he has win xp pro sp1 French edition and release() returns "" the Simon's trick will return to him XP which is correct!! -- Comment By: Nikos Kouremenos (nkour) Date: 2005-04-11 15:38 Message: Logged In: YES user_id=865368 ok nevermind the platform.release() part for windows name. it seems to work now.. :$ -- Comment By: Nikos Kouremenos (nkour) Date: 2005-04-10 19:46 Message: Logged In: YES user_id=865368 identation went to take a walk :( I'm sorry look here: http://nkour.blogspot.com/2005/03/python-script-to-detect-gnulinux.html --
[ python-Bugs-1182603 ] re.escape(s) prints wrong for chr(0)
Bugs item #1182603, was opened at 2005-04-13 17:54 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1182603&group_id=5470 Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Nick Jacobson (nickjacobson) Assigned to: Nobody/Anonymous (nobody) Summary: re.escape(s) prints wrong for chr(0) Initial Comment: >>> import re >>> s = chr(0) >>> s '\x00' >>> re.escape(s) '\000' I believe it should print: '\\x00' -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1182603&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[ python-Bugs-1182614 ] dir() does not include _
Bugs item #1182614, was opened at 2005-04-13 18:21 Message generated for change (Tracker Item Submitted) made by Item Submitter You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1182614&group_id=5470 Category: None Group: Python 2.4 Status: Open Resolution: None Priority: 5 Submitted By: Nick Jacobson (nickjacobson) Assigned to: Nobody/Anonymous (nobody) Summary: dir() does not include _ Initial Comment: At the interpreter prompt, dir() does not include the variable _ >>> dir() ['__builtins__', '__doc__', '__name__'] >>> x = 5 >>> dir() ['__builtins__', '__doc__', '__name__', 'x'] >>> _ ['__builtins__', '__doc__', '__name__', 'x'] -- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1182614&group_id=5470 ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com