pyicu 2.15.1__tar.gz → 2.15.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (112) hide show
  1. {pyicu-2.15.1 → pyicu-2.15.3}/CHANGES +13 -0
  2. {pyicu-2.15.1/py/PyICU.egg-info → pyicu-2.15.3}/PKG-INFO +1 -1
  3. {pyicu-2.15.1 → pyicu-2.15.3}/arg.h +4 -4
  4. {pyicu-2.15.1 → pyicu-2.15.3}/bidi.cpp +15 -30
  5. {pyicu-2.15.1 → pyicu-2.15.3}/char.cpp +3 -2
  6. {pyicu-2.15.1 → pyicu-2.15.3}/collator.cpp +10 -14
  7. {pyicu-2.15.1 → pyicu-2.15.3}/common.cpp +0 -29
  8. {pyicu-2.15.1 → pyicu-2.15.3}/common.h +36 -1
  9. {pyicu-2.15.1 → pyicu-2.15.3}/format.cpp +2 -2
  10. {pyicu-2.15.1 → pyicu-2.15.3}/iterators.cpp +3 -11
  11. {pyicu-2.15.1 → pyicu-2.15.3}/locale.cpp +32 -45
  12. {pyicu-2.15.1 → pyicu-2.15.3/py/PyICU.egg-info}/PKG-INFO +1 -1
  13. {pyicu-2.15.1 → pyicu-2.15.3}/setup.py +1 -1
  14. {pyicu-2.15.1 → pyicu-2.15.3}/timezone.cpp +3 -11
  15. {pyicu-2.15.1 → pyicu-2.15.3}/CREDITS +0 -0
  16. {pyicu-2.15.1 → pyicu-2.15.3}/LICENSE +0 -0
  17. {pyicu-2.15.1 → pyicu-2.15.3}/MANIFEST.in +0 -0
  18. {pyicu-2.15.1 → pyicu-2.15.3}/README.md +0 -0
  19. {pyicu-2.15.1 → pyicu-2.15.3}/_icu_.cpp +0 -0
  20. {pyicu-2.15.1 → pyicu-2.15.3}/bases.cpp +0 -0
  21. {pyicu-2.15.1 → pyicu-2.15.3}/bases.h +0 -0
  22. {pyicu-2.15.1 → pyicu-2.15.3}/bidi.h +0 -0
  23. {pyicu-2.15.1 → pyicu-2.15.3}/calendar.cpp +0 -0
  24. {pyicu-2.15.1 → pyicu-2.15.3}/calendar.h +0 -0
  25. {pyicu-2.15.1 → pyicu-2.15.3}/casemap.cpp +0 -0
  26. {pyicu-2.15.1 → pyicu-2.15.3}/casemap.h +0 -0
  27. {pyicu-2.15.1 → pyicu-2.15.3}/char.h +0 -0
  28. {pyicu-2.15.1 → pyicu-2.15.3}/charset.cpp +0 -0
  29. {pyicu-2.15.1 → pyicu-2.15.3}/charset.h +0 -0
  30. {pyicu-2.15.1 → pyicu-2.15.3}/collator.h +0 -0
  31. {pyicu-2.15.1 → pyicu-2.15.3}/dateformat.cpp +0 -0
  32. {pyicu-2.15.1 → pyicu-2.15.3}/dateformat.h +0 -0
  33. {pyicu-2.15.1 → pyicu-2.15.3}/displayoptions.cpp +0 -0
  34. {pyicu-2.15.1 → pyicu-2.15.3}/displayoptions.h +0 -0
  35. {pyicu-2.15.1 → pyicu-2.15.3}/errors.cpp +0 -0
  36. {pyicu-2.15.1 → pyicu-2.15.3}/errors.h +0 -0
  37. {pyicu-2.15.1 → pyicu-2.15.3}/format.h +0 -0
  38. {pyicu-2.15.1 → pyicu-2.15.3}/gender.cpp +0 -0
  39. {pyicu-2.15.1 → pyicu-2.15.3}/gender.h +0 -0
  40. {pyicu-2.15.1 → pyicu-2.15.3}/idna.cpp +0 -0
  41. {pyicu-2.15.1 → pyicu-2.15.3}/idna.h +0 -0
  42. {pyicu-2.15.1 → pyicu-2.15.3}/iterators.h +0 -0
  43. {pyicu-2.15.1 → pyicu-2.15.3}/layoutengine.cpp +0 -0
  44. {pyicu-2.15.1 → pyicu-2.15.3}/layoutengine.h +0 -0
  45. {pyicu-2.15.1 → pyicu-2.15.3}/locale.h +0 -0
  46. {pyicu-2.15.1 → pyicu-2.15.3}/macros.h +0 -0
  47. {pyicu-2.15.1 → pyicu-2.15.3}/measureunit.cpp +0 -0
  48. {pyicu-2.15.1 → pyicu-2.15.3}/measureunit.h +0 -0
  49. {pyicu-2.15.1 → pyicu-2.15.3}/messagepattern.cpp +0 -0
  50. {pyicu-2.15.1 → pyicu-2.15.3}/messagepattern.h +0 -0
  51. {pyicu-2.15.1 → pyicu-2.15.3}/normalizer.cpp +0 -0
  52. {pyicu-2.15.1 → pyicu-2.15.3}/normalizer.h +0 -0
  53. {pyicu-2.15.1 → pyicu-2.15.3}/numberformat.cpp +0 -0
  54. {pyicu-2.15.1 → pyicu-2.15.3}/numberformat.h +0 -0
  55. {pyicu-2.15.1 → pyicu-2.15.3}/py/PyICU.egg-info/SOURCES.txt +0 -0
  56. {pyicu-2.15.1 → pyicu-2.15.3}/py/PyICU.egg-info/dependency_links.txt +0 -0
  57. {pyicu-2.15.1 → pyicu-2.15.3}/py/PyICU.egg-info/top_level.txt +0 -0
  58. {pyicu-2.15.1 → pyicu-2.15.3}/py/icu/__init__.py +0 -0
  59. {pyicu-2.15.1 → pyicu-2.15.3}/pyproject.toml +0 -0
  60. {pyicu-2.15.1 → pyicu-2.15.3}/regex.cpp +0 -0
  61. {pyicu-2.15.1 → pyicu-2.15.3}/regex.h +0 -0
  62. {pyicu-2.15.1 → pyicu-2.15.3}/samples/break.py +0 -0
  63. {pyicu-2.15.1 → pyicu-2.15.3}/samples/strsrch.py +0 -0
  64. {pyicu-2.15.1 → pyicu-2.15.3}/script.cpp +0 -0
  65. {pyicu-2.15.1 → pyicu-2.15.3}/script.h +0 -0
  66. {pyicu-2.15.1 → pyicu-2.15.3}/search.cpp +0 -0
  67. {pyicu-2.15.1 → pyicu-2.15.3}/search.h +0 -0
  68. {pyicu-2.15.1 → pyicu-2.15.3}/setup.cfg +0 -0
  69. {pyicu-2.15.1 → pyicu-2.15.3}/shape.cpp +0 -0
  70. {pyicu-2.15.1 → pyicu-2.15.3}/shape.h +0 -0
  71. {pyicu-2.15.1 → pyicu-2.15.3}/spoof.cpp +0 -0
  72. {pyicu-2.15.1 → pyicu-2.15.3}/spoof.h +0 -0
  73. {pyicu-2.15.1 → pyicu-2.15.3}/test/__init__.py +0 -0
  74. {pyicu-2.15.1 → pyicu-2.15.3}/test/lohit_hi.ttf +0 -0
  75. {pyicu-2.15.1 → pyicu-2.15.3}/test/noms.txt +0 -0
  76. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Bidi.py +0 -0
  77. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_BreakIterator.py +0 -0
  78. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_BytesTrie.py +0 -0
  79. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Charset.py +0 -0
  80. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Collator.py +0 -0
  81. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_DateTimePatternGenerator.py +0 -0
  82. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_LayoutEngine.py +0 -0
  83. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_ListFormatter.py +0 -0
  84. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Locale.py +0 -0
  85. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_LocaleData.py +0 -0
  86. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_LocaleMatcher.py +0 -0
  87. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_MessageFormat.py +0 -0
  88. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_MessagePattern.py +0 -0
  89. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Normalizer.py +0 -0
  90. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_NumberFormat.py +0 -0
  91. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_NumberFormatter.py +0 -0
  92. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Property.py +0 -0
  93. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_PythonReplaceable.py +0 -0
  94. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Regex.py +0 -0
  95. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Script.py +0 -0
  96. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_SimpleFormatter.py +0 -0
  97. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Spoof.py +0 -0
  98. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_TimeZone.py +0 -0
  99. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_Transliterator.py +0 -0
  100. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_UCS4.py +0 -0
  101. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_UCharsTrie.py +0 -0
  102. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_UDate.py +0 -0
  103. {pyicu-2.15.1 → pyicu-2.15.3}/test/test_UnicodeSet.py +0 -0
  104. {pyicu-2.15.1 → pyicu-2.15.3}/timezone.h +0 -0
  105. {pyicu-2.15.1 → pyicu-2.15.3}/transliterator.cpp +0 -0
  106. {pyicu-2.15.1 → pyicu-2.15.3}/transliterator.h +0 -0
  107. {pyicu-2.15.1 → pyicu-2.15.3}/tries.cpp +0 -0
  108. {pyicu-2.15.1 → pyicu-2.15.3}/tries.h +0 -0
  109. {pyicu-2.15.1 → pyicu-2.15.3}/tzinfo.cpp +0 -0
  110. {pyicu-2.15.1 → pyicu-2.15.3}/tzinfo.h +0 -0
  111. {pyicu-2.15.1 → pyicu-2.15.3}/unicodeset.cpp +0 -0
  112. {pyicu-2.15.1 → pyicu-2.15.3}/unicodeset.h +0 -0
