Re: efficient 'tail' implementation

2005-12-15 Thread Marius Gedminas
Magnus Lycka wrote: To read the last x bytes of a file, you could do: import os x = 2000 # or whatever... f=open('my_big_file') l=os.fstat(f.fileno()).st_size f.seek(l-x) f.read() You don't need fstat/st_size, you can ask seek to move to an offset relative to the end of the

Re: python coding contest

2005-12-28 Thread Marius Gedminas
Jean-Paul Calderone wrote: On Tue, 27 Dec 2005 14:02:57 -0700, Tim Hochberg [EMAIL PROTECTED] wrote: Shane Hathaway wrote: Paul McGuire wrote: Also, here's another cheat version. (No, 7seg.com does not exist.) import urllib2 def seven_seg(x):return

Re: python coding contest

2005-12-29 Thread Marius Gedminas
I cannot not reach the contest site at since all this morning. :-( -- http://mail.python.org/mailman/listinfo/python-list

Re: python coding contest

2005-12-29 Thread Marius Gedminas
I cannot reach the contest site at since all this morning. :-( -- http://mail.python.org/mailman/listinfo/python-list

Re: understanding stat module names

2006-01-18 Thread Marius Gedminas
David Bear wrote: I'm trying to use os.chmod and am refered to the stat module. Is there are explanation of: * S_ISUID ... * S_IXOTH These come from the POSIX standard. See http://www.opengroup.org/onlinepubs/007908799/xsh/sysstat.h.html HTH, Marius Gedminas -- http

Re: days since epoch

2006-02-17 Thread Marius Gedminas
The datetime module is usually more convenient for date/time arithmetic. However in your particular case, you may find the time.time() function convenient. It returns the number of seconds since the epoch. To get the number of days divide the number of seconds by 86400. --

Re: Python Generators

2008-03-18 Thread Marius Gedminas
, 7, 8]])) [1, 2, 3, 4, 5, 6, 7, 8] wondering if google groups will add a .sig or not-ly, Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Collections of non-arbitrary objects ?

2007-06-25 Thread Marius Gedminas
On Jun 24, 2:12 pm, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: 7stud wrote: if hasattr(elmt, some_func): elmt.some_func() Personally, I prefer try: elmt.some_func() except AttributeError: # do stuff That also hides attribute errors that occur within some_func. I

Re: *Naming Conventions*

2007-06-11 Thread Marius Gedminas
On Jun 6, 3:18 pm, Neil Cerutti [EMAIL PROTECTED] wrote: Since 'i' and 'j' are canonically loop indices, I find it totally confusing to use them to name the iteration variable - which is not an index. Certainly i and j are just as generic, but they have the advantage over 'item' of being

Re: Python and Ruby

2010-02-04 Thread Marius Gedminas
of people that way. Someone already did: Advanced Python or Understanding Python http://video.google.com/videoplay?docid=7760178035196894549 (76 minutes). Worth watching. Regards, -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Python-URL! - weekly Python news and links (Feb 9)

2010-02-09 Thread Marius Gedminas
://groups.google.com/group/comp.lang.pythonfd36962c4970ac487ea/ Any chance of getting them fixed? Regards, -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: your favorite debugging tool?

2009-09-03 Thread Marius Gedminas
On Aug 25, 2:55 pm, Esmail ebo...@hotmail.com wrote: Re pdb, if you have a 'pointer' (ie reference) to an object, is there an easy way to dump out its contents, ie all of its members short of writing a method that does that and then calling it? Usually pp vars(your_object) does what you

Re: Application-global switches?

2009-09-17 Thread Marius Gedminas
On Sep 4, 9:29 pm, kj no.em...@please.post wrote: The only solution I can come up with is to define a dummy module, say _config.py, which contains only upper-case variables representing these global switches, and is imported by all the other modules in the application with the line from

Re: How to check what is holding reference to object

