]> granicus.if.org Git - python/commitdiff
Issue #15424: Add a __sizeof__ implementation for array objects.
authorMeador Inge <meadori@gmail.com>
Sat, 11 Aug 2012 04:21:39 +0000 (23:21 -0500)
committerMeador Inge <meadori@gmail.com>
Sat, 11 Aug 2012 04:21:39 +0000 (23:21 -0500)
Patch by Ludwig Hähne.

1  2 
Lib/test/test_array.py
Misc/ACKS
Misc/NEWS
Modules/arraymodule.c

index eb6d77fc29d2f53aa9069f7d2deac3bd8d0ce0a2,e26e9add0559340636133b1546da3a0cff484214..544c2cefa23bb80d78d0cfde55119fad6b7b6c46
@@@ -1015,6 -988,19 +1015,19 @@@ class BaseTest(unittest.TestCase)
          a = array.array('H', b"1234")
          self.assertEqual(len(a) * a.itemsize, 4)
  
 -        basesize = support.calcvobjsize('4Pi')
+     @support.cpython_only
+     def test_sizeof_with_buffer(self):
+         a = array.array(self.typecode, self.example)
 -        basesize = support.calcvobjsize('4Pi')
++        basesize = support.calcvobjsize('Pn2Pi')
+         buffer_size = a.buffer_info()[1] * a.itemsize
+         support.check_sizeof(self, a, basesize + buffer_size)
+     @support.cpython_only
+     def test_sizeof_without_buffer(self):
+         a = array.array(self.typecode)
++        basesize = support.calcvobjsize('Pn2Pi')
+         support.check_sizeof(self, a, basesize)
  
  class StringTest(BaseTest):
  
diff --cc Misc/ACKS
index 4dce609a0466884645847cfa6ef6c245b33593be,36dc7fe0a6e8912ff8be2923745a8c81d7b4d61b..037089679be592767da8529893aca571dc1617a7
+++ b/Misc/ACKS
@@@ -477,11 -433,10 +477,12 @@@ Michael Hudso
  Jim Hugunin
  Greg Humphreys
  Eric Huss
 +Taihyun Hwang
  Jeremy Hylton
+ Ludwig Hähne
  Gerhard Häring
  Fredrik Håård
 +Catalin Iacob
  Mihai Ibanescu
  Ali Ikinci
  Lars Immisch