@@ -1,3 +1,16 @@
1
+ Issues can be seen at https://gitlab.pyicu.org/main/pyicu/-/issues/<num>
2
+
3
+ Version 2.15.2 -> 2.15.3
4
+ ------------------------
5
+ - replaced all malloc/calloc/free with std::unique_ptr<T[]>
6
+ - fixed issue #173
7
+ - fixed issue #175
8
+ - fixed issue #176
9
+
10
+ Version 2.15.1 -> 2.15.2
11
+ ------------------------
12
+ - fixed calloc/free mismatch with arg::Q() uses (Fredrik Roubert)
13
+
1
14
  Version 2.15 -> 2.15.1
2
15
  ----------------------
3
16
  - fixed build error missing conditional ICU < 70 in UnicodeSetIterator()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyicu
3
- Version: 2.15.1
3
+ Version: 2.15.3
4
4
  Summary: Python extension wrapping the ICU C++ API
5
5
  Home-page: https://gitlab.pyicu.org/main/pyicu
6
6
  Author: Andi Vajda
@@ -385,13 +385,13 @@ template <typename T> class ICUObjectArray {
385
385
  private:
386
386
  const classid id;
387
387
  PyTypeObject *const type;
388
- std::unique_ptr<T *> *const array;
388
+ std::unique_ptr<T *[]> *const array;
389
389
  size_t *const len;
390
390
 
391
391
  public:
392
392
  ICUObjectArray() = delete;
393
393
 
394
- explicit ICUObjectArray(classid param1, PyTypeObject *param2, std::unique_ptr<T *> *param3, size_t *param4) noexcept
394
+ explicit ICUObjectArray(classid param1, PyTypeObject *param2, std::unique_ptr<T *[]> *param3, size_t *param4) noexcept
395
395
  : id(param1), type(param2), array(param3), len(param4) {}
396
396
 
397
397
  int parse(PyObject *arg) const
@@ -409,7 +409,7 @@ public:
409
409
  return -1;
410
410
  }