2010-05-05 Thread Marius Gedminas
import gc gc.get_referrers(42) ? Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: How to check what is holding reference to object

2010-05-05 Thread Marius Gedminas
unable to do that just looking to the code or debugging it because it is pretty complicated, but I am able to invoke this situation again. I wrote http://pypi.python.org/pypi/objgraph for this purpose. -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Q's on my first python script

2009-05-14 Thread Marius Gedminas
messages to sys.stderr. BTW, in this particular case you may want to use parser.error(e) instead of print + sys.exit. -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

Re: Q's on my first python script

2009-05-14 Thread Marius Gedminas
!) The warnings module is used for warnings about program code, not user input. import logging logging.warn(Oh noes, you passed me two arguments instead of one!) -- Marius Gedminas -- http://mail.python.org/mailman/listinfo/python-list

[issue3096] sphinx: sort warnings by filename

2008-06-12 Thread Marius Gedminas
New submission from Marius Gedminas [EMAIL PROTECTED]: Here's a patch that makes Sphinx sort warnings about unused documents by file name. Without it you get them in seemingly arbitrary order, which makes it harder to parse, when your documents are scattered in a large tree

[issue3097] sphinx: config option for exclude_dirnames

2008-06-12 Thread Marius Gedminas
New submission from Marius Gedminas [EMAIL PROTECTED]: I'm building developer documentation for an existing project that already had reStructuredText files scattered in the source tree. Unfortunately these use the same extension (.txt) as functional doctest files, but fortunately tests live

[issue7539] unicode exceptions terminate pdb.pm() loop

2009-12-18 Thread Marius Gedminas
New submission from Marius Gedminas mar...@gedmin.as: $ python2.6 Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type help, copyright, credits or license for more information. None() Traceback (most recent call last): File stdin, line 1, in module TypeError: 'NoneType

[issue7539] unicode exceptions terminate pdb.pm() loop

2009-12-20 Thread Marius Gedminas
Marius Gedminas mar...@gedmin.as added the comment: I don't know what I was smoking when I said pdb.set_trace() wasn't affected; I just reproduced the bug with Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15) [GCC 4.4.1] on linux2 Type help, copyright, credits or license for more information

[issue16657] traceback.format_tb incorrect docsting

2012-12-10 Thread Marius Gedminas
New submission from Marius Gedminas: The docstring for traceback.format_tb says A shorthand for 'format_list(extract_stack(f, limit)). which is incorrect -- it's actually a shorthand for format_list(extract_tb(tb, limit)). Patch attached. -- components: Library (Lib) files: fix

[issue17346] Pickle tests do not test protocols 0, 1, and 2 for bytes

2013-03-04 Thread Marius Gedminas
New submission from Marius Gedminas: I was reading Lib/test/pickletester.py when I noticed that test_bytes loops over all the protocols but doesn't actually use the loop variable anywhere. Attached patch should fix this. -- components: Tests files: actually-test-all-protocols.diff

[issue9327] doctest DocFileCase setUp/tearDown asymmetry

2012-08-08 Thread Marius Gedminas
Marius Gedminas added the comment: Duplicate of issue2604? -- nosy: +mgedmin ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9327 ___ ___ Python

[issue2604] doctest.DocTestCase fails when run repeatedly

2012-08-08 Thread Marius Gedminas
Marius Gedminas added the comment: For the record, this bug also breaks zope.testrunner's --repeat option, if you have any doctests in your test suite that rely on test.globs not going away. -- nosy: +mgedmin ___ Python tracker rep

[issue19333] distutils.util.grok_environment_error loses the error message

2013-10-21 Thread Marius Gedminas
New submission from Marius Gedminas: Steps to reproduce: $ python -c 'from distutils.util import grok_environment_error as e; print(e(IOError(message)))' What I expect to see: error: message What I get instead: error: None This is a problem because it hides the error message in a real-life

[issue19342] Improve grp module docstrings

