Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #102921
| Path | csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ben Finney <ben+python@benfinney.id.au> |
| Newsgroups | comp.lang.python |
| Subject | Make a unique filesystem path, without creating the file |
| Date | Mon, 15 Feb 2016 08:46:03 +1100 |
| Lines | 35 |
| Message-ID | <mailman.117.1455486378.22075.python-list@python.org> (permalink) |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de bNSub0NHOWMp1o9z+jAKMgGvPdOClEswqig+RmEjMlfQ== |
| Cancel-Lock | sha1:qygpNPBi2vXmhx+bW+5qIDGtz/k= |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '*not*': 0.07; 'subject:file': 0.07; 'api': 0.09; 'deprecated,': 0.09; 'facts': 0.09; 'filesystem': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'explicitly': 0.15; '*do': 0.16; 'apis.': 0.16; 'creation.': 0.16; 'deprecated.': 0.16; 'deprecation': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'still,': 0.16; 'tests)': 0.16; 'all,': 0.20; 'library': 0.20; 'file.': 0.22; 'decide': 0.23; 'header:User-Agent:1': 0.26; "doesn't": 0.26; 'appear': 0.26; 'header:X-Complaints-To:1': 0.26; '(e.g.': 0.27; 'function': 0.28; 'concern': 0.29; 'code': 0.30; 'law.': 0.30; 'strongly': 0.30; 'entry': 0.31; 'point': 0.33; 'url:python': 0.33; 'file': 0.34; 'exist': 0.35; 'path': 0.35; 'problem.': 0.35; 'unit': 0.35; 'but': 0.36; 'should': 0.36; 'instead': 0.36; 'there': 0.36; 'url:org': 0.36; 'url:library': 0.36; 'to:addr:python-list': 0.36; 'agree': 0.37; 'received:org': 0.37; 'subject:the': 0.39; 'to:addr:python.org': 0.40; 'some': 0.40; 'url:3': 0.60; 'ever': 0.60; 'your': 0.60; 'avoid': 0.61; 'provide': 0.61; 'real': 0.62; 'concerns': 0.66; 'future,': 0.70; '_o__)': 0.84; 'insecure': 0.84; 'irrelevant': 0.84; 'received:125': 0.84; 'vulnerable': 0.84; 'prone': 0.91; 'subject:Make': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | jigong.madmonks.org |
| X-Public-Key-ID | 0xAC128405 |
| X-Public-Key-Fingerprint | 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 |
| X-Public-Key-URL | http://www.benfinney.id.au/contact/bfinney-pubkey.asc |
| X-Post-From | Ben Finney <bignose+hates-spam@benfinney.id.au> |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21rc2 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:102921 |
Show key headers only | View raw
Howdy all, How should a program generate a unique filesystem path and *not* create the filesystem entry? The ‘tempfile.mktemp’ function is strongly deprecated, and rightly so <URL:https://docs.python.org/3/library/tempfile.html#tempfile.mktemp> because it leaves the program vulnerable to insecure file creation. In some code (e.g. unit tests) I am calling ‘tempfile.mktemp’ to generate a unique path for a filesystem entry that I *do not want* to exist on the real filesystem. In this case the filesystem security concerns are irrelevant because there is no file. The deprecation of that function is a concern still, because I don't want code that makes every conscientious reader need to decide whether the code is a problem. Instead the code should avoid rightly-deprecated APIs. It is also prone to that API function disappearing at some point in the future, because it is explicitly and strongly deprecated. So I agree with the deprecation, but the library doesn't appear to provide a replacement. What standard library function should I be using to generate ‘tempfile.mktemp’-like unique paths, and *not* ever create a real file by that path? -- \ “If you have the facts on your side, pound the facts. If you | `\ have the law on your side, pound the law. If you have neither | _o__) on your side, pound the table.” —anonymous | Ben Finney
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
Make a unique filesystem path, without creating the file Ben Finney <ben+python@benfinney.id.au> - 2016-02-15 08:46 +1100
Re: Make a unique filesystem path, without creating the file Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-02-14 23:48 +0100
Re: Make a unique filesystem path, without creating the file Grant Edwards <invalid@invalid.invalid> - 2016-02-15 15:46 +0000
Re: Make a unique filesystem path, without creating the file "Mario R. Osorio" <nimbiotics@gmail.com> - 2016-02-15 20:46 -0800
Re: Make a unique filesystem path, without creating the file Ben Finney <ben+python@benfinney.id.au> - 2016-02-16 16:03 +1100
csiph-web