411
411
 
412
- array->reset(reinterpret_cast<T **>(pl2cpa(arg, len, id, type)));
412
+ *array = pl2cpa<T>(arg, len, id, type);
413
413
  if (!array->get())
414
414
  return -1;
415
415
 
@@ -853,7 +853,7 @@ public:
853
853
  };
854
854
 
855
855
  #define _IS_POD(T) \
856
- static_assert(std::is_trivial<T>::value); \
856
+ static_assert(std::is_trivially_copyable<T>::value); \
857
857
  static_assert(std::is_standard_layout<T>::value)
858
858
 
859
859
  _IS_POD(AnyPythonObject);
@@ -672,17 +672,12 @@ static PyObject *t_bidi_getLogicalMap(t_bidi *self)
672
672
  else
673
673
  length = ubidi_getProcessedLength(self->object);
674
674
 
675
- int *indexMap = (int *) calloc(length, sizeof(int));
675
+ std::unique_ptr<int[]> indexMap(new int[length]);
676
676
 
677
- if (indexMap == NULL)
677
+ if (!indexMap.get())
678
678
  return PyErr_NoMemory();
679
679
 
680
- STATUS_CALL(
681
- {
682
- ubidi_getLogicalMap(self->object, indexMap, &status);
683
- if (U_FAILURE(status))
684
- free(indexMap);
685
- });
680
+ STATUS_CALL(ubidi_getLogicalMap(self->object, indexMap.get(), &status));
686
681
 
687
682
  PyObject *result = PyTuple_New(length);
688
683
 
@@ -691,7 +686,6 @@ static PyObject *t_bidi_getLogicalMap(t_bidi *self)
691
686
  for (int i = 0; i < length; ++i)
692
687
  PyTuple_SET_ITEM(result, i, PyInt_FromLong(indexMap[i]));
693
688
  }
694
- free(indexMap);
695
689
 
696
690
  return result;
697
691
  }
@@ -705,17 +699,12 @@ static PyObject *t_bidi_getVisualMap(t_bidi *self)
705
699
  else
706
700
  length = ubidi_getResultLength(self->object);
707
701
 
708
- int *indexMap = (int *) calloc(length, sizeof(int));
702
+ std::unique_ptr<int[]> indexMap(new int[length]);
709
703
 
710
- if (indexMap == NULL)
704
+ if (!indexMap.get())
711
705
  return PyErr_NoMemory();
712
706
 
713
- STATUS_CALL(
714
- {
715
- ubidi_getVisualMap(self->object, indexMap, &status);
716
- if (U_FAILURE(status))
717
- free(indexMap);
718
- });
707
+ STATUS_CALL(ubidi_getVisualMap(self->object, indexMap.get(), &status));
719
708
 
720
709
  PyObject *result = PyTuple_New(length);
721
710
 
@@ -724,7 +713,6 @@ static PyObject *t_bidi_getVisualMap(t_bidi *self)
724
713
  for (int i = 0; i < length; ++i)
725
714
  PyTuple_SET_ITEM(result, i, PyInt_FromLong(indexMap[i]));
726
715
  }
727
- free(indexMap);
728
716
 
729
717
  return result;
730
718
  }
@@ -736,12 +724,12 @@ static PyObject *t_bidi_reorderLogical(PyTypeObject *type, PyObject *arg)
736
724
 
737
725
  if (!parseArg(arg, arg::H(&levels, &length)))
738
726
  {
739
- int *indexMap = (int *) calloc(length, sizeof(int));
727
+ std::unique_ptr<int[]> indexMap(new int[length]);
740
728
 
741
- if (indexMap == NULL)
729
+ if (!indexMap.get())
742
730
  return PyErr_NoMemory();
743
731
 
744
- ubidi_reorderLogical((const UBiDiLevel *) levels.get(), length, indexMap);
732
+ ubidi_reorderLogical((const UBiDiLevel *) levels.get(), length, indexMap.get());
745
733
 
746
734
  PyObject *result = PyTuple_New(length);
747
735
 
@@ -750,7 +738,6 @@ static PyObject *t_bidi_reorderLogical(PyTypeObject *type, PyObject *arg)
750
738
  for (size_t i = 0; i < length; ++i)
751
739
  PyTuple_SET_ITEM(result, i, PyInt_FromLong(indexMap[i]));
752
740
  }
