- 25 Jul, 2024 3 commits
-
-
Arnaud Fontaine authored
fixup! erp5_accounting_l10n_fr: the French Fiscal Report (FEC) can be generated for different ledgers
-
Arnaud Fontaine authored
key()-based sorting is now used instead, available since Python 2.4.
-
Arnaud Fontaine authored
-
- 23 Jul, 2024 5 commits
-
-
Jérome Perrin authored
Also, remove `if True/1/False/0` statement raising pylint warnings. Co-authored-by: Arnaud Fontaine <arnaud.fontaine@nexedi.com>
-
Jérome Perrin authored
* Zope API changes: + publish() stdin is now BytesIO rather than StringIO. + BaseResponse `body` property is now bytes(). * Python3 API changes: + builtin reduce() was removed. + Use BytesIO rather than StringIO to follow py3 API. + hmac.new() requires digestmod argument from Python 3.8. + Use six.moves library to handle moved objects from py2 to py3. + `modernize -f xrange_six` then slightly adjusted manually to just use range where it does not make a significant difference (for example in test). + base64.b64encode() now expects bytes(). + UserDict() interface changed: - New parameter in update() and pop(). - `failobj` setdefault parameter renamed to `default`. + ensure_list() on dict.{values,items}() and list(dict) for dict.keys() when we really need a list and not an iterable (Python3). - Add ensure_list() to RestrictedPython safe_builtins as it's very common usage. + Make dict iteration works on both version of Python. - Use six.iter{items,values,keys}(). - has_key() has been removed. - Make sure that dict.{items,values,keys}() returns a real list when modified (ensure_list()). + Exceptions no longer behave as sequences. Using `args` attribute instead. Co-Authored-by: Kazuhiko SHIOZAKI <kazuhiko@nexedi.com> Arnaud Fontaine <arnaud.fontaine@nexedi.com> Carlos Ramos Carreño <carlos.ramos@nexedi.com> Emmeline Vouriot <emmeline.vouriot@nexedi.com>
-
Jérome Perrin authored
-
Jérome Perrin authored
some conversion (TextDocument) depend on the content type, so it's necessary to first update the content type before trying to convert to base format
-
Jérome Perrin authored
The methods used in indexing did not make a difference between the case where the price is None (ie. price is not set) or where the price is set to 0 - in both cases this was saved as NULL in stock.total_price column. This is incorrect, we need to keep the distinction between these two cases also for inventory calculation. We had some places where we select IFNULL(stock.total_price, 0) to work around this, we don't plan to change the existing ones for now, but while discussing on !1974 we concluded that a newly idenfified case of a problem consequence of these NULL should be handled by fixing the indexation. To benefit from the fix, impacted instances will have to reindex documents present in the stock table with stock.total_price is null.
-
- 18 Jul, 2024 1 commit
-
-
Nicolas Wavrant authored
-
- 17 Jul, 2024 2 commits
-
-
Arnaud Fontaine authored
__import__ `fromlist` argument was wrong. It was working anyway with Python2 but not anymore with Python3, raising a `ModuleNotFoundError` exception. According to Python `__import__(name, globals, locals, fromlist)` documentation: When the `name` variable is of the form `package.module`, normally, the top-level package (the `name` up till the first dot) is returned, *not* the module named by `name`. However, when a non-empty `fromlist` argument is given, the module named by `name` is returned. Thus, the following patterns were wrong: * __import__(MODULE_NAME, globals(), locals(), MODULE_NAME) => Iterate through each character of MODULE_NAME as fromlist is expected to be a list/tuple. * __import__(MODULE_NAME, globals(), locals(), [MODULE_NAME]) => This works but actually tries to import MODULE_NAME object from MODULE_NAME module (no error if it cannot). The goal of such __import__ calls were for __import__ to return the right-end module instead of the top-level package. In such case, `fromlist=['']` is the way to go as it __import__ does not check if the object exists in the module if it's an empty string. However, it is even better and easier to read to use importlib.import_module() for that... Also, add `from __future__ import absolute_import` because python2 tries both relative and absolute import (level=-1 __import__ parameter) whereas python3 does absolute import by default (level=0). Co-authored-by: Kazuhiko SHIOZAKI <kazuhiko@nexedi.com>
-
Nicolas Wavrant authored
-
- 15 Jul, 2024 1 commit
-
-
Jérome Perrin authored
When under a pinDateTime context, d.isPast() was comparing d with the actual current date, not the fake date from the pinned context. Also, make the methods class methods, so that they can be used as external methods in Zelenium tests.
-
- 11 Jul, 2024 17 commits
-
-
Jérome Perrin authored
- Products.PythonScripts now has a __loader__ - do not use < > as filename for component on py3, this makes linecache work out of the box. On py2 I think it was causing errors trying to actually open the file, but this does not seem needed on py3 and simplifies everything
-
Jérome Perrin authored
-
Jérome Perrin authored
-
Jérome Perrin authored
-
Jérome Perrin authored
new test with ERP5-style workflow to cover python3 migration
-
Kazuhiko Shiozaki authored
with ROUND_DOWN, we have a different behaviour between py2/py3, that caused failures in erp5_simplified_invoicing:testTradeModelLine. Here is what happened in _round(1.9999999999999998) in bt5/erp5_simulation/DocumentTemplateItem/portal_components/document.erp5.FloatEquivalenceTester.py * py2 decimal.Decimal(str(1.9999999999999998)).quantize(decimal.Decimal('0.000001'), 'ROUND_DOWN') => Decimal('2.000000') (because str(1.9999999999999998) is '2.0') * py3 decimal.Decimal(str(1.9999999999999998)).quantize(decimal.Decimal('0.000001'), 'ROUND_DOWN') => Decimal('1.999999') (because str(1.9999999999999998) is '1.9999999999999998') But ROUND_DOWN result of 1.9999999999999998 with 0.000001 precision should be 1.999999 thus py2 behaviour is wrong.
-
Jérome Perrin authored
-
Jérome Perrin authored
Run zope with ERP5_COMPONENT_OVERRIDE_PATH set to a : separated list of path containing components files to load components from files instead of portal_components. This can be used to repair zope after a bad edit of component.
-
Jérome Perrin authored
for pylint 3 to understand erp5 dynamic modules
-
Jérome Perrin authored
We want these columns to be "binary" so that mariadbd compares them without any collation, but we don't want to use binary type, because on python 3 the brain attributes are bytes (user ids are strings everywhere else). This also normalize the same columns present in worklist cache table.
-
Jérome Perrin authored
I don't know a PYTHONHASHSEED to see the problem on python2, but on python 3 erp5_payroll_l10n_fr:testSimplifiedPayslipReport fails all the time with this.
-
Jérome Perrin authored
On python3 the percentages are sometimes printed as 6.8500000000000005%
-
Jérome Perrin authored
-
Kazuhiko Shiozaki authored
-
Jérome Perrin authored
cookie crumbler uses username:password base64 encoded and this relies on extracting the username from the cookie to set the session, but other authentication methods do not embed the username, but still share the same scripts to set the authentication cookie (so that we have one central point setting cookie with all the necessary attributes for security). The problem is that it's incorrect to try to decode an username with cookies from other authentication methods, simply because they do not contain the username. On python2 this was not causing visible error because everything is str, but the decoding error on python3 revealed this.
-
Jérome Perrin authored
-
Jérome Perrin authored
-
- 09 Jul, 2024 11 commits
-
-
Kazuhiko Shiozaki authored
in Python 2, _aq_dynamic() returns None without try..except but it raises ValueError in Python 3. (python 2) > /SR/parts/erp5/product/ZSQLCatalog/Extensions/zsqlbrain.py(31)_aq_dynamic() 31 -> def _aq_dynamic(self, name): 32 """Acquire an attribute from a real object. 33 """ 34 if name.startswith('__') : 35 return None 36 return getattr(self.getObject(), name, None) ((Pdb)) getattr(self.getObject(), name, None) *** ValueError: Unable to getObject from ZSQLBrain if ZSQL Method does not retrieve the `path` column from catalog table. ((Pdb)) r --Return-- > /SR/parts/erp5/product/ZSQLCatalog/Extensions/zsqlbrain.py(36)_aq_dynamic()->None # <-- !!! Co-authored-by: Jérome Perrin <jerome@nexedi.com>
-
Jérome Perrin authored
-
Jérome Perrin authored
- HTMLParseError no longer exist, on python3 parse_declaration throws AttributeError py2: https://github.com/python/cpython/blob/2.7/Lib/markupbase.py#L135-L140 https://github.com/python/cpython/blob/2.7/Lib/HTMLParser.py#L124 py3: https://github.com/python/cpython/blob/3.12/Lib/_markupbase.py#L130-L134 - scrubHTML must pass `html` as unicode on python2 and str on python3, adjust the check to cover both py2 / py3
-
Jérome Perrin authored
-
Jérome Perrin authored
On python2, attributes of new style classes (classes, not instances) were not properly validated. On python3, attributes of classes were not.
-
Jérome Perrin authored
In current versions, sorted is allowed in RestrictedPython. Also, our implementation of sorted was not correct with generators, it consumed the generator by iterating on it a first time to check the values.
-
Jérome Perrin authored
-
Jérome Perrin authored
-
Jérome Perrin authored
otherwise we will have an Exception in Python 3 while importing a Business Template, if a new portal type and its documents exist in the same Business Template. while importing a content file, like *.js... (BusinessTemplate.py) try: setattr(obj, property_name, data) except BrokenModified: obj.__Broken_state__[property_name] = data # <-- !!! obj._p_changed = 1 obj.__Broken_state__ access here also raises BrokenModified. while importing an XML file... (ZODB/broken.py) def __new__(class_, *args): result = object.__new__(class_) # <-- !!! result.__dict__['__Broken_newargs__'] = args return result we get an exception 'TypeError: object.__new__(Portal Type) is not safe, use Base.__new__()' Co-authored-by: Kazuhiko SHIOZAKI <kazuhiko@nexedi.com>
-
Rafael Monnerat authored
This prevents be confuse while editing the Connector.
-
Rafael Monnerat authored
This allow user know what is he configuring or accessing
-