Commit Graph

117 Commits

Author SHA1 Message Date
Gregory P. Smith 8cb6569fe1 Implements issue #9951: Adds a hex() method to bytes, bytearray, & memoryview.
Also updates a few internal implementations of the same thing to use the
new built-in code.

Contributed by Arnon Yaari.
2015-04-25 23:22:26 +00:00
Antoine Pitrou 31084ba528 Issue #23632: Memoryviews now allow tuple indexing (including for multi-dimensional memoryviews). 2015-03-19 23:29:36 +01:00
Serhiy Storchaka 009b811d67 Removed unintentional trailing spaces in non-external and non-generated C files. 2015-03-18 21:53:15 +02:00
Stefan Krah f5324d7074 Closes #22668: Merge from 3.4. 2015-01-29 14:29:51 +01:00
Stefan Krah fa5d6a5ff3 Issue #22668: Ensure that format strings survive slicing after casting. 2015-01-29 14:27:23 +01:00
R David Murray 861470c836 #16518: Bring error messages in harmony with docs ("bytes-like object")
Some time ago we changed the docs to consistently use the term 'bytes-like
object' in all the contexts where bytes, bytearray, memoryview, etc are used.
This patch (by Ezio Melotti) completes that work by changing the error
messages that previously reported that certain types did "not support the
buffer interface" to instead say that a bytes-like object is required.  (The
glossary entry for bytes-like object references the discussion of the buffer
protocol in the docs.)
2014-10-05 11:47:01 -04:00
Stefan Krah bcaf5999e6 Issue #20186: memoryobject.c: add function signatures. 2014-05-18 00:35:09 +02:00
Victor Stinner 45e8e2f218 Issue #21490: Add new C macros: Py_ABS() and Py_STRINGIFY()
Keep _Py_STRINGIZE() in PC/pyconfig.h to not introduce a dependency between
pyconfig.h and pymacros.h.
2014-05-14 17:24:35 +02:00
Christian Heimes 985ecdcfc2 ssue #19183: Implement PEP 456 'secure and interchangeable hash algorithm'.
Python now uses SipHash24 on all major platforms.
2013-11-20 11:46:18 +01:00
Antoine Pitrou 0e61ed8400 Issue #19014: memoryview.cast() is now allowed on zero-length views. 2013-10-03 19:56:54 +02:00
Antoine Pitrou 60b183407c Issue #19014: memoryview.cast() is now allowed on zero-length views. 2013-10-03 19:55:41 +02:00
Nick Coghlan a0f169cde8 Close #19078: memoryview now supports reversed
Patch by Claudiu Popa
2013-10-02 22:06:54 +10:00
Stefan Krah 674a42b114 Fix error messages. 2013-02-19 13:44:49 +01:00
Stefan Krah 4af77a0276 Issue #15814: Use hash function that is compatible with the equality
definition from #15573.
2012-11-02 17:49:22 +01:00
Alexander Belopolsky f73c69e06f Issue #15855: added docstrings for memoryview methods and data descriptors new in 3.3. 2012-09-03 16:51:01 -04:00
Alexander Belopolsky e370c38131 Issue #15855: added docstrings for memoryview methods and data descriptors (merge 3.2). 2012-09-03 16:43:55 -04:00
Alexander Belopolsky 397e5c98bc Issue #15855: added docstrings for memoryview methods and data descriptors. 2012-09-03 16:29:11 -04:00
Nick Coghlan 06e1ab0a6b Close #15573: use value-based memoryview comparisons (patch by Stefan Krah) 2012-08-25 17:59:50 +10:00
Stefan Krah e4c0799d9c Add unused parameter to a METH_NOARGS function. 2012-07-28 14:10:02 +02:00
Stefan Krah 7d12d9df13 Issue #12834: Fix PyBuffer_ToContiguous() for non-contiguous arrays. 2012-07-28 12:25:55 +02:00
Richard Oudkerk 3e0a1eb889 Issue #14930: Make memoryview objects weakrefable. 2012-05-28 21:35:09 +01:00
Stefan Krah 1649c1b33a Issue #14181: Preserve backwards compatibility for getbufferprocs that a) do
not adhere to the new documentation and b) manage to clobber view->obj before
returning failure.
2012-03-05 17:45:17 +01:00
Stefan Krah 4e99a315b7 Issue #14181: Allow memoryview construction from an object that uses the
getbuffer redirection scheme.
2012-03-05 09:30:47 +01:00
Stefan Krah 9a2d99e28a - Issue #10181: New memoryview implementation fixes multiple ownership
and lifetime issues of dynamically allocated Py_buffer members (#9990)
  as well as crashes (#8305, #7433). Many new features have been added
  (See whatsnew/3.3), and the documentation has been updated extensively.
  The ndarray test object from _testbuffer.c implements all aspects of
  PEP-3118, so further development towards the complete implementation
  of the PEP can proceed in a test-driven manner.

  Thanks to Nick Coghlan, Antoine Pitrou and Pauli Virtanen for review
  and many ideas.

- Issue #12834: Fix incorrect results of memoryview.tobytes() for
  non-contiguous arrays.

- Issue #5231: Introduce memoryview.cast() method that allows changing
  format and shape without making a copy of the underlying memory.
2012-02-25 12:24:21 +01:00
Antoine Pitrou ce4a9da705 Issue #13411: memoryview objects are now hashable when the underlying object is hashable. 2011-11-21 20:46:33 +01:00
Brian Curtin dfc80e3d97 Replace Py_NotImplemented returns with the macro form Py_RETURN_NOTIMPLEMENTED.
The macro was introduced in #12724.
2011-08-10 20:28:54 -05:00
Antoine Pitrou 915605c59a Merged revisions 88550 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k

........
  r88550 | antoine.pitrou | 2011-02-24 21:50:49 +0100 (jeu., 24 févr. 2011) | 4 lines

  Issue #11286: Raise a ValueError from calling PyMemoryView_FromBuffer with
  a buffer struct having a NULL data pointer.
........
2011-02-24 20:53:48 +00:00
Antoine Pitrou 5bffa79c22 Issue #11286: Raise a ValueError from calling PyMemoryView_FromBuffer with
a buffer struct having a NULL data pointer.
2011-02-24 20:50:49 +00:00
Antoine Pitrou ad62b03949 Issue #10451: memoryview objects could allow to mutate a readable buffer.
Initial patch by Ross Lagerwall.
2011-01-18 18:57:52 +00:00
Martin v. Löwis 4d0d471a80 Merge branches/pep-0384. 2010-12-03 20:14:31 +00:00
Antoine Pitrou aeb6ceead7 Issue #10293: Remove obsolete field in the PyMemoryView structure,
unused undocumented value PyBUF_SHADOW, and strangely-looking code in
PyMemoryView_GetContiguous.
2010-11-04 20:30:33 +00:00
Benjamin Peterson 83473288a8 deuglify 2010-11-03 23:11:10 +00:00
Antoine Pitrou 6e6cc830c4 Issue #9757: memoryview objects get a release() method to release the
underlying buffer (previously this was only done when deallocating the
memoryview), and gain support for the context management protocol.
2010-09-09 12:59:39 +00:00
Antoine Pitrou c73b909a2b Fix a compilation warning 2010-09-01 21:14:46 +00:00
Antoine Pitrou e0793ba992 Issue #9737: Fix a crash when trying to delete a slice or an item from
a memoryview object.
2010-09-01 21:14:16 +00:00
Antoine Pitrou f68c2a701b Issue #3101: Helper functions _add_one_to_C() and _add_one_to_F() become
_Py_add_one_to_C() and _Py_add_one_to_F(), respectively.
2010-09-01 12:58:21 +00:00
Alexander Belopolsky f0f45142d5 Issue #2443: Added a new macro, Py_VA_COPY, which is equivalent to C99
va_copy, but available on all python platforms.  Untabified a few
unrelated files.
2010-08-11 17:31:17 +00:00
Antoine Pitrou 1ac745b5c5 Issue #7616: Fix copying of overlapping memoryview slices with the Intel
compiler.
2010-07-11 12:12:00 +00:00
Antoine Pitrou 05b7c5644c Merged revisions 77916 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r77916 | antoine.pitrou | 2010-02-02 23:36:17 +0100 (mar., 02 févr. 2010) | 4 lines

  Issue #7385: Fix a crash in `MemoryView_FromObject` when
  `PyObject_GetBuffer` fails.  Patch by Florent Xicluna.
........
2010-02-02 22:47:00 +00:00
Georg Brandl 61b96dc2fe Slightly improve buffer-related error message. 2009-08-04 20:29:27 +00:00
Raymond Hettinger 159eac92c5 Issue 6329: Fix iteration for memoryviews. 2009-06-23 20:38:54 +00:00
Benjamin Peterson 876185542d remove memoryview.__str__ #5182 2009-02-08 15:00:52 +00:00
Mark Dickinson e94c679df0 Issue #1717: rename tp_compare to tp_reserved. I'll change the
type of tp_compare in a separate commit, for ease of reversion
should things go wrong.
2009-02-02 20:36:42 +00:00
Antoine Pitrou 35b7e837ab Issue #4822: fix messy indentation in memoryobject.c/.h, before we may backport it to trunk.
Reviewed on IRC by Georg Brandl, with assistance by Benjamin Peterson.
2009-01-03 19:20:36 +00:00
Antoine Pitrou c3b39245a7 Issue #4580: slicing of memoryviews when itemsize != 1 is wrong.
Also fix len() to return number of items rather than length in bytes.

I'm sorry it was not possible for me to work on this without reindenting
a bit some stuff around. The indentation in memoryobject.c is a mess,
I'll open a separate bug for it.
2009-01-03 16:59:18 +00:00
Antoine Pitrou bc420400eb Issue #4569: Interpreter crash when mutating a memoryview with an item size larger than 1.
(together with a bit of reindenting)
2008-12-07 20:14:49 +00:00
Benjamin Peterson 5e19e44413 kill memoryview.size in favor of len(view)
Reviewer: Antoine Pitrou #3827
2008-09-10 21:47:03 +00:00
Antoine Pitrou c6b09ebe58 #3712: The memoryview object had a reference leak and didn't support cyclic garbage collection.
Reviewed by Benjamin Peterson.
2008-09-01 15:10:14 +00:00
Antoine Pitrou 616d28566b Issue #2394: implement more of the memoryview API. 2008-08-19 22:09:34 +00:00
Antoine Pitrou ee58fa484e #3560: cleanup C memoryview API 2008-08-19 18:22:14 +00:00
Martin v. Löwis 423be95dcf Merged revisions 65654 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r65654 | martin.v.loewis | 2008-08-12 16:49:50 +0200 (Tue, 12 Aug 2008) | 6 lines

  Issue #3139: Make buffer-interface thread-safe wrt. PyArg_ParseTuple,
  by denying s# to parse objects that have a releasebuffer procedure,
  and introducing s*.

  More module might need to get converted to use s*.
........
2008-08-13 15:53:07 +00:00
Antoine Pitrou 2f89aa6785 #2538: bytes objects can only provide read-only buffers 2008-08-02 21:02:48 +00:00
Amaury Forgeot d'Arc 9c74b14fe9 Merged revisions 64114 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk

........
  r64114 | gregory.p.smith | 2008-06-11 09:41:16 +0200 (mer., 11 juin 2008) | 6 lines

  Merge in release25-maint r60793:

   Added checks for integer overflows, contributed by Google. Some are
   only available if asserts are left in the code, in cases where they
   can't be triggered from Python code.
........
2008-06-18 00:47:36 +00:00
Travis E. Oliphant 3900088cb6 Remove locking from buffer protocol as-per discussion. 2008-06-06 20:52:38 +00:00
Christian Heimes 9c4756ea26 Renamed PyBytes to PyByteArray 2008-05-26 13:22:05 +00:00
Christian Heimes 217cfd1c86 Cleanup: Replaced most PyInt_ aliases with PyLong_ and disabled the aliases in intobject.h 2007-12-02 14:31:20 +00:00
Christian Heimes 7b6fc8e19d Fixed memoryview constructor. It allowed arbitrary keyword arguments. The bug was found by mykhal from #python. I've also added a small test case in the new test_memoryview.py 2007-11-08 02:28:11 +00:00
Neal Norwitz 61ec0d3263 Fix some Py_ssize_t warnings on Win64 that were probably bugs 2007-10-26 06:44:10 +00:00
Travis E. Oliphant fe9bed02e4 Fix problems with memoryview object. There is still more to do to finish PEP 3118. The memory-view object needs to be fleshed out and the struct module needs to be modified. 2007-10-12 23:27:53 +00:00
Guido van Rossum be801acbb1 Delete bufferobject.[ch].
This will undoubtedly require Windows build file changes too.
2007-10-08 03:32:34 +00:00
Neal Norwitz b35f128711 At least one of the buildbots was complaining about newview being used
without being initialized.  Also make the code conform to the comment and
return the new object.  This code needs a test!
2007-10-07 19:26:50 +00:00
Guido van Rossum 5dde61d0b9 Whitespace and line lengrth cleanup. 2007-09-25 22:10:05 +00:00
Travis E. Oliphant 8ae62b6094 Change PyBuffer to Py_buffer to be consistent with other non-object structures like Py_complex. Add some more functionality to the memoryview object. 2007-09-23 02:00:13 +00:00
Sean Reifscheider 54cf12b625 Fixing the spelling of "writeable" to "writable", particularly PyBUF_WRITEABLE. 2007-09-17 17:55:36 +00:00
Neal Norwitz 666bb419cb SF #1777057, fix memoryview('test') so it works in debug mode too.
Also return a boolean for the readonly flag.

Other cleanup: make sure to set an exception when returning NULL and
reformat the getsets to be shorter by putting them all on one line.
2007-08-19 18:38:46 +00:00
Neal Norwitz faa54a3929 Code review of the new buffer protocol. Mostly add questions that should
be answered with the comments removed.

There are many places that require checks when doing arithmetic for memory
sizes when allocating memory.  Otherwise, overflow is possible with
a subsequent crash.

Fix SF #1777057 which was a result of not initializing the new BufferError
properly.  Had to update the test for exceptions for BufferError too.
2007-08-19 04:23:20 +00:00
Travis E. Oliphant b99f762f10 Merged in py3k-buffer branch to main line. All objects now use the buffer protocol in PEP 3118. 2007-08-18 11:21:56 +00:00