753
- free(indexMap);
754
741
 
755
742
  return result;
756
743
  }
@@ -765,12 +752,12 @@ static PyObject *t_bidi_reorderVisual(PyTypeObject *type, PyObject *arg)
765
752
 
766
753
  if (!parseArg(arg, arg::H(&levels, &length)))
767
754
  {
768
- int *indexMap = (int *) calloc(length, sizeof(int));
755
+ std::unique_ptr<int[]> indexMap(new int[length]);
769
756
 
770
- if (indexMap == NULL)
757
+ if (!indexMap.get())
771
758
  return PyErr_NoMemory();
772
759
 
773
- ubidi_reorderVisual((const UBiDiLevel *) levels.get(), length, indexMap);
760
+ ubidi_reorderVisual((const UBiDiLevel *) levels.get(), length, indexMap.get());
774
761
 
775
762
  PyObject *result = PyTuple_New(length);
776
763
 
@@ -779,7 +766,6 @@ static PyObject *t_bidi_reorderVisual(PyTypeObject *type, PyObject *arg)
779
766
  for (size_t i = 0; i < length; ++i)
780
767
  PyTuple_SET_ITEM(result, i, PyInt_FromLong(indexMap[i]));
781
768
  }
782
- free(indexMap);
783
769
 
784
770
  return result;
785
771
  }
@@ -801,12 +787,12 @@ static PyObject *t_bidi_invertMap(PyTypeObject *type, PyObject *arg)
801
787
  maxSrc = srcMap[i];
802
788
 
803
789
  int destLength = maxSrc + 1;
804
- int *destMap = (int *) calloc(destLength, sizeof(int));
790
+ std::unique_ptr<int[]> destMap(new int[destLength]);
805
791
 
806
- if (destMap == NULL)
792
+ if (!destMap.get())
807
793
  return PyErr_NoMemory();
808
794
 
809
- ubidi_invertMap((const int *) srcMap.get(), destMap, srcLength);
795
+ ubidi_invertMap((const int *) srcMap.get(), destMap.get(), srcLength);
810
796
 
811
797
  PyObject *result = PyTuple_New(destLength);
812
798
 
@@ -815,7 +801,6 @@ static PyObject *t_bidi_invertMap(PyTypeObject *type, PyObject *arg)
815
801
  for (int i = 0; i < destLength; ++i)
816
802
  PyTuple_SET_ITEM(result, i, PyInt_FromLong(destMap[i]));
817
803
  }
818
- free(destMap);
819
804
 
820
805
  return result;
821
806
  }