diff --cc Misc/NEWS
index 972e769c05ae6e5c33820bfbcaf95175b18c270e,5a4d71bc358fa2d0c373f81a8f710e3e97095971..3de680549c42b0ea03402211d47fce235a9422e6
+++ b/Misc/NEWS
@@@ -16,86 -13,96 +16,89 @@@ Core and Builtin
  - Issue #13119: sys.stdout and sys.stderr are now using "\r\n" newline on
    Windows, as Python 2.
  
 -- Issue #14579: Fix CVE-2012-2135: vulnerability in the utf-16 decoder after
 -  error handling.  Patch by Serhiy Storchaka.
 -
 -- Issue #15404: Refleak in PyMethodObject repr.
 -
 -- Issue #15394: An issue in PyModule_Create that caused references to
 -  be leaked on some error paths has been fixed.  Patch by Julia Lawall.
 +- Issue #15534: Fix the fast-search function for non-ASCII Unicode strings.
  
 -- Issue #15368: An issue that caused bytecode generation to be
 -  non-deterministic when using randomized hashing (-R) has been fixed.
 +- Issue #15508: Fix the docstring for __import__ to have the proper default
 +  value of 0 for 'level' and to not mention negative levels since they are
 +  not supported.
  
 -- Issue #15020: The program name used to search for Python's path is now
 -  "python3" under Unix, not "python".
 +- Issue #15425: Eliminated traceback noise from more situations involving
 +  importlib
  
 -- Issue #15033: Fix the exit status bug when modules invoked using -m swith,
 -  return the proper failure return value (1). Patch contributed by Jeff Knupp.
 +- Issue #14578: Support modules registered in the Windows registry again.
  
 -- Issue #12268: File readline, readlines and read() or readall() methods
 -  no longer lose data when an underlying read system call is interrupted.
 -  IOError is no longer raised due to a read system call returning EINTR
 -  from within these methods.
 +- Issue #15466: Stop using TYPE_INT64 in marshal, to make importlib.h
 +  (and other byte code files) equal between 32-bit and 64-bit systems.
  
 -- Issue #15142: Fix reference leak when deallocating instances of types
 -  created using PyType_FromSpec().
 +- Issue #1692335: Move initial args assignment to
 +  BaseException.__new__ to help pickling of naive subclasses.
  
 -- Issue #10053: Don't close FDs when FileIO.__init__ fails. Loosely based on
 -  the work by Hirokazu Yamamoto.
 +- Issue #12834: Fix PyBuffer_ToContiguous() for non-contiguous arrays.
  
 -- Issue #14775: Fix a potential quadratic dict build-up due to the garbage
 -  collector repeatedly trying to untrack dicts.
 +- Issue #15456: Fix code __sizeof__ after #12399 change.
 +  Patch by Serhiy Storchaka.
  
 -- Issue #14494: Fix __future__.py and its documentation to note that
 -  absolute imports are the default behavior in 3.0 instead of 2.7.
 -  Patch by Sven Marnach.
 +- Issue #15404: Refleak in PyMethodObject repr.
  
 -- Issue #14761: Fix potential leak on an error case in the import machinery.
 +- Issue #15394: An issue in PyModule_Create that caused references to
 +  be leaked on some error paths has been fixed.  Patch by Julia Lawall.
  
 -- Issue #14699: Fix calling the classmethod descriptor directly.
 +- Issue #15368: An issue that caused bytecode generation to be
 +  non-deterministic has been fixed.
  
 -- Issue #14433: Prevent msvcrt crash in interactive prompt when stdin
 -  is closed.
 +- Issue #15202: Consistently use the name "follow_symlinks" for
 +  new parameters in os and shutil functions.
  
 -- Issue #11603 (again): Setting __repr__ to __str__ now raises a RuntimeError
 -  when repr() or str() is called on such an object.
 +- Issue #15314: __main__.__loader__ is now set correctly during
 +  interpreter startup
  
 -- Issue #14658: Fix binding a special method to a builtin implementation of a
 -  special method with a different name.
 +- Issue #15111: When a module imported using 'from import' has an ImportError
 +  inside itself, don't mask that fact behind a generic ImportError for the
 +  module itself.
  
 -- Issue #14630: Fix a memory access bug for instances of a subclass of int
 -  with value 0.
 +- Issue #15293: Add GC support to the AST base node type.
  
 -- Issue #14612: Fix jumping around with blocks by setting f_lineno.
 +- Issue #15291: Fix a memory leak where AST nodes where not properly
 +  deallocated.
  
 -- Issue #14607: Fix keyword-only arguments which started with ``__``.
 +- Issue #15110: Fix the tracebacks generated by "import xxx" to not show
 +  the importlib stack frames.
  
 -- Issue #13889: Check and (if necessary) set FPU control word before calling
 -  any of the dtoa.c string <-> float conversion functions, on MSVC builds of
 -  Python.  This fixes issues when embedding Python in a Delphi app.
 +- Issue #15020: The program name used to search for Python's path is now
 +  "python3" under Unix, not "python".
  
 -- Issue #14474: Save and restore exception state in thread.start_new_thread()
 -  while writing error message if the thread leaves a unhandled exception.
 +- Issue #15033: Fix the exit status bug when modules invoked using -m swith,
 +  return the proper failure return value (1). Patch contributed by Jeff Knupp.
  
 -- Issue #13019: Fix potential reference leaks in bytearray.extend().  Patch
 -  by Suman Saha.
 +- Issue #15229: An OSError subclass whose __init__ doesn't call back
 +  OSError.__init__ could produce incomplete instances, leading to crashes
 +  when calling str() on them.
  
 -- Issue #14378: Fix compiling ast.ImportFrom nodes with a "__future__" string as
 -  the module name that was not interned.
 +- Issue 15307: Virtual environments now use symlinks with framework builds
 +  on Mac OS X, like other POSIX builds.
  
 -- Issue #14331: Use significantly less stack space when importing modules by
 -  allocating path buffers on the heap instead of the stack.
 +Library
 +-------
  
 -- Issue #14334: Prevent in a segfault in type.__getattribute__ when it was not
 -  passed strings.
++- Issue #15424: Add a __sizeof__ implementation for array objects.
++  Patch by Ludwig Hähne.
 -- Issue #1469629: Allow cycles through an object's __dict__ slot to be
 -  collected. (For example if ``x.__dict__ is x``).
 +- Issue #15576: Allow extension modules to act as a package's __init__ module.
  
 -- Issue #14172: Fix reference leak when marshalling a buffer-like object
 -  (other than a bytes object).
 +- Issue #15502: Have importlib.invalidate_caches() work on sys.meta_path
 +  instead of sys.path_importer_cache.
  
 -- Issue #13521: dict.setdefault() now does only one lookup for the given key,
 -  making it "atomic" for many purposes.  Patch by Filip Gruszczyński.
 +- Issue #15163: Pydoc shouldn't list __loader__ as module data.
  
 -- Issue #14471: Fix a possible buffer overrun in the winreg module.
 +- Issue #15471: Do not use mutable objects as defaults for
 +  importlib.__import__().
  
 -Library
 --------
 +- Issue #15559: To avoid a problematic failure mode when passed to the bytes
 +  constructor, objects in the ipaddress module no longer implement __index__
 +  (they still implement __int__ as appropriate)
  
 -- Issue #15424: Add a __sizeof__ implementation for array objects.
 -  Patch by Ludwig Hähne.
 +- Issue #15546: Fix handling of pathological input data in the peek() and
 +  read1() methods of the BZ2File, GzipFile and LZMAFile classes.
  
  - Issue #13052: Fix IDLE crashing when replace string in Search/Replace dialog
    ended with '\'. Patch by Roger Serwy.
Simple merge