[issue29464] Specialize FASTCALL for functions with positional-only parameters
Tim Graham added the comment: Hi, I observed an error while trying to install numpy after 6969eaf4682beb01bc95eeb14f5ce6c01312e297. gcc: numpy/random/mtrand/mtrand.c numpy/random/mtrand/mtrand.c: In function ‘__Pyx_PyCFunction_FastCall’: numpy/random/mtrand/mtrand.c:44374:5: error: too many arguments to function ‘(struct PyObject * (*)(struct PyObject *, struct PyObject **, Py_ssize_t))meth’ return (*((__Pyx_PyCFunctionFast)meth)) (self, args, nargs, NULL); ^ Is this a bug in Python or does it need to be fixed in numpy? -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue29464> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue29464] Specialize FASTCALL for functions with positional-only parameters
Tim Graham added the comment: Thanks, I'm not sure what that means exactly but I added the note to https://github.com/numpy/numpy/issues/9391. Perhaps a note in the Python release notes is warranted? -- ___ Python tracker <http://bugs.python.org/issue29464> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue16932] urlparse fails at parsing "www.python.org:80/"
Changes by Tim Graham : -- pull_requests: +542 ___ Python tracker <http://bugs.python.org/issue16932> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue754016] urlparse goes wrong with IP:port without scheme
Changes by Tim Graham : -- pull_requests: +544 ___ Python tracker <http://bugs.python.org/issue754016> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27657] urlparse fails if the path is numeric
Changes by Tim Graham : -- pull_requests: +543 ___ Python tracker <http://bugs.python.org/issue27657> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27657] urlparse fails if the path is numeric
Tim Graham added the comment: Based on discussion in issue 16932, I agree that reverting the parsing decisions from issue 754016 (as Martin suggested in msg271719) seems appropriate. I created a pull request that does that. -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue27657> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22891] code removal from urllib.parse.urlsplit()
Tim Graham added the comment: I sent a pull request for this issue's dependency (issue 27657) and added a second commit there with this patch. A test added in the first commit demonstrates that removing this code no longer results in the behavior change described in msg238254. -- nosy: +Tim.Graham pull_requests: +549 ___ Python tracker <http://bugs.python.org/issue22891> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27172] Undeprecate inspect.getfullargspec()
Tim Graham added the comment: Does it seems likely that getfullargspec() will be deprecated after Python 2 is EOL? Django is currently reimplementing getargspec(): https://github.com/django/django/blob/8ab7ce8558792f41637d6f87f2a8a117e169dd18/django/utils/inspect.py#L4-L24 A pull request proposes to modify that implementation to behave as getfullargspec(): https://github.com/django/django/pull/8410 Django master now supports Python 3.4+, so I guess we would rather use getfullargspec() if it's not going to be deprecated in the future. The only downside is that it would introduce deprecation warnings for Python 3.5 users since those warnings haven't been removed yet. I guess Django could silence them. -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue27172> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25988] collections.abc.Indexable
Tim Graham added the comment: The last commit that added the deprecation warning needs to be added to the 3.7 branch. -- nosy: +Tim.Graham ___ Python tracker <https://bugs.python.org/issue25988> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30349] Preparation for advanced set syntax in regular expressions
Tim Graham added the comment: It might be worth adding part of the problematic regex to the warning message. For Django's tests, I see an error like "FutureWarning: Possible nested set at position 17 return re.compile(res).match". It took some effort to track down the source. A partial traceback is: File "/home/tim/code/django/django/core/management/commands/loaddata.py", line 247, in find_fixtures for candidate in glob.iglob(glob.escape(path) + '*'): File "/home/tim/code/cpython/Lib/glob.py", line 72, in _iglob for name in glob_in_dir(dirname, basename, dironly): File "/home/tim/code/cpython/Lib/glob.py", line 83, in _glob1 return fnmatch.filter(names, pattern) File "/home/tim/code/cpython/Lib/fnmatch.py", line 52, in filter match = _compile_pattern(pat) File "/home/tim/code/cpython/Lib/fnmatch.py", line 46, in _compile_pattern return re.compile(res).match File "/home/tim/code/cpython/Lib/re.py", line 240, in compile return _compile(pattern, flags) File "/home/tim/code/cpython/Lib/re.py", line 292, in _compile p = sre_compile.compile(pattern, flags) File "/home/tim/code/cpython/Lib/sre_compile.py", line 764, in compile p = sre_parse.parse(p, flags) File "/home/tim/code/cpython/Lib/sre_parse.py", line 930, in parse p = _parse_sub(source, pattern, flags & SRE_FLAG_VERBOSE, 0) File "/home/tim/code/cpython/Lib/sre_parse.py", line 426, in _parse_sub not nested and not items)) File "/home/tim/code/cpython/Lib/sre_parse.py", line 816, in _parse p = _parse_sub(source, state, sub_verbose, nested + 1) File "/home/tim/code/cpython/Lib/sre_parse.py", line 426, in _parse_sub not nested and not items)) File "/home/tim/code/cpython/Lib/sre_parse.py", line 524, in _parse FutureWarning, stacklevel=nested + 6 FutureWarning: Possible nested set at position 17 As an aside, I'm not sure how to fix the warning in Django. It comes from the test added in https://github.com/django/django/commit/98df288ddaba9787e4a370f12aba51c2b9133142 where a path like 'tests/fixtures/fixtures/fixture_with[special]chars' is run through glob.escape() which creates 'tests/fixtures/fixtures/fixture_with[[]special]chars'. -- nosy: +Tim.Graham ___ Python tracker <https://bugs.python.org/issue30349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32775] fnmatch.translate() can produce a pattern which emits a nested set warning
New submission from Tim Graham : As discussed in issue30349#msg311684, fnmatch.translate() can produce a pattern which emits a nested set warning: >>> import fnmatch, re >>> re.compile(fnmatch.translate('[[]foo]')) __main__:1: FutureWarning: Possible nested set at position 10 re.compile('(?s:\\(.s:[[]foo\\]\\)Z)\\Z') -- components: Library (Lib) messages: 311687 nosy: Tim.Graham, serhiy.storchaka priority: normal severity: normal status: open title: fnmatch.translate() can produce a pattern which emits a nested set warning type: behavior versions: Python 3.7 ___ Python tracker <https://bugs.python.org/issue32775> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue30349] Preparation for advanced set syntax in regular expressions
Tim Graham added the comment: Okay, I created #32775. -- ___ Python tracker <https://bugs.python.org/issue30349> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27172] Undeprecate inspect.getfullargspec()
Tim Graham added the comment: Perhaps the reason for the undeprecation could use some clarification. In a Python 3 only world (where Django's master branch is), I believe there's still usefulness for inspect.getfullargspec() -- see https://github.com/django/django/search?q=getfullargspec for usages. -- ___ Python tracker <https://bugs.python.org/issue27172> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue32071] Add py.test-like "-k" test selection to unittest
Tim Graham added the comment: This is appearing as a backwards incompatible change for Django because test case class attributes are now evaluated at load time before setUpClass runs (which initializes some things that those class attributes use). It's possible to adapt Django for this change, but it might affect other projects as well. Traceback from Django's tests: $ python -Wall tests/runtests.py Testing against Django installed in '/home/tim/code/django/django' with up to 3 processes Traceback (most recent call last): File "tests/runtests.py", line 477, in options.exclude_tags, File "tests/runtests.py", line 282, in django_tests extra_tests=extra_tests, File "/home/tim/code/django/django/test/runner.py", line 598, in run_tests suite = self.build_suite(test_labels, extra_tests) File "/home/tim/code/django/django/test/runner.py", line 513, in build_suite tests = self.test_loader.discover(start_dir=label, **kwargs) File "/home/tim/code/cpython/Lib/unittest/loader.py", line 346, in discover tests = list(self._find_tests(start_dir, pattern)) File "/home/tim/code/cpython/Lib/unittest/loader.py", line 403, in _find_tests full_path, pattern, namespace) File "/home/tim/code/cpython/Lib/unittest/loader.py", line 457, in _find_test_path return self.loadTestsFromModule(module, pattern=pattern), False File "/home/tim/code/cpython/Lib/unittest/loader.py", line 124, in loadTestsFromModule tests.append(self.loadTestsFromTestCase(obj)) File "/home/tim/code/cpython/Lib/unittest/loader.py", line 90, in loadTestsFromTestCase testCaseNames = self.getTestCaseNames(testCaseClass) File "/home/tim/code/cpython/Lib/unittest/loader.py", line 234, in getTestCaseNames testFnNames = list(filter(shouldIncludeMethod, dir(testCaseClass))) File "/home/tim/code/cpython/Lib/unittest/loader.py", line 227, in shouldIncludeMethod testFunc = getattr(testCaseClass, attrname) File "/home/tim/code/django/django/utils/decorators.py", line 172, in __get__ return self.fget(cls) File "/home/tim/code/django/django/test/testcases.py", line 1269, in live_server_url return 'http://%s:%s' % (cls.host, cls.server_thread.port) AttributeError: type object 'AdminSeleniumTestCase' has no attribute 'server_thread' -- nosy: +Tim.Graham ___ Python tracker <https://bugs.python.org/issue32071> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31047] Windows: os.path.isabs(os.path.abspath(" ")) == False
Tim Graham added the comment: I think this caused a behavior change: Before (Python 3.6.6): >>> from os.path import abspath >>> abspath('/abc/') 'C:\\abc' After (Python 3.6.7): >>> abspath('/abc/') 'C:\\abc\\' This causes a test failure in Django's safe_join() function: https://github.com/django/django/blob/10d82c85aa5f8bd6adff0db49798dd368455cdcf/django/utils/_os.py#L24-L47 https://github.com/django/django/blob/10d82c85aa5f8bd6adff0db49798dd368455cdcf/tests/utils_tests/test_os_utils.py#L10 Traceback (most recent call last): File "C:\Jenkins\workspace\django-windows\database\sqlite3\label\windows\python\Python36\tests\utils_tests\test_os_utils.py", line 10, in test_base_path_ends_with_sep drive, path = os.path.splitdrive(safe_join("/abc/", "abc")) File "C:\Jenkins\workspace\django-windows\database\sqlite3\label\windows\python\Python36\django\utils\_os.py", line 46, in safe_join 'component ({})'.format(final_path, base_path)) django.core.exceptions.SuspiciousFileOperation: The joined path (C:\abc\abc) is located outside of the base path component (C:\abc\) -- nosy: +Tim.Graham ___ Python tracker <https://bugs.python.org/issue31047> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33899] Tokenize module does not mirror "end-of-input" is newline behavior
Change by Tim Graham : -- pull_requests: +9415 ___ Python tracker <https://bugs.python.org/issue33899> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue31047] Windows: os.path.isabs(os.path.abspath(" ")) == False
Change by Tim Graham : -- pull_requests: +9423 stage: needs patch -> patch review ___ Python tracker <https://bugs.python.org/issue31047> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue33899] Tokenize module does not mirror "end-of-input" is newline behavior
Change by Tim Graham : -- pull_requests: +9424 ___ Python tracker <https://bugs.python.org/issue33899> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23722] During metaclass.__init__, super() of the constructed class does not work
Tim Graham added the comment: Hi, this causes a regression in Django and I'm not sure if Django or cpython is at fault. For a simple model that uses super() rather than super(Model self) in save(): from django.db import models class Model(models.Model): def save(self, *args, **kwargs): super().save(*args, **kwargs) >>> Model().save() Traceback (most recent call last): File "/home/tim/code/mysite/model/tests.py", line 8, in test Model().save() File "/home/tim/code/mysite/model/models.py", line 5, in save super().save(*args, **kwargs) RuntimeError: super(): empty __class__ cell django.db.models.Model does some things with metaclasses which is likely related to the root cause: https://github.com/django/django/blob/6d1394182d8c4c02598e0cf47f42a5e86706411f/django/db/models/base.py If someone could provide guidance about what the issue might be, I'm happy to provide more details or to debug this further. Thank you! -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue23722> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23722] During metaclass.__init__, super() of the constructed class does not work
Tim Graham added the comment: Thanks Nick. Your suggestion does fix the issue for Django: https://github.com/django/django/pull/7653. -- ___ Python tracker <http://bugs.python.org/issue23722> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25548] Show the address in the repr for class objects
Tim Graham added the comment: I'll echo what Peter said and say that this breaks 5 tests in Django's test suite which are checking error messages. If it stays, perhaps it could be added to the release notes instead of just NEWS. -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue25548> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27498] Regression in repr() of class object
Changes by Tim Graham : -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue27498> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue27737] email.header.Header.encode() crashes with IndexError on spaces only value
New submission from Tim Graham: Python 2.7: >>> from email.header import Header >>> Header(' ').encode() '' Python 3.2+ (I didn't check older versions of Python 3): >>> Header(' ').encode() Traceback (most recent call last): File "", line 1, in File "/home/tim/code/cpython/Lib/email/header.py", line 391, in encode value = formatter._str(linesep) File "/home/tim/code/cpython/Lib/email/header.py", line 427, in _str self.newline() File "/home/tim/code/cpython/Lib/email/header.py", line 439, in newline self._lines[-1] += str(self._current_line) IndexError: list index out of range (Originally reported at https://code.djangoproject.com/ticket/27051) -- components: Library (Lib) files: whitespace-header-test.diff keywords: patch messages: 272447 nosy: Tim.Graham priority: normal severity: normal status: open title: email.header.Header.encode() crashes with IndexError on spaces only value versions: Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 Added file: http://bugs.python.org/file44077/whitespace-header-test.diff ___ Python tracker <http://bugs.python.org/issue27737> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
New submission from Tim Graham: I noticed some failing Django tests on Python 3.2.6 the other day. The regression is caused by this change: https://github.com/python/cpython/commit/572d9c59a1441c6f8ffb9308824c804856020e31 Behavior before that commit (and on other version of Python even after that commit): >>> from http.cookies import SimpleCookie >>> SimpleCookie("Set-Cookie: foo=bar; Path=/") New broken behavior on Python 3.2.6: >>> from http.cookies import SimpleCookie >>> SimpleCookie("Set-Cookie: foo=bar; Path=/") Python 3.2.6 no longer accepts the "Set-Cookie: " prefix to BaseCookie.load: >>> SimpleCookie("Set-Cookie: foo=bar; Path=/") >>> SimpleCookie("foo=bar; Path=/") This issue doesn't affect 2.7, 3.3, or 3.4 because of https://github.com/python/cpython/commit/b92e104dc57c37ddf22ada1c6e5380e09268ee93 (this commit wasn't backported to 3.2 because that branch is in security-fix-only mode). I asked Berker about this and he suggested to create this issue and said, "If Georg is OK to backout the commit I can write a patch with additional test cases and commit it." He also confirmed the regression as follows: I've tested your example on Python 2.7.8, 3.2.6, 3.3.6, 3.4.2, 3.5.0 (all unreleased development versions - they will be X.Y.Z+1) and looks like it's a regression. My test script is: try: from http.cookies import SimpleCookie except ImportError: from Cookie import SimpleCookie c = SimpleCookie("Set-Cookie: foo=bar; Path=/") print(c) Here are the results: Python 2.7.8: Set-Cookie: foo=bar; Path=/ Python 3.5.0: Set-Cookie: foo=bar; Path=/ Python 3.4.2: Set-Cookie: foo=bar; Path=/ Python 3.3.6: Set-Cookie: foo=bar; Path=/ [45602 refs] Python 3.2.6: [38937 refs] -- components: Library (Lib) messages: 230200 nosy: Tim.Graham, berker.peksag, georg.brandl, pitrou, r.david.murray priority: normal severity: normal status: open title: Regression in Python 3.2 cookie parsing type: behavior versions: Python 3.2 ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: I wasn't sure if it was expected behavior or not. I'm attaching a file with the list of failing tests on Django's master. Perhaps more useful is a reference to the problematic usage in Django: https://github.com/django/django/blob/349471eeb9a4db2f5d8e95cb6555e7b3f2c94e3f/django/http/response.py#L208-L217 That logic was added to fix https://code.djangoproject.com/ticket/15863. -- Added file: http://bugs.python.org/file37061/failing-django-tests-22758.txt ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: Thank-you Georg; I believe I was able to fix some of the failures by patching Django as you suggested. However, I think I found another issue due to #16611 (support for httponly/secure cookies) not being backported to Python 3.2. The issue is that any cookies that appear after one that uses httponly or secure are dropped: >>> from http.cookies import SimpleCookie >>> c = SimpleCookie() >>> c['a'] = 'b' >>> c['a']['httponly'] = True >>> c['d'] = 'e' >>> out = c.output(header='', sep='; ') >>> SimpleCookie(out) Here's another example using the 'domain' option to show the same flow from above working as expected: >>> c = SimpleCookie() >>> c['a'] = 'b' >>> c['a']['domain'] = 'foo.com' >>> c['d'] = 'e' >>> out = c.output(header='', sep='; ') >>> SimpleCookie(out) It seems to me this may warrant backporting httponly/secure support to Python 3.2 now that cookie parsing is more strict (unless Django is again relying on incorrect behavior). -- ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22775] SimpleCookie not picklable with HIGHEST_PROTOCOL
New submission from Tim Graham: Expected: >>> import pickle >>> from http.cookies import SimpleCookie >>> pickle.loads(pickle.dumps(SimpleCookie('hi=there'),2)) # Actual Patch is based on the suggestion from Georg Brandl in #22758 (I added the "else" as the fix did not work without it). -- components: Library (Lib) files: cookie-pickle-highest.diff keywords: patch messages: 230354 nosy: Tim.Graham, berker.peksag, georg.brandl priority: normal severity: normal status: open title: SimpleCookie not picklable with HIGHEST_PROTOCOL type: behavior versions: Python 3.5 Added file: http://bugs.python.org/file37088/cookie-pickle-highest.diff ___ Python tracker <http://bugs.python.org/issue22775> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22775] SimpleCookie not picklable with HIGHEST_PROTOCOL
Tim Graham added the comment: By the way, this is my first patch for Python and I submitted a CLA 2 days ago. -- ___ Python tracker <http://bugs.python.org/issue22775> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: FYI, I created #22775 and submitted a patch for the issue that SimpleCookie doesn't pickle properly with HIGHEST_PROTOCOL. -- ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22775] SimpleCookie not picklable with HIGHEST_PROTOCOL
Tim Graham added the comment: Updated patch to test pickling of all protocols. -- Added file: http://bugs.python.org/file37100/cookie-pickling-all-protocols.diff ___ Python tracker <http://bugs.python.org/issue22775> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22775] SimpleCookie not picklable with HIGHEST_PROTOCOL
Tim Graham added the comment: Updated patch per comments. -- Added file: http://bugs.python.org/file37114/cookie-pickling-all-protocols-2.diff ___ Python tracker <http://bugs.python.org/issue22775> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue826897] Proto 2 pickle vs dict subclass
Tim Graham added the comment: Cookie pickling issue should be fixed in #22775. -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue826897> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: Georg, how do want to proceed with this issue? Should we backport #16611 (support for parsing secure/httponly flag) to 3.2 to fix this regression and then create a separate issue to fix the lax parsing issue on all versions? -- ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: The patch from #16611 applies cleanly to 3.2. I added a mention in Misc/NEWS and confirmed that all tests pass. -- Added file: http://bugs.python.org/file37127/secure-httponly-3.2-backport.diff ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22796] Support for httponly/secure cookies reintroduced lax parsing behavior
New submission from Tim Graham: As noted in the comments of #22758 by Georg Brandle: * Django uses __init__(str()) roundtripping, which is not explicitly supported by the library, and worked by accident with previous versions. That it works again with 3.3+ is another accident, and a bug. (The change for #16611 reintroduces "lax" parsing behavior that the security fix [1] was supposed to prevent.) [1] https://hg.python.org/cpython/rev/d3663a0f97ed -- components: Library (Lib) messages: 230637 nosy: Tim.Graham, berker.peksag, georg.brandl, pitrou, r.david.murray priority: normal severity: normal status: open title: Support for httponly/secure cookies reintroduced lax parsing behavior type: security versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4 ___ Python tracker <http://bugs.python.org/issue22796> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: I also created #22796 for the lax parsing issue. -- ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22796] Support for httponly/secure cookies reintroduced lax parsing behavior
Tim Graham added the comment: Django's test suite passes with the proposed patch after some updates: https://github.com/django/django/pull/3455 -- ___ Python tracker <http://bugs.python.org/issue22796> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue7559] TestLoader.loadTestsFromName swallows import errors
Changes by Tim Graham : -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue7559> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22796] Support for httponly/secure cookies reintroduced lax parsing behavior
Tim Graham added the comment: Security-wise? I don't know, I haven't really been in the loop on the original issue. -- ___ Python tracker <http://bugs.python.org/issue22796> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22796] Support for httponly/secure cookies reintroduced lax parsing behavior
Tim Graham added the comment: Django's test suite doesn't reveal any regressions. All the changes there are expected as far as I can see. -- ___ Python tracker <http://bugs.python.org/issue22796> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Changes by Tim Graham : Added file: http://bugs.python.org/file39512/secure-httponly-3.2-backport.diff ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: Patch rebased again after cookie fix from #22931. -- ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24134] assertRaises can behave differently
Tim Graham added the comment: Unfortunately, the revert wasn't merged to the 2.7 branch until after the release of 2.7.10. I guess this regression wouldn't be considered serious enough to warrant a 2.7.11 soon, correct? -- ___ Python tracker <http://bugs.python.org/issue24134> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14373] C implementation of functools.lru_cache
Tim Graham added the comment: This changed caused a problem in Django's test suite (bisected to 0d0989359bbb0). File "/home/tim/code/django/django/db/models/options.py", line 709, in _populate_directed_relation_graph all_models = self.apps.get_models(include_auto_created=True) TypeError: get_models() missing 1 required positional argument: 'self' The get_models() method is decorated with @lru_cache.lru_cache(maxsize=None) https://github.com/django/django/blob/c2b4967e76fd671e6199e4dd54d2a2c1f096b8eb/django/apps/registry.py#L157-L179 -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue14373> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14373] C implementation of functools.lru_cache
Tim Graham added the comment: Thanks, that does resolve the issue. -- ___ Python tracker <http://bugs.python.org/issue14373> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue14373] C implementation of functools.lru_cache
Changes by Tim Graham : -- nosy: -Tim.Graham ___ Python tracker <http://bugs.python.org/issue14373> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25137] Behavioral change / regression? with nested functools.partial
Changes by Tim Graham : -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue25137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25137] Behavioral change / regression? with nested functools.partial
Tim Graham added the comment: We can use an alternate approach in Django, if appropriate: https://github.com/django/django/pull/5294 -- ___ Python tracker <http://bugs.python.org/issue25137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25137] Behavioral change / regression? with nested functools.partial
Tim Graham added the comment: It's fine with me. -- ___ Python tracker <http://bugs.python.org/issue25137> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25228] Regression in cookie parsing with brackets and quotes
New submission from Tim Graham: Regression in https://hg.python.org/cpython/rev/9e765e65e5cb (affects 2.7 and 3.2+), similar to issue22931 where inserting an invalid cookie value can cause the rest of the cookie to be ignored. A test is attached, and here's a quick demo: Old: >>> from http.cookies import SimpleCookie >>> SimpleCookie('a=b; messages=[\"\"]; c=d;') {'a': 'b', 'c': 'd', 'messages': ''} New: >>> SimpleCookie('a=b; messages=[\"\"]; c=d;') {'a': 'b'} Reported in Django's tracker, but Django simply delegates to SimpleCookie: https://code.djangoproject.com/ticket/25458 -- components: Library (Lib) files: cookie-bracket-quotes-test.diff keywords: patch messages: 251538 nosy: Tim.Graham priority: normal severity: normal status: open title: Regression in cookie parsing with brackets and quotes type: behavior versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5, Python 3.6 Added file: http://bugs.python.org/file40566/cookie-bracket-quotes-test.diff ___ Python tracker <http://bugs.python.org/issue25228> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25228] Regression in cookie parsing with brackets and quotes
Tim Graham added the comment: It might be a case of issue22983. I'll try to look into the details and offer a patch next week. For what it's worth, there are other regressions in Python 3.2 cookie parsing that makes the latest patch release (3.2.6) unusable with Django (issue22758), so from my perspective fixing this issue there isn't as high priority as that one. -- ___ Python tracker <http://bugs.python.org/issue25228> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25228] Regression in cookie parsing with brackets and quotes
Tim Graham added the comment: Sure, feel free to propose a patch. -- ___ Python tracker <http://bugs.python.org/issue25228> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25228] Regression in cookie parsing with brackets and quotes
Tim Graham added the comment: Could you please integrate my unit test into your patch? You also need to sign the PSF Contributor Agreement: https://www.python.org/psf/contrib/contrib-form/ -- ___ Python tracker <http://bugs.python.org/issue25228> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25228] Regression in cookie parsing with brackets and quotes
Tim Graham added the comment: I had already proposed a test, see cookie-bracket-quotes-test.diff. What I meant was that the fix and the test should be combined into a single patch. -- ___ Python tracker <http://bugs.python.org/issue25228> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25228] Regression in cookie parsing with brackets and quotes
Tim Graham added the comment: Yes, when I have some time. By the way, did you intentionally remove all the "Python 3.X" versions on the issue? -- ___ Python tracker <http://bugs.python.org/issue25228> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: Given the inactivity here, I guess the patch won't be applied before Python 3.2 is end-of-life so I'm going to close the ticket. -- resolution: -> wont fix status: open -> closed ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue25935] OrderedDict prevents garbage collection if a circulary referenced class is used as key
Changes by Tim Graham : -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue25935> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22931] cookies with square brackets in value
Changes by Tim Graham : -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue22931> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22758] Regression in Python 3.2 cookie parsing
Tim Graham added the comment: Patch updated to fix conflict in NEWS. Could we have it committed to ensure it gets fixed in the next 3.2 released? -- Added file: http://bugs.python.org/file38609/secure-httponly-3.2-backport.diff ___ Python tracker <http://bugs.python.org/issue22758> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23571] Raise SystemError if a function returns a result with an exception set
Tim Graham added the comment: Here's an exception in Django after the latest patch. The Django code block in the last exception catches ValueError, but this doesn't seem to work any longer since it's "wrapped" in SystemError. As Berker mentioned, some upgrade tips would be great as I'm not sure what adaptions in Django need to be made. Traceback (most recent call last): File "/home/tim/code/django/django/contrib/contenttypes/views.py", line 17, in shortcut content_type = ContentType.objects.get(pk=content_type_id) File "/home/tim/code/django/django/db/models/manager.py", line 127, in manager_method return getattr(self.get_queryset(), name)(*args, **kwargs) File "/home/tim/code/django/django/db/models/query.py", line 387, in get self.model._meta.object_name django.contrib.contenttypes.models.DoesNotExist: ContentType matching query does not exist. ... During handling of the above exception, another exception occurred: Traceback (most recent call last): ValueError: could not convert string to float: request_path During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/tim/code/django/django/template/base.py", line 792, in __init__ self.literal = float(var) SystemError: returned a result with an error set -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue23571> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue23571] Raise SystemError if a function returns a result with an exception set
Tim Graham added the comment: That last commit fixed compatibility with Django. -- ___ Python tracker <http://bugs.python.org/issue23571> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22931] cookies with square brackets in value
Tim Graham added the comment: Will this regression be fixed in Python 2.7, 3.2, and 3.3? If not, Django may need to vendor Python's cookie class to workaround this bug to prevent users from losing sessions and/or being unable to login to Django powered sites as reported in https://code.djangoproject.com/ticket/24492. -- ___ Python tracker <http://bugs.python.org/issue22931> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24134] assertRaises can behave differently
Tim Graham added the comment: I noticed this is backwards incompatible for a small feature in Django. If you want to leave this feature in Python 2.7 and 3.4, it'll break things unless we push out a patch for Django; see https://github.com/django/django/pull/4637. -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue24134> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue24134] assertRaises can behave differently
Tim Graham added the comment: I didn't find any problems while testing your proposed new patch for cpython and your proposed patch for Django together. -- ___ Python tracker <http://bugs.python.org/issue24134> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22493] Deprecate the use of flags not at the start of regular expression
Tim Graham added the comment: Could we include the offending pattern in the deprecation message? I'm attaching a proposed patch. With that patch I can more easily find the offending pattern, whereas before I had no idea: django/django/urls/resolvers.py:101: DeprecationWarning: Flags not at the start of the expression ^(?i)test/2/?$ compiled_regex = re.compile(regex, re.UNICODE) -- nosy: +Tim.Graham Added file: http://bugs.python.org/file44675/better-warning.diff ___ Python tracker <http://bugs.python.org/issue22493> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22493] Deprecate the use of flags not at the start of regular expression
Tim Graham added the comment: And on further investigation, I'm not sure how to fix the deprecation warnings in Django. We have a urlpattern like this: url(r'^(?i)CaseInsensitive/(\w+)', empty_view, name="insensitive"), The regex string r'^(?i)CaseInsensitive/(\w+)' is later substituted in this line in Django's URL resolver as the `pattern`: if re.search('^%s%s' % (re.escape(_prefix), pattern), candidate_pat % candidate_subs, re.UNICODE): It seems Django would need to extract any flags from `pattern` and put them at the start of the '^%s%s' string that's constructed for re.search(). I'm not sure if this can be done easily. -- ___ Python tracker <http://bugs.python.org/issue22493> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22493] Deprecate the use of flags not at the start of regular expression
Tim Graham added the comment: Looks like we could remove the '^', but it doesn't resolve the deprecation warnings. The inline flags in `pattern` still need to be moved before `_prefix`. -- ___ Python tracker <http://bugs.python.org/issue22493> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28128] Improve the warning message for invalid escape sequences
Tim Graham added the comment: I hope the message can be improved for Python 3.6 as the warnings I see when running Django's test suite are rather useless to help find and fix the issues: cpython/Lib/importlib/_bootstrap.py:205: DeprecationWarning: invalid escape sequence '\:' Grepping for these characters patterns to try to figure out where they come from is quite difficult. I did track down one instance in a docstring: https://github.com/django/django/blob/82f8996785751c413e3b4ac12bf387f781c200d8/django/contrib/gis/maps/google/__init__.py#L41 Is the correct resolution to add an r prefix to the string? It could be nice if the release notes contained some guidance on that. -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue28128> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22493] Deprecate the use of flags not at the start of regular expression
Tim Graham added the comment: Adding an updated patch. I guess the (?i:CaseInsensitive) syntax isn't merged yet? I tried it but it didn't work. It might be premature to proceed with this deprecation if that alternative isn't already present. Is there an issue for it? -- Added file: http://bugs.python.org/file44680/better-warning-2.diff ___ Python tracker <http://bugs.python.org/issue22493> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28128] Improve the warning message for invalid escape sequences
Tim Graham added the comment: Eric, your patch was good enough to allow me to easily identify and fix all the warnings in Django: https://github.com/django/django/pull/7254. Thanks! -- ___ Python tracker <http://bugs.python.org/issue28128> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22493] Deprecate the use of flags not at the start of regular expression
Tim Graham added the comment: Yes, I found that Django needs an update to support that syntax in URLpatterns. Thanks. -- ___ Python tracker <http://bugs.python.org/issue22493> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28214] Improve exception reporting for problematic __set_name__ attributes
New submission from Tim Graham: As requested by Nick [0], this is a usability issue against CPython 3.6 to provide a better chained TypeError in this case: class _TokenType(tuple): parent = None def __getattr__(self, name): new = _TokenType(self + (name,)) setattr(self, name, new) new.parent = self return new Token = _TokenType() Keyword = Token.Keyword class KeywordCaseFilter(object): ttype = Keyword Traceback (most recent call last): File "test.py", line 14, in class KeywordCaseFilter(object): TypeError: '_TokenType' object is not callable The exception should report the specific object with the problematic __set_name__ attribute (rather than just passing along the underlying exception), as well as supporting __set_name__ = None to explicitly disable further lookup processing. Follow up to #27366. [0] https://github.com/andialbrecht/sqlparse/issues/286#issuecomment-248208900 -- components: Interpreter Core messages: 277027 nosy: Tim.Graham, ncoghlan priority: normal severity: normal status: open title: Improve exception reporting for problematic __set_name__ attributes type: behavior versions: Python 3.6, Python 3.7 ___ Python tracker <http://bugs.python.org/issue28214> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28210] argparse with subcommands difference in python 2.7 / 3.5
Tim Graham added the comment: The behavior change is from #10424. Do you believe the new behavior is incorrect? -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue28210> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22431] Change format of test runner output
Tim Graham added the comment: Is there opposition to changing the default output as outlined in the first comment? If so, then I think this ticket should be closed or retitled to reflect the intent. -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue22431> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue22431] Change format of test runner output
Tim Graham added the comment: Here's the patch if we make the change in Django instead: https://github.com/cjerdonek/django/commit/9c8d162f3f616e9d9768659a06fcf27bb389214b -- ___ Python tracker <http://bugs.python.org/issue22431> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28210] argparse with subcommands difference in python 2.7 / 3.5
Tim Graham added the comment: Based on the usage output, it looks like the subcommand is required, but I'm not sure if there are cases where a subcommand could be optional. David, can you advise? usage: test_argparse.py [-h] command ... -- nosy: +r.david.murray ___ Python tracker <http://bugs.python.org/issue28210> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue21720] "TypeError: Item in ``from list'' not a string" message
Tim Graham added the comment: As far as I can tell, this isn't an issue on Python 3. Can this be closed since Python 2 is only receiving bug fixes now? -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue21720> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28128] Improve the warning message for invalid escape sequences
Tim Graham added the comment: The patch is working well to identify warnings when running Django's test suite. Thanks! -- ___ Python tracker <http://bugs.python.org/issue28128> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28563] Arbitrary code execution in gettext.c2py
Tim Graham added the comment: Hi, this broke a couple tests with Django because it's passing number as a float rather than an integer. For example: == ERROR: test_localized_formats (template_tests.filter_tests.test_filesizeformat.FunctionTests) -- Traceback (most recent call last): File "/home/tim/code/django/tests/template_tests/filter_tests/test_filesizeformat.py", line 28, in test_localized_formats self.assertEqual(filesizeformat(1023), '1023\xa0Bytes') File "/home/tim/code/django/django/template/defaultfilters.py", line 895, in filesizeformat value = ungettext("%(size)d byte", "%(size)d bytes", bytes_) % {'size': bytes_} File "/home/tim/code/django/django/utils/translation/__init__.py", line 91, in ungettext return _trans.ungettext(singular, plural, number) File "/home/tim/code/django/django/utils/translation/trans_real.py", line 385, in ngettext return do_ntranslate(singular, plural, number, 'ngettext') File "/home/tim/code/django/django/utils/translation/trans_real.py", line 372, in do_ntranslate return getattr(t, translation_function)(singular, plural, number) File "/home/tim/code/cpython/Lib/gettext.py", line 441, in ngettext tmsg = self._catalog[(msgid1, self.plural(n))] File "", line 4, in func ValueError: Plural value must be an integer, got 1023.0. Can you advise if this patch could be adapted or if Django should adapt? By the way, I used this patch to get a more useful error message: diff --git a/Lib/gettext.py b/Lib/gettext.py index 7032efa..2076a3f 100644 --- a/Lib/gettext.py +++ b/Lib/gettext.py @@ -185,7 +185,7 @@ def c2py(plural): exec('''if True: def func(n): if not isinstance(n, int): -raise ValueError('Plural value must be an integer.') +raise ValueError('Plural value must be an integer, got %%s. return int(%s) ''' % result, ns) return ns['func'] -- nosy: +Tim.Graham ___ Python tracker <http://bugs.python.org/issue28563> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28563] Arbitrary code execution in gettext.c2py
Tim Graham added the comment: Thanks, that does fix that first test. There is one more that still fails: $ python -Wall tests/runtests.py humanize_tests.tests.HumanizeTests.test_i18n_intword Testing against Django installed in '/home/tim/code/django/django' with up to 3 processes Creating test database for alias 'default'... Creating test database for alias 'other'... /home/tim/code/cpython/Lib/gettext.py:454: DeprecationWarning: Plural value must be an integer, got 1.2 tmsg = self._catalog[(msgid1, self.plural(n))] /home/tim/code/cpython/Lib/gettext.py:454: DeprecationWarning: Plural value must be an integer, got 1.2 tmsg = self._catalog[(msgid1, self.plural(n))] F == FAIL: test_i18n_intword (humanize_tests.tests.HumanizeTests) -- Traceback (most recent call last): File "/home/tim/code/django/tests/humanize_tests/tests.py", line 133, in test_i18n_intword self.humanize_tester(test_list, result_list, 'intword') File "/home/tim/code/django/tests/humanize_tests/tests.py", line 39, in humanize_tester msg="%s test failed, produced '%s', should've produced '%s'" % (method, rendered, result)) AssertionError: '1,2 Million' != '1,2 Millionen' : intword test failed, produced '1,2 Million', should've produced '1,2 Millionen' I think the relevant code is https://github.com/django/django/blob/cbae4d31847d75d889815bfe7c04af035f45e28d/django/contrib/humanize/templatetags/humanize.py#L60-L63. I'm not too familiar with this code, but I'll try to get a better explanation if it's not clear to you. -- ___ Python tracker <http://bugs.python.org/issue28563> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue28563] Arbitrary code execution in gettext.c2py
Tim Graham added the comment: Yes, that fixes the second test. Current warning (with stacklevel=3): /home/tim/code/cpython/Lib/gettext.py:454: DeprecationWarning: Plural value must be an integer, got 1.29 tmsg = self._catalog[(msgid1, self.plural(n))] Possibly the stacklevel should instead be 4: /home/tim/code/django/django/utils/translation/trans_real.py:373: DeprecationWarning: Plural value must be an integer, got 1.29 return getattr(t, translation_function)(singular, plural, number) -- ___ Python tracker <http://bugs.python.org/issue28563> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com