2013-10-22 Thread Marius Gedminas
New submission from Marius Gedminas: This patch gives grp.getgrnam and grp.getgrgid sligtly more useful docstrings, and brings them in line with pwd.getpwnam/pwd.getpwuid. Compare pydoc pwd.getpwnam: pwd.getpwnam = getpwnam(...) getpwnam(name) - (pw_name,pw_passwd,pw_uid

[issue19345] Unclear phrasing in whatsnew/3.4.rst

2013-10-22 Thread Marius Gedminas
New submission from Marius Gedminas: Quoting http://docs.python.org/dev/whatsnew/3.4.html#deprecated-functions-and-types-of-the-c-api The PyThreadState.tick_counter field has been value: its value was meaningless since Python 3.2 (“new GIL”). I've no idea what has been value is supposed

[issue19344] ReStructuredText error in whatsnew/3.4.rst

2013-10-22 Thread Marius Gedminas
New submission from Marius Gedminas: Trivial syntax fix attached -- assignee: docs@python components: Documentation files: whatsnew-rst-fix.patch keywords: patch messages: 200907 nosy: docs@python, mgedmin priority: normal severity: normal status: open title: ReStructuredText error

[issue9736] doctest.DocTestSuite doesn't handle test globs correctly

2013-05-29 Thread Marius Gedminas
Marius Gedminas added the comment: This is a duplicate of issue2604, isn't it? -- nosy: +mgedmin ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue9736

[issue16484] Missing/broken documentation redirect for http://docs.python.org/library/xml.etree.ElementTree

2012-11-16 Thread Marius Gedminas
New submission from Marius Gedminas: Do this: pydoc2.7 xml.etree.ElementTree then click on the MODULE DOCS link, which is http://docs.python.org/library/xml.etree.ElementTree You're redirected to http://docs.python.org/2/library/xml.etree.ElementTree which is a 404 page

[issue16484] Missing/broken documentation redirect for http://docs.python.org/library/xml.etree.ElementTree

2012-11-16 Thread Marius Gedminas
Marius Gedminas added the comment: A working link is http://docs.python.org/2/library/xml.etree.elementtree.html or http://docs.python.org/2/library/xml.etree.elementtree (with no .html at the end). Looks like capitalization is causing a problem. Did these pydoc links ever work? Would

[issue16484] pydoc generates invalid docs.python.org link for xml.etree.ElementTree and other modules

2012-12-05 Thread Marius Gedminas
Marius Gedminas added the comment: Considering many existing Python installations out there would it be possible to fix this on the server side? I.e. lowercase the URL while redirecting? -- ___ Python tracker rep...@bugs.python.org http

[issue5719] optparse: please provide a usage example in the module docstring

2009-04-07 Thread Marius Gedminas
New submission from Marius Gedminas mar...@gedmin.as: Please add a simple usage example to the module docstring in optparse.py. The example available in the Python library reference would suffice (see http://python.org/doc/current/library/optparse.html). Rationale: optparse is convenient

[issue20509] logging.config.fileConfig() docs could link to the config file format

2014-02-04 Thread Marius Gedminas
New submission from Marius Gedminas: When one is reading the description of logging.config.fileConfig() at http://docs.python.org/3.3/library/logging.config.html#logging.config.fileConfig not immediately apparent what the configparser-format file should contain (i.e. the naming convention

[issue20608] 'SyntaxError: invalid token' is unfriendly

2014-02-12 Thread Marius Gedminas
New submission from Marius Gedminas: Type something like the following at the interpreter prompt: 04208 File stdin, line 1 04208 ^ SyntaxError: invalid token This is not very descriptive. I suggest SyntaxError: invalid octal digit. -- components: Interpreter Core

[issue20608] 'SyntaxError: invalid token' is unfriendly

2014-02-12 Thread Marius Gedminas
Marius Gedminas added the comment: I was looking at the current hg tip. The lexer emits E_TOKEN errors for the following cases: - invalid hex digit - invalid octal digit - invalid binary digit - invalid digit in float exponent - old-style octal constant (e.g. 001), which is no longer accepted

[issue20608] 'SyntaxError: invalid token' is unfriendly

2014-02-15 Thread Marius Gedminas
Marius Gedminas added the comment: Oh, hey, PEP 3127 actually asks for a better error message than invalid token for this case: http://www.python.org/dev/peps/pep-3127/#tokenizer-exception-handling So here's a tentative patch to test the waters. I still haven't figured out how to write

[issue20608] 'SyntaxError: invalid token' is unfriendly

2014-02-15 Thread Marius Gedminas
Marius Gedminas added the comment: I resolved my compilation problems (by running 'make distclean'). There are some problems with my patch: - leading is misspelled (as lleading) - literals like 0x1z, 0o18, 0b12, 1.2e-1x produce a generic invalid syntax message instead of the specific bad digit

[issue20608] 'SyntaxError: invalid token' is unfriendly

2014-02-15 Thread Marius Gedminas
Marius Gedminas added the comment: I see that I misunderstood Serhiy's comment. I assumed he meant the caret will be pointing to the 1st digit that is invalid. Instead what actually happens is that E_TOKEN is emitted only if the 1st digit after the 0x/0o/0b prefix is invalid. So, I get

[issue20608] 'SyntaxError: invalid token' is unfriendly

2014-02-15 Thread Marius Gedminas
Marius Gedminas added the comment: Here's version 2 of the patch: - spelling error fixed - 0b2, 0o8, 0xg, 0e-x show the expected error at the expected place - 0b02, 0o08, 0x0g, 0e-0x continue produce a generic syntax error because the tokenizer thinks these are a pair of valid tokens (0b0

[issue20608] 'SyntaxError: invalid token' is unfriendly

2014-02-15 Thread Marius Gedminas
Marius Gedminas added the comment: Version 3 of the patch catches bad digits in the middle of a literal, like this: 0o01010118001 File stdin, line 1 0o01010118001 ^ SyntaxError: bad digit in octal literal -- Added file: http://bugs.python.org/file34092/better-errors

[issue20608] 'SyntaxError: invalid token' is unfriendly

2014-02-15 Thread Marius Gedminas
Marius Gedminas added the comment: Here are some unit tests for the new syntax errors (in test_syntax.py; test_tokenize.py turned out to be totally unrelated). One possible shortcoming: they do not test the column of the syntax error. -- Added file: http://bugs.python.org/file34093

[issue20608] 'SyntaxError: invalid token' is unfriendly

2014-02-15 Thread Marius Gedminas
Marius Gedminas added the comment: Updated test that checks the syntax error offset as well. I think I'm done with the iterations. I'll be waiting for feedback. -- Added file: http://bugs.python.org/file34094/better-errors-test-v2.patch ___ Python

[issue16484] pydoc generates invalid docs.python.org link for xml.etree.ElementTree and other modules

2014-02-25 Thread Marius Gedminas
Marius Gedminas added the comment: Near the top: Help on module xml.etree.ElementTree in xml.etree: NAME xml.etree.ElementTree FILE /usr/lib/python2.7/xml/etree/ElementTree.py MODULE DOCS http://docs.python.org/library/xml.etree.ElementTree DESCRIPTION

[issue24297] Lib/symbol.py is out of sync with Grammar/Grammar

2015-05-27 Thread Marius Gedminas
New submission from Marius Gedminas: While investigating https://bitbucket.org/pypa/setuptools/issue/388/install-from-sdist-fails-on-python-350b1 I noticed that Grammar/Grammar changed in 3.5, but Lib/symbol.py wasn't updated. I'm not familiar with the CPython parser, but I suspect

[issue12612] Valgrind suppressions

2015-11-04 Thread Marius Gedminas
Marius Gedminas added the comment: Could this fix be backported to the 2.7 branch as well? -- nosy: +mgedmin ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue25077] Compiler warnings: initialization from incompatible pointer type

2015-09-12 Thread Marius Gedminas
New submission from Marius Gedminas: I'm seeing these compiler warnings while trying to build Python 3.5 on Ubuntu 15.04: In file included from Python/ceval.c:300:0: Python/ceval_gil.h: In function ‘drop_gil’: Python/ceval_gil.h:181:144: warning: initialization from incompatible pointer type

[issue25117] Windows installer: precompiling stdlib fails with missing DLL errors

2015-09-14 Thread Marius Gedminas
New submission from Marius Gedminas: I installed Python 3.5 on a Windows Server 2012 VM, twice (once the 32-bit, and once the 64-bit version). When it started throwing error dialogs at me, I started taking screenshots: http://imgur.com/a/zwfz4. What happened: - I selected advanced

[issue25119] Windows installer fails to install VCRUNTIME140.DLL

2015-09-15 Thread Marius Gedminas
New submission from Marius Gedminas: 1. Install Python 3.5 using the official Windows installer 2. Get a shell 3. python -m ensurepip (because the installer didn't install pip for me -- is that another bug? I thought the installer was supposed to run ensurepip for me? Is it fallout from bug

[issue25117] Windows installer: precompiling stdlib fails with missing DLL errors

2015-09-16 Thread Marius Gedminas
Changes by Marius Gedminas <mged...@gmail.com>: Added file: http://bugs.python.org/file40487/Python 3.5.0 installer crash logs.zip ___ Python tracker <rep...@bugs.python.org> <http://bugs.python

[issue25117] Windows installer: precompiling stdlib fails with missing DLL errors

2015-09-17 Thread Marius Gedminas
Marius Gedminas added the comment: Yes, it exists: http://imgur.com/YCmApN7 -- ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue25119] Windows installer fails to install VCRUNTIME140.DLL

2015-09-15 Thread Marius Gedminas
Marius Gedminas added the comment: Thank you for the pointer! It's hard to tell which software component is at fault when multiple components fail to collaborate. I cannot choose to use venv because I'm actually using tox, which runs virtualenv for a bunch of Python versions, some of which

[issue25316] distutils: broken error reporting about vcvarsall.bat

2015-10-05 Thread Marius Gedminas
New submission from Marius Gedminas: When you try to build a C extension on Windows without having a C compiler, distutils tries to raise DistutilsPlatformError("Unable to find vcvarsall.bat"). However, on Python 3.5, it doesn't do that -- instead it lets a WinError(2 &qu

[issue25117] Windows installer: precompiling stdlib fails with missing DLL errors

2015-09-23 Thread Marius Gedminas
Marius Gedminas added the comment: For the record, I rebooted once, after installing both 32-bit and 64-bit versions of Python 3.5. (Also, it seems that the Python 3.5 installer didn't install pip for me, which could be fallout from this bug? I had to run python -m ensurepip to get

[issue25900] unittest ignores the first ctrl-c when it shouldn't

2015-12-18 Thread Marius Gedminas
New submission from Marius Gedminas: unittest.signals._InterruptHandler is very nice: on first ^C it tells any registered unittest Result instances to gracefully stop the test run, and on any subsequent ^C it defers to the default interrupt handler, which immediately terminates the test run

[issue25900] unittest ignores the first ctrl-c when it shouldn't

2015-12-22 Thread Marius Gedminas
Marius Gedminas added the comment: Somewhat unrelated nitpick: I'm not very happy that _InterruptHandler doesn't return early after calling the original handler. It's all very well, if the original handler raises or does nothing at all, but if it's a user-installed handler that does something

[issue25900] unittest ignores the first ctrl-c when it shouldn't

2015-12-22 Thread Marius Gedminas
Marius Gedminas added the comment: Here's an updated patch with tests -- Added file: http://bugs.python.org/file41383/dont-ignore-first-ctrl-c-with-tests.patch ___ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/i

[issue25900] unittest ignores the first ctrl-c when it shouldn't

2015-12-22 Thread Marius Gedminas
Marius Gedminas added the comment: I looked for any existing tests (by grepping for 'signals' and 'import' on the same line), didn't find any (because my assumption that 'signals' would have to be explicitly imported was wrong). Wrote some new tests, which made me also make some further

[issue28894] Memory leak in dict.pop()

2016-12-07 Thread Marius Gedminas
Marius Gedminas added the comment: If you're curious where this happens in real life, py.test's CaptureManager.deactivate_funcargs() does self.__dict__.pop("_capfuncarg", None) and I found it by running 'tox -e py36' on https://github.com/mgedm

[issue28894] Memory leak in dict.pop()

2016-12-07 Thread Marius Gedminas
New submission from Marius Gedminas: Run the following script with Python 3.6.0rc1: class O: pass o = O() for n in range(20): print(n) o.x = 42 o.__dict__.pop('x', None) You can observe the memory usage of the Python process growing exponentially

[issue33851] 3.7 regression: ast.get_docstring() for a node that lacks a docstring

2018-06-13 Thread Marius Gedminas
New submission from Marius Gedminas : Python 3.7 removes an isinstance(node.body[0], Expr) check ast.get_docstring() that makes it crash when you pass in AST nodes of modules or functions that do not have docstrings. Steps to reproduce: - git clone https://github.com/mgedmin/findimports

[issue33851] 3.7 regression: ast.get_docstring() for a node that lacks a docstring

2018-06-25 Thread Marius Gedminas
Marius Gedminas added the comment: I've ran my findimports testsuite with CPython's git commit a50b825c18a92655f3dd7939e793fa3d4440d886 and my tests passed, so yes. -- ___ Python tracker <https://bugs.python.org/issue33

[issue33215] PyPI API wiki pages could link to Warehous docs please

2018-04-03 Thread Marius Gedminas
New submission from Marius Gedminas <mar...@gedmin.as>: Now that Warehouse is preparing to replace the old PyPI codebase I think it would be a good idea if the old PyPI API documentation pages on the Python wiki would link to the new Warehouse API documentation. Specifically, -

[issue29564] ResourceWarning: suggest to enable tracemalloc in the message

2018-10-19 Thread Marius Gedminas
Marius Gedminas added the comment: @stinner: https://haypo.github.io/contrib-cpython-2016q1.html is now showing a 404 error. Has the site moved? Do you have a working URL? (I did find https://docs.python.org/3/whatsnew/3.6.html#warnings, which was very helpful.) -- nosy: +mgedmin

[issue37269] Python 3.8b1 miscompiles conditional expressions containing __debug__

2019-06-13 Thread Marius Gedminas
New submission from Marius Gedminas : Python 3.8 miscompiles the following code: $ cat /tmp/wat.py enable_debug = False if not enable_debug or not __debug__: print("you shall not pass!") $ python3.7 /tmp/wat.py you shall not pass! $ python3.8 /

[issue37738] curses.addch('a', curses.color_pair(1)) ignores the color information

2019-08-01 Thread Marius Gedminas
New submission from Marius Gedminas : curses.addch() ignores color information if I pass it a string of length one. Color works fine if I pass it a byte string or an int. Here's a reproducer: ### start of example ### import curses

[issue14106] Distutils manifest: recursive-(include|exclude) matches suffix instead of full filename

2020-05-03 Thread Marius Gedminas
Marius Gedminas added the comment: For the record, this is still a bug in Python 3.8 distutils (and it affects global-(include|exclude) as well), but it's been fixed in setuptools, so it shouldn't affect people writing MANIFEST.in files in 2020. -- nosy: +mgedmin