commit python-posix_ipc for openSUSE:Factory
Hello community, here is the log from the commit of package python-posix_ipc for openSUSE:Factory checked in at 2016-11-24 21:22:46 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/python-posix_ipc (Old) and /work/SRC/openSUSE:Factory/.python-posix_ipc.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "python-posix_ipc" Changes: -------- --- /work/SRC/openSUSE:Factory/python-posix_ipc/python-posix_ipc.changes 2015-02-18 12:08:51.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.python-posix_ipc.new/python-posix_ipc.changes 2016-11-24 21:22:47.000000000 +0100 @@ -1,0 +2,8 @@ +Mon Nov 14 14:02:43 UTC 2016 - dmueller@suse.com + +- update to 1.0.0: + * Added ability to pass names as unicode in Python 2. + * Added ability to pass names as bytes in Python 3. + * Made unit tests nicer by taking advantage of Python 2.7+ + +------------------------------------------------------------------- Old: ---- posix_ipc-0.9.9.tar.gz New: ---- posix_ipc-1.0.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ python-posix_ipc.spec ++++++ --- /var/tmp/diff_new_pack.eyt6FE/_old 2016-11-24 21:22:48.000000000 +0100 +++ /var/tmp/diff_new_pack.eyt6FE/_new 2016-11-24 21:22:48.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package python-posix_ipc # -# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,7 +17,7 @@ Name: python-posix_ipc -Version: 0.9.9 +Version: 1.0.0 Release: 0 Summary: POSIX IPC primitives for Python License: BSD-3-Clause ++++++ posix_ipc-0.9.9.tar.gz -> posix_ipc-1.0.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/PKG-INFO new/posix_ipc-1.0.0/PKG-INFO --- old/posix_ipc-0.9.9/PKG-INFO 2014-11-14 16:09:24.000000000 +0100 +++ new/posix_ipc-1.0.0/PKG-INFO 2015-03-12 02:08:28.000000000 +0100 @@ -1,12 +1,12 @@ Metadata-Version: 1.1 Name: posix_ipc -Version: 0.9.9 +Version: 1.0.0 Summary: POSIX IPC primitives (semaphores, shared memory and message queues) for Python Home-page: http://semanchuk.com/philip/posix_ipc/ Author: Philip Semanchuk Author-email: philip@semanchuk.com License: http://creativecommons.org/licenses/BSD/ -Download-URL: http://semanchuk.com/philip/posix_ipc/posix_ipc-0.9.9.tar.gz +Download-URL: http://semanchuk.com/philip/posix_ipc/posix_ipc-1.0.0.tar.gz Description: posix_ipc is a Python module (written in C) that permits creation and manipulation of POSIX inter-process semaphores, shared memory and message queues on platforms supporting the POSIX Realtime Extensions a.k.a. POSIX diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/ReadMe.html new/posix_ipc-1.0.0/ReadMe.html --- old/posix_ipc-0.9.9/ReadMe.html 2014-11-14 16:04:30.000000000 +0100 +++ new/posix_ipc-1.0.0/ReadMe.html 2015-03-12 02:06:18.000000000 +0100 @@ -4,7 +4,7 @@ <head> <meta name="author" content="Philip Semanchuk"> - <meta name="copyright" content="All contents © 2014 Philip Semanchuk"> + <meta name="copyright" content="All contents © 2015 Philip Semanchuk"> <meta name="keywords" content="python posix ipc semaphore shared memory message queue"> <title>POSIX IPC for Python</title> @@ -30,14 +30,6 @@ pre { margin-left: 2em; } - #download_box { - float: right; - width: 12em; - background-color: #d0d0a9; - border: 1px solid #666; - padding: .33em; - } - /* This style is only present on the local version of the readme. In the online version, the RSS feed is displayed. */ div.rss { display: none; } @@ -66,16 +58,16 @@ the platform notes below</a> for more details. </p> -<p>This module works under Python 2.4 – 3.4. It is released +<p>This module works under Python 2.7 and 3.x. It is released under a BSD license. </p> <p>You can <strong>download -<a href="posix_ipc-0.9.9.tar.gz">posix_ipc version 0.9.9</a> +<a href="posix_ipc-1.0.0.tar.gz">posix_ipc version 1.0.0</a> </strong> -<a href="posix_ipc-0.9.9.md5.txt">[MD5 sum]</a> -<a href="posix_ipc-0.9.9.sha1.txt">[SHA1 sum]</a> +<a href="posix_ipc-1.0.0.md5.txt">[MD5 sum]</a> +<a href="posix_ipc-1.0.0.sha1.txt">[SHA1 sum]</a> which contains the source code, setup.py, installation instructions, tests, and <a href="#samples">sample code</a>. The exact same @@ -435,7 +427,7 @@ <dd> Closes the file descriptor associated with this SharedMemory object. Calling <tt>close_fd()</tt> is the same as calling - <tt><a href="http://www.python.org/doc/2.6/library/os.html#os.close">os.close()</a></tt> + <tt><a href="https://docs.python.org/2/library/os.html#os.close">os.close()</a></tt> on a SharedMemory object's <tt>fd</tt> attribute. <p>You must call <tt>close_fd()</tt> or <tt>os.close()</tt> @@ -685,11 +677,12 @@ <h4 id="samples">Sample Code</h4> -<p>This module comes with three demonstrations. The first (in the +<p>This module comes with four demonstrations. The first (in the directory <tt>demo</tt>) shows how to use shared memory and semaphores. The second (in the directory <tt>demo2</tt>) shows how to use message queues. The third (<tt>demo3</tt>) shows how to use message queue -notifications. +notifications. The fourth (<tt>demo4</tt>) shows how to use a semaphore in +a context manager. </p> <h4>Nobody Likes a Mr. Messy</h4> @@ -783,25 +776,23 @@ <p>For Pythonistas –</p> <ul> - <li><a href="http://www.youtube.com/watch?v=13JK5kChbRw">A meditation on the + <li><a href="https://www.youtube.com/watch?v=VKHFZBUTA4k">A meditation on the inaccuracy of shared memories</a> </li> </ul> - <h3><a name="KnownBugs">Known Bugs</a></h3> -<p>I don't know of any bugs in this code. However, under Python 3 the -standard library modules accept bytes and bytearray objects for filenames in -addition to strings. One could argue that this module should behave the -same way. -</p> +<p>I don't know of any bugs in this code.</p> -<p>Also, this module doesn't support Python 3 memory views, which it -probably should (for shared memory objects). Support for that might come in -a later version. -</p> +<h3>Support for Older Pythons</h3> +<p> +If you need to support Python < 2.7, try +<a href="posix_ipc-0.9.9.tar.gz">posix_ipc version 0.9.9</a> +<a href="posix_ipc-0.9.9.md5.txt">[MD5 sum]</a> +<a href="posix_ipc-0.9.9.sha1.txt">[SHA1 sum]</a>. +</p> <h2 id="platforms">Platform Notes</h2> @@ -849,7 +840,7 @@ </p> </dd> - <dt>OS X (up to and including 10.9)</dt> + <dt>OS X (up to and including 10.10)</dt> <dd> Message queues are not supported by OS X. Also, <tt>sem_getvalue()</tt> and <tt>sem_timedwait()</tt> are not diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/VERSION new/posix_ipc-1.0.0/VERSION --- old/posix_ipc-0.9.9/VERSION 2014-11-14 16:06:00.000000000 +0100 +++ new/posix_ipc-1.0.0/VERSION 2015-03-12 02:00:45.000000000 +0100 @@ -1 +1 @@ -0.9.9 \ No newline at end of file +1.0.0 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/history.html new/posix_ipc-1.0.0/history.html --- old/posix_ipc-0.9.9/history.html 2014-11-14 15:56:52.000000000 +0100 +++ new/posix_ipc-1.0.0/history.html 2015-03-12 02:03:52.000000000 +0100 @@ -4,7 +4,7 @@ <head> <meta name="author" content="Philip Semanchuk"> - <meta name="copyright" content="All contents © 2012 Philip Semanchuk"> + <meta name="copyright" content="All contents © 2015 Philip Semanchuk"> <meta name="keywords" content="python posix ipc semaphore shared memory message queue"> <title>The posix_ipc Module for POSIX IPC Under Python -- Version History</title> @@ -27,7 +27,23 @@ <a href="http://semanchuk.com/philip/posix_ipc/">posix_ipc module</a>.</p> +<p>As of version 1.0.0, I consider this module complete. I will continue to +suppport it and look for useful features to add, but right now I don't see any. +</p> + <ul id="history"> + + <li><strong><span id="current">Current</span> – 1.0.0 (11 Mar 2015) –</strong> + <ul> + <li>Added ability to pass names as unicode in Python 2.</li> + <li>Added ability to pass names as bytes in Python 3.</li> + <li>Dropped support for Python < 2.7.</li> + <li>Made unit tests nicer by taking advantage of Python 2.7+ + certainty and removed some code that only supported Python 2.6. + </li> + </ul> + </li> + <li><strong><span id="current">Current</span> – 0.9.9 (14 Nov 2014) –</strong> <ul> <li>Added the ability to build on platforms that don't support the diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/posix_ipc_module.c new/posix_ipc-1.0.0/posix_ipc_module.c --- old/posix_ipc-0.9.9/posix_ipc_module.c 2014-10-25 05:13:01.000000000 +0200 +++ new/posix_ipc-1.0.0/posix_ipc_module.c 2015-03-12 01:44:06.000000000 +0100 @@ -251,6 +251,11 @@ char *p_name_as_c_string = NULL; #endif + DPRINTF("inside convert_name_param\n"); + DPRINTF("PyBytes_Check() = %d \n", PyBytes_Check(py_name_param)); + DPRINTF("PyString_Check() = %d \n", PyString_Check(py_name_param)); + DPRINTF("PyUnicode_Check() = %d \n", PyUnicode_Check(py_name_param)); + p_name->is_none = 0; // The name can be None or a Python string @@ -260,13 +265,22 @@ p_name->is_none = 1; } #if PY_MAJOR_VERSION > 2 - else if (PyUnicode_Check(py_name_param)) { - // The caller passed me a Unicode string; I need a char *. Getting - // from one to the other takes a couple steps. - - // PyUnicode_FSConverter() converts the Unicode object into a - // bytes or a bytearray object. (Why can't it be one or the other?!?) - PyUnicode_FSConverter(py_name_param, &py_name_as_bytes); + else if (PyUnicode_Check(py_name_param) || PyBytes_Check(py_name_param)) { + DPRINTF("name is Unicode or bytes\n"); + // The caller passed me a Unicode string or a byte array; I need a + // char *. Getting from one to the other takes a couple steps. + + if (PyUnicode_Check(py_name_param)) { + DPRINTF("name is Unicode\n"); + // PyUnicode_FSConverter() converts the Unicode object into a + // bytes or a bytearray object. (Why can't it be one or the other?) + PyUnicode_FSConverter(py_name_param, &py_name_as_bytes); + } + else { + DPRINTF("name is bytes\n"); + // Make a copy of the name param. + py_name_as_bytes = PyBytes_FromObject(py_name_param); + } // bytes_to_c_string() returns a pointer to the buffer. p_name_as_c_string = bytes_to_c_string(py_name_as_bytes, 0); @@ -286,7 +300,8 @@ release_bytes(py_name_as_bytes); } #else - else if (PyString_Check(py_name_param)) { + else if (PyString_Check(py_name_param) || PyUnicode_Check(py_name_param)) { + DPRINTF("name is string or unicode\n"); // PyMalloc memory and copy the user-supplied name to it. p_name->name = (char *)PyMem_Malloc(PyString_Size(py_name_param) + 1); if (p_name->name) { @@ -825,7 +840,7 @@ /* else acquisition failed for some reason so just fall through to the return statement below and return NULL. Semaphore_acquire() has already called PyErr_SetString() to set the relevant error. - */ + */ Py_DECREF(args); @@ -1818,9 +1833,9 @@ Py_XDECREF(py_result); - /* Release the thread. No Python API allowed beyond this point. */ + /* Release the thread. No Python API allowed beyond this point. */ DPRINTF("Calling PyGILState_Release()\n"); - PyGILState_Release(gstate); + PyGILState_Release(gstate); DPRINTF("exiting thread\n"); }; @@ -2544,9 +2559,9 @@ PyModule_AddIntConstant(module, "QUEUE_MESSAGE_SIZE_MAX_DEFAULT", QUEUE_MESSAGE_SIZE_MAX_DEFAULT); PyModule_AddIntConstant(module, "QUEUE_PRIORITY_MAX", QUEUE_PRIORITY_MAX); #ifdef SIGRTMAX - // SIGRTMIN and SIGRTMAX are only defined on platforms that support - // the Realtime Signals Extension (RTS). NetBSD prior to 6.0 is an - // example of a platform that doesn't support RTS. + // SIGRTMIN and SIGRTMAX are only defined on platforms that support + // the Realtime Signals Extension (RTS). NetBSD prior to 6.0 is an + // example of a platform that doesn't support RTS. PyModule_AddIntConstant(module, "USER_SIGNAL_MIN", SIGRTMIN); PyModule_AddIntConstant(module, "USER_SIGNAL_MAX", SIGRTMAX); #endif diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/prober.py new/posix_ipc-1.0.0/prober.py --- old/posix_ipc-0.9.9/prober.py 2014-02-21 05:10:06.000000000 +0100 +++ new/posix_ipc-1.0.0/prober.py 2015-03-09 04:05:04.000000000 +0100 @@ -3,7 +3,7 @@ import os import sys -# Set these to None for compile/link debugging or subprocess.PIPE to silence +# Set these to None for compile/link debugging or subprocess.PIPE to silence # compiler warnings and errors. STDOUT = subprocess.PIPE STDERR = subprocess.PIPE @@ -26,7 +26,7 @@ done = True lines.append(s[beginning:]) else: - last_space = s[beginning:end].rfind(' ') + last_space = s[beginning:end].rfind(' ') lines.append(s[beginning:beginning + last_space]) beginning += (last_space + 1) @@ -39,13 +39,13 @@ s = "Setup can't determine %s on your system, so it will default to %s which may not be correct." \ % (value_name, default) plea = "Please report this message and your operating system info to the package maintainer listed in the README file." - + lines = line_wrap_paragraph(s) + [''] + line_wrap_paragraph(plea) border = '*' * MAX_LINE_LENGTH - + s = border + "\n* " + ('\n* '.join(lines)) + '\n' + border - + print (s) @@ -62,50 +62,50 @@ cmd = "cc -Wall -o ./prober/foo ./prober/%s %s -lpthread" % (filename, linker_options) p = subprocess.Popen(cmd, shell=True, stdout=STDOUT, stderr=STDERR) - - # p.wait() returns the process' return code, so 0 implies that + + # p.wait() returns the process' return code, so 0 implies that # the compile & link succeeded. return not bool(p.wait()) def compile_and_run(filename, linker_options = ""): - # Utility function that returns the stdout output from running the + # Utility function that returns the stdout output from running the # compiled source file; None if the compile fails. cmd = "cc -Wall -o ./prober/foo %s ./prober/%s" % (linker_options, filename) p = subprocess.Popen(cmd, shell=True, stdout=STDOUT, stderr=STDERR) - - if p.wait(): + + if p.wait(): # uh-oh, compile failed return None else: - s = subprocess.Popen(["./prober/foo"], + s = subprocess.Popen(["./prober/foo"], stdout=subprocess.PIPE).communicate()[0] return s.strip().decode() - + def get_sysctl_value(name): """Given a sysctl name (e.g. 'kern.mqueue.maxmsg'), returns sysctl's value - for that variable or None if the sysctl call fails (unknown name, not + for that variable or None if the sysctl call fails (unknown name, not a BSD-ish system, etc.) - Only makes sense on systems that implement sysctl (BSD derivatives). + Only makes sense on systems that implement sysctl (BSD derivatives). """ s = None - try: - # I redirect stderr to /dev/null because if sysctl is availble but - # doesn't know about the particular item I'm querying, it will - # kvetch with a message like 'second level name mqueue in - # kern.mqueue.maxmsg is invalid'. This always happens under OS X + try: + # I redirect stderr to /dev/null because if sysctl is availble but + # doesn't know about the particular item I'm querying, it will + # kvetch with a message like 'second level name mqueue in + # kern.mqueue.maxmsg is invalid'. This always happens under OS X # (which doesn't have any kern.mqueue values) and under FreeBSD when # the mqueuefs kernel module isn't loaded. - s = subprocess.Popen(["sysctl", "-n", name], + s = subprocess.Popen(["sysctl", "-n", name], stdout=subprocess.PIPE, stderr=open(os.devnull, 'rw')).communicate()[0] s = s.strip().decode() except: pass - + return s @@ -117,7 +117,7 @@ # Realtime libs not needed rc = False else: - # cc failed when not linked to realtime libs; let's try again + # cc failed when not linked to realtime libs; let's try again # with the realtime libs involved and see if things go better. if does_build_succeed(filename, "-lrt"): # Realtime libs are needed @@ -131,7 +131,7 @@ print_bad_news("if it needs to link to the realtime libraries", "'no'") return rc - + def sniff_sem_getvalue(linker_options): return does_build_succeed("sniff_sem_getvalue.c", linker_options) @@ -145,7 +145,7 @@ # default is to return None which means that it is #defined in a standard # header file and doesn't need to be added to my custom header file. sem_value_max = None - + if not does_build_succeed("sniff_sem_value_max.c"): # OpenSolaris 2008.05 doesn't #define SEM_VALUE_MAX. (This may # be true elsewhere too.) Ask sysconf() instead if it exists. @@ -154,20 +154,20 @@ ("SC_SEM_VALUE_MAX" in os.sysconf_names): sem_value_max = os.sysconf("SC_SEM_VALUE_MAX") else: - # This value of last resort should be #defined everywhere. What + # This value of last resort should be #defined everywhere. What # could possibly go wrong? sem_value_max = "_POSIX_SEM_VALUE_MAX" return sem_value_max - + def sniff_page_size(): DEFAULT_PAGE_SIZE = 4096 - + # Linker options don't matter here because I'm not calling any # functions, just getting the value of a #define. page_size = compile_and_run("sniff_page_size.c") - + if page_size is None: page_size = DEFAULT_PAGE_SIZE print_bad_news("the value of PAGE_SIZE", page_size) @@ -180,10 +180,10 @@ def sniff_mq_prio_max(): - # MQ_PRIO_MAX is #defined in limits.h on all of the systems that I + # MQ_PRIO_MAX is #defined in limits.h on all of the systems that I # checked that support message queues at all. (I checked 2 Linux boxes, - # OpenSolaris and FreeBSD 8.0.) - + # OpenSolaris and FreeBSD 8.0.) + # 32 = minimum allowable max priority per POSIX; systems are permitted # to define a larger value. # ref: http://www.opengroup.org/onlinepubs/009695399/basedefs/limits.h.html @@ -194,7 +194,7 @@ # doesn't define MQ_PRIO_MAX. Maybe this aggravation will cease in 10.9? if does_build_succeed("sniff_mq_prio_max.c"): max_priority = compile_and_run("sniff_mq_prio_max.c") - + if max_priority: try: max_priority = int(max_priority) @@ -215,7 +215,7 @@ if max_priority < 0: max_priority = DEFAULT_PRIORITY_MAX - # Adjust for the fact that these are 0-based values; i.e. permitted + # Adjust for the fact that these are 0-based values; i.e. permitted # priorities range from 0 - (MQ_PRIO_MAX - 1). So why not just make # the #define one smaller? Because this one goes up to eleven... max_priority -= 1 @@ -226,21 +226,21 @@ def sniff_mq_max_messages(): # This value is not defined by POSIX. - - # On most systems I've tested, msg Qs are implemented via mmap-ed files + + # On most systems I've tested, msg Qs are implemented via mmap-ed files # or a similar interface, so the only theoretical limits are imposed by the - # file system. In practice, Linux and *BSD impose some fairly tight - # limits. + # file system. In practice, Linux and *BSD impose some fairly tight + # limits. # On Linux it's available in a /proc file and often defaults to the wimpy # value of 10. - + # On FreeBSD (and other BSDs, I assume), it's available via sysctl as # kern.mqueue.maxmsg. On my FreeBSD 9.1 test system, it defaults to 100. - # mqueue.h defines mq_attr.mq_maxmsg as a C long, so that's + # mqueue.h defines mq_attr.mq_maxmsg as a C long, so that's # a practical limit for this value. - + # ref: http://linux.die.net/man/7/mq_overview # ref: http://www.freebsd.org/cgi/man.cgi?query=mqueuefs&sektion=5&manpath=FreeBSD+7.0-RELEASE # http://fxr.watson.org/fxr/source/kern/uipc_mqueue.c?v=FREEBSD91#L195 @@ -263,9 +263,9 @@ mq_max_messages = int(mq_max_messages) if not mq_max_messages: - # We're on a non-Linux, non-BSD system, or OS X, or BSD with + # We're on a non-Linux, non-BSD system, or OS X, or BSD with # the mqueuefs kernel module not loaded (which it's not, by default, - # under FreeBSD 8.x and 9.x. which are the only systems I've tested). + # under FreeBSD 8.x and 9.x which are the only systems I've tested). # # If we're on FreeBSD and mqueuefs isn't loaded when this code runs, # sysctl won't be able to provide mq_max_messages to me. (I assume other @@ -279,7 +279,7 @@ mq_max_messages = 100 else: # We're on a non-Linux, non-BSD system. I take a wild guess at an - # appropriate value. The max possible is > 2 billion, but the + # appropriate value. The max possible is > 2 billion, but the # values used by Linux and FreeBSD suggest that a smaller default # is wiser. mq_max_messages = 1024 @@ -289,27 +289,27 @@ def sniff_mq_max_message_size_default(): # The max message size is not defined by POSIX. - - # On most systems I've tested, msg Qs are implemented via mmap-ed files - # or a similar interface, so the only theoretical limits are imposed by - # the file system. In practice, Linux and *BSD impose some tighter limits. - # On Linux, max message size is available in a /proc file and often + # On most systems I've tested, msg Qs are implemented via mmap-ed files + # or a similar interface, so the only theoretical limits are imposed by + # the file system. In practice, Linux and *BSD impose some tighter limits. + + # On Linux, max message size is available in a /proc file and often # defaults to the value of 8192. # On FreeBSD (and other BSDs, I assume), it's available via sysctl as - # kern.mqueue.maxmsgsize. On my FreeBSD 9.1 test system, it defaults to - # 16384. + # kern.mqueue.maxmsgsize. On my FreeBSD 9.1 test system, it defaults to + # 16384. - # mqueue.h defines mq_attr.mq_msgsize as a C long, so that's + # mqueue.h defines mq_attr.mq_msgsize as a C long, so that's # a practical limit for this value. - + # Further complicating things is the fact that the module has to allocate - # a buffer the size of the queue's max message every time receive() is + # a buffer the size of the queue's max message every time receive() is # called, so it would be a bad idea to set this default to the max. # I set it to 8192 -- not too small, not too big. I only set it smaller # if I'm on a system that tells me I must do so. - DEFAULT = 8192 + DEFAULT = 8192 mq_max_message_size_default = 0 # Try to get the value from where Linux stores it. @@ -328,7 +328,7 @@ if not mq_max_message_size_default: mq_max_message_size_default = DEFAULT - + return mq_max_message_size_default @@ -336,21 +336,21 @@ def probe(): linker_options = "" d = { } - + f = open("VERSION") d["POSIX_IPC_VERSION"] = '"%s"' % f.read().strip() f.close() - # Sniffing of the realtime libs has to go early in the list so as - # to provide correct linker options to the rest of the tests. + # Sniffing of the realtime libs has to go early in the list so as + # to provide correct linker options to the rest of the tests. if "Darwin" in platform.uname(): # I skip the test under Darwin/OS X for two reasons. First, I know # it isn't needed there. Second, I can't even compile the test for # the realtime lib because it references mq_unlink() which OS X - # doesn't support. Unfortunately sniff_realtime_lib.c *must* - # reference mq_unlink() or some other mq_xxx() function because + # doesn't support. Unfortunately sniff_realtime_lib.c *must* + # reference mq_unlink() or some other mq_xxx() function because # it is only the message queues that need the realtime libs under - # FreeBSD. + # FreeBSD. realtime_lib_is_needed = False else: # Some platforms (e.g. Linux & OpenSuse) require linking to librt @@ -361,19 +361,19 @@ linker_options = " -lrt " d["PAGE_SIZE"] = sniff_page_size() - + if sniff_sem_getvalue(linker_options): d["SEM_GETVALUE_EXISTS"] = "" if ("SEM_GETVALUE_EXISTS" in d) and ("Darwin" in platform.uname()): - # sem_getvalue() isn't available on OS X. The function exists but - # always returns -1 (under OS X 10.9) or ENOSYS ("Function not + # sem_getvalue() isn't available on OS X. The function exists but + # always returns -1 (under OS X 10.9) or ENOSYS ("Function not # implemented") under some earlier version(s). del d["SEM_GETVALUE_EXISTS"] if sniff_sem_timedwait(linker_options): d["SEM_TIMEDWAIT_EXISTS"] = "" - + d["SEM_VALUE_MAX"] = sniff_sem_value_max() # A return of None means that I don't need to #define this myself. if d["SEM_VALUE_MAX"] is None: @@ -381,7 +381,7 @@ if sniff_mq_existence(linker_options): d["MESSAGE_QUEUE_SUPPORT_EXISTS"] = "" - + d["QUEUE_MESSAGES_MAX_DEFAULT"] = sniff_mq_max_messages() d["QUEUE_MESSAGE_SIZE_MAX_DEFAULT"] = sniff_mq_max_message_size_default() d["QUEUE_PRIORITY_MAX"] = sniff_mq_prio_max() @@ -389,11 +389,11 @@ if PY_MAJOR_VERSION == 2: # I only need this for Python 2.x d["PY_INT_MAX"] = sys.maxint - + msg = """/* This header file was generated when you ran setup. Once created, the setup -process won't overwrite it, so you can adjust the values by hand and +process won't overwrite it, so you can adjust the values by hand and recompile if you need to. On your platform, this file may contain only this comment -- that's OK! @@ -402,26 +402,26 @@ */ """ - filename = "probe_results.h" + filename = "probe_results.h" if not os.path.exists(filename): lines = ["#define %s\t\t%s" % (key, d[key]) for key in d if key != "PAGE_SIZE"] - # PAGE_SIZE gets some special treatment. It's defined in header files - # on some systems in which case I might get a redefinition error in + # PAGE_SIZE gets some special treatment. It's defined in header files + # on some systems in which case I might get a redefinition error in # my header file, so I wrap it in #ifndef/#endif. - + lines.append("#ifndef PAGE_SIZE") lines.append("#define PAGE_SIZE\t\t%s" % d["PAGE_SIZE"]) lines.append("#endif") - + # A trailing '\n' keeps compilers happy... open(filename, "w").write(msg + '\n'.join(lines) + '\n') - + return d if __name__ == "__main__": print (probe()) - - + + diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/tests/base.py new/posix_ipc-1.0.0/tests/base.py --- old/posix_ipc-0.9.9/tests/base.py 2014-10-25 20:35:58.000000000 +0200 +++ new/posix_ipc-1.0.0/tests/base.py 2015-03-09 02:04:50.000000000 +0100 @@ -7,10 +7,9 @@ # Project imports import posix_ipc -import utils_for_py26 IS_PY3 = (sys.version_info[0] == 3) -IS_PY_LT_27 = ((sys.version_info[0] == 2) and (sys.version_info[1] < 7)) + def make_name(): """Generate a random name suitable for an IPC object.""" @@ -18,14 +17,7 @@ return '/' + ''.join(random.sample(alphabet, random.randint(3, 12))) class Base(unittest.TestCase): - """Base class for test cases. - - Under Python < 2.7, there's some handy unittest methods that aren't - defined, so I define them here. They are assertIsNotNone, - assertGreaterEqual, assertIn, and assertIsInstance. I also redefine - assertRaises() so that it can be used in a context manager. The - implementation of each is copied directly from Python's source. - """ + """Base class for test cases.""" def assertWriteToReadOnlyPropertyFails(self, target_object, property_name, value): """test that writing to a readonly property raises an exception""" @@ -44,45 +36,3 @@ # ref: http://bugs.python.org/msg127173 with self.assertRaises((TypeError, AttributeError)): setattr(target_object, property_name, value) - - if IS_PY_LT_27: - # Python < 2.7 has assertRaises(), but it can't be used as a - # context manager. This version (copied from the Python 2.7 - # standard library) implements a context manager. - def assertRaises(self, excClass, callableObj=None, *args, **kwargs): - context = utils_for_py26._AssertRaisesContext(excClass, self) - if callableObj is None: - return context - with context: - callableObj(*args, **kwargs) - - if not hasattr(unittest.TestCase, 'assertIsNotNone'): - def assertIsNotNone(self, obj, msg=None): - """Included for symmetry with assertIsNone.""" - if obj is None: - standardMsg = 'unexpectedly None' - self.fail(self._formatMessage(msg, standardMsg)) - - if not hasattr(unittest.TestCase, 'assertGreaterEqual'): - def assertGreaterEqual(self, a, b, msg=None): - """Just like self.assertTrue(a >= b), but with a nicer default message.""" - if not a >= b: - standardMsg = '%s not greater than or equal to %s' % (utils_for_py26._safe_repr(a), utils_for_py26._safe_repr(b)) - self.fail(self._formatMessage(msg, standardMsg)) - - if not hasattr(unittest.TestCase, 'assertIn'): - def assertIn(self, member, container, msg=None): - """Just like self.assertTrue(a in b), but with a nicer default message.""" - if member not in container: - standardMsg = '%s not found in %s' % (utils_for_py26._safe_repr(member), - utils_for_py26._safe_repr(container)) - self.fail(self._formatMessage(msg, standardMsg)) - - if not hasattr(unittest.TestCase, 'assertIsInstance'): - def assertIsInstance(self, obj, cls, msg=None): - """Same as self.assertTrue(isinstance(obj, cls)), with a nicer - default message.""" - if not isinstance(obj, cls): - standardMsg = '%s is not an instance of %r' % (utils_for_py26._safe_repr(obj), cls) - self.fail(self._formatMessage(msg, standardMsg)) - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/tests/test_memory.py new/posix_ipc-1.0.0/tests/test_memory.py --- old/posix_ipc-0.9.9/tests/test_memory.py 2014-10-25 20:38:12.000000000 +0200 +++ new/posix_ipc-1.0.0/tests/test_memory.py 2015-03-12 01:39:24.000000000 +0100 @@ -79,15 +79,12 @@ self.assertRaises(posix_ipc.ExistentialError, posix_ipc.SharedMemory, '/foo', posix_ipc.O_CREX) - if "Darwin" in platform.uname(): - # O_TRUNC is not supported under OS X - pass - else: - def test_o_trunc(self): - """Test that O_TRUNC truncates the memory to 0 bytes""" - mem_copy = posix_ipc.SharedMemory(self.mem.name, posix_ipc.O_TRUNC) + @unittest.skipIf("Darwin" in platform.uname(), "O_TRUNC is not supported under OS X") + def test_o_trunc(self): + """Test that O_TRUNC truncates the memory to 0 bytes""" + mem_copy = posix_ipc.SharedMemory(self.mem.name, posix_ipc.O_TRUNC) - self.assertEqual(mem_copy.size, 0) + self.assertEqual(mem_copy.size, 0) def test_randomly_generated_name(self): """tests that the randomly-generated name works""" @@ -98,6 +95,39 @@ mem.close_fd() mem.unlink() + def test_name_as_bytes(self): + """Test that the name can be bytes. + + In Python 2, bytes == str. This test is really only interesting in Python 3. + """ + if tests_base.IS_PY3: + name = bytes(tests_base.make_name(), 'ASCII') + else: + name = bytes(tests_base.make_name()) + mem = posix_ipc.SharedMemory(name, posix_ipc.O_CREX, size=4096) + # No matter what the name is passed as, posix_ipc.name returns the default string type, + # i.e. str in Python 2 and unicode in Python 3. + if tests_base.IS_PY3: + self.assertEqual(name, bytes(mem.name, 'ASCII')) + else: + self.assertEqual(name, mem.name) + mem.close_fd() + mem.unlink() + + def test_name_as_unicode(self): + """Test that the name can be unicode. + + In Python 3, str == unicode. This test is really only interesting in Python 2. + """ + if tests_base.IS_PY3: + name = tests_base.make_name() + else: + name = unicode(tests_base.make_name(), 'ASCII') + mem = posix_ipc.SharedMemory(name, posix_ipc.O_CREX, size=4096) + self.assertEqual(name, mem.name) + mem.close_fd() + mem.unlink() + # # don't bother testing mode, it's ignored by the OS? def test_mmap_size(self): diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/tests/test_message_queues.py new/posix_ipc-1.0.0/tests/test_message_queues.py --- old/posix_ipc-0.9.9/tests/test_message_queues.py 2014-10-31 15:56:41.000000000 +0100 +++ new/posix_ipc-1.0.0/tests/test_message_queues.py 2015-03-12 01:42:00.000000000 +0100 @@ -2,6 +2,7 @@ # Don't add any from __future__ imports here. This code should execute # against standard Python. import unittest +from unittest import skipUnless import datetime import random import time @@ -49,7 +50,7 @@ test_case_instance.notification_event.set() -if posix_ipc.MESSAGE_QUEUES_SUPPORTED: + @skipUnless(posix_ipc.MESSAGE_QUEUES_SUPPORTED, "Requires MessageQueue support") class TestMessageQueues(tests_base.Base): """Exercise the MessageQueue class""" def setUp(self): @@ -120,6 +121,39 @@ mq.close() mq.unlink() + def test_name_as_bytes(self): + """Test that the name can be bytes. + + In Python 2, bytes == str. This test is really only interesting in Python 3. + """ + if tests_base.IS_PY3: + name = bytes(tests_base.make_name(), 'ASCII') + else: + name = bytes(tests_base.make_name()) + mq = posix_ipc.MessageQueue(name, posix_ipc.O_CREX) + # No matter what the name is passed as, posix_ipc.name returns the default string type, + # i.e. str in Python 2 and unicode in Python 3. + if tests_base.IS_PY3: + self.assertEqual(name, bytes(mq.name, 'ASCII')) + else: + self.assertEqual(name, mq.name) + mq.unlink() + mq.close() + + def test_name_as_unicode(self): + """Test that the name can be unicode. + + In Python 3, str == unicode. This test is really only interesting in Python 2. + """ + if tests_base.IS_PY3: + name = tests_base.make_name() + else: + name = unicode(tests_base.make_name(), 'ASCII') + mq = posix_ipc.MessageQueue(name, posix_ipc.O_CREX) + self.assertEqual(name, mq.name) + mq.unlink() + mq.close() + # don't bother testing mode, it's ignored by the OS? def test_max_messages(self): @@ -462,7 +496,6 @@ # The mqd is of type mqd_t. I can't find doc that states what this # type is. All I know is that -1 is an error so it's probably # int-ish, but I can't tell exactly what to expect. - self.assertWriteToReadOnlyPropertyFails('mqd', 42) def test_property_max_messages(self): @@ -545,6 +578,5 @@ mq.close() mq.unlink() - if __name__ == '__main__': unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/tests/test_semaphores.py new/posix_ipc-1.0.0/tests/test_semaphores.py --- old/posix_ipc-0.9.9/tests/test_semaphores.py 2014-10-25 20:38:01.000000000 +0200 +++ new/posix_ipc-1.0.0/tests/test_semaphores.py 2015-03-12 01:40:53.000000000 +0100 @@ -2,6 +2,7 @@ # Don't add any from __future__ imports here. This code should execute # against standard Python. import unittest +from unittest import skipUnless import datetime import random @@ -13,6 +14,7 @@ sys.path.insert(0, os.path.join(os.getcwd(), 'tests')) import base as tests_base + # N_RELEASES is the number of times release() is called in test_release() N_RELEASES = 1000000 # 1 million @@ -88,28 +90,61 @@ self.assertGreaterEqual(len(sem.name), 2) sem.unlink() + def test_name_as_bytes(self): + """Test that the name can be bytes. + + In Python 2, bytes == str. This test is really only interesting in Python 3. + """ + if tests_base.IS_PY3: + name = bytes(tests_base.make_name(), 'ASCII') + else: + name = bytes(tests_base.make_name()) + sem = posix_ipc.Semaphore(name, posix_ipc.O_CREX) + # No matter what the name is passed as, posix_ipc.name returns the default string type, + # i.e. str in Python 2 and unicode in Python 3. + if tests_base.IS_PY3: + self.assertEqual(name, bytes(sem.name, 'ASCII')) + else: + self.assertEqual(name, sem.name) + sem.unlink() + sem.close() + + def test_name_as_unicode(self): + """Test that the name can be unicode. + + In Python 3, str == unicode. This test is really only interesting in Python 2. + """ + if tests_base.IS_PY3: + name = tests_base.make_name() + else: + name = unicode(tests_base.make_name(), 'ASCII') + sem = posix_ipc.Semaphore(name, posix_ipc.O_CREX) + self.assertEqual(name, sem.name) + sem.unlink() + sem.close() + # don't bother testing mode, it's ignored by the OS? + @skipUnless(posix_ipc.SEMAPHORE_VALUE_SUPPORTED, "Requires Semaphore.value support") def test_default_initial_value(self): """tests that the initial value is 0 by default""" - if posix_ipc.SEMAPHORE_VALUE_SUPPORTED: - sem = posix_ipc.Semaphore(None, posix_ipc.O_CREX) - self.assertEqual(sem.value, 0) - sem.unlink() + sem = posix_ipc.Semaphore(None, posix_ipc.O_CREX) + self.assertEqual(sem.value, 0) + sem.unlink() + @skipUnless(posix_ipc.SEMAPHORE_VALUE_SUPPORTED, "Requires Semaphore.value support") def test_zero_initial_value(self): """tests that the initial value is 0 when assigned""" - if posix_ipc.SEMAPHORE_VALUE_SUPPORTED: - sem = posix_ipc.Semaphore(None, posix_ipc.O_CREX, initial_value=0) - self.assertEqual(sem.value, 0) - sem.unlink() + sem = posix_ipc.Semaphore(None, posix_ipc.O_CREX, initial_value=0) + self.assertEqual(sem.value, 0) + sem.unlink() + @skipUnless(posix_ipc.SEMAPHORE_VALUE_SUPPORTED, "Requires Semaphore.value support") def test_nonzero_initial_value(self): """tests that the initial value is non-zero when assigned""" - if posix_ipc.SEMAPHORE_VALUE_SUPPORTED: - sem = posix_ipc.Semaphore(None, posix_ipc.O_CREX, initial_value=42) - self.assertEqual(sem.value, 42) - sem.unlink() + sem = posix_ipc.Semaphore(None, posix_ipc.O_CREX, initial_value=42) + self.assertEqual(sem.value, 42) + sem.unlink() # test acquisition @@ -134,63 +169,52 @@ behavior""" # Should not raise an error self.sem.acquire(0) + with self.assertRaises(posix_ipc.BusyError): + self.sem.acquire(0) - # I would prefer this syntax, but it doesn't work with Python < 2.7. - # with self.assertRaises(posix_ipc.BusyError): - # self.sem.acquire(0) - self.assertRaises(posix_ipc.BusyError, self.sem.acquire, 0) - + @skipUnless(posix_ipc.SEMAPHORE_TIMEOUT_SUPPORTED, "Requires Semaphore timeout support") def test_acquisition_nonzero_int_timeout(self): """tests that acquisition w/timeout=an int is reasonably accurate""" - if posix_ipc.SEMAPHORE_TIMEOUT_SUPPORTED: - # Should not raise an error - self.sem.acquire(0) + # Should not raise an error + self.sem.acquire(0) - # This should raise a busy error - wait_time = 1 - start = datetime.datetime.now() - # I would prefer this syntax, but it doesn't work with Python < 2.7. - # with self.assertRaises(posix_ipc.BusyError): - # self.sem.acquire(wait_time) - self.assertRaises(posix_ipc.BusyError, self.sem.acquire, wait_time) - end = datetime.datetime.now() - actual_delta = end - start - expected_delta = datetime.timedelta(seconds=wait_time) - - delta = actual_delta - expected_delta - - self.assertEqual(delta.days, 0) - self.assertEqual(delta.seconds, 0) - # I don't want to test microseconds because that granularity - # isn't under the control of this module. - # else: - # Can't test this! + # This should raise a busy error + wait_time = 1 + start = datetime.datetime.now() + with self.assertRaises(posix_ipc.BusyError): + self.sem.acquire(wait_time) + end = datetime.datetime.now() + actual_delta = end - start + expected_delta = datetime.timedelta(seconds=wait_time) + + delta = actual_delta - expected_delta + + self.assertEqual(delta.days, 0) + self.assertEqual(delta.seconds, 0) + # I don't want to test microseconds because that granularity + # isn't under the control of this module. + @skipUnless(posix_ipc.SEMAPHORE_TIMEOUT_SUPPORTED, "Requires Semaphore timeout support") def test_acquisition_nonzero_float_timeout(self): """tests that acquisition w/timeout=a float is reasonably accurate""" - if posix_ipc.SEMAPHORE_TIMEOUT_SUPPORTED: - # Should not raise an error - self.sem.acquire(0) + # Should not raise an error + self.sem.acquire(0) - # This should raise a busy error - wait_time = 1.5 - start = datetime.datetime.now() - # I would prefer this syntax, but it doesn't work with Python < 2.7. - # with self.assertRaises(posix_ipc.BusyError): - # self.sem.acquire(wait_time) - self.assertRaises(posix_ipc.BusyError, self.sem.acquire, wait_time) - end = datetime.datetime.now() - actual_delta = end - start - expected_delta = datetime.timedelta(seconds=wait_time) - - delta = actual_delta - expected_delta - - self.assertEqual(delta.days, 0) - self.assertEqual(delta.seconds, 0) - # I don't want to test microseconds because that granularity - # isn't under the control of this module. - # else: - # Can't test this! + # This should raise a busy error + wait_time = 1.5 + start = datetime.datetime.now() + with self.assertRaises(posix_ipc.BusyError): + self.sem.acquire(wait_time) + end = datetime.datetime.now() + actual_delta = end - start + expected_delta = datetime.timedelta(seconds=wait_time) + + delta = actual_delta - expected_delta + + self.assertEqual(delta.days, 0) + self.assertEqual(delta.seconds, 0) + # I don't want to test microseconds because that granularity + # isn't under the control of this module. def test_release(self): """tests that release works""" @@ -207,10 +231,8 @@ with self.sem as sem: if posix_ipc.SEMAPHORE_VALUE_SUPPORTED: self.assertEqual(sem.value, 0) - # I would prefer this syntax, but it doesn't work with Python < 2.7. - # with self.assertRaises(posix_ipc.BusyError): - # sem.acquire(0) - self.assertRaises(posix_ipc.BusyError, sem.acquire, 0) + with self.assertRaises(posix_ipc.BusyError): + sem.acquire(0) if posix_ipc.SEMAPHORE_VALUE_SUPPORTED: self.assertEqual(sem.value, 1) @@ -225,12 +247,10 @@ # and note that it does not fail. Also, it allows sem.unlink() to # tell the OS to delete the semaphore entirely, so it makes sense # to test them together. - self.sem.unlink() self.sem.close() self.assertRaises(posix_ipc.ExistentialError, posix_ipc.Semaphore, self.sem.name) - # Wipe this out so that self.tearDown() doesn't crash. self.sem = None @@ -242,14 +262,13 @@ self.assertWriteToReadOnlyPropertyFails('name', 'hello world') + @skipUnless(posix_ipc.SEMAPHORE_VALUE_SUPPORTED, "Requires Semaphore.value support") def test_property_value(self): """exercise Semaphore.value if possible""" # test read, although this has been tested very thoroughly above - if posix_ipc.SEMAPHORE_VALUE_SUPPORTED: - self.assertEqual(self.sem.value, 1) - - self.assertWriteToReadOnlyPropertyFails('value', 42) + self.assertEqual(self.sem.value, 1) + self.assertWriteToReadOnlyPropertyFails('value', 42) if __name__ == '__main__': unittest.main() diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/posix_ipc-0.9.9/tests/utils_for_py26.py new/posix_ipc-1.0.0/tests/utils_for_py26.py --- old/posix_ipc-0.9.9/tests/utils_for_py26.py 2014-10-25 04:43:42.000000000 +0200 +++ new/posix_ipc-1.0.0/tests/utils_for_py26.py 1970-01-01 01:00:00.000000000 +0100 @@ -1,52 +0,0 @@ -"""This module contains some utilities that make the unittest of Python <= 2.6 -behave more like Python 2.7 & 3. The code is copied from the Python 2.7 -standard library. -""" -# Don't add any from __future__ imports here. This code should execute -# against standard Python. - -# I swiped safe_repr() from Python 2.7 unittest.util. It's only called when the -# standard lib version doesn't exist (i.e. in Python <= 2.6). -_MAX_LENGTH = 80 -def _safe_repr(obj, short=False): - try: - result = repr(obj) - except Exception: - result = object.__repr__(obj) - if not short or len(result) < _MAX_LENGTH: - return result - return result[:_MAX_LENGTH] + ' [truncated]...' - -class _AssertRaisesContext(object): - """A context manager used to implement TestCase.assertRaises* methods.""" - - def __init__(self, expected, test_case, expected_regexp=None): - self.expected = expected - self.failureException = test_case.failureException - self.expected_regexp = expected_regexp - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, tb): - if exc_type is None: - try: - exc_name = self.expected.__name__ - except AttributeError: - exc_name = str(self.expected) - raise self.failureException( - "{0} not raised".format(exc_name)) - if not issubclass(exc_type, self.expected): - # let unexpected exceptions pass through - return False - self.exception = exc_value # store for later retrieval - if self.expected_regexp is None: - return True - - expected_regexp = self.expected_regexp - if isinstance(expected_regexp, basestring): - expected_regexp = re.compile(expected_regexp) - if not expected_regexp.search(str(exc_value)): - raise self.failureException('"%s" does not match "%s"' % - (expected_regexp.pattern, str(exc_value))) - return True
participants (1)
-
root@hilbert.suse.de