@@ -1,5 +1,5 @@
1
1
  /* ====================================================================
2
- * Copyright (c) 2004-2024 Open Source Applications Foundation.
2
+ * Copyright (c) 2004-2025 Open Source Applications Foundation.
3
3
  *
4
4
  * Permission is hereby granted, free of charge, to any person obtaining a
5
5
  * copy of this software and associated documentation files (the "Software"),
@@ -1166,6 +1166,7 @@ void _init_char(PyObject *m)
1166
1166
  INSTALL_ENUM(UProperty, "BIDI_MIRRORED", UCHAR_BIDI_MIRRORED);
1167
1167
  INSTALL_ENUM(UProperty, "DASH", UCHAR_DASH);
1168
1168
  INSTALL_ENUM(UProperty, "DEFAULT_IGNORABLE_CODE_POINT", UCHAR_DEFAULT_IGNORABLE_CODE_POINT);
1169
+ INSTALL_ENUM(UProperty, "DEPRECATED", UCHAR_DEPRECATED);
1169
1170
  INSTALL_ENUM(UProperty, "DIACRITIC", UCHAR_DIACRITIC);
1170
1171
  INSTALL_ENUM(UProperty, "EXTENDER", UCHAR_EXTENDER);
1171
1172
  INSTALL_ENUM(UProperty, "FULL_COMPOSITION_EXCLUSION", UCHAR_FULL_COMPOSITION_EXCLUSION);
@@ -1305,7 +1306,7 @@ void _init_char(PyObject *m)
1305
1306
  INSTALL_ENUM(UProperty, "IDENTIFIER_STATUS", UCHAR_IDENTIFIER_STATUS);
1306
1307
  INSTALL_ENUM(UProperty, "IDENTIFIER_TYPE", UCHAR_IDENTIFIER_TYPE);
1307
1308
  #endif
1308
- INSTALL_ENUM(UProperty, "INVALID_CODE ", UCHAR_INVALID_CODE );
1309
+ INSTALL_ENUM(UProperty, "INVALID_CODE", UCHAR_INVALID_CODE);
1309
1310
 
1310
1311
  INSTALL_ENUM(UCharDirection, "LEFT_TO_RIGHT", U_LEFT_TO_RIGHT);
1311
1312
  INSTALL_ENUM(UCharDirection, "RIGHT_TO_LEFT", U_RIGHT_TO_LEFT);
@@ -536,7 +536,7 @@ static PyObject *t_collator_getSortKey(t_collator *self, PyObject *args)
536
536
  UnicodeString *u;
537
537
  UnicodeString _u;
538
538
  int len, size;
539
- uint8_t *buf;
539
+ std::unique_ptr<uint8_t[]> buf;
540
540
  PyObject *key;
541
541
 
542
542
  switch (PyTuple_Size(args)) {
@@ -544,21 +544,18 @@ static PyObject *t_collator_getSortKey(t_collator *self, PyObject *args)
544
544
  if (!parseArgs(args, arg::S(&u, &_u)))
545
545
  {
546
546
  len = u->length() * 4 + 8;
547
- buf = (uint8_t *) malloc(len);
547
+ buf.reset(new uint8_t[len]);
548
548
  retry:
549
- if (buf == NULL)
549
+ if (!buf.get())
550
550
  return PyErr_NoMemory();
551
551
 
552
- size = self->object->getSortKey(*u, buf, len);
552
+ size = self->object->getSortKey(*u, buf.get(), len);
553
553
  if (size <= len)
554
- {
555
- key = PyBytes_FromStringAndSize((char *) buf, size);
556
- free(buf);
557
- }
554
+ key = PyBytes_FromStringAndSize((char *) buf.get(), size);
558
555
  else
559
556
  {
560
557
  len = size;
561
- buf = (uint8_t *) realloc(buf, len);
558
+ buf.reset(new uint8_t[len]);
562
559
  goto retry;
563
560
  }
564
561
 
@@ -568,13 +565,12 @@ static PyObject *t_collator_getSortKey(t_collator *self, PyObject *args)
568
565
  case 2:
569
566
  if (!parseArgs(args, arg::S(&u, &_u), arg::i(&len)))
570
567
  {
571
- buf = (uint8_t *) calloc(len, 1);
572
- if (buf == NULL)
568
+ buf.reset(new uint8_t[len]);
569
+ if (!buf.get())
573
570
  return PyErr_NoMemory();
574
571
 
575
- len = self->object->getSortKey(*u, buf, len);
576
- key = PyBytes_FromStringAndSize((char *) buf, len);
577
- free(buf);
572
+ len = self->object->getSortKey(*u, buf.get(), len);
573
+ key = PyBytes_FromStringAndSize((char *) buf.get(), len);
578
574
 
579
575
  return key;
580
576
  }
@@ -645,35 +645,6 @@ int isInstance(PyObject *arg, classid id, PyTypeObject *type)
645
645
  return 0;
646
646
  }
647
647
 
648
- UObject **pl2cpa(PyObject *arg, size_t *len, classid id, PyTypeObject *type)
649
- {
650
- if (PySequence_Check(arg))
651
- {
652
- *len = (int) PySequence_Size(arg);
653
- UObject **array = (UObject **) calloc(*len, sizeof(UObject *));
654
-
655
- for (size_t i = 0; i < *len; i++) {
656
- PyObject *obj = PySequence_GetItem(arg, i);
657
-
658
- if (isInstance(obj, id, type))
659
- {
660
- array[i] = ((t_uobject *) obj)->object;
661
- Py_DECREF(obj);
662
- }
663
- else
664
- {
665
- Py_DECREF(obj);
666
- free(array);
667
- return NULL;
668
- }
669
- }
670
-
671
- return array;
672
- }
673
-
674
- return NULL;
675
- }
676
-
677
648
  PyObject *cpa2pl(UObject **array, size_t len, PyObject *(*wrap)(UObject *, int))
678
649
  {
679
650
  PyObject *list = PyList_New(len);
@@ -449,7 +449,42 @@ Formattable *toFormattable(PyObject *arg);
449
449
  Formattable *toFormattableArray(PyObject *arg, size_t *len,
450
450
  classid id, PyTypeObject *type);
451
451
 
452
- UObject **pl2cpa(PyObject *arg, size_t *len, classid id, PyTypeObject *type);
452
+ #include "bases.h"
453
+
454
+ template <typename T>
455
+ std::unique_ptr<T *[]> pl2cpa(PyObject *arg, size_t *len, classid id, PyTypeObject *type)
456
+ {
457
+ std::unique_ptr<T *[]> array;
458
+
459
+ if (PySequence_Check(arg))
460
+ {
461
+ *len = (int) PySequence_Size(arg);
462
+ array.reset(new T *[*len]);
463
+ if (!array.get())
464
+ PyErr_NoMemory();
465
+ else
466
+ {
467
+ for (size_t i = 0; i < *len; i++) {
468
+ PyObject *obj = PySequence_GetItem(arg, i);
469
+
470
+ if (isInstance(obj, id, type))
471
+ {
472
+ array[i] = reinterpret_cast<T *>(((t_uobject *) obj)->object);
473
+ Py_DECREF(obj);
474
+ }
475
+ else
476
+ {
477
+ Py_DECREF(obj);
478
+ array.reset(nullptr);
479
+ break;
480
+ }
481
+ }
482
+ }
483
+ }
484
+
485
+ return array;
486
+ }
487
+
453
488
  PyObject *cpa2pl(UObject **array, size_t len, PyObject *(*wrap)(UObject *, int));
454
489
 
455
490
  int *toIntArray(PyObject *arg, size_t *len);
@@ -964,7 +964,7 @@ static PyObject *t_measureformat_formatMeasure(t_measureformat *self,
964
964
  static PyObject *t_measureformat_formatMeasures(t_measureformat *self,
965
965
  PyObject *args)
966
966
  {
967
- std::unique_ptr<Measure *> measures;
967
+ std::unique_ptr<Measure *[]> measures;
968
968
  size_t len;
969
969
  FieldPosition dont_care(FieldPosition::DONT_CARE);
970
970
  FieldPosition *fp;
@@ -1288,7 +1288,7 @@ static PyObject *t_messageformat_getFormats(t_messageformat *self)
1288
1288
  static PyObject *t_messageformat_setFormats(t_messageformat *self,
1289
1289
  PyObject *arg)
1290
1290
  {
1291
- std::unique_ptr<Format *> formats;
1291
+ std::unique_ptr<Format *[]> formats;
1292
1292
  size_t len;
1293
1293
 
1294
1294
  if (!parseArg(arg, arg::Q<Format>(TYPE_ID(Format), &formats, &len)))
@@ -1142,33 +1142,25 @@ static PyObject *t_breakiterator_getRuleStatusVec(t_breakiterator *self)
1142
1142
 
1143
1143
  if (status == U_BUFFER_OVERFLOW_ERROR)
1144
1144
  {
1145
- int32_t *buffer = (int32_t *) calloc(count, sizeof(int32_t));
1145
+ std::unique_ptr<int32_t[]> buffer(new int32_t[count]);
1146
1146
 
1147
- if (buffer == NULL)
1147
+ if (!buffer.get())
1148
1148
  return PyErr_NoMemory();
1149
1149
 
1150
1150
  status = U_ZERO_ERROR;
1151
- count = self->object->getRuleStatusVec(buffer, count, status);
1151
+ count = self->object->getRuleStatusVec(buffer.get(), count, status);
1152
1152
 
1153
1153
  if (U_FAILURE(status))
1154
- {
1155
- free(buffer);
1156
1154
  return ICUException(status).reportError();
1157
- }
1158
1155
 
1159
1156
  PyObject *tuple = PyTuple_New(count);
1160
1157
 
1161
1158
  if (!tuple)
1162
- {
1163
- free(buffer);
1164
1159
  return NULL;
1165
- }
1166
1160
 
1167
1161
  for (int i = 0; i < count; ++i)
1168
1162
  PyTuple_SET_ITEM(tuple, i, PyInt_FromLong(buffer[i]));
1169
1163
 
1170
- free(buffer);
1171
-
1172
1164
  return tuple;
1173
1165
  }
1174
1166
 
@@ -2253,33 +2253,25 @@ static PyObject *t_localebuilder_build(t_localebuilder *self)
2253
2253
 
2254
2254
  #if U_ICU_VERSION_HEX >= VERSION_HEX(65, 0, 0)
2255
2255
 
2256
- // takes ownership of locales pointer array
2257
2256
  class LocaleIterator : public Locale::Iterator {
2258
2257
  public:
2259
- LocaleIterator(Locale **locales, int len) :
2260
- locales_(locales), len_(len),
2261
- current_(0)
2258
+ LocaleIterator(std::unique_ptr<Locale *[]> &&locales, int len) :
2259
+ locales(std::move(locales)), len(len), current(0)
2262
2260
  {}
2263
2261
 
2264
- ~LocaleIterator()
2265
- {
2266
- free(locales_); // allocated with calloc in pl2cpa in common.cpp
2267
- }
2268
-
2269
2262
  UBool hasNext() const override
2270
2263
  {
2271
- return current_ < len_;
2264
+ return current < len;
2272
2265
  }
2273
2266
 
2274
2267
  const Locale &next() override
2275
2268
  {
2276
- return *locales_[current_++];
2269
+ return *locales[current++];
2277
2270
  }
2278
2271
 
2279
2272
  private:
2280
- Locale **locales_;
2281
- int len_;
2282
- int current_;
2273
+ std::unique_ptr<Locale *[]> locales;
2274
+ int len, current;
2283
2275
  };
2284
2276
 
2285
2277
 
@@ -2322,12 +2314,12 @@ static PyObject *t_localematcherbuilder_setSupportedLocalesFromListString(
2322
2314
  static PyObject *t_localematcherbuilder_setSupportedLocales(
2323
2315
  t_localematcherbuilder *self, PyObject *arg)
2324
2316
  {
2325
- std::unique_ptr<Locale *> locales;
2317
+ std::unique_ptr<Locale *[]> locales;
2326
2318
  size_t len;
2327
2319
 
2328
2320
  if (!parseArg(arg, arg::Q<Locale>(TYPE_CLASSID(Locale), &locales, &len)))
2329
2321
  {
2330
- LocaleIterator it(locales.release(), len);
2322
+ LocaleIterator it(std::move(locales), len);
2331
2323
 
2332
2324
  self->object->setSupportedLocales(it);
2333
2325
  Py_RETURN_SELF();
@@ -2499,7 +2491,7 @@ static PyObject *t_localematcher_getBestMatch(t_localematcher *self,
2499
2491
  PyObject *arg)
2500
2492
  {
2501
2493
  Locale *locale;
2502
- std::unique_ptr<Locale *> locales;
2494
+ std::unique_ptr<Locale *[]> locales;
2503
2495
  size_t len;
2504
2496
 
2505
2497
  if (!parseArg(arg, arg::P<Locale>(TYPE_CLASSID(Locale), &locale)))
@@ -2512,7 +2504,7 @@ static PyObject *t_localematcher_getBestMatch(t_localematcher *self,
2512
2504
 
2513
2505
  if (!parseArg(arg, arg::Q<Locale>(TYPE_CLASSID(Locale), &locales, &len)))
2514
2506
  {
2515
- LocaleIterator it(locales.release(), len);
2507
+ LocaleIterator it(std::move(locales), len);
2516
2508
  const Locale *result;
2517
2509
 
2518
2510
  STATUS_CALL(result = self->object->getBestMatch(it, status));
@@ -2546,7 +2538,7 @@ static PyObject *t_localematcher_getBestMatchResult(
2546
2538
  t_localematcher *self, PyObject *arg)
2547
2539
  {
2548
2540
  Locale *locale;
2549
- std::unique_ptr<Locale *> locales;
2541
+ std::unique_ptr<Locale *[]> locales;
2550
2542
  size_t len;
2551
2543
 
2552
2544
  if (!parseArg(arg, arg::P<Locale>(TYPE_CLASSID(Locale), &locale)))
@@ -2559,7 +2551,7 @@ static PyObject *t_localematcher_getBestMatchResult(
2559
2551
 
2560
2552
  if (!parseArg(arg, arg::Q<Locale>(TYPE_CLASSID(Locale), &locales, &len)))
2561
2553
  {
2562
- LocaleIterator it(locales.release(), len);
2554
+ LocaleIterator it(std::move(locales), len);
2563
2555
 
2564
2556
  STATUS_RESULT_CALL(
2565
2557
  LocaleMatcherResult result = self->object->getBestMatchResult(
@@ -2608,17 +2600,11 @@ static PyObject *t_localematcher_acceptLanguage(PyTypeObject *type,
2608
2600
  arg::m(&accepts, &num_accepts),
2609
2601
  arg::m(&locales, &num_locales)))
2610
2602
  {
2611
- const char **accept_buffers =
2612
- (const char **) calloc(num_accepts, sizeof(char *));
2613
- const char **locale_buffers =
2614
- (const char **) calloc(num_locales, sizeof(char *));
2603
+ std::unique_ptr<const char *[]> accept_buffers(new const char *[num_accepts]);
2604
+ std::unique_ptr<const char *[]> locale_buffers(new const char *[num_locales]);
2615
2605
 
2616
- if (!accept_buffers || !locale_buffers)
2617
- {
2618
- free(locale_buffers);
2619
- free(accept_buffers);
2606
+ if (!accept_buffers.get() || !locale_buffers.get())
2620
2607
  return PyErr_NoMemory();
2621
- }
2622
2608
 
2623
2609
  for (size_t i = 0; i < num_accepts; ++i)
2624
2610
  accept_buffers[i] = accepts[i].c_str();
@@ -2628,14 +2614,10 @@ static PyObject *t_localematcher_acceptLanguage(PyTypeObject *type,
2628
2614
 
2629
2615
  UErrorCode status = U_ZERO_ERROR;
2630
2616
  UEnumeration *locale_enum = uenum_openCharStringsEnumeration(
2631
- locale_buffers, num_locales, &status);
2617
+ locale_buffers.get(), num_locales, &status);
2632
2618
 
2633
2619
  if (U_FAILURE(status))
2634
- {
2635
- free(locale_buffers);
2636
- free(accept_buffers);
2637
2620
  return ICUException(status).reportError();
2638
- }
2639
2621
  else
2640
2622
  status = U_ZERO_ERROR;
2641
2623
 
@@ -2643,11 +2625,9 @@ static PyObject *t_localematcher_acceptLanguage(PyTypeObject *type,
2643
2625
  char buffer[128];
2644
2626
  size_t size = uloc_acceptLanguage(
2645
2627
  buffer, sizeof(buffer), &result,
2646
- accept_buffers, num_accepts, locale_enum, &status);
2628
+ accept_buffers.get(), num_accepts, locale_enum, &status);
2647
2629
 
2648
2630
  uenum_close(locale_enum);
2649
- free(locale_buffers);
2650
- free(accept_buffers);
2651
2631
 
2652
2632
  if (U_FAILURE(status))
2653
2633
  return ICUException(status).reportError();
@@ -2682,10 +2662,9 @@ static PyObject *t_localematcher_acceptLanguageFromHTTP(PyTypeObject *type,
2682
2662
  arg::n(&header_value),
2683
2663
  arg::m(&locales, &num_locales)))
2684
2664
  {
2685
- const char **locale_buffers =
2686
- (const char **) calloc(num_locales, sizeof(char *));
2665
+ std::unique_ptr<const char *[]> locale_buffers(new const char *[num_locales]);
2687
2666
 
2688
- if (!locale_buffers)
2667
+ if (!locale_buffers.get())
2689
2668
  return PyErr_NoMemory();
2690
2669
 
2691
2670
  for (size_t i = 0; i < num_locales; ++i)
@@ -2693,13 +2672,10 @@ static PyObject *t_localematcher_acceptLanguageFromHTTP(PyTypeObject *type,
2693
2672
 
2694
2673
  UErrorCode status = U_ZERO_ERROR;
2695
2674
  UEnumeration *locale_enum = uenum_openCharStringsEnumeration(
2696
- locale_buffers, num_locales, &status);
2675
+ locale_buffers.get(), num_locales, &status);
2697
2676
 
2698
2677
  if (U_FAILURE(status))
2699
- {
2700
- free(locale_buffers);
2701
2678
  return ICUException(status).reportError();
2702
- }
2703
2679
  else
2704
2680
  status = U_ZERO_ERROR;
2705
2681
 
@@ -2710,7 +2686,6 @@ static PyObject *t_localematcher_acceptLanguageFromHTTP(PyTypeObject *type,
2710
2686
  header_value.c_str(), locale_enum, &status);
2711
2687
 
2712
2688
  uenum_close(locale_enum);
2713
- free(locale_buffers);
2714
2689
 
2715
2690
  if (U_FAILURE(status))
2716
2691
  return ICUException(status).reportError();
@@ -3003,11 +2978,23 @@ void _init_locale(PyObject *m)
3003
2978
 
3004
2979
  INSTALL_ENUM(ULocaleDataExemplarSetType, "ES_STANDARD",
3005
2980
  ULOCDATA_ES_STANDARD);
2981
+ INSTALL_ENUM(ULocaleDataExemplarSetType, "STANDARD",
2982
+ ULOCDATA_ES_STANDARD);
3006
2983
  INSTALL_ENUM(ULocaleDataExemplarSetType, "ES_AUXILIARY",
3007
2984
  ULOCDATA_ES_AUXILIARY);
2985
+ INSTALL_ENUM(ULocaleDataExemplarSetType, "AUXILIARY",
2986
+ ULOCDATA_ES_AUXILIARY);
3008
2987
  #if U_ICU_VERSION_HEX >= 0x04080000
3009
2988
  INSTALL_ENUM(ULocaleDataExemplarSetType, "ES_INDEX",
3010
2989
  ULOCDATA_ES_INDEX);
2990
+ INSTALL_ENUM(ULocaleDataExemplarSetType, "INDEX",
2991
+ ULOCDATA_ES_INDEX);
2992
+ #endif
2993
+ #if U_ICU_VERSION_HEX >= VERSION_HEX(51, 0, 0)
2994
+ INSTALL_ENUM(ULocaleDataExemplarSetType, "ES_PUNCTUATION",
2995
+ ULOCDATA_ES_PUNCTUATION);
2996
+ INSTALL_ENUM(ULocaleDataExemplarSetType, "PUNCTUATION",
2997
+ ULOCDATA_ES_PUNCTUATION);
3011
2998
  #endif
3012
2999
 
3013
3000
  INSTALL_ENUM(UMeasurementSystem, "SI", UMS_SI);
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pyicu
3
- Version: 2.15.1
3
+ Version: 2.15.3
4
4
  Summary: Python extension wrapping the ICU C++ API
5
5
  Home-page: https://gitlab.pyicu.org/main/pyicu
6
6
  Author: Andi Vajda
@@ -8,7 +8,7 @@ except ImportError:
8
8
 
9
9
  from distutils.spawn import find_executable
10
10
 
11
- VERSION = '2.15.1'
11
+ VERSION = '2.15.3'
12
12
  ICU_MAX_MAJOR_VERSION = '77' # max supported major version of ICU
13
13
 
14
14
  try:
@@ -1419,33 +1419,25 @@ static PyObject *t_basictimezone_getTimeZoneRules(t_basictimezone *self)
1419
1419
  STATUS_CALL(count = self->object->countTransitionRules(status));
1420
1420
 
1421
1421
  const InitialTimeZoneRule *initial;
1422
- const TimeZoneRule **rules =
1423
- (const TimeZoneRule **) calloc(count, sizeof(const TimeZoneRule *));
1424
- if (rules == NULL)
1422
+ std::unique_ptr<const TimeZoneRule *[]> rules(new const TimeZoneRule *[count]);
1423
+ if (!rules.get())
1425
1424
  return PyErr_NoMemory();
1426
1425
 
1427
1426
  UErrorCode status = U_ZERO_ERROR;
1428
1427
 
1429
- self->object->getTimeZoneRules(initial, rules, count, status);
1428
+ self->object->getTimeZoneRules(initial, rules.get(), count, status);
1430
1429
  if (U_FAILURE(status))
1431
- {
1432
- free(rules);
1433
1430
  return ICUException(status).reportError();
1434
- }
1435
1431
 
1436
1432
  PyObject *result = PyTuple_New(count + 1);
1437
1433
 
1438
1434
  if (result == NULL)
1439
- {
1440
- free(rules);
1441
1435
  return NULL;
1442
- }
1443
1436
 
1444
1437
  PyTuple_SET_ITEM(result, 0, wrap_TimeZoneRule(*initial));
1445
1438
  for (int i = 0; i < count; ++i)
1446
1439
  PyTuple_SET_ITEM(result, i + 1, wrap_TimeZoneRule(*rules[i]));
1447
1440
 
1448
- free(rules);
1449
1441
  return result;
1450
1442
  }
1451
1443
 
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes