[issue44996] tarfile missing TarInfo.offset_data member in documentation
New submission from Nils : The title says it all: `TarInfo` objects are missing their `offset_data` member in all documentation versions. -- assignee: docs@python components: Documentation messages: 400248 nosy: docs@python, nilsnolde priority: normal severity: normal status: open title: tarfile missing TarInfo.offset_data member in documentation versions: Python 3.10, Python 3.11, Python 3.6, Python 3.7, Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue44996> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22240] argparse support for "python -m module" in help
Nils Kattenbeck added the comment: I implemented the logic and adjusted the existing tests to have a fixed program name. I also fixed the build error by changing how zip files are detected. Based on you comment Nick you however even had a different idea. Currently I check if __spec__.__loader__ is a zip loader but if I understood correct you suggest the check if __spec__.__location__ is a proper subdir of sys.argv[0]? https://github.com/septatrix/cpython/compare/main...septatrix:enhance/argparse-prog-name. When I have some more time I will check whether mocking works and otherwise checkout test.support.script_helper or making the function accept spec/argv0 -- ___ Python tracker <https://bugs.python.org/issue22240> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue13824] argparse.FileType opens a file and never closes it
Nils Kattenbeck added the comment: A good alternative would be to use pathlib.Path. The only downside would be that one has to manually handle `-` but besides that it solves most problems. Still the fact that file descriptors are kept open should be added as a warning to the docs -- nosy: +Nils Kattenbeck ___ Python tracker <https://bugs.python.org/issue13824> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22240] argparse support for "python -m module" in help
Nils Kattenbeck added the comment: I expanded the patch from tebeka to also work with invocations like `python3 -m serial.tools.miniterm` where `miniterm.py` is a file and not a directory with a `__main__.py`. This was able to handle everything I threw at it. However due to the import of zipfile which itself imports binascii the build of CPython itself fails at the `sharedmods` stage... ```text CC='gcc -pthread' LDSHARED='gcc -pthread -shared' OPT='-DNDEBUG -g -fwrapv -O3 -Wall' _TCLTK_INCLUDES='' _TCLTK_LIBS='' ./python -E ./setup.py build Traceback (most recent call last): File "/home/septatrix/Documents/programming/cpython/./setup.py", line 3, in import argparse ^^^ File "/home/septatrix/Documents/programming/cpython/Lib/argparse.py", line 93, in from zipfile import is_zipfile as _is_zipfile ^ File "/home/septatrix/Documents/programming/cpython/Lib/zipfile.py", line 6, in import binascii ^^^ ModuleNotFoundError: No module named 'binascii' make: *** [Makefile:639: sharedmods] Error 1 ``` I guess this is because binascii is a c module and not yet build at that point in time. Does anyone who knows more about the build system have an idea how to resolve this? --- Resolving this bug would also allow the removal of several workarounds for this in the stdlib: * https://github.com/python/cpython/blob/83d1430ee5b8008631e7f2a75447e740eed065c1/Lib/unittest/__main__.py#L4 * https://github.com/python/cpython/blob/83d1430ee5b8008631e7f2a75447e740eed065c1/Lib/json/tool.py#L19 * https://github.com/python/cpython/blob/83d1430ee5b8008631e7f2a75447e740eed065c1/Lib/venv/__init__.py#L426 -- Added file: https://bugs.python.org/file50174/patch.diff ___ Python tracker <https://bugs.python.org/issue22240> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22240] argparse support for "python -m module" in help
Nils Kattenbeck added the comment: I am not sure if the patch correctly handles calling a nested module (e.g. `python3 -m serial.tools.miniterm`). Would it also be possible to detect if python or python3 was used for the invocation? -- nosy: +Nils Kattenbeck ___ Python tracker <https://bugs.python.org/issue22240> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41249] TypedDict inheritance doesn't work with get_type_hints and postponed evaluation of annotations across modules
Nils Kattenbeck added the comment: > The way I fixed this is I added `__forward_module__` to `typing.ForwardRef`, > so that it can resolve the forward reference with the same globals as the > ones specified by the module in `__forward_module__`. `TypedDict`'s metaclass > should then pass the dictionary’s module name to the annotations’ forward > references via the added `module`’s keyword argument in > `typing._type_check()`. I can work in a pull request with this solution and > discuss any potential problems. While this seems like a good solution I would still like to figure out why TypedDict do not preserve MRO. Because for now I have not found a reason nor did someone on the typing-sig mailinglist have a clue. Should there (no longer) be a reason for this then this problem has a trivial solution (just re-add the MRO and use that). -- ___ Python tracker <https://bugs.python.org/issue41249> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41249] TypedDict inheritance doesn't work with get_type_hints and postponed evaluation of annotations across modules
Nils Kattenbeck added the comment: > I believe it had something to do with TypedDict instances being instances of > dict at runtime, but I can't actually reconstruct the reason. Hm that may be true. My limited low-level Python knowledge leads me to believe that this could also be done using __new__ but I also read that most magic methods get called as type(Foo).__magic__(bar, ...) so that might not be possible. (However also no methods can be declared on a TypedDict class so that might not be a problem?) > Maybe it's written up in PEP 589, but I suspect not (I skimmed and couldn't > find it). I read it completely and could not find anything > If you ask on typing-sig maybe David Foster (who contributed the initial idea > and implementation) remembers. I asked [here on typing-sig](https://mail.python.org/archives/list/typing-...@python.org/thread/RNFWPRLHTUTZES2FDSSMY472JFGMD4EW/) but did not yet get any responses. -- ___ Python tracker <https://bugs.python.org/issue41249> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue41249] TypedDict inheritance doesn't work with get_type_hints and postponed evaluation of annotations across modules
Nils Kattenbeck added the comment: What is/was the initial reason to not preserve the MRO for a TypedDict? The only thing which came to my mind would be instantiation performance but as annotations are not evaluated by default and on the right-hide side of assignment most people will use dict literals I am not sure if this is still relevant. Otherwise it might even be simpler to just preserve the original bases in TypedDict but please correct me if I overlooked something -- nosy: +Nils Kattenbeck ___ Python tracker <https://bugs.python.org/issue41249> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25024] Allow passing "delete=False" to TemporaryDirectory
Nils Kattenbeck added the comment: While the proposal linked by C.A.M. solves one of the use cases but it does not address the others. One use cases which is rather common for me it is e.g. to have scripts/programs which allow configuring whether temporary directories should get deleted or stay persistent after program exit. Currently this always requires hand rolled wrappers like the following: def mkdtemp_persistent(*args, persistent=True, **kwargs): if persistent: @contextmanager def normal_mkdtemp(): yield tempfile.mkdtemp() return normal_mkdtemp(*args, **kwargs) else: return tempfile.TemporaryDirectory(*args, **kwargs) with mkdtemp_persistent(persistent=False) as dir: ... Which gets the job done but is not as user friendly as other parts of the stdlib. -- nosy: +Nils Kattenbeck ___ Python tracker <https://bugs.python.org/issue25024> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue1717] Get rid of more references to __cmp__
Nils Kattenbeck added the comment: Has there been any resolution regarding `sortTestMethodsUsing`? See https://bugs.python.org/msg77261 I spend a decent time and read the documentation thrice before realizing it received an old-style compare function. Brett's proposal for a new attribute seems like a sane way to do this without breaking backwards compatibility. Or will this continue using an old-style compare function for the foreseeable future? -- nosy: +Nils Kattenbeck ___ Python tracker <https://bugs.python.org/issue1717> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44137] importlib.resources.path raises RuntimeError when FileNotFoundError is raise in context manager
Nils Kattenbeck added the comment: Thanks for looking into it. Yes I can confirm that `importlib_resources` has the expected behaviour - I did not download Python 3.10 as the code seems to be the same. -- ___ Python tracker <https://bugs.python.org/issue44137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44137] importlib.resources.path raises RuntimeError when FileNotFoundError is raise in context manager
Nils Kattenbeck added the comment: Yes I understand that the function handles this specially to not raise an exception if the file is not found in the package (even though the intention behind this is not clear to me). However if a user causes a FileNotFoundException itself inside of the context manager everything breaks (e.g. does something erroneous with the path, calls subprocess.run with a non existing binary etc). -- ___ Python tracker <https://bugs.python.org/issue44137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44137] importlib.resources.path raises RuntimeError when FileNotFoundError is raise in context manager
Change by Nils Kattenbeck : -- title: importlib.resources.path raises RuntimeError import FileNotFoundError is raise in context manager -> importlib.resources.path raises RuntimeError when FileNotFoundError is raise in context manager ___ Python tracker <https://bugs.python.org/issue44137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue44137] importlib.resources.path raises RuntimeError import FileNotFoundError is raise in context manager
New submission from Nils Kattenbeck : When a FileNotFoundError is raised inside while the importlib.resources.path context manager is active a RuntimeError is raised. Looking at the (3.8) code it seems that FileNotFound exceptions are handled specially from all other exceptions which may lead to this behaviour. While the code in 3.9 changed significantly the same behaviour can be observed. Files: . └── my_package ├── data.txt (empty) ├── __init__.py (empty) └── test.py Content of test.py: import importlib.resources def main(): with importlib.resources.path('my_package', 'data.txt') as p: raise FileNotFoundError() if __name__ == '__main__': main() Exact error message: RuntimeError: generator didn't stop after throw() -- components: Library (Lib) messages: 393686 nosy: Nils Kattenbeck, brett.cannon, jaraco priority: normal severity: normal status: open title: importlib.resources.path raises RuntimeError import FileNotFoundError is raise in context manager type: behavior versions: Python 3.8, Python 3.9 ___ Python tracker <https://bugs.python.org/issue44137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34137] Add Path.lexist() to pathlib
Nils Philippsen added the comment: I've come across this issue lately and proposed a PR which implements this and, analogous to os.stat(), adds a follow_symlinks parameter to Path.exists(). -- ___ Python tracker <https://bugs.python.org/issue34137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34137] Add Path.lexist() to pathlib
Change by Nils Philippsen : -- keywords: +patch pull_requests: +20316 stage: -> patch review pull_request: https://github.com/python/cpython/pull/21157 ___ Python tracker <https://bugs.python.org/issue34137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue34137] Add Path.lexist() to pathlib
Change by Nils Philippsen : -- nosy: +nils ___ Python tracker <https://bugs.python.org/issue34137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38756] Add generic versions of weakref types to typing module
Nils Kattenbeck added the comment: Okay, if I want to start a discussion about adding weakref types to PEP 585 where should do it? The mailing list or as an issue in the PEP repo? -- ___ Python tracker <https://bugs.python.org/issue38756> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38761] weakref.WeakSet not instanceof collections.abc.Set
New submission from Nils Kattenbeck : Instances of weakref.WeakSet are not instances of Set and therefore not of MutableSet but they are instances of Collection. They however implement all required methods for a MutableSet and Weak(Key|Value)Dictionary are correctly identified. Is this just an oversight or am I missing something? from weakref import WeakKeyDictionary, WeakValueDictionary, WeakSet from collections.abc import MutableMapping, Collection, Set, MutableSet wkdict = WeakKeyDictionary() wvdict = WeakValueDictionary() ws = WeakSet() assert isinstance(wkdict, MutableMapping) assert isinstance(wvdict, MutableMapping) assert isinstance(ws, Collection) assert not isinstance(ws, Set) assert not isinstance(ws, MutableSet) -- components: Library (Lib) messages: 356326 nosy: Nils Kattenbeck priority: normal severity: normal status: open title: weakref.WeakSet not instanceof collections.abc.Set versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue38761> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38756] Add generic versions of weakref types to typing module
Nils Kattenbeck added the comment: Okay nevermind, after looking in the PEP again and inspecting the __annotations__ property I learned that annotations are never evaluated and just saved as a string when using said future statement. However this may still be relevant as typing.get_type_hints will still fail. For my use case however this is sufficient. -- ___ Python tracker <https://bugs.python.org/issue38756> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38756] Add generic versions of weakref types to typing module
Nils Kattenbeck added the comment: Yes thank you, using 'from __future__ import annotations' works fantastic. I did not knew about this functionality of the annotations future import statement, I thought it was only for postponed evaluation but I probably missed something in the PEP... -- ___ Python tracker <https://bugs.python.org/issue38756> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38756] Add generic versions of weakref types to typing module
Nils Kattenbeck added the comment: A possible use case would be having multiple users and some groups said users can belong to. When using a WeakSet a user won't be part of a groups after he deleted his account without having to iterate over all groups. class User: pass class Group: users: WeakSet[User] def __init__(self, users: Iterable[User]): self.users = WeakSet(users) # somewhere else a collection of all active users Types I would like to see added as a generic would be primarily: - WeakKeyDictionary - WeakValueDictionary - WeakSet Additionally it would be nice to have generic versions of: - ref (would probably return Optional[T] on call?) - WeakMethod - ProxyType - CallableProxyType Although the last two could probably be just annotated using T because they mostly should behave the same... -- ___ Python tracker <https://bugs.python.org/issue38756> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue38756] Add generic versions of weakref types to typing module
New submission from Nils Kattenbeck : I would like to request the addition of generic variants of some of the types in weakref to the typing module. This would for example include weakref.WeakKeyDictionary among others. Doing so would allow one to add type annotations to code using such data structures. -- components: Library (Lib) messages: 356304 nosy: Nils Kattenbeck priority: normal severity: normal status: open title: Add generic versions of weakref types to typing module type: enhancement versions: Python 3.9 ___ Python tracker <https://bugs.python.org/issue38756> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31652] make install fails: no module _ctypes
Nils Goroll added the comment: In case this helps: I noticed this during the build: *** WARNING: renaming "_ssl" since importing it failed: ld.so.1: python: fatal: libssl.so.1.1: open failed: No such file or directory *** WARNING: renaming "_hashlib" since importing it failed: ld.so.1: python: fatal: libssl.so.1.1: open failed: No such file or directory *** WARNING: renaming "_ctypes" since importing it failed: ld.so.1: python: fatal: libffi.so.6: open failed: No such file or directory ... Following modules built successfully but were removed because they could not be imported: _ctypes _hashlib _ssl In my case the reason was that libffi was installed under /opt/local, so the fix was: ./configure LDFLAGS='-L/opt/local/lib -R/opt/local/lib' and rebuild For other users I would recommend to inspect the build output for _ctypes related errors, I am not saying that the cause is the same -- nosy: +slink ___ Python tracker <https://bugs.python.org/issue31652> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35558] venv: running activate.bat gives ' parameter format not correct - 65001'
Change by Nils Lindemann : -- resolution: -> duplicate stage: -> resolved status: -> closed ___ Python tracker <https://bugs.python.org/issue35558> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue35558] venv: running activate.bat gives ' parameter format not correct - 65001'
New submission from Nils Lindemann : Windows 7, Python 3.7.1:260ec2c36a after doing C:\python\python -m venv C:\myvenv and then C:\>myvenv\Scripts\activate.bat it prints parameter format not correct - 65001 However, it activates the venv - the prompt shows (myvenv) C:\> and C:\myvenv\Scripts; gets prepended to PATH. When i outcomment for /f "tokens=2 delims=:" %%a in ('"%SystemRoot%\System32\chcp.com"') do ( set "_OLD_CODEPAGE=%%a" ) in the activate.bat then the message wont show up. related: https://stackoverflow.com/questions/51358202/python-3-7-activate-venv-error-parameter-format-not-correct-65001-windows -- messages: 332320 nosy: Nils-Hero priority: normal severity: normal status: open title: venv: running activate.bat gives ' parameter format not correct - 65001' type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue35558> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31816] Unexpected behaviour of `dir()` after implementation of __dir__
Nils Diefenbach <23okrs20+pyt...@mykolab.com> added the comment: Alright. Are there any other magic methods that do some post-processing on a custom implementation of them ? I couldn't think of one, which is why this behaviour appeared odd to me. -- status: pending -> open ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31816> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31816] Unexpected behaviour of `dir()` after implementation of __dir__
New submission from Nils Diefenbach <23okrs20+pyt...@mykolab.com>: When defining a custom __dir__ method in a class, calling dir() on said class still sorts the output. This is, imo, unexpected behaviour, especially if the order of output was specified in __dir__ and is somehow relevant. Example and more detail here https://stackoverflow.com/questions/46824459/custom-dir-returns-list-of-attributes-sorted-alphabetically -- messages: 304606 nosy: nlsdfnbch priority: normal severity: normal status: open title: Unexpected behaviour of `dir()` after implementation of __dir__ type: behavior versions: Python 3.5 ___ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue31816> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30580] WSGI examples raise AttributeError: __exit__
Nils Lindemann added the comment: ok -- status: open -> closed ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30580> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30580] WSGI examples raise AttributeError: __exit__
Nils Lindemann added the comment: I am not sure if the py package i found on PyPi is what you meant, but if you mean the py launcher (the py.exe in the windows dir), yes, i have that. My system was indeed misconfigured as you correctly guessed, i had the .py filetype pointing to a Python version 3.5. I have now uninstalled everything, manually cleaned up the registry, reinstalled Python 3.6 and now everything works. Sorry, my mistake. -- resolution: not a bug -> status: closed -> open ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30580> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30580] WSGI examples raise AttributeError: __exit__
Nils Lindemann added the comment: What would that be? If i google 'py helper command' i get no good results. -- resolution: not a bug -> status: closed -> open ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30580> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30580] WSGI examples raise AttributeError: __exit__
Nils Lindemann added the comment: I just found out that the example works in idle and if i do in a console: python server.py but not if i do just: server.py What is the secret behind this? -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30580> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30580] WSGI examples raise AttributeError: __exit__
Nils Lindemann added the comment: I tried a few online python 3 interpreters. These give the same exception: http://www.learnpython.org/en/Hello%2C_World%21 http://rextester.com/l/python3_online_compiler http://ideone.com/pIMilt http://www.tutorialspoint.com/execute_python3_online.php And this one worked: https://repl.it/languages/python3 the example i tried was: from wsgiref.simple_server import make_server, demo_app with make_server('', 8000, demo_app) as httpd: print("Serving HTTP on port 8000...") httpd.serve_forever() My Python installation is a default x64 installation. No changes were made during installation, except installation path, which has no spaces in it. I have no third part modules installed which could interfer. I have also a Python 2.7 installed but it is not on my path. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30580> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30580] WSGI examples raise AttributeError: __exit__
New submission from Nils Lindemann: All examples on https://docs.python.org/3/library/wsgiref.html raise this exception: Traceback (most recent call last): File "C:\Code\test\server.py", line 110, in with make_server('', 8000, simple_app) as httpd: AttributeError: __exit__ Tested with Python 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 18:41:36) [MSC v.1900 64 bit (AMD64)] on win32 -- messages: 295253 nosy: Nils-Hero priority: normal severity: normal status: open title: WSGI examples raise AttributeError: __exit__ versions: Python 3.6 ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue30580> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25444] Py Launch Icon
Nils Lindemann added the comment: Two years later: To the dude who removed the rocket from the icons in 3.6: I LOVE YOU! -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25444> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25444] Py Launch Icon
Nils Lindemann added the comment: i see now what you mean. I have this icon too (py 3.5.0 idle icon.png). Something is misconfigured with the icons in the python 3.5.0 windows installer, also python files in explorer have no icons. Thanks for your hint with the python ideas list, i will post a message there. -- Added file: http://bugs.python.org/file40894/py 3.5.0 idle icon.png ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25444> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25444] Py Launch Icon
Nils Lindemann added the comment: it seems i have still not explained my issue in an understandable way: the three first icons in the file list in the screenshot, aka the icons which are used in eg py 3.2, these icons are cool. the icon i do not like, is the launcher icon which is used in eg py 3.5 and which shows up in the windows task bar when i run python scripts which open a commandline. This is the last icon in the file list in the screenshot. Im fine with everything else, i always liked the original icons, just the new launcher icon is terrible in my opinion :-( -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25444> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25444] Py Launch Icon
Nils Lindemann added the comment: The icons are not intended to be used instead of the three default icons, please dont, these are just great. I am just targeting the current launcher symbol: * It contains a symbol of an instrument which can be used to kill people. * in the 16x16 icon it is not clear at all what this is. it just looks like a smudge on the icon. When i first saw it i touched it to see if the smudge is on my screen. * the symbol indicates that one is running the launcher. But thats not true, he is running the process that was launched by the launcher. So if this symbol is used for the exe which is the launcher, ok, but using it for all processes started with it is wrong in my opinion. The icons for idle are just suggestions, using an alternative icon for idele, as i said, may be helpful to separate idle from command lines. The alternative icons for the launcher are just thought as source of inspiration. Actually i think launched processes (except maybe idle) should use the standard py exe icon! -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25444> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25444] Py Launch Icon
Nils Lindemann added the comment: let me reformulate it: my main intention is to get rid of the launcher symbol, or at least have a nicer looking symbol, i dont care for the idle symbol. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25444> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25444] Py Launch Icon
Nils Lindemann added the comment: Here is also a zip containing the icons. -- Added file: http://bugs.python.org/file40818/icons.zip ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25444> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25444] Py Launch Icon
Nils Lindemann added the comment: Hm actually an alternative icon for idle can be useful to separate it from command lines in the task bar. But a special launcher symbol is not necessary in my opinion. -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25444> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25444] Py Launch Icon
New submission from Nils Lindemann: Hi, See attached screen for a list of alternative 16x16 icon suggestions to the current launcher symbol, which i dont like (Dudes, rockets are used in wars!). I copied them a few times to show how they look in groups. (while i was at it i also created an icon for idle, see the idle window in the Screenshot). Actually i wonder why it is necessary at all to use more than the three default icons, but if, then my icons are better. Hopefully i can inspire the designer to do a redesign of the luncher icon :-) Nils -- components: IDLE, Installation, Windows files: (py icons, idle) screenshot.png messages: 253203 nosy: Nils-Hero, paul.moore, steve.dower, tim.golden, zach.ware priority: normal severity: normal status: open title: Py Launch Icon type: enhancement versions: Python 3.5, Python 3.6 Added file: http://bugs.python.org/file40815/(py icons, idle) screenshot.png ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue25444> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Python 3.5.0 Feedback
Hallo, Zuerst mal, ein dickes Danke an alle, die an Python mitarbeiten! Hier ein paar Dinge, die mir an 3.5.0 aufgefallen sind (ich komme von 3.2.3): === Informitis === * Die Namen der Links im Startmenü und die erste Zeile der interaktiven Kommandozeile sind von (noch größerer) Informitis befallen. Wie auch schon die Doku seit langem. Informitis: Informationen im unpassenden Format an eine unpassende Stelle setzen. === Symbole === * Die Python-Dateien haben keine Symbole im Explorer. * Das Symbol von IDLE is grau und wenig ansehnlich. * In der Symboleiste: 16x16 Symbole von Kommandozeilen haben einen schwarzen "Schmutzfleck" oben links. Gräßlich! === Installer === * Der neue Installer lässt beim Vorkompilieren nicht mehr die gerade kompilierten Dateien durchrasen, so wirkt es, als sei der Installer eingefroren. * Auch verwendet der Installer bei der fortgeschrittenen Installation einige Formulierungen, die schwer zu verstehen sein könnten: "requires Elevation" (Was ist "Elevation"? leo.org gibt nur: "Erhöhung") "Install Debugging Symbols" (Was sind Debugging Symbole? Icons?) "Create Shortcuts for installed applications" (Das sollte "create shortcuts in Startmenu and on Desktop" sein) === HTML Doku === * JavaScript-Suchfunktion der HTML Doku zeigt in der Beschreibung von gefundenen Links Dinge wie '= (etc)' an. * Globale Funktionen wie 'open' sind nicht mehr an der ersten Stelle bei der Suche (welches Sie zwischendurch mal waren, glaube ich). === Bugs === * Python 3.5 verträgt a=input('\n') nicht. Gruß, Nils -- Nils-Hero Lindemann <nilsherolindem...@gmail.com> -- https://mail.python.org/mailman/listinfo/python-list
UDP and Python2.7 and 2.7 documentation gives error!
UDP and Python2.7 and 2.7 documentation gives error! I am trying to send UDP messages from one PC to another, using P2.7. BUT I get an error I do not understand, this as I am following the doc's for Python2.7! Listing of the script with error result following: import socket UDP_IP = '192.168.0.90' UDP_PORT = 45121 msg = '7654321' print ("UDP target IP:", UDP_IP) print ("UDP target port:", UDP_PORT) print ("message:", msg) sock = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP sock.bind((UDP_IP, UDP_PORT)) sock.send( msg ) C:\Utveckling\Counter_pythonCounter_send.py ('UDP target IP:', '192.168.0.90') ('UDP target port:', 45121) ('message:', '7654321') Traceback (most recent call last): File "C:\Utveckling\Counter_python\Counter_send.py", line 13, in module sock.bind((UDP_IP, UDP_PORT)) File "C:\Python27\lib\socket.py", line 228, in meth return getattr(self._sock,name)(*args) socket.error: [Errno 10049] The requested address is not valid in its context C:\Utveckling\Counter_python So, please tell me where I am doing wrong, or is doc's wrong?? Nils in Uppsala -- -- https://mail.python.org/mailman/listinfo/python-list
[issue21121] -Werror=declaration-after-statement is added even for extension modules through setup.py
New submission from nils: I got an error while rebuilding a module for 3.4. This was a ISO C90 error but setup.py explicitely adds -std=c99 to the gcc parameters, and indeed it is used. fifo.h:114:5: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] uint32_t ofs = fifo-write_count - fifo-write_offset; However, Py 3.4 seems to add -Werror=declaration-after-statement also for extension modules. This should not happe (said also Yhg1s in #python). Attached is a file that shows the setup.py and also the error log. -- components: Build, Distutils, Extension Modules files: pybug.txt messages: 215305 nosy: dstufft, eric.araujo, nilsge priority: normal severity: normal status: open title: -Werror=declaration-after-statement is added even for extension modules through setup.py versions: Python 3.4 Added file: http://bugs.python.org/file34692/pybug.txt ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21121 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21121] -Werror=declaration-after-statement is added even for extension modules through setup.py
nils added the comment: The workaround indeed works. At least I can work now until this gets officialy fixed. Thanks! export CFLAGS=$(python3.4 -c 'import sysconfig; print(sysconfig.get_config_var(CFLAGS).replace(-Werror=declaration-after-statement,))') -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue21121 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Critic: New Python Front Page
Hi, (Please forgive (or correct) my mistakes, i am non native) http://www.python.org/community/sigs/retired/parser-sig/towards-standard/ * Formatting bug * Needs breadcrumb navigation (Where am i?) (i came there via http://theory.stanford.edu/~amitp/yapps/) * blue background makes top links invisible when i look on laptop screen from a 60% angle. Prefer white. * 1 third of space on y-axis is used for 15 navigation links and a search bar. * 1 third of space on x-axis is used for one sentence about and a link to PSF. * I can not easily get rid of this by using e.g. HackTheWeb (https://addons.mozilla.org/de/firefox/addon/hack-the-web/). Please compare with e.g. Wikipedia, it is easy there to isolate the main content. http://www.python.org/community/ That picture is scary. Regards, Nils -- Nils-Hero Lindemann nilsherolindem...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Critic: New Python Front Page
Hello, The source for the site is on github, and they are taking and resolving issues there: https://github.com/python/pythondotorg/issues Thanks for pointing me to the right place. I copypasted my mail to ... https://github.com/python/pythondotorg/issues/266 also i added a comment to ... https://github.com/python/pythondotorg/issues/265 Regards, Nils -- Nils-Hero Lindemann nilsherolindem...@gmail.com -- https://mail.python.org/mailman/listinfo/python-list
Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2
Hi Neil, Thanks for looking at this. I'm trying to create a multipart MIME for an HTTP POST request, not an email. This is for a third-party API that requires a multipart POST with a binary file, so I don't have the option to just use a different encoding. Multipart HTTP is standardized in HTTP 1.0 and supports binary parts. Also, no one will re-interpret contents of HTTP on the wire, as binary is quite normal in HTTP. The issue seems to be some parts of the python MIME encoder still assume it's for email only, where everything would be b64 encoded. Maybe I have to roll my own to create a multipart msg with a binary file? I was hoping to avoid that. Nils ps. You probably know this, but in case anyone else reads this thread, HTTP requires all headers to have CRLF, not native line endings. The python MIME modules can do that properly as of python 3.2 (fixed as of this bug http://hg.python.org/cpython/rev/ebf6741a8d6e/) I got interested in it since I have never used any of the modules. So I played with it enough to discover that the part of the code above that converts the \r to \n is the flatten call. I got to here and RFC 2049 and gave up. The following guidelines may be useful to anyone devising a data format (media type) that is supposed to survive the widest range of networking technologies and known broken MTAs unscathed. Note that anything encoded in the base64 encoding will satisfy these rules, but that some well-known mechanisms, notably the UNIX uuencode facility, will not. Note also that anything encoded in the Quoted-Printable encoding will survive most gateways intact, but possibly not some gateways to systems that use the EBCDIC character set. (1) Under some circumstances the encoding used for data may change as part of normal gateway or user agent operation. In particular, conversion from base64 to quoted-printable and vice versa may be necessary. This may result in the confusion of CRLF sequences with line breaks in text bodies. As such, the persistence of CRLF as something other than a line break must not be relied on. (2) Many systems may elect to represent and store text data using local newline conventions. Local newline conventions may not match the RFC822 CRLF convention -- systems are known that use plain CR, plain LF, CRLF, or counted records. The result is that isolated CR and LF characters are not well tolerated in general; they may be lost or converted to delimiters on some systems, and hence must not be relied on. So putting a raw CR in a binary chunk maybe be intolerable, and you need to use a different encoder. But I'm out of my element. -- Neil Cerutti -- https://mail.python.org/mailman/listinfo/python-list
Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2
Hi all, I was able to workaround this problem by encoding a unique 'marker' in the binary part, then replacing the marker with the actual binary content after generating the MIME message. See my answer on Stack Overflow http://stackoverflow.com/a/19033750/526098 for the code. Thanks, your suggestions helped me think of this. Nils On Wednesday, September 25, 2013 9:38:17 AM UTC-7, Nils Bunger wrote: Hi, I'm having trouble encoding a MIME message with a binary file. Newline characters are being interpreted even though the content is supposed to be binary. This is using Python 3.3.2 Small test case: app = MIMEApplication(b'Q\x0dQ', _encoder=encode_noop) b = io.BytesIO() g = BytesGenerator(b) g.flatten(app) for i in b.getvalue()[-3:]: print (%02x % i, end=) print () This prints 51 0a 51, meaning the 0x0d character got reinterpreted as a newline. I've tried setting an email policy of HTTP policy, but that goes even further, converting \r to \r\n This is for HTTP transport, so binary encoding is normal. Any thoughts how I can do this properly? -- https://mail.python.org/mailman/listinfo/python-list
Re: Newline interpretation issue with MIMEApplication with binary data, Python 3.3.2
Chris, Thanks for answering. Yes, it's email.mime.MIMEApplication. I've pasted a snippet with the imports below. I'm trying to use this to build a multi-part MIME message, with this as one part. I really can't figure out any way to attach a binary part like this to a multi-part MIME message without the encoding issue... any help would be greatly appreciate! Nils - import io from email.mime.application import MIMEApplication from email.generator import BytesGenerator from email.encoders import encode_noop app = MIMEApplication(b'Q\x0dQ', _encoder=encode_noop) b = io.BytesIO() g = BytesGenerator(b) g.flatten(app) for i in b.getvalue()[-3:]: print(%02x % i, end=) print() On Wednesday, September 25, 2013 9:11:31 PM UTC-7, Chris Angelico wrote: On Thu, Sep 26, 2013 at 2:38 AM, nilsbun...@gmail.com wrote: app = MIMEApplication(b'Q\x0dQ', _encoder=encode_noop) What is MIMEApplication? It's not a builtin, so your test case is missing an import, at least. Is this email.mime.MIMEApplication? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
[issue17816] Weak*Dictionary KeyErrors during callbacks
Nils Bruin added the comment: One solution is to patch both WeakValueDictionary and WeakKeyDictionary with their own clear methods where we first store the strong links (to keys, resp. values) in a list, then clear the underlying dictionaries (this will now trigger the deletion of the weakrefs, so all callbacks are neutralized), and then delete the list. It does use more storage that way, but it gets rid of the ignored key errors. This is a different problem from issue7105, which deals with the (much more complicated) scenario of avoiding dictionary reshaping due to GC when iterators are still (potentially) active. -- keywords: +patch Added file: http://bugs.python.org/file30101/17816_custom_clear.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17816 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17816] Weak*Dictionary KeyErrors during callbacks
New submission from Nils Bruin: The following program is a little dependent on memory layout but will usually generate lots of Exception KeyError: (A(9996),) in function remove at 0xa47050 ignored messages in Python 2.7. import weakref class A(object): def __init__(self,n): self.n=n def __repr__(self): return A(%d)%self.n def mess(n): D=weakref.WeakValueDictionary() L=[A(i) for i in range(n)] for i in range(n-1): j=(i+10)%n D[L[i]]=L[j] return D D=mess(1) D.clear() The reason is that on D.clear() all entries are removed from D before actually deleting those entries. Once the entries are deleted one-by-one, sometimes the removal of a key will result in deallocation of that key, which may be a not-yet-deleted ex-value of the dictionary as well. The callback triggers on the weakref, but the dict itself was already emptied, so nothing is found. I've checked and on Python 3.2.3 this problem does not seem to occur. I haven't checked the Python source to see how Python 3 behaves differently and whether that behaviour would be easy to backport to fix this bug in 2.7. -- components: Library (Lib) messages: 187570 nosy: Nils.Bruin priority: normal severity: normal status: open title: Weak*Dictionary KeyErrors during callbacks versions: Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17816 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17816] Weak*Dictionary KeyErrors during callbacks
Nils Bruin added the comment: Have you tried if the fix at issue7105 solves the problem? I don't see the patch there introduce a `clear` method override for WeakValueDictionary or WeakKeyDictionary. The one for WeakSet still calls self.data.clear(), which for dictionaries would still result in the problem in this ticket (but not for WeakSet, because clearing a WeakSet shouldn't decref anything other than the weak references stored in the underlying set). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17816 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17816] Weak*Dictionary KeyErrors during callbacks
Nils Bruin added the comment: I think the difference in behaviour between Py3 and Py2 is coming from: http://hg.python.org/cpython/file/a26df2d03989/Objects/dictobject.c#l1275 which first clears all values before removing any keys. For a WeakValueDictionary that means all the weakrefs are neutralized before the can be activated. I don't quite understand how Py3 manages to avoid problems for a WeakKeyDictionary, but apparently it does. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17816 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17526] inspect.findsource raises undocumented error for code objects with empty filename
Nils Bruin added the comment: The most straightforward change I can think of is to change the line if not sourcefile and file[0] + file[-1] != '': to if not sourcefile and (not file or file[0] + file[-1] != ''): That solves the problem in the cases I have observed. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17526 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17526] inspect.findsource raises undocumented error for code objects with empty filename
New submission from Nils Bruin: It would seem reasonable that an empty filename would be a legitimate way of indicating that a code object does not have a corresponding source file. However, if one does that then inspect.findsource raises an unexpected IndexError rather than the documented IOError. This seems due to the fix introduced on issue9284 Python 3.2.3 (default, Jun 8 2012, 05:40:07) [GCC 4.6.3 20120306 (Red Hat 4.6.3-2)] on linux2 Type help, copyright, credits or license for more information. import inspect C=compile(print(1),string,single) D=compile(print(1),,single) inspect.findsource(C) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib64/python3.2/inspect.py, line 547, in findsource raise IOError('could not get source code') IOError: could not get source code inspect.findsource(D) Traceback (most recent call last): File stdin, line 1, in module File /usr/lib64/python3.2/inspect.py, line 537, in findsource if not sourcefile and file[0] + file[-1] != '': IndexError: string index out of range -- components: Library (Lib) messages: 185025 nosy: Nils.Bruin priority: normal severity: normal status: open title: inspect.findsource raises undocumented error for code objects with empty filename type: behavior versions: Python 2.7, Python 3.2 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue17526 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11912] Python shouldn't use the mprotect() system call
Nils Breunese n...@breun.nl added the comment: I contacted the author of iotop and he told me iotop does not use mprotect (but it does use dlopen). Guess I'll have to do some more digging to find what is exactly doing the call to mprotect. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11912 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11912] Python shouldn't use the mprotect() system call
New submission from Nils Breunese n...@breun.nl: When I try to run iotop [0] on CentOS 5.6 on a kernel with grsecurity [1] then iotop won't start because grsecurity is blocking Python because of its use of the mprotect() system call. Please see http://www.atomicorp.com/wiki/index.php/ASL_FAQ#grsec:_denied_RWX_mprotect for more information. The authors of this hardened Linux kernel suggested to file a bug with Python because using mprotect() is apparently a very bad thing to do. [0] http://guichaz.free.fr/iotop/ [1] http://grsecurity.net/ -- messages: 134314 nosy: breun priority: normal severity: normal status: open title: Python shouldn't use the mprotect() system call type: security versions: 3rd party ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11912 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11912] Python shouldn't use the mprotect() system call
Nils Breunese n...@breun.nl added the comment: I got this error message in /var/log/messages when trying to start iotop: Apr 13 08:49:37 hostname kernel: grsec: From xxx.xxx.xxx.xxx: denied RWX mprotect of /lib64/ld-2.5.so by /usr/bin/iotop[iotop:9836] uid/euid:0/0 gid/egid:0/0, parent /bin/bash[bash:9351] uid/euid:0/0 gid/egid:0/0 Apr 13 08:49:37 hostname kernel: iotop[9836]: segfault at 6248c405dda0 ip 6248c3e489ec sp 7fffa52e8410 error 7 in ld-2.5.so[6248c3e42000+1c000] /usr/bin/iotop is a Python script and according to that log message grsecurity detected a call to mprotect(). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11912 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue11912] Python shouldn't use the mprotect() system call
Nils Breunese n...@breun.nl added the comment: I haven't had any problems with other Python applications like this, Python seems fine otherwise. I just noticed that iotop has a dependency on python-ctypes, which sounds like it could be iotop doing the mprotect() calls via ctypes. Does that make sense? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue11912 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6011] python doesn't build if prefix contains non-ascii characters
Nils Philippsen n...@redhat.com added the comment: NB: it's not the shell, but the kernel which interprets the shebang line (and subsequently calls the shell /bin/sh with it if it's missing, causing funny effects when it encounters the first import line and you happen to have ImageMagick installed). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6011 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: Standardizing RPython - it's time.
Hi, On 10/12/2010 07:41 AM, John Nagle wrote: [...] With Unladen Swallow looking like a failed IT project, a year behind schedule and not delivering anything like the promised performance, Google management may pull the plug on funding. Since there hasn't been a quarterly release in a year, that may already have effectively happened. are you sure that the project has failed? Yes the project page is outdated, but there is also pep-3146 [1] Merging Unladen Swallow into CPython Regarding the accepted pep, the merge is planed for Python 3.3. So for me it looks like the development itself has finished and the merging has started... Does anyone has more details? Regrads, Nils [1] http://www.python.org/dev/peps/pep-3146/ -- http://mail.python.org/mailman/listinfo/python-list
Re: Standardizing RPython - it's time.
On 10/12/2010 05:18 PM, Nils Ruettershoff wrote: Hi, On 10/12/2010 07:41 AM, John Nagle wrote: [...] With Unladen Swallow looking like a failed IT project, a year behind schedule and not delivering anything like the promised performance, Google management may pull the plug on funding. Since there hasn't been a quarterly release in a year, that may already have effectively happened. are you sure that the project has failed? Yes the project page is outdated, but there is also pep-3146 [1] Merging Unladen Swallow into CPython Regarding the accepted pep, the merge is planed for Python 3.3. So for me it looks like the development itself has finished and the merging has started... I've just found a statement from Collin Winter [1]. He says, that he is working on other google projects, but they are still targeting the merge Unladen Swallow with cPython 3.3. The last commitmend to the branch (py3-jit) was in June this year So I would say the project is not dead or has failed, but delayed. Cheers, Nils [1] http://groups.google.com/group/unladen-swallow/browse_thread/thread/f2011129c4414d04 -- http://mail.python.org/mailman/listinfo/python-list
[issue6011] python doesn't build if prefix contains non-ascii characters
Changes by Nils Philippsen n...@redhat.com: -- nosy: +nils ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6011 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
use of gtk in a nautilus extension
Hi, I am having some trouble opening a simple message/dialog to the user from a natilus extension.. I have written a simple nautilus extension using python. It adds one MenuItem to the context menu. for testing I wanted to open a simple dialog when the user clicks this menuitem. (The code can be found - with some nice formatting here: http://stackoverflow.com/questions/3325772/use-gtk-in-a-nautilus-extension-using-python) The code is as follows: --- cut --- import gtk import nautilus import os def alert(message): A function to debug dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_INFO, gtk.BUTTONS_CLOSE, message) dialog.run() dialog.destroy() class TestExtension(nautilus.MenuProvider): def __init__(self): pass def get_file_items(self, window, files): items = [] Called when the user selects a file in Nautilus. item = nautilus.MenuItem(NautilusPython::test_item, Test, Test) item.connect(activate, self.menu_activate_cb, files) items.append(item) return items def menu_activate_cb(self, menu, files): Called when the user selects the menu. for name in files: alert(name) --- cut --- When I click on the menuitem nothing happens... But when I replace def alert(message) like this: def alert(message): A function to debug easygui.msgbox(message) and obviously drop import gtk and add import easygui, The dialog does appear. Can someone tell me why this is ?? Yours, Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: pre-uninstall script in bdist_wininst
On 6 Aug., 04:02, Mark Hammond skippy.hamm...@gmail.com wrote: According to a comment in pywin32's post-install script: elif arg == -remove: # bdist_msi calls us before uninstall, so we can undo what we # previously did. Sadly, bdist_wininst calls us *after*, so # we can't do much at all. Sadly, I can not confirm this. I wrote the simplest install-script (dump call-parameters to a txt-file) and tested with 2.6 and 2.7 On bdist_wininst my install_script was called on install with parameter -install On bdist_wininst my install_script was called on install without parameters My script was never (ever) called on uninstall... I'd suggest using py2exe to package the object and inno installer or similar to handle the install and uninstall parts. Yes, I'll try that, thanks. -- http://mail.python.org/mailman/listinfo/python-list
pre-uninstall script in bdist_wininst
Hi. I am using a postinstall-script like this: setup( ... scripts=['scripts\install.py'], options = { ... bdist_wininst : { install_script : install.py, ... }, } ) According to the docs in [1] this script is a) called after install (with the -install parameter) - this works fine for me... b) called before uninstall (with tho -remove parameter) - this however does not work. Can someone please point me to the direction on how to get a pre- uninstall script working? btw: With that I am trying to register a com-server on install and de- register on uninstall - so if other ideas are around I'd love to hear them, too... Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: pre-uninstall script in bdist_wininst
On 5 Aug., 20:26, Nils andresen.n...@googlemail.com wrote: According to the docs in [1] [...] and with [1] I meant http://docs.python.org/distutils/builtdist.html#the-postinstallation-script Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: source install of python2.7 and rpm install of cx_Oracle collision
Hi Jim, Jim Qiu wrote: [...] I find out that only libpython2.7.a generated when I install python2.7, who can tell me what I need to do ? I want a libpython2.7.so.1.0 generated when I've didn't read your complete mail... In addition to the steps I've described in my other mail, you need to the configure script, that you like to have shared libraries. So you need to add --enable-shared to your configure call: ./configure --prefix=/opt/Python2.7a --enable-shared Now you got the shared libraries in the lib folder. Cheers, Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: source install of python2.7 and rpm install of cx_Oracle collision
Hi Jim, Jim Qiu wrote: I make installed python 2.7 from source, and also installed the RPM version of cx_Oracle for python 2.7. But ldd tells me : #ldd cx_Oracle.so libpython2.7.so.1.0 = not found I find out that only libpython2.7.a generated when I install python2.7, who can tell me what I need to do ? I want a libpython2.7.so.1.0 generated when [...] Due to the fact that you have compiled python from source, the python library is not in the defaul library path. Due to that the lib can't be found. As a quick workourd you can extend the LD_LIBRARY_PATH variable with the path and check if cx_Orcacle get now the lib. Lets assume you installed python at /opt/Python2.7a, then you need to extend the variable in this way: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/Python2.7a/lib afterwards do the ldd again and check if the lib could be found now. If not, you've got the wrong path. Now you need to perist the changed library path. For this, you need to be root: 1. echo /opt/Python2.7a/lib /etc/ld.so.conf.d/Pathon2.7a.conf 2. refresh your shared library cache with ldconfig Now you OS knows the new library location. But this is not clean. As Daniel mention, you should try to get a rpm. Otherwise you may get in trouble, if you install a newer Python2.7 version and forget to maintain you library paths. Cheers, Nils -- http://mail.python.org/mailman/listinfo/python-list
[issue1675951] [gzip] Performance for small reads and fix seek problem
Changes by Nils Philippsen n...@redhat.com: -- nosy: +nils ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue1675951 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2504] Add gettext.pgettext() and variants support
Changes by Nils Philippsen n...@redhat.com: -- nosy: +nils ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue2504 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
Re: multiprocessing problems
Hi Doxa, DoxaLogos wrote: [...] I found out my problems. One thing I did was followed the test queue example in the documentation, but the biggest problem turned out to be a pool instantiated globally in my script was causing most of the endless process spawn, even with the if __name__ == __main__: block. Problems who solves them self, are the best problems ;) One tip: currently your algorithm has some overhead. 'Cause you are starting 4 time an additional python interpreter, compute the files and, closing all new spawned interpreter and starting again 4 interpreter, which are processing the files. For such kind of jobs I prefer to start processes once and feeding them with data via a queue. This reduces some overhead and increase runtime performance. This could look like this: (due some pseudo functions not directly executeable - untested) import multiprocessing import Queue class Worker(multiprocessing.Process): def __init__(self, feeder_q, queue_filled): multiprocessing.Process.__init__(self) self.feeder_q = feeder_q self.queue_filled = queue_filled def run(self): serve = True # start infinite loop while serve: try: # scan queue for work, will block process up to 5 seconds. If until then no item is in queue a Queue.Empty will be raised text = self.feeder_q.get(True, timeout=5) if text: do_stuff(text) # very important! tell the queue that the fetched work has been finished # otherwise the feeder_q.join() would block infinite self.input_queue.task_done() except Queue.Empty: # as soon as queue is empty and all work has been enqueued # process can terminate itself if self.queue_filled.is_set() and feeder_q.empty(): serve = False return if __name__ == '__main__': number_of_processes = 4 queue_filled = multiprocessing.Event() feeder_q = multiprocessing.JoinableQueue() process_list =[] # get file name which need to be processed all_files = get_all_files() # start processes for i in xrange(0,number_of_processes): process = Worker(feeder_q, queue_filled) process.start() process_list.append(thread) # start feeding for file in all_files: feeder_q.put(file) # inform processes that all work has been ordered queue_filled.set() # wait until queue is empty feeder_q.join() # wait until all processed have finished their jobs for process in process_list: process.join() Cheers, Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: multiprocessing problems
Hi, Adam Tauno Williams wrote: [...] Here's the guts of my latest incarnation. def ProcessBatch(files): p = [] for file in files: p.append(Process(target=ProcessFile,args=file)) for x in p: x.start() for x in p: x.join() p = [] return Now, the function calling ProcessBatch looks like this: def ReplaceIt(files): processFiles = [] for replacefile in files: if(CheckSkipFile(replacefile)): processFiles.append(replacefile) if(len(processFiles) == 4): ProcessBatch(processFiles) processFiles = [] #check for left over files once main loop is done and process them if(len(processFiles) 0): ProcessBatch(processFiles) According to this you will create files is sets of four, but an unknown number of sets of four. This is not correct, 'cause of the x.join(). This will block the parent process until all processes have been terminated. So as soon as the current set of processes have finished their job, a new set will be spawned. Cheers, Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: Seeding the rand() Generator
Hi Fred, I just saw your SQL Statement An example would be: SELECT first, second, third, fourth, fifth, sixth from sometable order by rand() limit 1 and I feel me constrained to give you an advice. Don't use this SQL statement to pick up a random row, your user and maybe DBA would much appreciate it. You are certainly asking why. Lets have a brief look what you are asking your mysql DB: Fetch all rows from 'sometable', but only with attribute 'first, second,...' sort them all starting at 'random row' and afterward through anything away you did before, but the first line If you have a table with 10 rows you would fetch and sort up to 10 rows, pick up one row and discard up to 9 rows. That sounds not very clever, right? So please take a look at this site to get a better alternate way for that approach: http://jan.kneschke.de/projects/mysql/order-by-rand/ if you want to know more please check this article too: http://jan.kneschke.de/2007/2/22/analyzing-complex-queries regards, Nils -- http://mail.python.org/mailman/listinfo/python-list
performance problem with time.strptime()
Hi everyone, In my free time I translate scripts from open source projects or write my own, to train my python skills. ATM I convert the aplogmerge.pl from awstats. It merges multiple apache logfiles and sort the output by the timestamps of each line. My first version of this script hasn't a good performance, so I started profiling. It turned out that the script spend much time for converting the timestamps of the line into a struct_time object. Here a code example (Python 2.6.2 on Ubuntu 7.10): Rec = re.compile(r^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s-\s\d+\s\[(\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2})\s\+\d{4}\].*) Line = '1.2.3.4 - 4459 [02/Jul/2009:01:50:26 +0200] GET /foo HTTP/1.0 200 - - www.example.org - - -' def strptime(): m = Rec.match(Line) if m: date_string = m.group(1) # date_string example: '02/Jul/2009:01:50:26' return time.strptime(date_string, %d/%b/%Y:%H:%M:%S) with timeit this functions takes approximate 125 sec and 29.004.081 function calls (I've configured timeit with 1.000.000 runs). A look at the output of cProfile told me that more than the half time is spent in locale.py: 102 11.7120.000 19.5920.000 locale.py:316(normalize) 1023.6390.000 23.2310.000 locale.py:382(_parse_localename) 1025.1620.000 30.2710.000 locale.py:481(getlocale) I studied the time documentation and thought that I had to set TZ in os environ: os.environ['TZ'] = 'Europe/Berlin' time.set() but that had no effect. I don't know why time.strptime() looks every time for my locale. Maybe it's a problem with my OS locale... However. I've introduced a work around, which works perfectly for my problem. For time comparison I could use any sort of time representation and so I convert to epoch: # needed to translate month str to dig repr Shortmonth = {'Jan' : '01', 'Feb' : '02', 'Mar' : '03', 'Apr' : '04', 'May' : '05', 'Jun' : '06', 'Jul' : '07', 'Aug' : '08', 'Sep' : '09', 'Oct' : '10', 'Nov' : '11', 'Dec' : '12'} Rec = re.compile(r^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s-\s\d+\s\[(?Pday\d{2})/(?Pmonth\w+)/(?Pyear\d{4}):(?Phour\d{2}):(?Pmin\d{2}):(?Psec\d{2})\s\+\d{4}\].*) Line = '1.2.3.4 - 4459 [02/Jul/2009:01:50:26 +0200] GET /foo HTTP/1.0 200 - - www.example.org - - -' def epoch(): m = Rec.match(Line) if m: result = m.groupdict() date_tuple = (result[year], Shortmonth[result[month]], result[day], result[hour], result[min], result[sec], -1, -1, -1) date_tuple = map(int,date_tuple) return time.mktime(date_tuple) with this workaround I had a speed up to 4 times; it tooks only 31 sec with only 5.000.009 function calls. Maybe this helps some of you, who had the similar problems with time conversion ...But one big question remains: Why time.strptime() checks everytime the locale? had I missed something or could I have a problem with my OS locale? With python 3.1 there is no difference, unless that time.strptime() took approx 12 sec longer... :( regards, Nils Here a complete test script: #!/opt/python/2.6.2/bin/python import time import timeit import cProfile import re # needed to tranlate month str to dig repr Shortmonth = {'Jan' : '01', 'Feb' : '02', 'Mar' : '03', 'Apr' : '04', 'May' : '05', 'Jun' : '06', 'Jul' : '07', 'Aug' : '08', 'Sep' : '09', 'Oct' : '10', 'Nov' : '11', 'Dec' : '12'} Rec1 = re.compile(r^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s-\s\d+\s\[(?Pday\d{2})/(?Pmonth\w+)/(?Pyear\d{4}):(?Phour\d{2}):(?Pmin\d{2}):(?Psec\d{2})\s\+\d{4}\].*) Rec2 = re.compile(r^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s-\s\d+\s\[(\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2})\s\+\d{4}\].*) Line = '1.2.3.4 - 4459 [02/Jul/2009:01:50:26 +0200] GET /foo HTTP/1.0 200 - - www.example.org - - -' def epoch(): m = Rec1.match(Line) if m: result = m.groupdict() date_tuple = (result[year], Shortmonth[result[month]], result[day], result[hour], result[min], result[sec], -1, -1, -1) date_tuple = map(int,date_tuple) return time.mktime(date_tuple) def strptime(): m = Rec2.match(Line) if m: date_string = m.group(1) return time.strptime(date_string, %d/%b/%Y:%H:%M:%S) if __name__ == __main__: t1 = timeit.Timer(epoch(),from __main__ import epoch) t2 = timeit.Timer(strptime(), from __main__ import strptime) cProfile.run(t1.timeit();print) print cProfile.run(t2.timeit();print) -- http://mail.python.org/mailman/listinfo/python-list
Re: performance problem with time.strptime()
Hi Casey Casey Webster wrote: On Jul 2, 7:30 am, Nils Rüttershoff n...@ccsg.de wrote: Rec = re.compile(r^\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3}\s-\s\d+\s\[(\d{2}/\w+/\d{4}:\d{2}:\d{2}:\d{2})\s\+\d{4}\].*) Line = '1.2.3.4 - 4459 [02/Jul/2009:01:50:26 +0200] GET /foo HTTP/1.0 200 - - www.example.org - - -' I'm not sure how much it will help but if you are only using the regex to get the date/time group element, it might be faster to replace the regex with: date_string = Line.split()[3][1:-1] Indeed this would give a little speed up (by 100 iteration approx 3-4 sec). But this would be only a small piece of the cake. Although thx :) The problem is that time.strptime() consult locale.py for each iteration. Here the hole cProfile trace: first with epoch and second with strptime (condensed): 509 function calls in 33.084 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 10.0000.000 33.084 33.084 string:1(module) 12.4172.417 33.084 33.084 timeit-src:2(inner) 1009.6480.000 30.6670.000 time_test.py:30(epoch) 10.0000.000 33.084 33.084 timeit.py:177(timeit) 1003.7110.0003.7110.000 {built-in method groupdict} 1004.3180.0004.3180.000 {built-in method match} 10.0000.0000.0000.000 {gc.disable} 10.0000.0000.0000.000 {gc.enable} 10.0000.0000.0000.000 {gc.isenabled} 1007.7640.0007.7640.000 {map} 10.0000.0000.0000.000 {method 'disable' of '_lsprof.Profiler' objects} 1005.2250.0005.2250.000 {time.mktime} 20.0000.0000.0000.000 {time.time} 2909 function calls in 124.449 CPU seconds Ordered by: standard name ncalls tottime percall cumtime percall filename:lineno(function) 10.0000.000 124.449 124.449 string:1(module) 12.2442.244 124.449 124.449 timeit-src:2(inner) 1003.5000.000 33.5590.000 _strptime.py:27(_getlang) 100 41.8140.000 100.7540.000 _strptime.py:295(_strptime) 1004.0100.000 104.7640.000 _strptime.py:453(_strptime_time) 100 11.6470.000 19.5290.000 locale.py:316(normalize) 1003.6380.000 23.1670.000 locale.py:382(_parse_localename) 1005.1200.000 30.0590.000 locale.py:481(getlocale) 1007.2420.000 122.2050.000 time_test.py:37(strptime) 10.0000.000 124.449 124.449 timeit.py:177(timeit) 1001.7710.0001.7710.000 {_locale.setlocale} 1001.7350.0001.7350.000 {built-in method __enter__} 1001.6260.0001.6260.000 {built-in method end} 1003.8540.0003.8540.000 {built-in method groupdict} 1001.6460.0001.6460.000 {built-in method group} 2008.4090.0008.4090.000 {built-in method match} 10.0000.0000.0000.000 {gc.disable} 10.0000.0000.0000.000 {gc.enable} 10.0000.0000.0000.000 {gc.isenabled} 2002.9420.0002.9420.000 {len} 10.0000.0000.0000.000 {method 'disable' of '_lsprof.Profiler' objects} 3004.5520.0004.5520.000 {method 'get' of 'dict' objects} 1002.0720.0002.0720.000 {method 'index' of 'list' objects} 1001.5170.0001.5170.000 {method 'iterkeys' of 'dict' objects} 2003.1130.0003.1130.000 {method 'lower' of 'str' objects} 2003.2330.0003.2330.000 {method 'replace' of 'str' objects} 2002.9530.0002.9530.000 {method 'toordinal' of 'datetime.date' objects} 1001.4760.0001.4760.000 {method 'weekday' of 'datetime.date' objects} 1004.3320.000 109.0970.000 {time.strptime} 20.0000.0000.0000.000 {time.time} -- http://mail.python.org/mailman/listinfo/python-list
Re: Spam? Re: whizBase vs. Python
NurAzije wrote: On Jun 29, 11:04 am, Tim Harig user...@ilthio.net wrote: On 2009-06-29, NurAzije nuraz...@gmail.com wrote: Hi, I am working on a study and I need expert opinion, I did not work with Python before, can anyone help me with a comparison betweenWhizBase (www.whizbase.com) and Python please. Given posts like:http://groups.google.com/group/Server-side-programing/browse_thread/t... is this just thinly veiled spam? The domain and the posting IP address are both out of Sarajevo, Bosnia. Obviously you alreadly know your product is nothing but a database macro processor. Python is a dynamic programming language and therefore far more capable. Your product is proprietary with less capability while Python is free and powerful. Hi Tim, I am not a spammer, WhizBase is from Sarajevo and I am from Sarajevo, for that it is interesting for me. regards, Ashraf Gheith Hi Ashraf, hm... but it seems you know WhizBase very well, here a blog (http://whizbase-scripting-language.blogspot.com/) of you with very detailed information about WhizBase. Why you are asking nearly any programming list/group about the difference?: http://www.highdots.com/forums/javascript-discussion-multi-lingual/whizbase-vs-javascript-281242.html http://groups.google.com/group/alt.comp.lang.learn.c-c++/browse_thread/thread/a7a47adb904319ad http://groups.google.com/group/comp.lang.lisp/browse_thread/thread/9dfa76ad94d75168/01a999b7b8638621?lnk=raot http://www.mail-archive.com/dotnetdevelopm...@googlegroups.com/msg07381.html Hm here the main blog: http://whizbase.blogspot.com/ There is a second contributer Faik Djikic and Whizbase is from a company called Djikic Software Development.. What's the Topic of your study? Whizbase compared to other languages? Why Whizbase? Is your study public and if so were we could read it? ;) Regards, Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: seeking thru a file
Hi Mag, Mag Gam wrote: I have a compressed CSV gziped file. I was wondering if it is possible to seek thru a file For example: I want to load the first 100 lines into an array. Process the data Seek from 101 line to 200 lines. Process the data (remove lines 0 - 100) from memory Seek 201 to 300 line. Process the data (remove 200-300)) from memory etc..etc.. This would be very easy. Here is one way you could do it: (I didn't test the code; I've just write it down, assuming you use python 2.6, cause you didn't mentioned which version you are using...) import gzip step = 100 data_present = True with gzip.open(foo.csv.gzip) as my_file: counter = 0 my_buffer = [] while data_present: while counter = step: line = my_file.readline() if line: my_buffer.append(my_file.readline()) counter += 1 else: data_present = False break if len(my_buffer) 0: do_something(my_buffer) counter = 0 my_buffer = [] Kind Regards, Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: Python Query: Related to locking a resource in a multithreaded environment
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi, I don't think the global interpreter lock is what you need ... read here for reference: http://docs.python.org/api/threads.html My approach what be to write one class for reading and writing to the configuration and make that class thread-safe using the RLock. Then you create one and only one instance of this class and let all your threads use (not import) that one instance. You could achieve that one and only one either by having a main program which creates the instance and pass the reference to each thread via its __init__ or you implement the Configuration class as a singleton like this: class Singleton(object): A simple example implementing the singleton design pattern in python #we need two class attributes (which translate to static attributes in java) __lock = Lock() #a lock for thread safety __instance = None #and to remember the one instance #first of all: make pythons usual way of creating objects # unusable because we cannot just hide them as one would in java # or C++ def __new__(cls, *args, **kwargs): pass def __init__(self): pass @classmethod def getInstance(cls, *args, **kwargs): The famous gatInstance method which resturns the one instance of our class. params: cls - reference to the class *args - the tuple of arguments paassed by position **kwargs - the dictionary of arguments passed by keyword #enter critical section cls.__lock.acquire() try: if cls.__instance is None: #use the superclasses __new__ for creation cls.__instance = object.__new__(cls, *args, **kwargs) #place initialisation code (everything which #would usually happen in __init__) here cls.__instance.SomeInt = 1 finally: #leave critical section cls.__lock.release() return cls.__instance Add your methods for accessing as instance methods to this class and get the same instance of this class in each thread by calling Singleton.getInstance(). Hope that helps Regards Nils tarun schrieb: I think I need something called global interpreter lock which is accessible to all the threads. But I am not sure how to implement this. On Tue, Aug 19, 2008 at 11:28 AM, tarun [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hello All, I've a configuration.ini file. This particular can be accessed by several threads of my application. Each thread can read/write configuration parameters from/to the configuration.ini file. I am using threading (Rlock) to lock the resource (configuration.ini file) while accessing it from any thread. I use the file available at http://www.voidspace.org.uk/python/configobj.html for read/write. I did the following in one of my files: import threading class Synchronization: def __init__(self): self.mutex = threading.RLock() Now this I can create instances of the class Synchronization and use acquire/release to work on the shared resource. But every thread would need to import this class and hence each thread would create a separate instance of the class. This means several lock variables. But I think we need a global lock flag that is accessible across all the threads. How do i do this? Please let me know ASAP. Thanks In Advance, Tarun -- http://mail.python.org/mailman/listinfo/python-list -BEGIN PGP SIGNATURE- iD8DBQFIqxfCzvGJy8WEGTcRApe+AJ9MNqWI9FOsJIKuTKxy8ZNSGYTy2gCdHtGc clDPMMAPRoIxsBvVm4ygi6U= =vIPW -END PGP SIGNATURE- begin:vcard fn;quoted-printable:Nils Oliver Kr=C3=B6ger n;quoted-printable:Kr=C3=B6ger;Nils Oliver email;internet:[EMAIL PROTECTED] version:2.1 end:vcard -- http://mail.python.org/mailman/listinfo/python-list
Re: Cant run application as ./myapp.py
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hi Robert, I have to guesses: a) The user as which you are trying to run the script is missing the execute right - fix by chmod u+x MyApplication.px b) You did not specify the interpreter - the first line of your script should look something like #!/usr/bin/python If none of this is the problem please post the error message you (hopefully) get. hth Nils Robert Rawlins schrieb: Hello Guys, I’ve got an application here which for some reason won’t start using the following syntax from the command line: Cd /mydirectory ./MyApplication.py I have to run this as a fully qualified python launch such as: Cd /mydirectory python MyApplication.py This is a little bit confusing to me as I have other applications which run just fine using the ./somthing.py syntax. Is there any reason why this doesn’t work? Cheers, Robert -BEGIN PGP SIGNATURE- iD8DBQFHzALBzvGJy8WEGTcRAtE8AJ4jGFTjZ8G8ayZM2AUcLcArnF5d1QCdH0gj kCdp0414HwPaIMIDv/SSTZA= =tF3K -END PGP SIGNATURE- begin:vcard fn;quoted-printable:Nils Oliver Kr=C3=B6ger n;quoted-printable:Kr=C3=B6ger;Nils Oliver email;internet:[EMAIL PROTECTED] version:2.1 end:vcard -- http://mail.python.org/mailman/listinfo/python-list
Re: Exception or not
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello, I don't think it is a good pattern because you are kind of mixing exceptions with return codes which makes the code a lot less readable later on. I personally would strongly opt for return codes in this case as one would intuitively expect a function named validateThisAndThat to return the result of a validation. This might me a simple true/false, a numeric code with 0=OK, 1=password not correct, 2=user does not exist or a string, whatever you need. In my opinion, such a function should raise an exception if it is unable to fullfill its task. For example lost connection to user database or things like that. A function should never propagate an expected result as an exception. Greetings Nils Monica Leko schrieb: | Suppose you have some HTML forms which you would like to validate. | Every field can have different errors. For example, this are the | forms: | | username | password | etc | | And you want to validate them with some class. Is this good pattern: | | class Foo(object): | def validateUsername(username): | if username isn't correct: | raise ValidationError() | def validatePassword(password): | if password isn't correct: | raise ValidationError() | | code: | try: | usernameError = validateUsername() | except ValidationError: | usernameError = error from exception | try: | passwordError = validatePassword() | except ValidationError: | passwordError = error from exception | | So, if there wasn't any errors, usernameError and passwordError both | contains None, and there was error, both contains some string? Should | I use exception or just return None or some string without | exception? -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFHzCGhzvGJy8WEGTcRAvbGAJoDjn39xCmiOLmkc//0RTfeVXJFTACePRIG uYoDiQBZwRsShUn60LN/9oQ= =zvAY -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: how to iterate over sequence and non-sequence ?
On Oct 19, 10:58 am, Steven D'Aprano [EMAIL PROTECTED] wrote: On Fri, 19 Oct 2007 01:24:09 +0200, stef mientki wrote: hello, I generate dynamically a sequence of values, but this sequence could also have length 1 or even length 0. So I get some line in the form of: line = '(2,3,4)' line = '' line = '(2)' (in fact these are not constant numbers, but all kind of integer variables, coming from all over the program, selected from a tree, that shows all reachable variables) So in fact I get the value from an exec statement, like this exec 'signals = ' + line And then, one day, somebody who doesn't like you will add the following to your input data: 0; import os; os.system('rm # -rf /') [ Kids: don't try this at home! Seriously, running that command will be bad for your computer's health. Or at least it would, if I hadn't put a spike in it. ] Don't use exec in production code unless you know what you're doing. In fact, don't use exec in production code. Now I want to iterate over signals, which works perfect if there are 2 or more signals, but it fails when I have none or just 1 signal. for value in signals : do something No, I would say it already failed before it even got there. line = '' exec 'signals = ' + line Traceback (most recent call last): File stdin, line 1, in ? File string, line 1 signals = ^ SyntaxError: unexpected EOF while parsing This is the right way to deal with your data: input_data = (2, 3 , 4) (2) (3,4,5) ( 1, 2,3) for line in input_data.split('\n'): line = line.strip().strip('()') values = line.split(',') for value in values: value = value.strip() if value: print(value) As this meant for real-time signals, I want it fast, so (I think) I can't afford extensive testing. Don't guess, test it and see if it is fast enough. Some speed ups: If you're reading from a file, you can just say: for line in file: instead of slurping the whole lot into one enormous string, then splitting over newlines. If you can guarantee that there is no extra whitespace in the file, you can change the line line = line.strip().strip('()') to the following: line = line.strip('\n()') and save a smidgen of time per loop. Likewise, drop the value = value.strip() in the inner loop. -- Steven. why not: for i in eval('(1,2,3)'): ... print i 1 2 3 -- http://mail.python.org/mailman/listinfo/python-list
Re: dynamic invoke
On Oct 19, 12:39 pm, [EMAIL PROTECTED] wrote: Hello, Is there any way (other then eval) to invoke a method by passing method name in a string. It's very simple in php: $oFoo = new Foo(); $dynamiMethod = bar; $oFoo-$dynamiMethod(); Unfortunately I can't find a good solution to do the same thing in python. Does it have some build-in function to do it? Kind Regards, Lukasz. Use apply(): http://docs.python.org/lib/non-essential-built-in-funcs.html Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: Threads and racing conditions
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Flavio Preto schrieb: Hi, I have a doubt. Supose that i have the minimun class below: class db: def __init__(self): self.db = {} def read(self, key): return self.db[key] def write(self, key, value): self.db[key] = value and an object of this class is shared among some threads. Is it possible that in a read, the method return a value that is not an old or a new value? In other words, is it possible that a 'read' return (due to a 'write' at the same time by another thread) an invalid value that was never supposed to be there? Thanks, Flavio Preto Make the class thread safe by using Lock or RLock ... that will save you a lot of trouble. Your limited example might or might not work, but once your class gets more complex you will most likely run into serious problems. Greetings Nils -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGzHsizvGJy8WEGTcRAgN1AJ42cM1P/NW7Ei3F5ViSsmTcKDvCIgCeIUGG GD7DAb3f+Lmcav663F+wkQg= =kJ0G -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Class destruction
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Robert Dailey schrieb: Hi, I'm wondering where the most appropriate location is to cleanup class objects. For example, i have a file handle as an instance attribute in one of my classes and I need to call f.close() on it when the class object falls out of scope. Any ideas? I've tried __del__() but I don't remember this working for some reason. I might try it again later just to be positive. __del__(self) is the perfectly right place for such cleanup ... it gets called once your instance is either deleted explicitly by you or it's handled by the garbage collector when there are no more references. The possible problem why this did not work four you is, that the destruction by the garbage collector cannot be predicted ... it may well take some time. If you try to open the same file from another class before yours gets cleaned you run into trouble. If you want to reuse the file, you will have to delete your classes instance explicitly using the del statement ... this will also call the destructor. The below code works fine: def __del__( self ): self._file.close() print File closed Hope that helps ... Nils -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGzISBzvGJy8WEGTcRAiOwAJ94fJza4/GVQsFmbXwsP8kdvQjV5wCfQktw F/zPJAw0ayjYe5MGxPR1YqI= =4Hl6 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: Python is removing my quotes!
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Robert Dailey schrieb: Thank you for your response. The back slashes work! It's a bit annoying; but I have Microsoft to thank for that. It's not Microsoft, you would experience the same problems under any Unix I know of. At least the bash treats quotes as special characters, so does afaik the sh and a couple of other shells in the Unixverse. You will also need to escape blanks and depending on the shell a number of other special characters (like for example the pipe). Greetings Nils -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGyye3zvGJy8WEGTcRAuWiAJ9SVUmNtQDkeGO1zBIXLeL548kXswCeMAEA zYMRE8LSV/9kYiAQkCz1PAU= =oDke -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: How to optimise this code?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David N Montgomery schrieb: class testCase: def __init__(self, tc): if tc == 1:self.testCase1() if tc == 2:self.testCase2() if tc == 3:self.testCase3() if tc == 4:self.testCase4() if tc == 5:self.testCase5() if tc == 6:self.testCase6() def testCase1(self): print tc1 def testCase2(self): print tc2 def testCase3(self): print tc3 def testCase4(self): print tc4 def testCase5(self): print tc5 def testCase6(self): print tc6 def testCaseX(self): print tcX totalNumberOfTestCases = 6 x = 0 while x = totalNumberOfTestCases: x += 1 testCase(x) This template code is working, but I envisage having 100+ test cases and am concerned about my useage of if statements. I would be grateful for any pointers as to how I can run all tests cases, regardless of how many, in a more efficient manner. Thank you in advance. Hi, generally a flexible way to avoid huge blocks of if elsif elsif elsif ... ad infintum is to use pythons built in dictionary like this: class Test: def __init__(self): self.cases = {1:self.test1, 2:self.test2, 3:self.test3 } self._member = I'm Test def test1(self, param): print one print param print self._member def test2(self, param): print two print param print self._member def test3(self, param): print three print param print self._member if __name__ == __main__: t = Test() for x in range(1, 4): t.cases[x](x) hope that helps ... -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.6 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFGyyDxzvGJy8WEGTcRAn2XAJ97z8o6Sxpi7euPtPUsm/FrD1bgEgCfeRcs TKzwnkIdbs3GRI0yXcVUugM= =HIJc -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Interpreter window
I have created a Python application in Windows XP which uses WxWidgets. When I start the application from the Python interpreter I get one empty interpreter window in addition to the application window. Is there a way to close the interpreter window without closing the application? Or, can I start the interpreter and the application script without starting the interpreter window? -- http://mail.python.org/mailman/listinfo/python-list
Re: Interpreter window
On 2 Feb, 13:07, skyofdreams [EMAIL PROTECTED] wrote: Nils Overas Bergen [EMAIL PROTECTED] [EMAIL PROTECTED] I have created a Python application in Windows XP which uses WxWidgets. When I start the application from the Python interpreter I get one empty interpreter window in addition to the application window. Is there a way to close the interpreter window without closing the application? Or, can I start the interpreter and the application script without starting the interpreter window? do you mean console window? you can try pythonw.exe instead of python.exe -sods Thanks! Now my application starts without the console window. Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: pdf to text
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 have a look at the pdflib (www.pdflib.com). Their Text Extraction Toolkit might be what you are looking for, though I'm not sure whether you can use it detached from the pdflib itself. hth Nils tubby schrieb: I know this question comes up a lot, so here goes again. I want to read text from a PDF file, run re searches on the text, etc. I do not care about layout, fonts, borders, etc. I just want the text. I've been reading Adobe's PDF Reference Guide and I'm beginning to develop a better understanding of PDF in general, but I need a bit of help... this seems like it should be easier than it is. Here's some code: import zlib fp = open('test.pdf', 'rb') bytes = [] while 1: byte = fp.read(1) #print byte bytes.append(byte) if not byte: break for byte in bytes: op = open('pdf.txt', 'a') dco = zlib.decompressobj() try: s = dco.decompress(byte) #print op, s print s except Exception, e: print e op.close() fp.close() I know the text is compressed... that it would have stream and endstream makers and BT (Begin Text) and ET (End Text) and that the uncompressed text is enclosed in parenthesis (this is my text). Has anyone here done this in a simple fashion? I've played with the pyPdf library some, but it seems overly complex for my needs (merge PDFs, write PDFs, etc). I just want a simple PDF text extractor. Thanks -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.3 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFFuSPozvGJy8WEGTcRAnY0AJ0VZez3XRbLm/JXZKhn/rgHP0R3qwCfWAnT EupBECHab2kG33Rmnh+xf74= =INM5 -END PGP SIGNATURE- -- http://mail.python.org/mailman/listinfo/python-list
Re: calling a class instance of function
Hi, Methods i.e functions bound to a class instance (or object) the self argument in their definition: [code] class pid: def add(self, toadd): pass #or some sensible code [/code] If you want to define a method without that implicit self argument you'll have to make this method a static: [code] class pid: @staticmethod def staticadd (param1, param2): pass #or some sensible code [/code] Furthermore, your test() seems to be rather a function than a class: You want to use this function to test the pid class but what you do with your code below is to define a class test which inherits pid. I'm not really sure what the following lines do ... this would usually be the place to introduce class variables. Hope that Helps! Greetings Nils Original-Nachricht Datum: 21 Dec 2006 11:09:32 +1100 Von: Pyenos [EMAIL PROTECTED] An: python-list@python.org Betreff: calling a class instance of function class pid: pid def add(original_pid,toadd): add pid original_pid.append(toadd) return original_pid def remove(something_to_remove_from,what): remove pid something_to_remove_from.remove(what) return something_to_remove_from def modify(source,element,changewiththis): modify pid source[source.index(element)]=changewiththis return source class test(pid): pid.original=[1,2,3] pid.toadd=4 pid.add(pid.original,pid.toadd) # error here says that # it expects pid instance as first arg # not a list that it got. why do i get an error? -- http://mail.python.org/mailman/listinfo/python-list -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer -- http://mail.python.org/mailman/listinfo/python-list
Re: what is wrong with my code?
Hi, this is the line that breaks your code: def progressTable(progress_table, action, task, pid=len(progress_table) your parameter progress_table is known inside the function, not inside its definition. So pid=len(progress_table) won't do. If you really think that it is possible that pid is anything else but len(progress_table), you should use for example -1 as the default value and calculate the length inside your functions if the parameter is not different. Otherwise dump this parameter. Hope that helps! Greetings Nils Original-Nachricht Datum: 21 Dec 2006 09:16:58 +1100 Von: Pyenos [EMAIL PROTECTED] An: python-list@python.org Betreff: what is wrong with my code? import cPickle, shelve could someone tell me what things are wrong with my code? class progress: PROGRESS_TABLE_ACTIONS=[new,remove,modify] DEFAULT_PROGRESS_DATA_FILE=progress_data PROGRESS_OUTCOMES=[pass, fail] def unpickleProgressTable(pickled_progress_data_file): return unpickled_progress_table def pickleProgressTable(progress_table_to_pickle): return pickled_progress_data_file # Of course, you get progress_table is unpickled progress table. def progressTable(progress_table, action, task, pid=len(progress_table), outcome=PROGRESS_OUTCOMES[1]): pid_column_list=progress_table[0] task_column_list=progress_table[1] outcome_column_list=progress_table[2] # But a task must also come with an outcome! def newEntry(new_task, new_outcome): new_pid=len(task_column_list) pid_column_list.extend(new_pid) task_column_list.extend(new_task) outcome_column_list.extend(new_outcome) def removeEntry(pid_to_remove, task_to_remove): if pid_column_list.index(pid_to_remove)==task_column_list.index(task_to_remove): # Must remove all columns for that task index_for_removal=pid_column_list.index(pid_to_remove) pid_column_list.remove(index_for_removal) task_column_list.remove(index_for_removal) outcome_column_list.remove(index_for_removal) # Default action is to modify to pass def modifyEntry(pid_to_modify, outcome_to_modify=PROGRESS_OUTCOMES[0]): index_for_modifying=pid_column_list.index(pid_to_modify) # Modify the outcome outcome_column_list[index_for_modifying]=outcome_to_modify -- http://mail.python.org/mailman/listinfo/python-list -- Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer -- http://mail.python.org/mailman/listinfo/python-list
Google code search (Was: Names changed to protect the guilty)
Google has a cool new service. http://www.google.com/codesearch You can use regular expressions! (I found at least 13 distinct utilities that used the idiom.) Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: Letting a Python application phone home
Am Freitag, 14. Juli 2006 15:26 schrieb Dieter Vanderelst: This is surely possible. You need to define a protocol for the communication between client and server. As you are planning to send data over the internet you should build it on top of tcp. Look at the python module socket resp. SocketServer for low level tcp functions. As the data should not be visible to everyone you need some kind of encryption. Either you rely on the ssl capabilities of the socket module, this way securing the transport layer (tcp) or you build encryption into your newly designed application layer protocol. For the latter have a look at the python cryptography toolkit. Sorry I have no url at hand, simply google. Concerning the question of stopping the program when the internet connection breaks: let your program contact the server periodically. If this fails quit the program. Regards Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: The Nature of the “Unix Philosophy”
Xah Lee wrote: The Nature of the “Unix Philosophy” Xah Lee, 2006-05 In the computing industry, especially among unix community, we often hear that there's a “Unix Philosophy”. In this essay, i dissect the nature and characterization of such “unix philosophy”, as have been described by Brian Kernighan, Rob Pike, Dennis Ritchie, Ken Thompson, and Richard P Gabriel et al, and in recent years by Eric Raymond. There is no one definite set of priciples that is the so-called “unix philosophy”, but rather, it consistest of various slogans developed over the decades by unix programers that purport to describe the way unix is supposed to have been designed. The characteristics include: “keep it simple”, “make it fast”, “keep it small”, “make it work on 99% of cases, but generality and correctness are less important”, “diversity rules”, “User interface is not important, raw power is good”, “everything should be a file”, “architecture is less important than immediate workability”. Often, these are expressed by chantible slogans that exhibits juvenile humor, such as “small is beautiful”, “KISS (Keep It Simple, Stupid)”. Perhaps you should take a peek at the ideas in Plan 9 from Bell Labs, which is a continuation of this philosophy, unlike the modern unix clones. -- http://mail.python.org/mailman/listinfo/python-list
Re: round() wrong in Python 2.4?
I am running Debian unstable for 386. Python 2.4 is from the official package archive, and seems to be compiled with GCC 4.0.2. $ dpkg -l python2.4 ii python2.4 2.4.1-4 ... $ python2.4 Python 2.4.1+ (#2, Sep 4 2005, 21:58:51) [GCC 4.0.2 20050821 (prerelease) (Debian 4.0.1-6)] on linux2 Type help, copyright, credits or license for more information. $ gcc-4.0 --version gcc-4.0 (GCC) 4.0.2 20050725 (prerelease) (Debian 4.0.1-3) Klem fra Nils -- http://mail.python.org/mailman/listinfo/python-list
round() wrong in Python 2.4?
Why did round() change in Python 2.4? $ python2.3 Python 2.3.5 (#2, Jun 19 2005, 13:28:00) [GCC 3.3.6 (Debian 1:3.3.6-6)] on linux2 round(0.0225, 3) 0.023 %.3f % round(0.0225, 3) '0.023' $ python2.4 Python 2.4.1 (#2, Jul 12 2005, 09:22:25) [GCC 4.0.1 (Debian 4.0.1-1)] on linux2 round(0.0225, 3) 0.021999 %.3f % round(0.0225, 3) '0.022' (Is this due to the different GCC used?) How do you correctly output floating-point numbers in 2.4? I do not like the print number + EPS solution, as you would need different EPS for different exponent sizes. In C you could get it by taking integer 1, and -ing in the right exponent, and then casting to double via void*. This would not be very portable, though. Klem fra Nils -- http://mail.python.org/mailman/listinfo/python-list
Re: Comm. between Python and PHP
Hello Python is perfectly capable of generating HTML. You don't have to demean yourself by working in PHP. Thanks for the tip about using Python instead of PHP to generate web pages. I may follow it. Nils Emil -- My reply-address is valid. www.bios-flash.dk Min svar-adresse er gyldig. Redning af døde BIOS'er -- http://mail.python.org/mailman/listinfo/python-list